Exemplo n.º 1
0
        private void SaveConfiguration()
        {
            plotPanel.SetCurrentSettings();
            foreach (TreeColumn column in treeView.Columns)
            {
                settings.SetValue("treeView.Columns." + column.Header + ".Width",
                                  column.Width);
            }

            this.settings.SetValue("listenerPort", server.ListenerPort);

            string fileName = Path.ChangeExtension(
                System.Windows.Forms.Application.ExecutablePath, ".config");

            try {
                settings.Save(fileName);
            } catch (UnauthorizedAccessException) {
                MessageBox.Show("Access to the path '" + fileName + "' is denied. " +
                                "The current settings could not be saved.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } catch (IOException) {
                MessageBox.Show("The path '" + fileName + "' is not writeable. " +
                                "The current settings could not be saved.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void SaveConfiguration()
        {
            plotPanel.SetCurrentSettings();

            foreach (TreeColumn column in treeView.Columns)
            {
                settings.SetValue($"treeView.Columns.{column.Header}.Width", column.Width);
            }

            settings.SetValue("listenerPort", server.ListenerPort);

            string fileName = Path.ChangeExtension(Application.ExecutablePath, ".config");

            try
            {
                settings.Save(fileName);
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show($"Access to the path '{fileName}' is denied. The current settings could not be saved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (IOException)
            {
                MessageBox.Show($"The path '{fileName}' is not writeable. The current settings could not be saved.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }