public Calculations(Settings global)
        {
            Logs.WriteLine("Инициализация формы калькулятора матриц");
            //загрузка настроек
            settings = global;

            //инициализация компонентов формы
            InitializeComponent();

            //размеры в зависимости от dpi
            using (Graphics myGraphics = this.CreateGraphics())
            {
                float dpi = myGraphics.DpiX;
                if (dpi > 96)
                {
                    this.splitContainerMatrix.SplitterDistance -= Convert.ToInt32(dpi) * 3 / 2 - 96;
                    this.splitContainerMain.SplitterDistance+= Convert.ToInt32(dpi) * 3 / 2 - 96;
                }

            }

            this.MinimumSize = new Size(this.Width, this.Height);
            this.splitContainerMain.Panel2MinSize = this.splitContainerMain.Panel2.Width;
            this.splitContainerMain.Panel1MinSize = this.mtr1col.Location.X + this.mtr1col.Width + this.splitContainerMatrix.Panel2.Width;
            //AutoScaleMode = AutoScaleMode.None;

            splitContainer1.Panel2Collapsed = true;
            splitContainer1.SplitterWidth = 15;
            splitContainerMain.SplitterWidth = 13;

            //по умолчанию грузится матрица 2 на 2
            string col = "";
            dgv_mtr1.Columns.Add(col, col);
            dgv_mtr1.Columns.Add(col, col);
            dgv_mtr1.Rows.Add(2);

            dgv_mtr2.Columns.Add(col, col);
            dgv_mtr2.Columns.Add(col, col);
            dgv_mtr2.Rows.Add(2);

            //установка индексов для выбора номера строк и прочего
            cmbx_две_матр_действия_вычитание.SelectedIndex = 0;
            cmbx_две_матр_действия_умножение.SelectedIndex = 0;
            cmbx_определитель_разложение_строка.SelectedIndex = 0;
            cmbx_определитель_разложение_столбец.SelectedIndex = 0;
            cmbx_определитель_лаплас.SelectedIndex = 0;
            cmbx_определитель_лаплас_2.SelectedIndex = 0;

            //проверка доступности опций
            CheckSizes();
            CheckBothSizes();

            //установка начальной страницы браузера(можно сделать какую-нибудь страничку,как в настройках)
            browser_results.Navigate("about:blank");
            settings.ApplyWebBrowserStyle(browser_results);
        }
Example #2
0
        public SettingsForm(Settings global)
        {
            backup = new Settings();
            global.CopyTo(backup);

            settings = global;

            InitializeComponent();

            //this.ClientSize = new Size(this.Width,this.Height);

            browser_test.Navigate(String.Format("file:///{0}", DirectoriesSettings.SettingsTestHTMLPath));
            numeric_font.Value = Convert.ToDecimal(settings.FontSize);

            for (int i = 0; i < colors.GetLength(0); i++)
                if (colors[i] == settings.BackgroundColor)
                    lbx_color.SelectedIndex = i;

            UpdateStyle();
        }
Example #3
0
 public void CopyTo(Settings other)
 {
     other.BackgroundColor = this.BackgroundColor;
     other.FontSize = this.FontSize;
 }
Example #4
0
        private void Main_Shown(object sender, EventArgs e)
        {
            LockControls();

            cmdDisableX_Click(sender, e);

            bool update = false;

            Converters.MainConverter converter = new Converters.MainConverter(DirectoriesSettings.UnconvertedPath);
            if (converter.CheckForUpdates())
            {
                Logs.WriteLine("Найдены обновления контента");
                update = true;

                MessageBox.Show("Начинается распаковка нового контента" + Environment.NewLine + "Главный элемент с вкладками будет временно недоступен", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //обновляем контент
                converter.UpdateContent(DirectoriesSettings.ConvertedPath);

                //перезаполняем treeview
                Scanners.MainScanner scanner = new Scanners.MainScanner(DirectoriesSettings.ConvertedPath);
                scanner.ScanContent(tree_Теория, tree_Примеры, tree_Тесты);

                //сериализуем treeview для будущего использования
                TreeViewUtils.Serialize(DirectoriesSettings.TreeViewPath, tree_Теория);
                TreeViewUtils.Serialize(DirectoriesSettings.TreeViewPath, tree_Примеры);
                TreeViewUtils.Serialize(DirectoriesSettings.TreeViewPath, tree_Тесты);

                File.Delete(Path.Combine(DirectoriesSettings.UnconvertedPath, "update.conf"));
                MessageBox.Show("Распаковка нового контента успешно завершена", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Logs.WriteLine("Обновления контента не найдены");
                TreeViewUtils.Deserialize(DirectoriesSettings.TreeViewPath, ref tree_Теория);
                TreeViewUtils.Deserialize(DirectoriesSettings.TreeViewPath, ref tree_Примеры);
                TreeViewUtils.Deserialize(DirectoriesSettings.TreeViewPath, ref tree_Тесты);
            }

            tree_Теория.ExpandAll();
            tree_Примеры.ExpandAll();
            tree_Тесты.ExpandAll();

            browser_Теория.Navigate("about:blank");
            browser_Примеры.Navigate("about:blank");

            Logs.WriteLine("Загрузка файла настроек");
            Settings temp = Settings.Load();
            if (temp == null)
            {
                Logs.WriteLine("Файл настроек не найден. Создание файла настроек.");
                settings = new Settings(this);
                try
                {
                    settings.Save();
                    Logs.WriteLine("Успешно сохранён файл настроек со стандартными значениями.");
                }
                catch (Exception ex)
                {
                    Logs.WriteLine("Ошибка при создании файла настроек.");
                    Logs.WriteException(ex);
                    MessageBox.Show("Невозможно сохранить настройки по умолчанию." + Environment.NewLine + "При следующем запуске будут загружены настройки по умолчанию." + Environment.NewLine + "Возможно, приложение нужно запустить с правами администратора.", "Ошибка сохранения", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                Logs.WriteLine("Файл настроек успешно загружен");
                settings = temp;
            }

            UpdateAllStyles();
            settings.LoadFormState(this);
            if (update == true)
                settings.ResetBookmarks();
            else
                settings.LoadBookmarks(tree_Теория, tree_Примеры, tree_Тесты);

            cmdEnableX_Click(sender, e);
            UnlockControls();
        }