/// <summary> /// Saving component position and other values. /// </summary> public static void SaveSetting(XPathHandler handler, IComponentSetting setting, string name, string type) { //TODO: Save first position values and then other. switch (type) { case "form": handler.SaveForm(@"/configuration/GUI/Forms/" + type + @"[@name=""$name""]".Replace("$name", name), (FormSetting)setting); break; case "toolbar": handler.SaveToolbar(@"/configuration/GUI/Toolbars/" + type + @"[@name=""$name""]".Replace("$name", name), (ToolbarSetting)setting); break; case "statusbar": handler.SaveStatusbar(@"/configuration/GUI/Statusbars/" + type + @"[@name=""$name""]".Replace("$name", name), (StatusbarSetting)setting); break; case "column": handler.SaveColumn(@"/configuration/GUI/MainWindow/Columns/" + type + @"[@name=""$name""]".Replace("$name", name), (ColumnSetting)setting); break; default: break; } }
public void TestGetComponentSettings() { XPathHandler handler = new XPathHandler(@"../../TestData/config.xml"); XPathNodeIterator iterator = handler.GetComponentSettings(@"/configuration/form[@name=""MainForm""]/*"); while (iterator.MoveNext()) { XPathNavigator navigator = iterator.Current.Clone(); switch (navigator.Name) { case "X": Assert.AreEqual("23", navigator.Value); break; case "Y": Assert.AreEqual("1", navigator.Value); break; case "Width": Assert.AreEqual("617", navigator.Value); break; case "Height": Assert.AreEqual("498", navigator.Value); break; default: break; } } }
public void TestFormSaveSettinAndGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/configWriteTemp.xml"); FormSetting mainFormSettingFirst = new FormSetting(handler); mainFormSettingFirst.GetSetting("MainForm"); FormSetting mainFormSettingSave = new FormSetting(handler); mainFormSettingSave.Name = "MainForm"; mainFormSettingSave.X = mainFormSettingFirst.X + 1; mainFormSettingSave.Y = mainFormSettingFirst.Y + 1; mainFormSettingSave.Width = mainFormSettingFirst.Width + 1; mainFormSettingSave.Height = mainFormSettingFirst.Height + 1; mainFormSettingSave.SaveSetting(); FormSetting mainFormSettingSecond = new FormSetting(handler); mainFormSettingSecond.GetSetting("MainForm"); Assert.AreEqual(mainFormSettingSave.Name, mainFormSettingSecond.Name); Assert.AreEqual(mainFormSettingSave.X, mainFormSettingSecond.X); Assert.AreEqual(mainFormSettingSave.Y, mainFormSettingSecond.Y); Assert.AreEqual(mainFormSettingSave.Width, mainFormSettingSecond.Width); Assert.AreEqual(mainFormSettingSave.Height, mainFormSettingSecond.Height); }
/// <summary> /// Get component position and other values. /// </summary> /// <param name="name"></param> public static void GetSetting(List <Setting> list, XPathHandler handler, IComponentSetting setting, string name, string type) { Setting settingName = new Setting(1, "Name", name); list.Add(settingName); string relPath = ""; switch (type) { case "form": relPath = "GUI/Forms/"; break; case "toolbar": relPath = "GUI/Toolbars/"; break; case "statusbar": relPath = "GUI/Statusbars/"; break; case "column": relPath = "GUI/MainWindow/Columns/"; break; } string path = "/configuration/" + relPath + type + @"[@name=""$name""]/*".Replace("$name", name); XPathNodeIterator iterator = handler.GetComponentSettings(path); switch (type) { case "form": SetFormValues((FormSetting)setting, iterator.Clone()); SetPositionValues((FormSetting)setting, iterator.Clone()); break; case "toolbar": SetPositionValues((ToolbarSetting)setting, iterator.Clone()); SetVisibleValue((ToolbarSetting)setting, iterator.Clone()); break; case "statusbar": SetVisibleValue((StatusbarSetting)setting, iterator.Clone()); break; case "column": SetColumnValues((ColumnSetting)setting, iterator.Clone()); break; default: break; } }
public void TestToolbarGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/config.xml"); StatusbarSetting settingStatusStrip1 = new StatusbarSetting(handler); settingStatusStrip1.GetSetting("statusStrip1"); Assert.AreEqual("statusStrip1", settingStatusStrip1.Name); Assert.AreEqual(true, settingStatusStrip1.Visible); }
public void TestToolbarGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/config.xml"); ToolbarSetting settingToolStripFile = new ToolbarSetting(handler); settingToolStripFile.GetSetting("toolStripFile"); Assert.AreEqual("toolStripFile", settingToolStripFile.Name); Assert.AreEqual(3, settingToolStripFile.X); Assert.AreEqual(24, settingToolStripFile.Y); Assert.AreEqual(true, settingToolStripFile.Visible); }
public void TestFormGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/config.xml"); FormSetting mainFormSetting = new FormSetting(handler); mainFormSetting.GetSetting("MainForm"); Assert.AreEqual("MainForm", mainFormSetting.Name); Assert.AreEqual(23, mainFormSetting.X); Assert.AreEqual(15, mainFormSetting.Y); Assert.AreEqual(617, mainFormSetting.Width); Assert.AreEqual(498, mainFormSetting.Height); }
/// <summary> /// Get component position and other values. /// </summary> /// <param name="name"></param> public static void GetSetting(List<Setting> list, XPathHandler handler, IComponentSetting setting, string name, string type) { Setting settingName = new Setting(1, "Name", name); list.Add(settingName); string relPath = ""; switch (type) { case "form": relPath = "GUI/Forms/"; break; case "toolbar": relPath = "GUI/Toolbars/"; break; case "statusbar": relPath = "GUI/Statusbars/"; break; case "column": relPath = "GUI/MainWindow/Columns/"; break; } string path = "/configuration/" + relPath + type + @"[@name=""$name""]/*".Replace("$name", name); XPathNodeIterator iterator = handler.GetComponentSettings(path); switch (type) { case "form": SetFormValues((FormSetting) setting, iterator.Clone()); SetPositionValues((FormSetting) setting, iterator.Clone()); break; case "toolbar": SetPositionValues((ToolbarSetting) setting, iterator.Clone()); SetVisibleValue((ToolbarSetting) setting, iterator.Clone()); break; case "statusbar": SetVisibleValue((StatusbarSetting) setting, iterator.Clone()); break; case "column": SetColumnValues((ColumnSetting) setting, iterator.Clone()); break; default: break; } }
public void TestToolbarSaveSettinAndGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/configWriteTemp.xml"); StatusbarSetting settingStatusStrip1First = new StatusbarSetting(handler); settingStatusStrip1First.GetSetting("statusStrip1"); StatusbarSetting settingStatusStrip1Save = new StatusbarSetting(handler); settingStatusStrip1Save.Name = "statusStrip1"; settingStatusStrip1Save.Visible = !settingStatusStrip1First.Visible; settingStatusStrip1Save.SaveSetting(); StatusbarSetting settingStatusStrip1Second = new StatusbarSetting(handler); settingStatusStrip1Second.GetSetting("statusStrip1"); Assert.AreEqual(settingStatusStrip1Save.Name, settingStatusStrip1Second.Name); Assert.AreEqual(settingStatusStrip1Save.Visible, settingStatusStrip1Second.Visible); }
public void TestToolbarSaveSettinAndGetSetting() { XPathHandler handler = new XPathHandler(@"../../TestData/configWriteTemp.xml"); ToolbarSetting settingToolStripFileFirst = new ToolbarSetting(handler); settingToolStripFileFirst.GetSetting("toolStripFile"); ToolbarSetting settingToolStripFileSave = new ToolbarSetting(handler); settingToolStripFileSave.Name = "toolStripFile"; settingToolStripFileSave.X = settingToolStripFileFirst.X + 1; settingToolStripFileSave.Y = settingToolStripFileFirst.Y + 1; settingToolStripFileSave.Visible = !settingToolStripFileFirst.Visible; settingToolStripFileSave.SaveSetting(); ToolbarSetting settingToolStripFileSecond = new ToolbarSetting(handler); settingToolStripFileSecond.GetSetting("toolStripFile"); Assert.AreEqual(settingToolStripFileSave.Name, settingToolStripFileSecond.Name); Assert.AreEqual(settingToolStripFileSave.X, settingToolStripFileSecond.X); Assert.AreEqual(settingToolStripFileSave.Y, settingToolStripFileSecond.Y); Assert.AreEqual(settingToolStripFileSave.Visible, settingToolStripFileSecond.Visible); }
/// <summary> /// Constructor. Set default values and handler. /// </summary> /// <param name="handler"></param> public StatusbarSetting(XPathHandler handler) { _handler = handler; }
/// <summary> /// Constructor. Set default values and handler. /// </summary> /// <param name="handler"></param> public FormSetting(XPathHandler handler) { _handler = handler; }
/// <summary> /// Saving component position and other values. /// </summary> public static void SaveSetting(XPathHandler handler, IComponentSetting setting, string name, string type) { //TODO: Save first position values and then other. switch (type) { case "form": handler.SaveForm(@"/configuration/GUI/Forms/" + type + @"[@name=""$name""]".Replace("$name", name), (FormSetting) setting); break; case "toolbar": handler.SaveToolbar(@"/configuration/GUI/Toolbars/" + type + @"[@name=""$name""]".Replace("$name", name), (ToolbarSetting) setting); break; case "statusbar": handler.SaveStatusbar(@"/configuration/GUI/Statusbars/" + type + @"[@name=""$name""]".Replace("$name", name), (StatusbarSetting) setting); break; case "column": handler.SaveColumn(@"/configuration/GUI/MainWindow/Columns/" + type + @"[@name=""$name""]".Replace("$name", name), (ColumnSetting) setting); break; default: break; } }
/// <summary> /// Constructor. Set default values and handler. /// </summary> /// <param name="handler"></param> public ToolbarSetting(XPathHandler handler) { _handler = handler; }
/// <summary> /// Constructor. Set default values and handler. /// </summary> /// <param name="handler"></param> public ColumnSetting(XPathHandler handler) { _handler = handler; }
/// <summary> /// Checking if the config file exist and is of correct version. If /// the config file is not found or it is unknown version, then the /// default config file (from program folder) is copied as new config /// file. /// </summary> private void CheckConfigFile() { bool success = true; string appDataPath = EnvironmentUtils.GetAppDataPath(); ConfigFile cfile = new ConfigFile(Application.StartupPath, appDataPath); if (!cfile.FileExists()) success = cfile.CreateDefaultFile(); // Check config file version // If incompatible version found, overwrite it. if (!cfile.IsCompatibleVersion()) success = cfile.ReplaceWithDefault(); if (success) _handler = new XPathHandler(cfile.FilePath); }