Exemplo n.º 1
0
        /// <summary>
        /// Updates the user interface of this form.
        /// </summary>
        private void UpdateUI()
        {
            // set values of size numeric up-downs
            widthNumericUpDown.Value  = Magnifier.Size.Width;
            heightNumericUpDown.Value = Magnifier.Size.Height;

            // set value of zoom numeric up-down
            zoomNumericUpDown.Value = Magnifier.Zoom;

            // display pen settings
            Pen pen = Magnifier.BorderPen;

            if (pen != null)
            {
                borderColorPanelControl.Color  = pen.Color;
                borderWidthNumericUpDown.Value = (decimal)pen.Width;
            }
            else
            {
                borderColorPanelControl.Color  = Color.Black;
                borderWidthNumericUpDown.Value = 0;
            }

            // set elliptical outline check box value
            ellipticalOutlineCheckBox.Checked = Magnifier.UseEllipticalOutline;

            // set visual tools visibility check box value
            showVisualToolsCheckBox.Checked = Magnifier.ShowVisualTools;

            // set processing commands check boxes to false
            invertCheckBox.Checked      = false;
            posterizeCheckBox.Checked   = false;
            oilPaintingCheckBox.Checked = false;
            grayscaleCheckBox.Checked   = false;

            // if the processing command is CompositeCommand
            if (Magnifier.ProcessingCommand is CompositeCommand)
            {
                CompositeCommand compositeCommand = (CompositeCommand)Magnifier.ProcessingCommand;

                // get sub commands
                ProcessingCommandBase[] commands = compositeCommand.GetCommands();

                // set processing commands check boxes
                for (int i = 0; i < commands.Length; i++)
                {
                    if (commands[i] is InvertCommand)
                    {
                        invertCheckBox.Checked = true;
                    }
                    else if (commands[i] is PosterizeCommand)
                    {
                        posterizeCheckBox.Checked = true;
                    }
                    else if (commands[i] is OilPaintingCommand)
                    {
                        oilPaintingCheckBox.Checked = true;
                    }
                    else if (commands[i] is ChangePixelFormatToGrayscaleCommand)
                    {
                        grayscaleCheckBox.Checked = true;
                    }
                }
            }
        }