123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using FastReport.Controls;
- using FastReport.Utils;
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace FastReport.Forms
- {
- internal partial class BorderEditorForm : BaseDialogForm
- {
- private Border border;
- private bool changed;
- public Border Border
- {
- get { return border; }
- set
- {
- border = value;
- pnSample.Border = value;
- UpdateBorder();
- UpdateControls();
- }
- }
- public bool Changed
- {
- get { return changed; }
- set { changed = value; }
- }
- private LineStyle LineStyle
- {
- get { return lsLineStyle.Style; }
- }
- private float LineWidth
- {
- get { return cbxLineWidth.LineWidth; }
- }
- private Color LineColor
- {
- get { return cbxLineColor.Color; }
- }
- private void Change()
- {
- changed = true;
- UpdateControls();
- }
- private void UpdateBorder()
- {
- cbxLineWidth.LineWidth = Border.Width;
- cbxLineColor.Color = Border.Color;
- lsLineStyle.Style = Border.Style;
- lsLineStyle.LineColor = Border.Color;
- lsLineStyle.LineWidth = Border.Width;
- cbShadow.Checked = Border.Shadow;
- cbxShadowWidth.LineWidth = Border.ShadowWidth;
- cbxShadowColor.Color = Border.ShadowColor;
- }
- private void Line_Click(object sender, EventArgs e)
- {
- BorderLines line = BorderLines.None;
- if (sender == cbTopLine)
- line = BorderLines.Top;
- else if (sender == cbBottomLine)
- line = BorderLines.Bottom;
- else if (sender == cbLeftLine)
- line = BorderLines.Left;
- else if (sender == cbRightLine)
- line = BorderLines.Right;
- ToggleLine(line, (sender as CheckBox).Checked);
- }
- private void btnNoLines_Click(object sender, EventArgs e)
- {
- Border.Lines = BorderLines.None;
- Change();
- }
- private void btnAllLines_Click(object sender, EventArgs e)
- {
- Border.Lines = BorderLines.All;
- Border.Style = LineStyle;
- Border.Width = LineWidth;
- Border.Color = LineColor;
- Change();
- }
- private void cbShadow_CheckedChanged(object sender, EventArgs e)
- {
- Border.Shadow = cbShadow.Checked;
- Change();
- }
- private void cbxShadowColor_ColorSelected(object sender, EventArgs e)
- {
- Border.ShadowColor = cbxShadowColor.Color;
- Change();
- }
- private void cbxShadowWidth_WidthSelected(object sender, EventArgs e)
- {
- if (cbxShadowWidth.LineWidth == 0) return;
- Border.ShadowWidth = cbxShadowWidth.LineWidth;
- Change();
- }
- private void cbxLineColor_ColorSelected(object sender, EventArgs e)
- {
- lsLineStyle.LineColor = LineColor;
- }
- private void cbxLineWidth_WidthSelected(object sender, EventArgs e)
- {
- lsLineStyle.LineWidth = LineWidth;
- }
- public void ToggleLine(BorderLines line, bool state)
- {
- BorderLine line1 = null;
- switch (line)
- {
- case BorderLines.Top:
- line1 = Border.TopLine;
- break;
- case BorderLines.Bottom:
- line1 = Border.BottomLine;
- break;
- case BorderLines.Left:
- line1 = Border.LeftLine;
- break;
- case BorderLines.Right:
- line1 = Border.RightLine;
- break;
- }
- if (line1 != null)
- {
- if (state || (line1.Style != LineStyle || line1.Width != LineWidth || line1.Color != LineColor))
- {
- Border.Lines = Border.Lines | line;
- line1.Style = LineStyle;
- line1.Width = LineWidth;
- line1.Color = LineColor;
- }
- else
- {
- Border.Lines = Border.Lines & ~line;
- }
- }
- Change();
- }
- private void pnSample_ToggleLine(object sender, ToggleLineEventArgs e)
- {
- ToggleLine(e.Line, e.Toggle);
- }
- private void btnOk_Click(object sender, EventArgs e)
- {
- Border.ShadowWidth = cbxShadowWidth.LineWidth;
- }
- public void UpdateControls()
- {
- cbTopLine.Checked = (Border.Lines & BorderLines.Top) != 0;
- cbBottomLine.Checked = (Border.Lines & BorderLines.Bottom) != 0;
- cbLeftLine.Checked = (Border.Lines & BorderLines.Left) != 0;
- cbRightLine.Checked = (Border.Lines & BorderLines.Right) != 0;
- cbShadow.Checked = Border.Shadow;
- cbxShadowWidth.LineWidth = Border.ShadowWidth;
- cbxShadowColor.Color = Border.ShadowColor;
- lblShadowWidth.Enabled = Border.Shadow;
- cbxShadowWidth.Enabled = Border.Shadow;
- lblShadowColor.Enabled = Border.Shadow;
- cbxShadowColor.Enabled = Border.Shadow;
- pnSample.Refresh();
- }
- public override void Localize()
- {
- base.Localize();
- MyRes res = new MyRes("Forms,Border");
- Text = res.Get("");
- gbBorder.Text = res.Get("Border");
- gbLine.Text = res.Get("Line");
- lblHint.Text = res.Get("Hint");
- cbShadow.Text = res.Get("Shadow");
- lblShadowWidth.Text = res.Get("Width");
- lblShadowColor.Text = res.Get("Color");
- lblStyle.Text = res.Get("Style");
- lblLineWidth.Text = res.Get("Width");
- lblLineColor.Text = res.Get("Color");
- }
- public override void UpdateDpiDependencies()
- {
- base.UpdateDpiDependencies();
- btnAllLines.Image = GetImage(36);
- btnNoLines.Image = GetImage(37);
- cbTopLine.Image = GetImage(32);
- cbBottomLine.Image = GetImage(33);
- cbLeftLine.Image = GetImage(34);
- cbRightLine.Image = GetImage(35);
- lblShadow.Left = cbShadow.Right + this.LogicalToDevice(4);
- lblShadow.Width = pnSample.Right - lblShadow.Left;
- }
- public BorderEditorForm()
- {
- InitializeComponent();
- Border = new Border();
- Border.Lines = BorderLines.All;
- pnSample.Border = Border;
- changed = false;
- Localize();
- UIUtils.CheckRTL(this);
- UpdateDpiDependencies();
- }
- }
- }
|