示例#1
0
        // Here we walk our controls collection and
        // sort the various controls by type.
        private void SortDialogControls()
        {
            foreach (TaskDialogControl control in controls)
            {
                if (control is TaskDialogButtonBase && String.IsNullOrEmpty(((TaskDialogButtonBase)control).Text))
                {
                    if (control is TaskDialogCommandLink && String.IsNullOrEmpty(((TaskDialogCommandLink)control).Instruction))
                    {
                        throw new InvalidOperationException(
                                  "Button text must be non-empty");
                    }
                }

                // Loop through child controls
                // and sort the controls based on type.
                if (control is TaskDialogCommandLink)
                {
                    commandLinks.Add((TaskDialogCommandLink)control);
                }
                else if (control is TaskDialogRadioButton)
                {
                    if (radioButtons == null)
                    {
                        radioButtons = new List <TaskDialogButtonBase>();
                    }
                    radioButtons.Add((TaskDialogRadioButton)control);
                }
                else if (control is TaskDialogButtonBase)
                {
                    if (buttons == null)
                    {
                        buttons = new List <TaskDialogButtonBase>();
                    }
                    buttons.Add((TaskDialogButtonBase)control);
                }
                else if (control is TaskDialogProgressBar)
                {
                    if (progressBar != null)
                    {
                        throw new InvalidOperationException(
                                  "Can't have more than one progress bar in dialog.");
                    }
                    progressBar = (TaskDialogProgressBar)control;
                }
                else if (control is TaskDialogMarquee)
                {
                    if (marquee != null)
                    {
                        throw new InvalidOperationException(
                                  "Can't have more than one marquee in dialog.");
                    }
                    marquee = (TaskDialogMarquee)control;
                }
                else
                {
                    throw new ArgumentException("Unknown dialog control type.");
                }
            }
        }
示例#2
0
        // Cleans up data and structs from a single
        // native dialog Show() invocation.
        private void CleanUp()
        {
            // Reset values that would be considered
            // 'volatile' in a given instance.
            if (progressBar != null)
            {
                progressBar.Reset();
            }
            if (marquee != null)
            {
                marquee.Reset();
            }

            // Clean out sorted control lists -
            // though we don't of course clear the main controls collection,
            // so the controls are still around; we'll
            // resort on next show, since the collection may have changed.
            if (buttons != null)
            {
                buttons.Clear();
            }
            if (commandLinks != null)
            {
                commandLinks.Clear();
            }
            if (radioButtons != null)
            {
                radioButtons.Clear();
            }
            progressBar = null;
            marquee     = null;

            // Have the native dialog clean up the rest.
            if (nativeDialog != null)
            {
                nativeDialog.Dispose();
            }
        }
示例#3
0
        // Cleans up data and structs from a single native dialog Show() invocation
        private void CleanUp()
        {
            // Reset values that would be considered 'volatile' in a given instance
            if (progressBar != null)
            {
                progressBar.Reset();
            }
            if (marquee != null)
            {
                marquee.Reset();
            }

            // Clean out sorted control lists - though we don't of course clear the main controls collection,
            // so the controls are still around; we'll resort on next show, since the 
            // collection may have changed
            if (buttons != null)
                buttons.Clear();
            if (commandLinks != null)
                commandLinks.Clear();
            if (radioButtons != null)
                radioButtons.Clear();
            progressBar = null;
            marquee = null;

            // Have the native dialog clean up the rest
            if (nativeDialog != null)
                nativeDialog.Dispose();
        }
示例#4
0
        // Here we walk our controls collection and sort the various controls by type. 
        private void SortDialogControls()
        {
            foreach (TaskDialogControl control in controls)
            {
                if (control is TaskDialogButtonBase && String.IsNullOrEmpty(((TaskDialogButtonBase)control).Text))
                {
                    if (control is TaskDialogCommandLink && String.IsNullOrEmpty(((TaskDialogCommandLink)control).Instruction))
                        throw new InvalidOperationException("Button text must be non-empty");
                }

                // Loop through child controls and sort the controls based on type
                if (control is TaskDialogCommandLink)
                {
                    commandLinks.Add((TaskDialogCommandLink)control);
                }
                else if (control is TaskDialogRadioButton)
                {
                    if (radioButtons == null)
                        radioButtons = new List<TaskDialogButtonBase>();
                    radioButtons.Add((TaskDialogRadioButton)control);
                }
                else if (control is TaskDialogButtonBase)
                {
                    if (buttons == null)
                        buttons = new List<TaskDialogButtonBase>();
                    buttons.Add((TaskDialogButtonBase)control);
                }
                else if (control is TaskDialogProgressBar)
                {
                    if (progressBar != null)
                        throw new InvalidOperationException("can't have more than one progress bar in dialog");
                    progressBar = (TaskDialogProgressBar)control;
                }
                else if (control is TaskDialogMarquee)
                {
                    if (marquee != null)
                        throw new InvalidOperationException("can't have more than one marquee in dialog");
                    marquee = (TaskDialogMarquee)control;
                }
                else
                {
                    throw new ArgumentException("Unknown dialog control type");
                }
            }
        }