/* Copyright (c) Citrix Systems Inc. * All rights reserved. * * Redistribution and use in source and binary forms, * with or without modification, are permitted provided * that the following conditions are met: * * * Redistributions of source code must retain the above * copyright notice, this list of conditions and the * following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the * following disclaimer in the documentation and/or other * materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ using System; using System.Drawing; using System.Windows.Forms; using System.Threading; using System.Collections.Generic; namespace XenAdmin.Dialogs { public partial class ThreeButtonDialog : XenDialogBase { private string helpName = "DefaultHelpTopic"; /// /// Gives you a dialog with a single OK button. /// /// /// public ThreeButtonDialog(Details properties, string helpName) : this(properties, ButtonOK) { this.helpName = helpName; HelpButton = true; } /// /// Gives you a dialog with the specified buttons. /// /// /// /// Must be between 1 and 3 buttons public ThreeButtonDialog(Details properties, string helpName, params TBDButton[] buttons) : this(properties, buttons) { this.helpName = helpName; HelpButton = true; } /// /// Gives you a dialog with a single OK button. /// /// /// public ThreeButtonDialog(Details properties) : this(properties, ButtonOK) { } /// /// Gives you a dialog with the specified buttons. /// /// /// >Must be between 1 and 3 buttons public ThreeButtonDialog(Details properties, params TBDButton[] buttons) { System.Diagnostics.Trace.Assert(buttons.Length > 0 && buttons.Length < 4, "Three button dialog can only have between 1 and 3 buttons."); InitializeComponent(); if (properties.Icon == null) pictureBoxIcon.Visible = false; else pictureBoxIcon.Image = properties.Icon.ToBitmap(); labelMessage.Text = properties.MainMessage; if (properties.linkLength > 0) labelMessage.Links.Add(new LinkLabel.Link(properties.linkStart, properties.linkLength, properties.linkUrl)); if (properties.WindowTitle != null) this.Text = properties.WindowTitle; button1.Visible = true; button1.Text = buttons[0].label; button1.DialogResult = buttons[0].result; if (buttons[0].defaultAction == ButtonType.ACCEPT) { AcceptButton = button1; if (buttons.Length == 1) CancelButton = button1; } else if (buttons[0].defaultAction == ButtonType.CANCEL) CancelButton = button1; if (buttons[0].selected) button1.Select(); if (buttons.Length > 1) { button2.Visible = true; button2.Text = buttons[1].label; button2.DialogResult = buttons[1].result; if (buttons[1].defaultAction == ButtonType.ACCEPT) AcceptButton = button2; else if (buttons[1].defaultAction == ButtonType.CANCEL) CancelButton = button2; if (buttons[1].selected) button2.Select(); } else { button2.Visible = false; } if (buttons.Length > 2) { button3.Visible = true; button3.Text = buttons[2].label; button3.DialogResult = buttons[2].result; if (buttons[2].defaultAction == ButtonType.ACCEPT) AcceptButton = button3; else if (buttons[2].defaultAction == ButtonType.CANCEL) CancelButton = button3; if (buttons[2].selected) button3.Select(); } else { button3.Visible = false; } } /// /// The message displayed on the dialog /// public String Message { get { return labelMessage.Text; } } /// /// A list of buttons on the page /// public List