Exemplo n.º 1
0
 public void UpdateAutostart()
 {
     if (Settings.Instance.MinimizeOnClose)
     {
         if (Settings.Instance.Autostart)
         {
             Autostart.Enable();
         }
         else
         {
             Autostart.Disable();
         }
     }
     else
     {
         Autostart.Disable();
     }
 }
        private void MangaShareCrawlerForm_Load(object sender, EventArgs e)
        {
            SetupLog4NET();

            ActiveLabelColor   = seriesTabLabel.ForeColor;
            InactiveLabelColor = downloadingsTabLabel.ForeColor;

            ListenForRestoreEvent();

            WM_TASKBARCREATED = RegisterWindowMessage("TaskbarCreated");

            Text = String.Format("{0} {1}.{2}", Text,
                                 Assembly.GetAssembly(GetType()).GetName().Version.Major,
                                 Assembly.GetAssembly(GetType()).GetName().Version.Minor);

            DownloadManager.Create(
                Settings.Instance.MangaSettings,
                Settings.GetSettingsDir());

            MovePanelFromTabControl(seriesTabPanel);
            MovePanelFromTabControl(downloadingsTabPanel);
            MovePanelFromTabControl(bookmarksTabPanel);
            MovePanelFromTabControl(optionsTabPanel);
            MovePanelFromTabControl(logTabPanel);
            tabControl.Hide();

            seriesListBox.Focus();
            m_focus[Tabs.Series]       = seriesListBox;
            m_focus[Tabs.Downloadings] = downloadingsGridView;
            m_focus[Tabs.Bookmarks]    = bookmarkedSeriesListBox;
            m_focus[Tabs.Options]      = mangaRootDirChooseButton;
            m_focus[Tabs.Log]          = logRichTextBox;

            FrontTab = Tabs.Log;
            FrontTab = Tabs.Series;

            versionLinkLabel.TabStop = false;

            if (Settings.Instance.MinimizeOnClose)
            {
                if (Settings.Instance.Autostart != Autostart.Enabled)
                {
                    Settings.Instance.Autostart = Autostart.Enabled;
                }
            }
            else
            {
                Autostart.Disable();
            }

            mangaRootDirTextBox.Text = Settings.Instance.MangaSettings.GetMangaRootDir(false);
            seriesSearchTextBox.Text = Settings.Instance.SeriesFilter;
            cbzCheckBox.Checked      = Settings.Instance.MangaSettings.UseCBZ;
            padImageNamesWithZerosCheckBox.Checked     = Settings.Instance.MangaSettings.PadPageNamesWithZeros;
            deleteDirWithImagesWhenCBZCheckBox.Checked = Settings.Instance.MangaSettings.DeleteDirWithImagesWhenCBZ;
            deleteDirWithImagesWhenCBZCheckBox.Enabled = Settings.Instance.MangaSettings.UseCBZ;
            minimizeOnCloseCheckBox.Checked            = Settings.Instance.MinimizeOnClose;
            showBaloonTipsCheckBox.Checked             = Settings.Instance.ShowBaloonTips;
            autostartCheckBox.Checked      = Settings.Instance.Autostart;
            showBaloonTipsCheckBox.Enabled = minimizeOnCloseCheckBox.Checked;
            autostartCheckBox.Enabled      = minimizeOnCloseCheckBox.Checked;

            if (Settings.Instance.MangaSettings.PageNamingStrategy == PageNamingStrategy.DoNotChange)
            {
                pageNamingStrategyComboBox.SelectedIndex = 0;
            }
            else if (Settings.Instance.MangaSettings.PageNamingStrategy == PageNamingStrategy.PrefixToPreserverOrder)
            {
                pageNamingStrategyComboBox.SelectedIndex = 1;
            }
            else if (Settings.Instance.MangaSettings.PageNamingStrategy == PageNamingStrategy.IndexToPreserveOrder)
            {
                pageNamingStrategyComboBox.SelectedIndex = 2;
            }
            else if (Settings.Instance.MangaSettings.PageNamingStrategy == PageNamingStrategy.AlwaysUsePrefix)
            {
                pageNamingStrategyComboBox.SelectedIndex = 3;
            }
            else if (Settings.Instance.MangaSettings.PageNamingStrategy == PageNamingStrategy.AlwaysUseIndex)
            {
                pageNamingStrategyComboBox.SelectedIndex = 4;
            }
            else
            {
                Loggers.GUI.Error("Invalid PageNamingStrategy");
            }

            playSoundWhenDownloadedCheckBox.Checked = Settings.Instance.PlaySoundWhenDownloaded;

            Task.Factory.StartNew(() => Commands.CheckNewVersion(), TaskCreationOptions.LongRunning);

            if (!Loggers.Log())
            {
                logTabLabel.Hide();
                LogManager.Shutdown();
                ContextMenuStrip = null;
            }

            // Flicker-free.
            typeof(DataGridView).InvokeMember(
                "DoubleBuffered",
                BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
                null, downloadingsGridView, new object[] { true });

            downloadingsGridView.AutoGenerateColumns = false;
            downloadingsGridView.DataSource          = new BindingList <DownloadingGridRow>();

            Commands.CheckNowBookmarks();

            ResizeToolStripImages();
            ResizeContextMenuStripImages();

            // VS designer bug
            // this post in from 2006, no comment...
            // http://social.msdn.microsoft.com/Forums/ar/winformsdesigner/thread/6f56b963-df4d-4f26-8dc3-0244d129f07c
            foreach (var ts in FindAll <ToolStrip>())
            {
                ts.Visible = true;
            }

            refreshTimer.Enabled = true;
            refreshTimer_Tick(this, EventArgs.Empty);
        }