123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- using System;
- using FastReport.Utils;
- using FastReport.Forms;
- using System.Windows.Forms;
- using System.Drawing;
- namespace FastReport.Gauge
- {
- internal enum GaugeEditorPage
- {
- Scale,
- Pointer,
- Label
- }
- internal partial class GaugeEditorForm : BaseDialogForm
- {
- #region Fields
- GaugeObject gauge;
- private bool deleteLabel;
- #endregion // Fields
- #region Properties
- internal GaugeObject Gauge { get { return gauge; } }
- internal bool DeleteLabel { set { deleteLabel = value; } }
- internal GaugeEditorPage ActivePage
- {
- set
- {
- if (value == GaugeEditorPage.Scale)
- pageControl1.ActivePage = pgScale;
- else if (value == GaugeEditorPage.Pointer)
- pageControl1.ActivePage = pgPointer;
- else if (value == GaugeEditorPage.Label)
- pageControl1.ActivePage = pgLabel;
- }
- }
- #endregion // Properties
- #region Constructors
- public GaugeEditorForm(GaugeObject gauge) : base()
- {
- deleteLabel = false;
- this.gauge = gauge;
- InitializeComponent();
- Init();
- Localize();
- }
- #endregion //Constructors
- #region Protected Methods
- protected virtual void Init()
- {
- if (deleteLabel)
- pageControl1.Pages.Remove(pgLabel);
- if (gauge != null)
- {
- numericUpDowMajorWidth.Value = gauge.Scale.MajorTicks.Width;
- cbxMajorTicksColor.Color = gauge.Scale.MajorTicks.Color;
- numericUpDowMinorWidth.Value = gauge.Scale.MinorTicks.Width;
- cbxMinorTicksColor.Color = gauge.Scale.MinorTicks.Color;
- textBoxButtonScaleFont.Text = gauge.Scale.Font.FontFamily.Name + ", " + gauge.Scale.Font.SizeInPoints + "pt";
- if (gauge.Scale.Font.Style != FontStyle.Regular)
- textBoxButtonScaleFont.Text += ", style=" + gauge.Scale.Font.Style.ToString();
- cbxPointerBorderColor.Color = gauge.Pointer.BorderColor;
- if (pgLabel != null)
- {
- textBoxButtonLabelFont.Text = gauge.Label.Font.FontFamily.Name + ", " + gauge.Label.Font.SizeInPoints + "pt";
- if (gauge.Label.Font.Style != FontStyle.Regular)
- textBoxButtonLabelFont.Text += ", style=" + gauge.Label.Font.Style.ToString();
- cbLabelColor.Color = gauge.Label.Color;
- tbLabelText.Text = gauge.Label.Text;
- }
- }
- }
- public override void UpdateDpiDependencies()
- {
- base.UpdateDpiDependencies();
- textBoxButtonScaleFont.Image = GetImage(59);
- textBoxButtonLabelFont.Image = GetImage(59);
- }
- #endregion // Protected Methods
- #region Public Methods
- public override void Localize()
- {
- base.Localize();
- MyRes res = new MyRes("Objects,Gauge,GaugeForms,PageGeneral");
- pgGeneral.Text = res.Get("");
- btnExpression.Text = res.Get("Expression");
- btnGeneralBorder.Text = res.Get("Border");
- btnGeneralFill.Text = res.Get("Fill");
- res = new MyRes("Objects,Gauge,GaugeForms,PageScale");
- pgScale.Text = res.Get("");
- res = new MyRes("Objects,Gauge,GaugeForms,PageScale,TabTicks");
- tabControl3.TabPages[0].Text = res.Get("");
- gpBoxMjr.Text = res.Get("MajorTicks");
- lblWidthMjr.Text = res.Get("MajorTicks,Width");
- lblColorMjr.Text = res.Get("MajorTicks,Color");
- gpBoxMnr.Text = res.Get("MinorTicks");
- lblWidthMnr.Text = res.Get("MinorTicks,Width");
- lblColorMnr.Text = res.Get("MinorTicks,Color");
- res = new MyRes("Objects,Gauge,GaugeForms,PageScale,TabText");
- tabControl3.TabPages[1].Text = res.Get("");
- lblScaleFont.Text = res.Get("Font");
- buttonFill.Text = res.Get("TextFill");
- res = new MyRes("Objects,Gauge,GaugeForms,PagePointer");
- pgPointer.Text = res.Get("");
- lblPtrBorderColor.Text = res.Get("BorderColor");
- btnPointerFill.Text = res.Get("PointerFill");
- res = new MyRes("Objects,Gauge,GaugeForms,PageLabel");
- pgLabel.Text = res.Get("");
- lblLblColor.Text = res.Get("LabelColor");
- lblLabelFont.Text = res.Get("Font");
- lblLabelText.Text = res.Get("Text");
- }
- #endregion // Public Methods
- #region Events Handlers
- protected virtual void GaugeEditorForm_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e)
- {
- if (this.DialogResult == DialogResult.OK)
- try
- {
- gauge.Scale.MajorTicks.Width = (int)numericUpDowMajorWidth.Value;
- gauge.Scale.MajorTicks.Color = cbxMajorTicksColor.Color;
- gauge.Scale.MinorTicks.Width = (int)numericUpDowMinorWidth.Value;
- gauge.Scale.MinorTicks.Color = cbxMinorTicksColor.Color;
- gauge.Pointer.BorderColor = cbxPointerBorderColor.Color;
- if (pgLabel != null)
- {
- gauge.Label.Color = cbLabelColor.Color;
- gauge.Label.Text = tbLabelText.Text;
- }
- }
- catch (Exception ex)
- {
- if (!Config.WebMode)
- {
- FRMessageBox.Error(ex.Message);
- }
- }
- }
- private void buttonFill_Click(object sender, EventArgs e)
- {
- using (FillEditorForm form = new FillEditorForm())
- {
- form.Fill = gauge.Scale.TextFill;
- if (form.ShowDialog() == DialogResult.OK)
- gauge.Scale.TextFill = form.Fill;
- }
- }
- private void textBoxButtonScaleFont_ButtonClick(object sender, EventArgs e)
- {
- using (FontDialog dialog = new FontDialog())
- {
- dialog.Font = gauge.Scale.Font;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- dialog.Font = new Font(dialog.Font.FontFamily, (float)Math.Round(dialog.Font.Size), dialog.Font.Style);
- textBoxButtonScaleFont.Text = Converter.ToString(dialog.Font);
- gauge.Scale.Font = dialog.Font;
- }
- }
- }
- private void btnPointerFill_Click(object sender, EventArgs e)
- {
- using (FillEditorForm form = new FillEditorForm())
- {
- form.Fill = gauge.Pointer.Fill;
- if (form.ShowDialog() == DialogResult.OK)
- gauge.Pointer.Fill = form.Fill;
- }
- }
- private void btnGeneralBorder_Click(object sender, EventArgs e)
- {
- using (BorderEditorForm form = new BorderEditorForm())
- {
- form.Border = gauge.Border;
- if (form.ShowDialog() == DialogResult.OK)
- gauge.Border = form.Border;
- }
- }
- private void btnGeneralFill_Click(object sender, EventArgs e)
- {
- using (FillEditorForm form = new FillEditorForm())
- {
- form.Fill = gauge.Fill;
- if (form.ShowDialog() == DialogResult.OK)
- gauge.Fill = form.Fill;
- }
- }
- private void textBoxButtonLabelFont_ButtonClick(object sender, EventArgs e)
- {
- using (FontDialog dialog = new FontDialog())
- {
- dialog.Font = gauge.Label.Font;
- if (dialog.ShowDialog() == DialogResult.OK)
- {
- dialog.Font = new Font(dialog.Font.FontFamily, (float)Math.Round(dialog.Font.Size), dialog.Font.Style);
- textBoxButtonLabelFont.Text = Converter.ToString(dialog.Font);
- gauge.Label.Font = dialog.Font;
- }
- }
- }
- private void btnExpression_Click(object sender, EventArgs e)
- {
- using (ExpressionEditorForm expressionForm = new ExpressionEditorForm(Gauge.Report))
- {
- expressionForm.ExpressionText = gauge.Expression;
- if (expressionForm.ShowDialog() == DialogResult.OK)
- {
- gauge.Expression = expressionForm.ExpressionText;
- }
- }
- }
- #endregion // Events Handlers
- }
- }
|