SavingPageOptions.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Windows.Forms;
  2. using FastReport.Design;
  3. using FastReport.Utils;
  4. namespace FastReport.Forms
  5. {
  6. internal partial class SavingPageOptions : DesignerOptionsPage
  7. {
  8. private Designer designer;
  9. public SavingPageOptions(Designer designer) : base()
  10. {
  11. InitializeComponent();
  12. Localize();
  13. this.designer = designer;
  14. nudMinutes.Left = cbAutoSave.Right;
  15. }
  16. private void Localize()
  17. {
  18. MyRes res = new MyRes("Forms,SavingPageOptions");
  19. tab1.Text = res.Get("");
  20. cbAutoSave.Text = res.Get("EnableAutoSave");
  21. }
  22. public override void Init()
  23. {
  24. //cbAutoSave.Checked = designer.AutoSaveTimer.Enabled;
  25. //nudMinutes.Value = designer.AutoSaveTimer.Interval / 60000;
  26. XmlItem xi = Config.Root.FindItem("Designer").FindItem("Saving");
  27. int minutes = 0;
  28. if (!int.TryParse(xi.GetProp("AutoSaveMinutes"), out minutes))
  29. minutes = 5;
  30. nudMinutes.Value = minutes;
  31. cbAutoSave.Checked = xi.GetProp("EnableAutoSave") != "0";
  32. cbAutoSave.Enabled = !designer.IsPreviewPageDesigner;
  33. nudMinutes.Enabled = !designer.IsPreviewPageDesigner;
  34. }
  35. public override void Done(DialogResult result)
  36. {
  37. if (result == DialogResult.OK)
  38. {
  39. designer.AutoSaveTimer.Enabled = cbAutoSave.Checked;
  40. designer.AutoSaveTimer.Interval = (int)nudMinutes.Value * 60000;
  41. XmlItem xi = Config.Root.FindItem("Designer").FindItem("Saving");
  42. xi.SetProp("EnableAutoSave", cbAutoSave.Checked ? "1" : "0");
  43. xi.SetProp("AutoSaveMinutes", "" + nudMinutes.Value);
  44. }
  45. }
  46. }
  47. }