Пример #1
0
        /// <summary>
        /// Saves statusbar values to config file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="toolbar"></param>
        public void SaveStatusbar(string path, StatusbarSetting statusbar)
        {
            XmlTextReader reader = new XmlTextReader(_fileName);
            XmlDocument   doc    = new XmlDocument();

            doc.Load(reader);
            reader.Close();

            XmlNode    oldForm;
            XmlElement root = doc.DocumentElement;

            oldForm = root.SelectSingleNode(path);
            XmlNode parentNode = oldForm.ParentNode;

            XmlElement newForm = doc.CreateElement("statusbar");

            newForm.SetAttribute("name", statusbar.Name);

            newForm.InnerXml = "<Visible>" + statusbar.Visible + "</Visible>";

            // If existing element was not found, append setting as new element
            if (oldForm != null)
            {
                parentNode.ReplaceChild(newForm, oldForm);
            }
            else
            {
                parentNode.AppendChild(newForm);
            }
            doc.Save(_fileName);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        /// <summary>
        /// Setting visible value info.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="iterator"></param>
        public static void SetVisibleValue(IComponentSetting component,
                                           XPathNodeIterator iterator)
        {
            bool visible = false;

            while (iterator.MoveNext())
            {
                XPathNavigator navigator = iterator.Current.Clone();

                switch (navigator.Name)
                {
                case "Visible":
                    try
                    {
                        visible = Convert.ToBoolean(navigator.Value);
                    }
                    catch (Exception)
                    {
                        visible = false;
                    }
                    break;

                default:
                    break;
                }
            }

            if (component is ToolbarSetting)
            {
                ToolbarSetting toolbar = (ToolbarSetting)component;
                toolbar.SetValues(visible);
            }

            if (component is StatusbarSetting)
            {
                StatusbarSetting statusbar = (StatusbarSetting)component;
                statusbar.SetValues(visible);
            }
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// Saves statusbar values to config file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="toolbar"></param>
        public void SaveStatusbar(string path, StatusbarSetting statusbar)
        {
            XmlTextReader reader = new XmlTextReader(_fileName);
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);
            reader.Close();

            XmlNode oldForm;
            XmlElement root = doc.DocumentElement;
            oldForm = root.SelectSingleNode(path);
            XmlNode parentNode = oldForm.ParentNode;

            XmlElement newForm = doc.CreateElement("statusbar");
            newForm.SetAttribute("name", statusbar.Name);

            newForm.InnerXml = "<Visible>" + statusbar.Visible + "</Visible>";

            // If existing element was not found, append setting as new element
            if (oldForm != null)
            {
                parentNode.ReplaceChild(newForm, oldForm);
            }
            else
            {
                parentNode.AppendChild(newForm);
            }
            doc.Save(_fileName);
        }
Пример #8
0
        /// <summary>
        /// Called when MainForm is starting.
        /// Setting positions for MainForm and Toolbars.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainFormLoad(object sender, EventArgs e)
        {
            // Setting MainForm starting values
            FormSetting mainFormSetting = new FormSetting(_handler);
            mainFormSetting.GetSetting("MainForm");

            if (mainFormSetting.X == -1 || mainFormSetting.Y == -1)
                StartPosition = FormStartPosition.CenterScreen;
            else
                Location = new Point(mainFormSetting.X, mainFormSetting.Y);

            Width = mainFormSetting.Width;
            Height = mainFormSetting.Height;

            // Setting toolStripFile starting values
            ToolbarSetting settingToolStripFile = new ToolbarSetting(_handler);
            settingToolStripFile.GetSetting("toolStripFile");

            if (settingToolStripFile.X == -1 || settingToolStripFile.Y == -1)
                toolStripFile.Location = new Point(3, 24);
            else
                toolStripFile.Location = new Point(settingToolStripFile.X, settingToolStripFile.Y);
            toolStripFile.Visible = settingToolStripFile.Visible;

            mainMenuViewToolbarsFile.Checked  = toolStripFile.Visible;
            contextMenuFile.Checked  = toolStripFile.Visible;

            // Setting toolStripSums starting values
            ToolbarSetting settingToolStripSums = new ToolbarSetting(_handler);
            settingToolStripSums.GetSetting("toolStripSums");

            if (settingToolStripSums.X == -1 || settingToolStripSums.Y == -1)
                toolStripSums.Location = new Point(3, 49);
            else
                toolStripSums.Location = new Point(settingToolStripSums.X, settingToolStripSums.Y);
            toolStripSums.Visible = settingToolStripSums.Visible;

            mainMenuViewToolbarsSums.Checked  = toolStripSums.Visible;
            contextMenuSums.Checked  = toolStripSums.Visible;

            // Setting statusStrip1 starting values
            StatusbarSetting settingStatusStrip1 = new StatusbarSetting(_handler);
            settingStatusStrip1.GetSetting("statusStrip1");

            statusStrip1.Visible = settingStatusStrip1.Visible;
            mainMenuViewStatusBar.Checked  = statusStrip1.Visible;

            // Setting columnSize starting values
            ColumnSetting settingColumnSize = new ColumnSetting(_handler);
            settingColumnSize.GetSetting("columnSize");

            columnSize.DisplayIndex = settingColumnSize.DisplayIndex;
            columnSize.Width = settingColumnSize.Width;

            // Setting columnFullpath starting values
            ColumnSetting settingColumnFullpath = new ColumnSetting(_handler);
            settingColumnFullpath.GetSetting("columnFullpath");

            columnFullpath.DisplayIndex = settingColumnFullpath.DisplayIndex;
            columnFullpath.Width = settingColumnFullpath.Width;

            //Setting columnVerified starting values
            ColumnSetting settingColumnVerified = new ColumnSetting(_handler);
            settingColumnVerified.GetSetting("columnVerified");

            columnVerified.DisplayIndex = settingColumnVerified.DisplayIndex;
            columnVerified.Width = settingColumnVerified.Width;

            // Setting columnType starting values
            ColumnSetting settingColumnType = new ColumnSetting(_handler);
            settingColumnType.GetSetting("columnType");

            columnType.DisplayIndex = settingColumnType.DisplayIndex;
            columnType.Width = settingColumnType.Width;

            // Setting columnFilename starting values
            ColumnSetting settingColumnFilename = new ColumnSetting(_handler);
            settingColumnFilename.GetSetting("columnFilename");

            columnFilename.DisplayIndex = settingColumnFilename.DisplayIndex;
            columnFilename.Width = settingColumnFilename.Width;

            UpdateViewMenuItems();
        }
Пример #9
0
        /// <summary>
        /// Called when MainForm is closing.
        /// Setting positio and visible values in user settings.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainFormFormClosing(object sender, FormClosingEventArgs e)
        {
            // Setting MainForm ending values
            FormSetting mainFormSetting = new FormSetting(_handler);
            mainFormSetting.SaveSetting("MainForm",
                                        this.Location.X,
                                        this.Location.Y,
                                        this.Width,
                                        this.Height);
            // Setting toolStripFile ending values
            ToolbarSetting toolStripFileSetting = new ToolbarSetting(_handler);
            toolStripFileSetting.SaveSetting("toolStripFile",
                                             toolStripFile.Location.X,
                                             toolStripFile.Location.Y,
                                             toolStripFile.Visible);

            // Setting toolStripSums ending values
            ToolbarSetting toolStripSumsSetting = new ToolbarSetting(_handler);
            toolStripSumsSetting.SaveSetting("toolStripSums",
                                             toolStripSums.Location.X,
                                             toolStripSums.Location.Y,
                                             toolStripSums.Visible);

            //Setting settingStatusStrip1 ending values
            StatusbarSetting settingStatusStrip1 = new StatusbarSetting(_handler);
            settingStatusStrip1.SaveSetting("statusStrip1", statusStrip1.Visible);

            //Setting columnSize starting ending values
            ColumnSetting settingColumnSize = new ColumnSetting(_handler);
            settingColumnSize.SaveSetting("columnSize", columnSize.DisplayIndex, columnSize.Width);

            //Setting columnFullpath starting ending values
            ColumnSetting settingColumnFullpath = new ColumnSetting(_handler);
            settingColumnFullpath.SaveSetting("columnFullpath", columnFullpath.DisplayIndex, columnFullpath.Width);

            //Setting columnVerified starting ending values
            ColumnSetting settingColumnVerified = new ColumnSetting(_handler);
            settingColumnVerified.SaveSetting("columnVerified", columnVerified.DisplayIndex, columnVerified.Width);

            //Setting columnType starting ending values
            ColumnSetting settingColumnType = new ColumnSetting(_handler);
            settingColumnType.SaveSetting("columnType", columnType.DisplayIndex, columnType.Width);

            //Setting columnFilename starting ending values
            ColumnSetting settingColumnFilename = new ColumnSetting(_handler);
            settingColumnFilename.SaveSetting("columnFilename", columnFilename.DisplayIndex, columnFilename.Width);
        }