コード例 #1
0
ファイル: XPathHandler.cs プロジェクト: s911415/CheckSum-Tool
        /// <summary>
        /// Saves toolbar values to config file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="toolbar"></param>
        public void SaveToolbar(string path, ToolbarSetting toolbar)
        {
            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("toolbar");

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

            newForm.InnerXml = "<X>" + toolbar.X + "</X>" +
                               "<Y>" + toolbar.Y + "</Y>" +
                               "<Visible>" + toolbar.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");
            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);
        }
コード例 #3
0
ファイル: SettingUtils.cs プロジェクト: s911415/CheckSum-Tool
        /// <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);
            }
        }
コード例 #4
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);
        }
コード例 #5
0
        /// <summary>
        /// Saves toolbar values to config file.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="toolbar"></param>
        public void SaveToolbar(string path, ToolbarSetting toolbar)
        {
            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("toolbar");
            newForm.SetAttribute("name", toolbar.Name);

            newForm.InnerXml = "<X>" + toolbar.X + "</X>" +
                               "<Y>" + toolbar.Y + "</Y>" +
                               "<Visible>" + toolbar.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);
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: erdincay/checksum-tool
        /// <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();
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: erdincay/checksum-tool
        /// <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);
        }
コード例 #8
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);
        }
コード例 #9
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);
        }