示例#1
0
        /// <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;
            }
        }
示例#2
0
        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;
                }
            }
        }
示例#3
0
        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);
        }
示例#4
0
        /// <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;
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        /// <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;
            }
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public StatusbarSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#13
0
        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);
        }
示例#14
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public FormSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#15
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public FormSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#16
0
 /// <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;
     }
 }
示例#17
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public ToolbarSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#18
0
        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);
        }
示例#19
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public StatusbarSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#20
0
        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);
        }
示例#21
0
        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;
                }
            }
        }
示例#22
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public ColumnSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#23
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public ToolbarSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#24
0
        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);
        }
示例#25
0
        /// <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);
        }
示例#26
0
 /// <summary>
 /// Constructor. Set default values and handler.
 /// </summary>
 /// <param name="handler"></param>
 public ColumnSetting(XPathHandler handler)
 {
     _handler = handler;
 }
示例#27
0
        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);
        }