SimpleProgressGaugeEditorForm.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using FastReport.Utils;
  2. using System;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. namespace FastReport.Gauge.Simple.Progress
  6. {
  7. internal partial class SimpleProgressGaugeEditorForm : SimpleGaugeEditorForm
  8. {
  9. private Label lblDecimals;
  10. private TextBox tbDecimals;
  11. private Label lblPtrType;
  12. private ComboBox cbPtrType;
  13. #region Constructors
  14. public SimpleProgressGaugeEditorForm(GaugeObject gauge) : base(gauge, true)
  15. {
  16. InitializeComponent();
  17. Localize();
  18. UIUtils.CheckRTL(this);
  19. UpdateDpiDependencies();
  20. }
  21. #endregion Constructors // Constructors
  22. #region ProtectedMethods
  23. protected override void Init()
  24. {
  25. base.Init();
  26. #region ControlsDesign
  27. pageControl1.Pages.Remove(pgScale);
  28. tbLabelText.Visible = false;
  29. tbLabelText.Enabled = false;
  30. lblLabelText.Visible = false;
  31. lblDecimals = new Label();
  32. tbDecimals = new TextBox();
  33. lblPtrType = new Label();
  34. cbPtrType = new ComboBox();
  35. lblDecimals.AutoSize = true;
  36. lblDecimals.Location = lblLabelText.Location;
  37. lblDecimals.Name = "lblDecimals";
  38. lblDecimals.Text = "Decimals :";
  39. tbDecimals.Location = tbLabelText.Location;
  40. tbDecimals.Size = textBoxButtonLabelFont.Size;
  41. tbDecimals.Name = "tbDecimals";
  42. lblPtrType.AutoSize = true;
  43. lblPtrType.Location = new Point(lblPtrBorderColor.Location.X, btnPointerFill.Location.Y + btnPointerFill.Height + 5);
  44. lblPtrType.Name = "lblPtrType";
  45. lblPtrType.Text = "Type :";
  46. cbPtrType.Size = btnPointerFill.Size;
  47. cbPtrType.DropDownStyle = ComboBoxStyle.DropDownList;
  48. cbPtrType.Location = new Point(btnPointerFill.Location.X, lblPtrType.Location.Y);
  49. cbPtrType.Items.Add("Full");
  50. cbPtrType.Items.Add("Small");
  51. cbPtrType.SelectedItem = "Full";
  52. cbPtrType.Name = "cbPtrType";
  53. pgLabel.Controls.AddRange(new Control[] { lblDecimals, tbDecimals });
  54. pgPointer.Controls.AddRange(new Control[] { lblPtrType, cbPtrType });
  55. #endregion // ControlsDesign
  56. if (Gauge != null)
  57. {
  58. try
  59. {
  60. tbDecimals.Text = Convert.ToString(((Gauge as SimpleProgressGauge).Label as SimpleProgressLabel).Decimals);
  61. cbPtrType.SelectedItem = ((Gauge as SimpleProgressGauge).Pointer as SimpleProgressPointer).Type == SimpleProgressPointerType.Full ? "Full" : "Small";
  62. }
  63. catch (Exception ex)
  64. {
  65. if (!Config.WebMode)
  66. {
  67. FRMessageBox.Error(ex.Message);
  68. }
  69. }
  70. }
  71. }
  72. /// <inheritdoc />
  73. protected override void GaugeEditorForm_FormClosing(object sender, FormClosingEventArgs e)
  74. {
  75. if (this.DialogResult == DialogResult.OK)
  76. {
  77. base.GaugeEditorForm_FormClosing(sender, e);
  78. try
  79. {
  80. ((Gauge as SimpleProgressGauge).Label as SimpleProgressLabel).Decimals = int.Parse(tbDecimals.Text);
  81. ((Gauge as SimpleProgressGauge).Pointer as SimpleProgressPointer).Type = cbPtrType.SelectedItem.ToString() == "Full" ? SimpleProgressPointerType.Full : SimpleProgressPointerType.Small;
  82. }
  83. catch (Exception ex)
  84. {
  85. if (!Config.WebMode)
  86. {
  87. FRMessageBox.Error(ex.Message);
  88. }
  89. }
  90. }
  91. }
  92. #endregion //Protected Methods
  93. /// <inheritdoc />
  94. public override void Localize()
  95. {
  96. base.Localize();
  97. MyRes res = new MyRes("Objects,Gauge,GaugeForms,SimpleProgressGauge");
  98. Text = res.Get("");
  99. res = new MyRes("Objects,Gauge,GaugeForms,PagePointer");
  100. lblPtrType.Text = res.Get("LabelPointerType");
  101. res = new MyRes("Objects,Gauge,GaugeForms,PageLabel");
  102. lblDecimals.Text = res.Get("Decimals");
  103. }
  104. }
  105. }