Ejemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists("Settings.xml"))
                {
                    Preferences = XmlManager.Deserialize();
                }
                else
                {
                    Preferences = new Settings
                    {
                        PageSize        = 50,
                        AutoSortByName  = true,
                        CropMaxViewSize = true,
                        FocusFirstItem  = true,
                        FormCaptionText = "Медиа-библиотекарь",
                        LastLibraryName = "",
                        MainFont        = new SFont {
                            FontFamilyName = "Tahoma", FontSize = 16, FontStyle = FontStyle.Bold
                        },
                        PicMaxHeight        = 720,
                        PicMaxWidth         = 720,
                        RememberLastLibrary = false,
                        StartFullScreen     = false,
                        ThemeColor1         = "WhiteSmoke",
                        ThemeColor2         = "SteelBlue",
                        MainColor           = "Blue",
                        FontColor           = "Black"
                    }
                };
                InitFont();
                if (Preferences.RememberLastLibrary && Preferences.LastLibraryName != "")
                {
                    _libManagerForm.ReadHeadersForTable(Preferences.LastLibraryName);
                    _libManagerForm.ReadTableFromDatabase(Preferences.LastLibraryName, Preferences.PageSize);
                    paginationToolStrip.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка открытия файла настроек", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            if (Preferences.StartFullScreen)
            {
                WindowState            = FormWindowState.Maximized;
                FullScreenTSMI.Checked = true;
            }

            if (Preferences.AutoSortByName)
            {
                AutoSortingTSMI.Checked = true;
            }

            Text                 = Preferences.FormCaptionText;
            BackColor            = Color.FromName(Preferences.ThemeColor1);
            TitleLabel.ForeColor = SelectedLibLabel.ForeColor = ElementCount.ForeColor =
                Color.FromName(Preferences.MainColor);

            TitleLabel.Font = new Font(Preferences.MainFont.FontFamilyName,
                                       Preferences.MainFont.FontSize, Preferences.MainFont.FontStyle);
        }