private void CommandButton_Click(object sender, EventArgs e) { CommandButton commandButton = (CommandButton)sender; this.dialogResult = (TaskButton)commandButton.Tag; Close(); }
private void InitCommandButtons() { SuspendLayout(); if (this.commandButtons != null) { foreach (CommandButton commandButton in this.commandButtons) { Controls.Remove(commandButton); commandButton.Tag = null; commandButton.Click -= CommandButton_Click; commandButton.Dispose(); } this.commandButtons = null; } this.commandButtons = new CommandButton[this.taskButtons.Length]; IButtonControl newAcceptButton = null; IButtonControl newCancelButton = null; for (int i = 0; i < this.commandButtons.Length; ++i) { TaskButton taskButton = this.taskButtons[i]; CommandButton commandButton = new CommandButton(); commandButton.ActionText = taskButton.ActionText; commandButton.ActionImage = taskButton.Image; commandButton.AutoSize = true; commandButton.ExplanationText = taskButton.ExplanationText; commandButton.Tag = taskButton; commandButton.Click += CommandButton_Click; this.commandButtons[i] = commandButton; Controls.Add(commandButton); if (this.acceptTaskButton == taskButton) { newAcceptButton = commandButton; } if (this.cancelTaskButton == taskButton) { newCancelButton = commandButton; } } AcceptButton = newAcceptButton; CancelButton = newCancelButton; if (newAcceptButton != null && newAcceptButton is Control) { ((Control)newAcceptButton).Select(); } ResumeLayout(); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.documentStrip = new PaintDotNet.DocumentStrip(); this.documentListHeader = new PaintDotNet.HeaderLabel(); this.hScrollBar = new System.Windows.Forms.HScrollBar(); this.saveButton = new PaintDotNet.CommandButton(); this.dontSaveButton = new PaintDotNet.CommandButton(); this.cancelButton = new PaintDotNet.CommandButton(); this.infoLabel = new System.Windows.Forms.Label(); this.SuspendLayout(); // // documentStrip // this.documentStrip.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.documentStrip.DocumentClicked += DocumentList_DocumentClicked; this.documentStrip.DrawDirtyOverlay = false; this.documentStrip.EnsureSelectedIsVisible = false; this.documentStrip.ManagedFocus = true; this.documentStrip.Name = "documentList"; this.documentStrip.ScrollOffset = 0; this.documentStrip.ScrollOffsetChanged += new EventHandler(DocumentList_ScrollOffsetChanged); this.documentStrip.ShowCloseButtons = false; this.documentStrip.ShowScrollButtons = false; this.documentStrip.TabIndex = 0; this.documentStrip.ThumbnailUpdateLatency = 10; // // documentListHeader // this.documentListHeader.Name = "documentListHeader"; this.documentListHeader.RightMargin = 0; this.documentListHeader.TabIndex = 1; this.documentListHeader.TabStop = false; // // hScrollBar // this.hScrollBar.Name = "hScrollBar"; this.hScrollBar.TabIndex = 2; this.hScrollBar.ValueChanged += new System.EventHandler(this.HScrollBar_ValueChanged); // // saveButton // this.saveButton.ActionImage = null; this.saveButton.AutoSize = true; this.saveButton.Name = "saveButton"; this.saveButton.TabIndex = 4; this.saveButton.Click += new System.EventHandler(this.SaveButton_Click); // // dontSaveButton // this.dontSaveButton.ActionImage = null; this.dontSaveButton.AutoSize = true; this.dontSaveButton.Name = "dontSaveButton"; this.dontSaveButton.TabIndex = 5; this.dontSaveButton.Click += new System.EventHandler(this.DontSaveButton_Click); // // cancelButton // this.cancelButton.ActionImage = null; this.cancelButton.AutoSize = true; this.cancelButton.Name = "cancelButton"; this.cancelButton.TabIndex = 6; this.cancelButton.Click += new System.EventHandler(this.CancelButton_Click); // // infoLabel // this.infoLabel.Name = "infoLabel"; this.infoLabel.TabIndex = 7; // // UnsavedChangesDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.ClientSize = new System.Drawing.Size(450, 100); this.Controls.Add(this.infoLabel); this.Controls.Add(this.documentListHeader); this.Controls.Add(this.cancelButton); this.Controls.Add(this.hScrollBar); this.Controls.Add(this.dontSaveButton); this.Controls.Add(this.documentStrip); this.Controls.Add(this.saveButton); this.AcceptButton = this.saveButton; this.CancelButton = this.cancelButton; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.Location = new System.Drawing.Point(0, 0); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "UnsavedChangesDialog"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Controls.SetChildIndex(this.saveButton, 0); this.Controls.SetChildIndex(this.documentStrip, 0); this.Controls.SetChildIndex(this.dontSaveButton, 0); this.Controls.SetChildIndex(this.hScrollBar, 0); this.Controls.SetChildIndex(this.cancelButton, 0); this.Controls.SetChildIndex(this.documentListHeader, 0); this.Controls.SetChildIndex(this.infoLabel, 0); this.ResumeLayout(false); this.PerformLayout(); }