private void InitializeComponent() { _searchQueryLabel = new Label(); _downloadPathLabel = new Label(); _searchQueryTextBox = new SearchQueryTextBox(); _downloadPathTextBox = new DerpiAdvancedPathTextBox(); _downloadProgressBar = new ProgressBar(); _logRichTextBox = new LoggerRichTextBox(); _startDownloadButton = new Button(); _removeOrRestartDownloadButton = new Button(); _pauseResumeButton = new Button(); _downloadValueLabel = new CurrentMaxValueLabel(); _helpToolTip = new HelpToolTip(); SuspendLayout(); _searchQueryLabel.Location = new Point(2, -3); _searchQueryLabel.Size = new Size(200, 20); _searchQueryLabel.AutoSize = false; _searchQueryLabel.TextAlign = ContentAlignment.MiddleLeft; _downloadPathLabel.Location = new Point(2, 40); _downloadPathLabel.Size = new Size(200, 20); _downloadPathLabel.AutoSize = false; _downloadPathLabel.TextAlign = ContentAlignment.MiddleLeft; _searchQueryTextBox.Location = new Point(5, 18); _searchQueryTextBox.Size = new Size(330, 22); _searchQueryTextBox.Multiline = false; _searchQueryTextBox.TextAlign = HorizontalAlignment.Left; _searchQueryTextBox.AutoSize = false; _searchQueryTextBox.TextChanged += (sender, args) => OnTextChanged(); _downloadPathTextBox.Location = new Point(3, 60); _downloadPathTextBox.Size = new Size(332, 22); _downloadPathTextBox.AutoSize = false; _downloadPathTextBox.PathType = PathType.File; _downloadPathTextBox.UpdateAvailableFormatingParts(typeof(Json.Image)); _downloadPathTextBox.TextChanged += (sender, args) => OnTextChanged(); _downloadPathTextBox.Text = Globals.CurrentDownloadPath; _downloadPathTextBox.PathBeenSelected += str => _downloadPathTextBox.Text = Path.Combine(str, Globals.CurrentDownloadFileName.GetValue()); _startDownloadButton.Location = new Point(3, 90); _startDownloadButton.Size = new Size(302, 25); _startDownloadButton.TextAlign = ContentAlignment.MiddleCenter; _startDownloadButton.Click += OnStartDownloadButton_Click; _pauseResumeButton.Location = new Point(_startDownloadButton.Location.X, _startDownloadButton.Location.Y); _pauseResumeButton.Size = new Size(_startDownloadButton.Size.Width, _startDownloadButton.Size.Height); _pauseResumeButton.TextAlign = ContentAlignment.MiddleCenter; _pauseResumeButton.Visible = false; _pauseResumeButton.Enabled = false; _pauseResumeButton.Click += OnPauseResumeButton_Click; _removeOrRestartDownloadButton.Location = new Point(304, 90); _removeOrRestartDownloadButton.Size = new Size(30, 30); _removeOrRestartDownloadButton.Click += OnRemoveOrRestartDownloadButtonClick; _logRichTextBox.Size = new Size(200, 75); _logRichTextBox.Location = new Point(340, 15); _logRichTextBox.Font = new Font(Font.Name, Font.Size - 1); _logRichTextBox.BorderStyle = BorderStyle.Fixed3D; _logRichTextBox.Reversed = false; _downloadProgressBar.Size = new Size(_startDownloadButton.Size.Width - 3, 5); _downloadProgressBar.Location = new Point(5, 115); _downloadProgressBar.Style = ProgressBarStyle.Continuous; _downloadValueLabel.Size = new Size(_logRichTextBox.Size.Width, 30); _downloadValueLabel.Location = new Point(_logRichTextBox.Location.X, _logRichTextBox.Location.Y + _logRichTextBox.Size.Height); _downloadValueLabel.AutoSize = false; _downloadValueLabel.Visible = false; _downloadValueLabel.TextAlign = ContentAlignment.MiddleLeft; _downloadValueLabel.Font = new Font(Font.Name, Font.Size + 3); _downloadValueLabel.DisplayType = MathUtils.DisplayType.ValueAndPercent; _downloadValueLabel.PercentFractionalCount = 2; Controls.Add(_searchQueryLabel); Controls.Add(_downloadPathLabel); Controls.Add(_searchQueryTextBox); Controls.Add(_downloadPathTextBox); Controls.Add(_startDownloadButton); Controls.Add(_removeOrRestartDownloadButton); Controls.Add(_pauseResumeButton); Controls.Add(_logRichTextBox); Controls.Add(_downloadValueLabel); Controls.Add(_downloadProgressBar); AcceptButton = _startDownloadButton; Globals.APIKey.Changed += OnTextChanged; ResumeLayout(); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { _aboutButton = new Button(); _taskCreatorButton = new Button(); _settingsButton = new Button(); _additionalsButton = new Button(); _downloadControl = new DownloadControl(this); _logRichTextBox = new LoggerRichTextBox(); _queueRequestListBox = new AdvancedListBox(); _helpToolTip = new HelpToolTip(); _pageControl = new PageControl <Control>(); SuspendLayout(); _pageControl.Size = new Size(LayoutGUI.DownloadControlSizeWidth, LayoutGUI.MainFormSizeHeight - LayoutGUI.ButtonSizeHeight - LayoutGUI.DistanceBetweenControls); _pageControl.Location = new Point(0, LayoutGUI.ButtonSizeHeight + 1); _pageControl.Font = new Font(Font.Name, Font.Size + 2); _pageControl.Position = TabAlignment.Bottom; _pageControl.Alignment = ContentAlignment.BottomCenter; _pageControl.NextPageButton.Enabled = false; _pageControl.PreviousPageButton.Enabled = false; _pageControl.PageValueLabel.Enabled = false; _pageControl.NextPageButton.Visible = false; _pageControl.PreviousPageButton.Visible = false; _pageControl.PageValueLabel.Visible = false; _pageControl.Add(_downloadControl); // //DownloadControl // _downloadControl.Location = new Point(0, 0); _downloadControl.Size = new Size(_pageControl.Size.Width, _pageControl.Size.Height - _pageControl.ButtonHeight); _downloadControl.VisibleChanged += (sender, args) => UpdateText(); // // taskCreatorButton // _taskCreatorButton.Location = new Point(0, 0); _taskCreatorButton.Size = new Size(LayoutGUI.ButtonSizeWidth, LayoutGUI.ButtonSizeHeight); _taskCreatorButton.Image = new Bitmap(Images.Lineal.Plus, new Size(LayoutGUI.ButtonSizeWidth / 2, LayoutGUI.ButtonSizeHeight / 2)); _taskCreatorButton.UseVisualStyleBackColor = true; _taskCreatorButton.Enabled = Globals.APIKey.IsValid; _taskCreatorButton.Click += (sender, args) => { if (_downloadControl.CurrentTasks < DownloadControl.MaximumTasks && (ModifierKeys == Keys.Control || ModifierKeys == (Keys.Shift | Keys.Control))) { _downloadControl.AddDownloadTaskControl(); return; } OpenTaskCreatorForm(ModifierKeys.HasFlag(Keys.Shift)); }; Globals.APIKey.Changed += () => { _taskCreatorButton.Enabled = Globals.APIKey.IsValid; }; Globals.APIKey.Changed += () => { if (Globals.APIKey.IsValid && _downloadControl.CurrentTasks <= 0) { _downloadControl.AddDownloadTaskControl(); } }; // // settingsButton // _settingsButton.Size = new Size(LayoutGUI.ButtonSizeWidth, LayoutGUI.ButtonSizeHeight); _settingsButton.Location = new Point(LayoutGUI.MainFormSizeWidth - _settingsButton.Size.Width, 0); _settingsButton.Image = new Bitmap(Images.Line.Settings, new Size(LayoutGUI.ButtonSizeWidth / 2, LayoutGUI.ButtonSizeHeight / 2)); _settingsButton.UseVisualStyleBackColor = true; _settingsButton.Click += (sender, args) => { _settingsForm.ShowDialog(); }; // // additionalsButton // _additionalsButton.Size = new Size(LayoutGUI.ButtonSizeWidth, LayoutGUI.ButtonSizeHeight); _additionalsButton.Location = new Point(LayoutGUI.MainFormSizeWidth - _settingsButton.Size.Width - _additionalsButton.Size.Width, 0); _additionalsButton.Image = new Bitmap(Images.Line.Tech, new Size(LayoutGUI.ButtonSizeWidth / 2, LayoutGUI.ButtonSizeHeight / 2)); _additionalsButton.UseVisualStyleBackColor = true; _additionalsButton.Click += (sender, args) => { _additionalsForm.ShowDialog(); }; // // aboutButton // _aboutButton.Size = new Size(LayoutGUI.ButtonSizeWidth, LayoutGUI.ButtonSizeHeight); _aboutButton.Location = new Point(LayoutGUI.MainFormSizeWidth - _settingsButton.Size.Width - _additionalsButton.Size.Width - _aboutButton.Size.Width, 0); _aboutButton.UseVisualStyleBackColor = true; _aboutButton.Image = new Bitmap(Images.Basic.Question, new Size(LayoutGUI.ButtonSizeWidth / 2, LayoutGUI.ButtonSizeHeight / 2)); _aboutButton.Click += (sender, args) => { new MessageForm(ModifierKeys == Keys.Shift ? Globals.Localization.FirstKnowText : Globals.Localization.AboutProgramText, Globals.Localization.AboutProgramTitle, Images.Basic.Information, Resource.icon.ToBitmap(), MessageBoxButtons.OK, new[] { Globals.Localization.Close }).ShowDialog(); }; _logRichTextBox.Size = new Size(LayoutGUI.MainFormLoggerRichTextBoxSizeWidth - 2, LayoutGUI.MainFormLoggerRichTextBoxSizeHeight); _logRichTextBox.Location = new Point(LayoutGUI.MainFormSizeWidth - _logRichTextBox.Size.Width - LayoutGUI.QueueRequestListBoxWidth, LayoutGUI.MainFormSizeHeight - _logRichTextBox.Size.Height - _pageControl.ButtonHeight - LayoutGUI.DistanceBetweenControls + 1); _logRichTextBox.BorderStyle = BorderStyle.None; _logRichTextBox.ScrollBars = RichTextBoxScrollBars.None; _logRichTextBox.Reversed = false; _logRichTextBox.BorderStyle = BorderStyle.Fixed3D; Globals.Logger.Logged += _logRichTextBox.Log; _queueRequestListBox.Size = new Size(LayoutGUI.QueueRequestListBoxWidth, _logRichTextBox.Size.Height); _queueRequestListBox.Location = new Point(_logRichTextBox.Location.X + _logRichTextBox.Size.Width, _logRichTextBox.Location.Y); _queueRequestListBox.AddButton.Click += (sender, args) => { OpenTaskCreatorForm(ModifierKeys.HasFlag(Keys.Shift)); }; _queueRequestListBox.ListBox.ItemAdded += (index, obj) => { if (obj is DownloadRequest request) { AddedRequest?.Invoke(request); } }; // // MainForm // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(LayoutGUI.MainFormSizeWidth, LayoutGUI.MainFormSizeHeight); FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; Controls.Add(_logRichTextBox); Controls.Add(_queueRequestListBox); Controls.Add(_aboutButton); Controls.Add(_additionalsButton); Controls.Add(_taskCreatorButton); Controls.Add(_settingsButton); Controls.Add(_pageControl); Icon = Resource.icon; Shown += OnForm_Shown; Globals.APIKey.Changed += OnAPIKeyChanged; OnAPIKeyChanged(); JsonAPI.OnExceptionResponce += code => { switch (code) { case HttpStatusCode.Forbidden: case HttpStatusCode.Unauthorized: new MessageForm(Globals.Localization.CurrentAPIKeyInvalid, Globals.Localization.APIKeyInvalid, Images.Basic.Error, Images.Basic.Error) .ShowDialog(); _settingsForm.ResetAPI(); _settingsForm.ShowDialog(); break; default: new MessageForm($"{Globals.Localization.UnknownError}: {code}", Globals.Localization.UnknownError, Images.Basic.Error, Images.Basic.Error).ShowDialog(); break; } }; ResumeLayout(); }