Sample Wait and Cancel form
Inheritance: Form
        /// <summary>
        /// Handle triggered action
        /// </summary>
        /// <param name="action">triggered action</param>
        /// <param name="status">synchronous status to update console</param>
        protected override void OnSyncAction(SyncAction action, SyncStatus status)
        {
            switch ((string)action.Tag)
            {
                case "ConnectTo":
                    {
                        ConnectDialog connectDialog = new ConnectDialog();
                        connectDialog.ConnectToServerName.Text = String.Empty;

                        if (this.SnapIn.Console.ShowDialog(connectDialog) == DialogResult.OK)
                        {
                            this.DisplayName = "Connected (" + connectDialog.ConnectToServerName.Text + ")";
                        }
                        break;
                    }
                case "CommonDialog":
                    {
                        ColorDialog colorDialog = new ColorDialog();
                        colorDialog.AllowFullOpen = false;

                        if (this.SnapIn.Console.ShowDialog(colorDialog) == DialogResult.OK)
                        {
                            this.DisplayName = "CommonDialog - Selected a Color";
                        }
                        break;
                    }
                case "MessageBox":
                    {
                        MessageBoxParameters messageBoxParameters = new MessageBoxParameters();

                        messageBoxParameters.Caption = "Sample MessageBox...";
                        messageBoxParameters.Buttons = MessageBoxButtons.OKCancel;
                        messageBoxParameters.Text = "Select Ok or Cancel";

                        if (this.SnapIn.Console.ShowDialog(messageBoxParameters) == DialogResult.OK)
                        {
                            this.DisplayName = "MessageBox - Selected Ok";
                        }
                        break;
                    }
                case "UserDefinedForm":
                    {
                        UserDefinedForm userDefinedForm = new UserDefinedForm();

                        if (this.SnapIn.Console.ShowDialog(userDefinedForm) == DialogResult.OK)
                        {
                            this.DisplayName = "User Defined Form - Ok";
                        }
                        break;
                    }
                case "UserDefinedFormWithWaitCursor":
                    {
                        WaitCursor waitCursor = new WaitCursor();
                        waitCursor.Timeout = new System.TimeSpan(0,0,5);

                        UserDefinedFormForWaiting userDefinedFormForWaiting = new UserDefinedFormForWaiting();

                        if (this.SnapIn.Console.ShowDialog(userDefinedFormForWaiting, waitCursor) == DialogResult.OK)
                        {
                            this.DisplayName = "User Defined Form with Wait Cursor - Ok";
                        }
                        break;
                    }
            }
        }
Exemple #2
0
        /// <summary>
        /// Handle triggered action
        /// </summary>
        /// <param name="action">triggered action</param>
        /// <param name="status">synchronous status to update console</param>
        protected override void  OnSyncAction(SyncAction action, SyncStatus status)
        {
            switch ((string)action.Tag)
            {
            case "ConnectTo":
            {
                ConnectDialog connectDialog = new ConnectDialog();
                connectDialog.ConnectToServerName.Text = String.Empty;

                if (this.SnapIn.Console.ShowDialog(connectDialog) == DialogResult.OK)
                {
                    this.DisplayName = "Connected (" + connectDialog.ConnectToServerName.Text + ")";
                }
                break;
            }

            case "CommonDialog":
            {
                ColorDialog colorDialog = new ColorDialog();
                colorDialog.AllowFullOpen = false;

                if (this.SnapIn.Console.ShowDialog(colorDialog) == DialogResult.OK)
                {
                    this.DisplayName = "CommonDialog - Selected a Color";
                }
                break;
            }

            case "MessageBox":
            {
                MessageBoxParameters messageBoxParameters = new MessageBoxParameters();

                messageBoxParameters.Caption = "Sample MessageBox...";
                messageBoxParameters.Buttons = MessageBoxButtons.OKCancel;
                messageBoxParameters.Text    = "Select Ok or Cancel";

                if (this.SnapIn.Console.ShowDialog(messageBoxParameters) == DialogResult.OK)
                {
                    this.DisplayName = "MessageBox - Selected Ok";
                }
                break;
            }

            case "UserDefinedForm":
            {
                UserDefinedForm userDefinedForm = new UserDefinedForm();

                if (this.SnapIn.Console.ShowDialog(userDefinedForm) == DialogResult.OK)
                {
                    this.DisplayName = "User Defined Form - Ok";
                }
                break;
            }

            case "UserDefinedFormWithWaitCursor":
            {
                WaitCursor waitCursor = new WaitCursor();
                waitCursor.Timeout = new System.TimeSpan(0, 0, 5);

                UserDefinedFormForWaiting userDefinedFormForWaiting = new UserDefinedFormForWaiting();

                if (this.SnapIn.Console.ShowDialog(userDefinedFormForWaiting, waitCursor) == DialogResult.OK)
                {
                    this.DisplayName = "User Defined Form with Wait Cursor - Ok";
                }
                break;
            }
            }
        }