Esempio n. 1
0
 private void Label_MouseEnter(object sender, EventArgs e)
 {//If the label is of type link, change the text color when the mouse passes over it.
     if (linkLabel == true)
     {
         this.ForeColor = ColorEditor.Lighten(UIAppearance.StyleColor, 20);
     }
 }
Esempio n. 2
0
 private void ApplyAppearanceSettings()
 {
     if (customizable == false)//Apply the setting as long as it is not customizable
     {
         //this.BackColor = Color.Transparent;
         if (backIcon == true)//Icon on any background of a form.
         {
             this.IconColor = UIAppearance.TextColor;
         }
         else //Main form title bar icon
         {
             if (UIAppearance.Theme == UITheme.Dark && UIAppearance.Style == UIStyle.Supernova)//if the theme is dark  and supernova skin, the icon color will be the same lightened color of the normal paragraph text
             {
                 this.IconColor = ColorEditor.Lighten(UIAppearance.TextColor, 65);
             }
             else if (UIAppearance.Theme == UITheme.Light && UIAppearance.Style == UIStyle.Supernova)//if the theme is light  and supernova skin, the icon color will be the same lightened color as the normal paragraph text
             {
                 this.IconColor = ColorEditor.Darken(UIAppearance.TextColor, 25);
             }
             else//if the style is another, the icon color will be white
             {
                 this.IconColor = Color.WhiteSmoke;
             }
         }
     }
 }
Esempio n. 3
0
        public void DefaultConstructor_ReturnsNewInstance()
        {
            // Call
            var editor = new ColorEditor();

            // Assert
            Assert.IsInstanceOf <UITypeEditor>(editor);
        }
Esempio n. 4
0
        private void button4_Click(object sender, EventArgs e)
        {
            ColorEditor editor = new ColorEditor();

            editor.ShowDialog();
            editor.Dispose();
            ReloadColors();
        }
Esempio n. 5
0
        public void Initialize(PaletteFromBinaryEditorVM vm)
        {
            _vm = vm ?? throw new ArgumentNullException(nameof(vm));

            ColorEditor.Initialize(_vm);
            ColorSelector.Initialize(_vm);

            tbxBinaryDataRef.DataBindings.Add(nameof(tbxBinaryDataRef.Text), _vm, nameof(_vm.DataRef), false, DataSourceUpdateMode.OnPropertyChanged);
        }
Esempio n. 6
0
        public void GetPaintValueSupported_Always_ReturnTrue()
        {
            // Setup
            var editor = new ColorEditor();

            // Call
            bool paintValueSupported = editor.GetPaintValueSupported();

            // Assert
            Assert.IsTrue(paintValueSupported);
        }
Esempio n. 7
0
        public void GetEditStyle_Always_ReturnUITypeEditorEditStyleModal()
        {
            // Setup
            var editor = new ColorEditor();

            // Call
            UITypeEditorEditStyle editStyle = editor.GetEditStyle(null);

            // Assert
            Assert.AreEqual(UITypeEditorEditStyle.Modal, editStyle);
        }
Esempio n. 8
0
        public void EditValue_WithOtherValue_ReturnSameValue()
        {
            // Setup
            var editor = new ColorEditor();
            var value  = new object();

            // Call
            object editedValue = editor.EditValue(null, null, value);

            // Assert
            Assert.AreSame(value, editedValue);
        }
Esempio n. 9
0
        private void Form_Activated(object sender, EventArgs e)
        {//When the form enters activated mode (regains focus - form is redisplayed),
         //Set the title bar back to normal color.

            this.BorderColor = UIAppearance.FormBorderColor;//Set border color
            if (UIAppearance.Style != UIStyle.Supernova)
            {
                pnlTitleBar.BackColor       = UIAppearance.PrimaryStyleColor;                        //Set title bar backcolor
                pnlSideMenuHeader.BackColor = ColorEditor.Darken(UIAppearance.PrimaryStyleColor, 6); //Set Side menu header backcolor
                pnlTitleBar.Update();                                                                //Force draw the title bar to avoid flickering when the background color is changed.
            }
        }
Esempio n. 10
0
 private void Form_Deactivated(object sender, EventArgs e)
 {//When the form goes into deactivated mode (loses focus) change the color of the title bar.
     if (deactivateFormEvent == true)
     {
         this.BorderColor = Colors.DefaultFormBorderColor;                                        //Set border color
         if (UIAppearance.Style != UIStyle.Supernova)                                             //If the style is not supernova, change the title bar color
         {
             pnlTitleBar.BackColor       = UIAppearance.DeactiveFormColor;                        //Set title bar backcolor
             pnlSideMenuHeader.BackColor = ColorEditor.Darken(UIAppearance.DeactiveFormColor, 6); //Set Side menu header backcolor
             pnlTitleBar.Update();                                                                //Force draw the title bar to avoid flickering when the background color is changed.
         }
     }
 }
Esempio n. 11
0
        public void Initialize(PaletteFromMapEditorVM vm)
        {
            _vm = vm ?? throw new ArgumentNullException(nameof(vm));

            ColorEditor.Initialize(_vm);
            ColorSelector.Initialize(_vm);

            tbxMapDataRef.DataBindings.Add(nameof(tbxMapDataRef.Text), _vm, nameof(_vm.DataRef), false, DataSourceUpdateMode.OnPropertyChanged);

            cbxMapBlockName.DataSource = _vm.BlockNames;
            cbxMapBlockName.DataBindings.Add(nameof(cbxMapBlockName.Text), _vm, nameof(_vm.BlockName), false, DataSourceUpdateMode.OnPropertyChanged);

            ColorEditor.DataBindings.Add(nameof(ColorEditor.Enabled), _vm, nameof(_vm.EditEnabled), false, DataSourceUpdateMode.OnPropertyChanged);
            ColorSelector.DataBindings.Add(nameof(ColorSelector.Enabled), _vm, nameof(_vm.EditEnabled), false, DataSourceUpdateMode.OnPropertyChanged);
        }
Esempio n. 12
0
 private void ColorTitleBar()
 {
     if (UIAppearance.Theme == UITheme.Light && UIAppearance.Style == UIStyle.Supernova)//If the theme is light and the style is supernova, darken the text color.
     {
         this.ForeColor = ColorEditor.Darken(UIAppearance.TextColor, 25);
     }
     else if (UIAppearance.Theme == UITheme.Dark && UIAppearance.Style == UIStyle.Supernova) //If the theme is dark and the style is supernova, lighten the text color.
     {
         this.ForeColor = ColorEditor.Lighten(UIAppearance.TextColor, 65);
     }
     else //If the style is any other set white as the text color
     {
         this.ForeColor = Color.WhiteSmoke;
     }
 }
Esempio n. 13
0
        private void rbLightTheme_CheckedChanged(object sender, EventArgs e)
        {
            if (rbLightTheme.Checked)
            {
                panelBackground.BackColor = Colors.LightBackground;
            }
            else
            {
                panelBackground.BackColor = Colors.DarkBackground;
            }

            if (cbStyles.SelectedIndex == (int)UIStyle.Supernova)
            {
                panelTitleBar.BackColor = ColorEditor.Darken(panelBackground.BackColor, 9);
            }
        }
Esempio n. 14
0
        //===========================================================================
        #region ** ctor

        public ColorEditorControl()
        {
            _editor = new ColorEditor();

            // initialize combo
            DrawMode = DrawMode.OwnerDrawFixed;

            // initialize drop down editor
            _form = new Form();
            _form.StartPosition   = FormStartPosition.Manual;
            _form.FormBorderStyle = FormBorderStyle.None;
            _form.ShowInTaskbar   = false;
            _form.TopLevel        = true;
            _form.KeyPreview      = true;
            _form.Deactivate     += new EventHandler(_form_Deactivate);
            _form.KeyDown        += new KeyEventHandler(_form_KeyDown);
        }
Esempio n. 15
0
        private void LoadAppearanceSettings()
        {//Display the current appearance settings on the form.
            //Theme
            if (UIAppearance.Theme == UITheme.Dark)
            {
                rbDarkTheme.Checked = true;
            }
            else
            {
                rbLightTheme.Checked = true;
            }

            //Style
            cbStyles.DataSource    = Enum.GetValues(typeof(UIStyle));
            cbStyles.SelectedIndex = (int)UIAppearance.Style;

            //Form Border Size
            tbmFormBorderSize.Value = UIAppearance.FormBorderSize;

            //Is Color Form Border
            tbColorFormBorder.Checked = UIAppearance.FormBorderColor == Colors.DefaultFormBorderColor ? false : true;

            //Child Form Marker
            tbChildFormMarker.Checked = UIAppearance.ChildFormMarker;

            //Form Icon in Activated Menu Item
            tbIconMenuItem.Checked = UIAppearance.FormIconActiveMenuItem;

            //MDI Desktop Panel
            tbMultiChildForms.Checked = UIAppearance.MultiChildForms;

            //Preview
            panelBorde.Padding        = new Padding(UIAppearance.FormBorderSize);
            panelBorde.BackColor      = UIAppearance.FormBorderColor;
            panelBackground.BackColor = UIAppearance.BackgroundColor;
            if (UIAppearance.Style == UIStyle.Supernova)
            {
                panelTitleBar.BackColor = ColorEditor.Darken(UIAppearance.BackgroundColor, 9);
            }
            else
            {
                panelTitleBar.BackColor = UIAppearance.PrimaryStyleColor;
            }
        }
Esempio n. 16
0
        private void ApplyAppearanceSettings()
        {                                                                                          //Apply settings
            pnlDesktop.BackColor       = UIAppearance.BackgroundColor;                             //Set background color
            pnlDesktopHeader.BackColor = UIAppearance.BackgroundColor;                             //set desktop header backcolor
            this.BorderColor           = UIAppearance.FormBorderColor;                             //Set border color
            this.BorderSize            = UIAppearance.FormBorderSize;                              //Set form Border Width

            if (UIAppearance.Style == UIStyle.Supernova)                                           //if the style is supernova
            {
                pnlTitleBar.BackColor       = ColorEditor.Darken(UIAppearance.BackgroundColor, 7); //Set title bar backcolor
                pnlSideMenuHeader.BackColor = Colors.SideMenuColor;                                //Set Side menu header backcolor
                pnlMarker.BackColor         = Color.CornflowerBlue;                                //Set marker colo
            }
            else //any style that is not supernova
            {
                pnlTitleBar.BackColor       = UIAppearance.PrimaryStyleColor;                        //Set title bar backcolor
                pnlSideMenuHeader.BackColor = ColorEditor.Darken(UIAppearance.PrimaryStyleColor, 6); //Set Side menu header backcolor
                pnlMarker.BackColor         = UIAppearance.StyleColor;                               //Set marker color
            }
        }
Esempio n. 17
0
 private void ShowDropDown()
 {
     try
     {
         var    editor      = new ColorEditor();
         Color  color       = Color;
         object objectValue = RuntimeHelpers.GetObjectValue(editor.EditValue(_EditorService, color));
         if ((objectValue != null) && !_EditorService.Canceled)
         {
             Color = (Color)objectValue;
         }
         _CheckBox.CheckState = CheckState.Unchecked;
     }
     catch (Exception exception1)
     {
         // ProjectData.SetProjectError(exception1);
         Trace.WriteLine(exception1.ToString());
         // ProjectData.ClearProjectError();
     }
 }
Esempio n. 18
0
    void answer(int pInputAnswer)
    {
        if (state != GameState.PLAYING ||
            _inputManager.disabled)
        {
            return;
        }
        string answer = "";

        if (_questionCtrl.getAnswer() < 0)
        {
            answer = "ERROR!!";
            DebugLogger.Log(answer);
            return;
        }
        DebugLogger.Log("getAnswer:" + _questionCtrl.getAnswer() + " myAnswer:" + pInputAnswer);

        if (_questionCtrl.getAnswer() == pInputAnswer)
        {
            _audioManager.play(Const.SE_CORRECT_CHIME);

            answer = Const.LBL_CORRECT;
            addScore(ADD_SCORE);

            addTime(_dataCtrl.getAddTime(score));
            setLabelAnswer(answer);
            UpdateImage();
        }
        else
        {
            _audioManager.play(Const.SE_WRONG_CHIME);

            answer = Const.LBL_WRONG;
            wrongAnswer(_questionCtrl.getAnswer());

            // 色を変更
            ColorEditor.setColorFromColorCode(_labelAnswer.gameObject, Const.COL_NEGATIVE);
            setLabelAnswer(answer, false);
        }
        DebugLogger.Log(answer);
    }
Esempio n. 19
0
    /// <summary>
    /// ゲームの準備
    /// インゲームデータを初期化
    /// </summary>
    void setGameReady()
    {
        // 質問リストの初期化
        _questionCtrl.initQuestions();

        // GameManager内変数の初期化
        state       = GameState.STAND_BY;
        time        = TIME_DEFAULT;
        time_passed = 0;
        score       = 0;
        isBest      = false;

        // UI
        setLabelAnswer("", false);
        ColorEditor.setColorFromColorCode(_labelAnswer.gameObject, Const.COL_POSITIVE);
        _objWrongReason.SetActive(false);
        setLabelScore(score);
        setLabelTime(time);
        setLabelCoin(_userData.coin);
        setLabelBestScore(_userData.best_score);
    }
Esempio n. 20
0
 private void FormOptions_VisibleChanged(object sender, EventArgs e)
 {                                      //When the form options dropdown is shown or hidden
     if (dmFormOptions.Visible == true) //If menu is displayed
     {                                  //keep button highlighted and set icon to options list
         btnFormIcon.BackColor = ColorEditor.Darken(btnFormIcon.BackColor, 15);
         btnFormIcon.FlatAppearance.MouseOverBackColor = btnFormIcon.BackColor;
         btnFormIcon.IconChar = IconChar.ListUl;//Options list Icon
     }
     else // If menu is hidden
     {//Return the default color and icon
         if (UIAppearance.Style == UIStyle.Supernova)
         {
             btnFormIcon.BackColor = Colors.DarkItemBackground;
         }
         else
         {
             btnFormIcon.BackColor = UIAppearance.PrimaryStyleColor;
         }
         btnFormIcon.IconChar = FormIcon;
     }
 }
Esempio n. 21
0
        public MainWindow()
        {
            InitializeComponent();

            ColorEditor colorEditor = new ColorEditor();

            colorEditor.ColorEditorViewModel.Color = Colors.Blue;
            colorEditor.ColorEditorViewModel.RGB.A = 67;

            Lovatts.ColorEditor.BrushEditor brushEditor = new Lovatts.ColorEditor.BrushEditor();
            brushEditor.BrushEditorViewModel.BrushType = BrushTypes.Radial;
            brushEditor.BrushEditorViewModel.Center    = new Point(1, 0);
            brushEditor.BrushEditorViewModel.GradientStops.Add(new GradientStopViewModel(Colors.Red, 0));
            brushEditor.BrushEditorViewModel.GradientStops.Add(new GradientStopViewModel(Colors.Blue, 1));

            string xml = brushEditor.BrushEditorViewModel.SerializeBrushToXml();

            brushEditor.BrushEditorViewModel.DeserializeBrushFromXml(xml);

            Debug.WriteLine(xml);
        }
Esempio n. 22
0
        public void ColorEditor_EditValue_ValidProvider_ReturnsValue(object value)
        {
            var editor              = new ColorEditor();
            var mockEditorService   = new Mock <IWindowsFormsEditorService>(MockBehavior.Strict);
            var mockServiceProvider = new Mock <IServiceProvider>(MockBehavior.Strict);

            mockServiceProvider
            .Setup(p => p.GetService(typeof(IWindowsFormsEditorService)))
            .Returns(mockEditorService.Object)
            .Verifiable();
            mockEditorService
            .Setup(e => e.DropDownControl(It.IsAny <Control>()))
            .Verifiable();
            Assert.Equal(value, editor.EditValue(null, mockServiceProvider.Object, value));
            mockServiceProvider.Verify(p => p.GetService(typeof(IWindowsFormsEditorService)), Times.Once());
            mockEditorService.Verify(e => e.DropDownControl(It.IsAny <Control>()), Times.Once());

            // Edit again.
            Assert.Equal(value, editor.EditValue(null, mockServiceProvider.Object, value));
            mockServiceProvider.Verify(p => p.GetService(typeof(IWindowsFormsEditorService)), Times.Exactly(2));
            mockServiceProvider.Verify(p => p.GetService(typeof(IWindowsFormsEditorService)), Times.Exactly(2));
        }
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ColorTabControl = (TabbedColorEditorControl)target;
                break;

            case 2:
                this.TabbedView = (TabControl)target;
                this.TabbedView.SelectionChanged += new SelectionChangedEventHandler(this.OnColorTabChanged);
                break;

            case 3:
                this.ColorEditorTabItem = (TabItem)target;
                break;

            case 4:
                this.ColorMarker = (PropertyMarker)target;
                break;

            case 5:
                this.ColorEditor = (ColorEditor)target;
                break;

            case 6:
                this.ColorResourceTabItem = (TabItem)target;
                break;

            case 7:
                this.ResourceList = (OnDemandControl)target;
                break;

            default:
                this._contentLoaded = true;
                break;
            }
        }
Esempio n. 24
0
        Color _color = Color.Empty;     // current editor value

        #endregion

        //------------------------------------------------------------------------
        #region ** ctor

        public ColorPicker()
        {
            // we don't want to show the dropdown, but it flickers in and out,
            // so make it as small as possible.
            if (!this.DesignMode)
            {
                DropDownWidth  = 1;
                DropDownHeight = 1;
            }

            // create color editor pane
            _editor = new ColorEditor();

            // initialize drop down editor
            _form = new Form();
            _form.StartPosition   = FormStartPosition.Manual;
            _form.FormBorderStyle = FormBorderStyle.None;
            _form.ShowInTaskbar   = false;
            _form.TopLevel        = true;
            _form.KeyPreview      = true;
            _form.Deactivate     += _form_Deactivate;
            _form.KeyDown        += _form_KeyDown;
        }
Esempio n. 25
0
        private Color menuItemBorder;           //Sets the border color of the menu item


        //Constructor
        public DropdownMenuColors(bool menuButtonOwner)
        {
            if (UIAppearance.Theme == UITheme.Dark || menuButtonOwner == true)//If the theme is dark or the dropdown menu is displayed from the menu button, set the following colors
            {
                dropdownMenuBackground   = Colors.DarkItemBackground;
                dropdownMenuBorder       = ColorEditor.Darken(Colors.DarkItemBackground, 10);
                menuItemBorder           = Colors.DarkActiveBackground;
                menuItemSelected         = Colors.DarkActiveBackground;
                leftColumnGradientBegin  = ColorEditor.Darken(Colors.DarkItemBackground, 4);
                leftColumnGradientMiddle = ColorEditor.Darken(Colors.DarkItemBackground, 4);
                leftColumnGradientEnd    = ColorEditor.Darken(Colors.DarkItemBackground, 4);
            }
            else //If the theme is light, set the following colors
            {
                dropdownMenuBackground   = Colors.LightItemBackground;
                dropdownMenuBorder       = ColorEditor.Darken(UIAppearance.BackgroundColor, 10);
                menuItemBorder           = Colors.LightActiveBackground;
                menuItemSelected         = Colors.LightActiveBackground;
                leftColumnGradientBegin  = ColorEditor.Darken(Colors.LightItemBackground, 4);
                leftColumnGradientMiddle = ColorEditor.Darken(Colors.LightItemBackground, 4);
                leftColumnGradientEnd    = ColorEditor.Darken(Colors.LightItemBackground, 4);
            }
        }
Esempio n. 26
0
        internal static ITypeEditor CreateDefaultEditor(Type propertyType, TypeConverter typeConverter, PropertyItem propertyItem)
        {
            ITypeEditor editor = null;

            var context = new EditorTypeDescriptorContext(null, propertyItem.Instance, propertyItem.PropertyDescriptor);

            if ((typeConverter != null) &&
                typeConverter.GetStandardValuesSupported(context) &&
                typeConverter.GetStandardValuesExclusive(context) &&
                (propertyType != typeof(bool)) && (propertyType != typeof(bool?)))   //Bool type always have a BooleanConverter with standardValues : True/False.
            {
                var items = typeConverter.GetStandardValues(context);
                editor = new SourceComboBoxEditor(items, typeConverter);
            }
            else if (propertyType == typeof(string))
            {
                editor = new TextBoxEditor();
            }
            else if (propertyType == typeof(bool) || propertyType == typeof(bool?))
            {
                editor = new CheckBoxEditor();
            }
            else if (propertyType == typeof(decimal) || propertyType == typeof(decimal?))
            {
                editor = new DecimalUpDownEditor();
            }
            else if (propertyType == typeof(double) || propertyType == typeof(double?))
            {
                editor = new DoubleUpDownEditor();
            }
            else if (propertyType == typeof(int) || propertyType == typeof(int?))
            {
                editor = new IntegerUpDownEditor();
            }
            else if (propertyType == typeof(short) || propertyType == typeof(short?))
            {
                editor = new ShortUpDownEditor();
            }
            else if (propertyType == typeof(long) || propertyType == typeof(long?))
            {
                editor = new LongUpDownEditor();
            }
            else if (propertyType == typeof(float) || propertyType == typeof(float?))
            {
                editor = new SingleUpDownEditor();
            }
            else if (propertyType == typeof(byte) || propertyType == typeof(byte?))
            {
                editor = new ByteUpDownEditor();
            }
            else if (propertyType == typeof(sbyte) || propertyType == typeof(sbyte?))
            {
                editor = new SByteUpDownEditor();
            }
            else if (propertyType == typeof(uint) || propertyType == typeof(uint?))
            {
                editor = new UIntegerUpDownEditor();
            }
            else if (propertyType == typeof(ulong) || propertyType == typeof(ulong?))
            {
                editor = new ULongUpDownEditor();
            }
            else if (propertyType == typeof(ushort) || propertyType == typeof(ushort?))
            {
                editor = new UShortUpDownEditor();
            }
            else if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
            {
                editor = new DateTimeUpDownEditor();
            }
            else if ((propertyType == typeof(Color)) || (propertyType == typeof(Color?)))
            {
                editor = new ColorEditor();
            }
            else if (propertyType.IsEnum)
            {
                editor = new EnumComboBoxEditor();
            }
            else if (propertyType == typeof(TimeSpan) || propertyType == typeof(TimeSpan?))
            {
                editor = new TimeSpanUpDownEditor();
            }
            else if (propertyType == typeof(FontFamily) || propertyType == typeof(FontWeight) || propertyType == typeof(FontStyle) || propertyType == typeof(FontStretch))
            {
                editor = new FontComboBoxEditor();
            }
            else if (propertyType == typeof(Guid) || propertyType == typeof(Guid?))
            {
                editor = new MaskedTextBoxEditor()
                {
                    ValueDataType = propertyType, Mask = "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"
                }
            }
            ;
            else if (propertyType == typeof(char) || propertyType == typeof(char?))
            {
                editor = new MaskedTextBoxEditor()
                {
                    ValueDataType = propertyType, Mask = "&"
                }
            }
            ;
            else if (propertyType == typeof(object))
            {
                // If any type of object is possible in the property, default to the TextBoxEditor.
                // Useful in some case (e.g., Button.Content).
                // Can be reconsidered but was the legacy behavior on the PropertyGrid.
                editor = new TextBoxEditor();
            }
            else
            {
                var listType = ListUtilities.GetListItemType(propertyType);

                // A List of T
                if (listType != null)
                {
                    if (!listType.IsPrimitive && !listType.Equals(typeof(String)) && !listType.IsEnum)
                    {
                        editor = new Xceed.Wpf.Toolkit.PropertyGrid.Editors.CollectionEditor();
                    }
                    else
                    {
                        editor = new Xceed.Wpf.Toolkit.PropertyGrid.Editors.PrimitiveTypeCollectionEditor();
                    }
                }
                else
                {
                    var dictionaryType = ListUtilities.GetDictionaryItemsType(propertyType);
                    var collectionType = ListUtilities.GetCollectionItemType(propertyType);
                    // A dictionary of T or a Collection of T or an ICollection
                    if ((dictionaryType != null) || (collectionType != null) || typeof(ICollection).IsAssignableFrom(propertyType))
                    {
                        editor = new Xceed.Wpf.Toolkit.PropertyGrid.Editors.CollectionEditor();
                    }
                    else
                    {
                        // If the type is not supported, check if there is a converter that supports
                        // string conversion to the object type. Use TextBox in theses cases.
                        // Otherwise, return a TextBlock editor since no valid editor exists.
                        editor = (typeConverter != null && typeConverter.CanConvertFrom(typeof(string)))
                          ? (ITypeEditor) new TextBoxEditor()
                          : (ITypeEditor) new TextBlockEditor();
                    }
                }
            }

            return(editor);
        }
Esempio n. 27
0
        internal static ITypeEditor CreateDefaultEditor(Type propertyType, TypeConverter typeConverter)
        {
            ITypeEditor editor = null;

            if (propertyType == typeof(bool) || propertyType == typeof(bool?))
            {
                editor = new CheckBoxEditor();
            }
            else if (propertyType == typeof(decimal) || propertyType == typeof(decimal?))
            {
                editor = new DecimalUpDownEditor();
            }
            else if (propertyType == typeof(double) || propertyType == typeof(double?))
            {
                editor = new DoubleUpDownEditor();
            }
            else if (propertyType == typeof(int) || propertyType == typeof(int?))
            {
                editor = new IntegerUpDownEditor();
            }
            else if (propertyType == typeof(short) || propertyType == typeof(short?))
            {
                editor = new ShortUpDownEditor();
            }
            else if (propertyType == typeof(long) || propertyType == typeof(long?))
            {
                editor = new LongUpDownEditor();
            }
            else if (propertyType == typeof(float) || propertyType == typeof(float?))
            {
                editor = new SingleUpDownEditor();
            }
            else if (propertyType == typeof(byte) || propertyType == typeof(byte?))
            {
                editor = new ByteUpDownEditor();
            }
            else if (propertyType == typeof(sbyte) || propertyType == typeof(sbyte?))
            {
                editor = new UpDownEditor <SByteUpDown, sbyte?>();
            }
            else if (propertyType == typeof(uint) || propertyType == typeof(uint?))
            {
                editor = new UpDownEditor <UIntegerUpDown, uint?>();
            }
            else if (propertyType == typeof(ulong) || propertyType == typeof(ulong?))
            {
                editor = new UpDownEditor <ULongUpDown, ulong?>();
            }
            else if (propertyType == typeof(ushort) || propertyType == typeof(ushort?))
            {
                editor = new UpDownEditor <UShortUpDown, ushort?>();
            }
            else if (propertyType == typeof(DateTime) || propertyType == typeof(DateTime?))
            {
                editor = new DateTimeUpDownEditor();
            }
            else if ((propertyType == typeof(Color)))
            {
                editor = new ColorEditor();
            }
            else if (propertyType.IsEnum)
            {
                editor = new EnumComboBoxEditor();
            }
            else if (propertyType == typeof(TimeSpan))
            {
                editor = new TimeSpanEditor();
            }
            else if (propertyType == typeof(FontFamily) || propertyType == typeof(FontWeight) || propertyType == typeof(FontStyle) || propertyType == typeof(FontStretch))
            {
                editor = new FontComboBoxEditor();
            }
            else if (propertyType == typeof(object))
            {
                // If any type of object is possible in the property, default to the TextBoxEditor.
                // Useful in some case (e.g., Button.Content).
                // Can be reconsidered but was the legacy behavior on the PropertyGrid.
                editor = new TextBoxEditor();
            }
            else
            {
                Type listType = CollectionControl.GetListItemType(propertyType);

                if (listType != null)
                {
                    if (!listType.IsPrimitive && !listType.Equals(typeof(String)))
                    {
                        editor = new Editors.CollectionEditor();
                    }
                    else
                    {
                        editor = new Editors.PrimitiveTypeCollectionEditor();
                    }
                }
                else
                {
                    // If the type is not supported, check if there is a converter that supports
                    // string conversion to the object type. Use TextBox in theses cases.
                    // Otherwise, return a TextBlock editor since no valid editor exists.
                    editor = (typeConverter != null && typeConverter.CanConvertFrom(typeof(string)))
                                          ? (ITypeEditor) new TextBoxEditor()
                                          : (ITypeEditor) new TextBlockEditor();
                }
            }

            return(editor);
        }
Esempio n. 28
0
        internal static FrameworkElement CreateDefaultEditor(PropertyItem propertyItem)
        {
            ITypeEditor editor = null;

            if (propertyItem.IsReadOnly)
            {
                editor = new TextBlockEditor();
            }
            else if (propertyItem.PropertyType == typeof(bool) || propertyItem.PropertyType == typeof(bool?))
            {
                editor = new CheckBoxEditor();
            }
            else if (propertyItem.PropertyType == typeof(decimal) || propertyItem.PropertyType == typeof(decimal?))
            {
                editor = new DecimalUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(double) || propertyItem.PropertyType == typeof(double?))
            {
                editor = new DoubleUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(int) || propertyItem.PropertyType == typeof(int?))
            {
                editor = new IntegerUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(DateTime) || propertyItem.PropertyType == typeof(DateTime?))
            {
                editor = new DateTimeUpDownEditor();
            }
            else if ((propertyItem.PropertyType == typeof(Color)))
            {
                editor = new ColorEditor();
            }
            else if (propertyItem.PropertyType.IsEnum)
            {
                editor = new EnumComboBoxEditor();
            }
            else if (propertyItem.PropertyType == typeof(TimeSpan))
            {
                editor = new TimeSpanEditor();
            }
            else if (propertyItem.PropertyType == typeof(FontFamily) || propertyItem.PropertyType == typeof(FontWeight) || propertyItem.PropertyType == typeof(FontStyle) || propertyItem.PropertyType == typeof(FontStretch))
            {
                editor = new FontComboBoxEditor();
            }
            else if (propertyItem.PropertyType.IsGenericType)
            {
                if (propertyItem.PropertyType.GetInterface("IList") != null)
                {
                    var t = propertyItem.PropertyType.GetGenericArguments()[0];
                    if (!t.IsPrimitive && !t.Equals(typeof(String)))
                    {
                        editor = new Microsoft.Windows.Controls.PropertyGrid.Editors.CollectionEditor();
                    }
                    else
                    {
                        editor = new Microsoft.Windows.Controls.PropertyGrid.Editors.PrimitiveTypeCollectionEditor();
                    }
                }
                else
                {
                    editor = new TextBlockEditor();
                }
            }
            else
            {
                editor = new TextBoxEditor();
            }

            return(editor.ResolveEditor(propertyItem));
        }
        //Method that will create our object color and will handle input and output of our program.
        public static void Main(String[] args)
        {
            // Creates a default color object, prints its values to the screen, and enables the user
            // to invoke methods to increase or decrease any color component.

            //1. Create a Color object.
            //2. Update the color values based on user input or print the inverse color.
            //3. Repeat step 2 until the user inputs 8.

            ColorEditor userColor = new ColorEditor();
            int         choice;

            userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
            do
            {
                Console.WriteLine("Do you want to:\n1) Increase Red, 2) Decrease Red\n3) Increase Green, 4) Decrease Green\n5) Increase Blue, 6) Decrease Blue\n7) Print the inverse, or 8) Quit");
                choice = Convert.ToInt32(Console.ReadLine());

                switch (choice)
                {
                case 1:     // increase red
                    if (userColor.getRed() >= 0 && userColor.getRed() <= 255)
                    {
                        userColor.setRed(userColor.IncreaseRed(userColor.getRed()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getRed() == 256)
                    {
                        Console.WriteLine("Red cannot increase further.");
                        userColor.setRed(255);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 2:     // decrease red
                    if (userColor.getRed() >= 0 && userColor.getRed() <= 255)
                    {
                        userColor.setRed(userColor.DecreaseRed(userColor.getRed()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getRed() == -1)
                    {
                        Console.WriteLine("Red cannot decrease further.");
                        userColor.setRed(0);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 3:     // increase green
                    if (userColor.getGreen() >= 0 && userColor.getGreen() <= 255)
                    {
                        userColor.setGreen(userColor.IncreaseGreen(userColor.getGreen()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getGreen() == 256)
                    {
                        Console.WriteLine("Green cannot increase further.");
                        userColor.setRed(255);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 4:     // decrease green
                    if (userColor.getGreen() >= 0 && userColor.getGreen() <= 255)
                    {
                        userColor.setGreen(userColor.DecreaseGreen(userColor.getGreen()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getGreen() == -1)
                    {
                        Console.WriteLine("Green cannot decrease further.");
                        userColor.setGreen(0);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 5:     // increase blue
                    if (userColor.getBlue() >= 0 && userColor.getBlue() <= 255)
                    {
                        userColor.setBlue(userColor.IncreaseBlue(userColor.getBlue()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getBlue() == 256)
                    {
                        Console.WriteLine("Blue cannot increase further.");
                        userColor.setBlue(255);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 6:     // decrease blue
                    if (userColor.getBlue() >= 0 && userColor.getBlue() <= 255)
                    {
                        userColor.setBlue(userColor.DecreaseBlue(userColor.getBlue()));
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    else if (userColor.getBlue() == -1)
                    {
                        Console.WriteLine("Blue cannot decrease further.");
                        userColor.setBlue(0);
                        userColor.ToString(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    }
                    break;

                case 7:     // print inverse
                    userColor.PrintInverse(userColor.getRed(), userColor.getGreen(), userColor.getBlue());
                    break;
                }
            } while (choice != 8);

            if (choice == 8)
            {
                Console.WriteLine("Thanks for playing!");
            }
        }
        internal static FrameworkElement CreateDefaultEditor(PropertyItem propertyItem)
        {
            ITypeEditor editor = null;


            if (propertyItem.IsReadOnly)
            {
                editor = new TextBlockEditor();
            }
            else if (propertyItem.PropertyType == typeof(bool) || propertyItem.PropertyType == typeof(bool?))
            {
                editor = new CheckBoxEditor();
            }
            else if (propertyItem.PropertyType == typeof(decimal) || propertyItem.PropertyType == typeof(decimal? ))
            {
                editor = new DecimalUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(double) || propertyItem.PropertyType == typeof(double?))
            {
                editor = new DoubleUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(int) || propertyItem.PropertyType == typeof(int?))
            {
                editor = new IntegerUpDownEditor();
            }
            else if (propertyItem.PropertyType == typeof(DateTime) || propertyItem.PropertyType == typeof(DateTime? ))
            {
                editor = new DateTimeUpDownEditor();
            }
            else if ((propertyItem.PropertyType == typeof(Color)))
            {
                editor = new ColorEditor();
            }
            else if (propertyItem.PropertyType.IsEnum)
            {
                editor = new EnumComboBoxEditor();
            }
            else if (propertyItem.PropertyType == typeof(TimeSpan))
            {
                editor = new TimeSpanEditor();
            }
            else if (propertyItem.PropertyType == typeof(FontFamily) || propertyItem.PropertyType == typeof(FontWeight) || propertyItem.PropertyType == typeof(FontStyle) || propertyItem.PropertyType == typeof(FontStretch))
            {
                editor = new FontComboBoxEditor();
            }
            else
            {
                Type listType = CollectionEditor.GetListItemType(propertyItem.PropertyType);

                if (listType != null)
                {
                    if (!listType.IsPrimitive && !listType.Equals(typeof(String)))
                    {
                        editor = new Xceed.Wpf.Toolkit.PropertyGrid.Editors.CollectionEditor();
                    }
                    else
                    {
                        editor = new Xceed.Wpf.Toolkit.PropertyGrid.Editors.PrimitiveTypeCollectionEditor();
                    }
                }
                else
                {
                    editor = new TextBoxEditor();
                }
            }

            return(editor.ResolveEditor(propertyItem));
        }
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
       this.okButton = new System.Windows.Forms.Button();
       this.cancelButton = new System.Windows.Forms.Button();
       this.previewPanel = new System.Windows.Forms.Panel();
       this.loadPaletteButton = new System.Windows.Forms.Button();
       this.savePaletteButton = new System.Windows.Forms.Button();
       this.toolTip = new System.Windows.Forms.ToolTip(this.components);
       this.screenColorPicker = new Cyotek.Windows.Forms.ScreenColorPicker();
       this.colorWheel = new Cyotek.Windows.Forms.ColorWheel();
       this.colorEditor = new Cyotek.Windows.Forms.ColorEditor();
       this.colorGrid = new Cyotek.Windows.Forms.ColorGrid();
       this.colorEditorManager = new Cyotek.Windows.Forms.ColorEditorManager();
       this.SuspendLayout();
       //
       // okButton
       //
       this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
       this.okButton.Location = new System.Drawing.Point(453, 12);
       this.okButton.Name = "okButton";
       this.okButton.Size = new System.Drawing.Size(75, 23);
       this.okButton.TabIndex = 1;
       this.okButton.Text = "OK";
       this.okButton.UseVisualStyleBackColor = true;
       this.okButton.Click += new System.EventHandler(this.okButton_Click);
       //
       // cancelButton
       //
       this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
       this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
       this.cancelButton.Location = new System.Drawing.Point(453, 41);
       this.cancelButton.Name = "cancelButton";
       this.cancelButton.Size = new System.Drawing.Size(75, 23);
       this.cancelButton.TabIndex = 2;
       this.cancelButton.Text = "Cancel";
       this.cancelButton.UseVisualStyleBackColor = true;
       this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
       //
       // previewPanel
       //
       this.previewPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
       this.previewPanel.Location = new System.Drawing.Point(453, 203);
       this.previewPanel.Name = "previewPanel";
       this.previewPanel.Size = new System.Drawing.Size(75, 47);
       this.previewPanel.TabIndex = 3;
       //
       // loadPaletteButton
       //
       this.loadPaletteButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
       this.loadPaletteButton.Image = global::YnoteThemeGenerator.Properties.Resources.palette_load;
       this.loadPaletteButton.Location = new System.Drawing.Point(12, 147);
       this.loadPaletteButton.Name = "loadPaletteButton";
       this.loadPaletteButton.Size = new System.Drawing.Size(23, 23);
       this.loadPaletteButton.TabIndex = 5;
       this.toolTip.SetToolTip(this.loadPaletteButton, "Load Palette");
       this.loadPaletteButton.UseVisualStyleBackColor = false;
       this.loadPaletteButton.Click += new System.EventHandler(this.loadPaletteButton_Click);
       //
       // savePaletteButton
       //
       this.savePaletteButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
     this.savePaletteButton.Image = global::YnoteThemeGenerator.Properties.Resources.palette_save;
       this.savePaletteButton.Location = new System.Drawing.Point(34, 147);
       this.savePaletteButton.Name = "savePaletteButton";
       this.savePaletteButton.Size = new System.Drawing.Size(23, 23);
       this.savePaletteButton.TabIndex = 6;
       this.toolTip.SetToolTip(this.savePaletteButton, "Save Palette");
       this.savePaletteButton.UseVisualStyleBackColor = false;
       this.savePaletteButton.Click += new System.EventHandler(this.savePaletteButton_Click);
       //
       // screenColorPicker
       //
       this.screenColorPicker.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
       this.screenColorPicker.Color = System.Drawing.Color.Black;
     this.screenColorPicker.Image = global::YnoteThemeGenerator.Properties.Resources.eyedropper1;
       this.screenColorPicker.Location = new System.Drawing.Point(453, 83);
       this.screenColorPicker.Name = "screenColorPicker";
       this.screenColorPicker.Size = new System.Drawing.Size(73, 85);
       this.toolTip.SetToolTip(this.screenColorPicker, "Click and drag to select screen color");
       this.screenColorPicker.Zoom = 6;
       //
       // colorWheel
       //
       this.colorWheel.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
       this.colorWheel.Location = new System.Drawing.Point(12, 12);
       this.colorWheel.Name = "colorWheel";
       this.colorWheel.Size = new System.Drawing.Size(192, 147);
       this.colorWheel.TabIndex = 4;
       //
       // colorEditor
       //
       this.colorEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     | System.Windows.Forms.AnchorStyles.Left)
     | System.Windows.Forms.AnchorStyles.Right)));
       this.colorEditor.Color = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
       this.colorEditor.Location = new System.Drawing.Point(210, 12);
       this.colorEditor.Name = "colorEditor";
       this.colorEditor.Size = new System.Drawing.Size(230, 238);
       this.colorEditor.TabIndex = 0;
       //
       // colorGrid
       //
       this.colorGrid.AutoAddColors = false;
       this.colorGrid.CellBorderStyle = Cyotek.Windows.Forms.ColorCellBorderStyle.None;
       this.colorGrid.EditMode = Cyotek.Windows.Forms.ColorEditingMode.Both;
       this.colorGrid.Location = new System.Drawing.Point(12, 176);
       this.colorGrid.Name = "colorGrid";
       this.colorGrid.Padding = new System.Windows.Forms.Padding(0);
       this.colorGrid.Palette = Cyotek.Windows.Forms.ColorPalette.Paint;
       this.colorGrid.SelectedCellStyle = Cyotek.Windows.Forms.ColorGridSelectedCellStyle.Standard;
       this.colorGrid.ShowCustomColors = false;
       this.colorGrid.Size = new System.Drawing.Size(192, 72);
       this.colorGrid.Spacing = new System.Drawing.Size(0, 0);
       this.colorGrid.TabIndex = 7;
       //
       // colorEditorManager
       //
       this.colorEditorManager.ColorEditor = this.colorEditor;
       this.colorEditorManager.ColorGrid = this.colorGrid;
       this.colorEditorManager.ColorWheel = this.colorWheel;
       this.colorEditorManager.ScreenColorPicker = this.screenColorPicker;
       this.colorEditorManager.ColorChanged += new System.EventHandler(this.colorEditorManager_ColorChanged);
       //
       // ColorPickerDialog
       //
       this.AcceptButton = this.okButton;
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.CancelButton = this.cancelButton;
       this.ClientSize = new System.Drawing.Size(540, 262);
       this.Controls.Add(this.savePaletteButton);
       this.Controls.Add(this.loadPaletteButton);
       this.Controls.Add(this.previewPanel);
       this.Controls.Add(this.cancelButton);
       this.Controls.Add(this.okButton);
       this.Controls.Add(this.screenColorPicker);
       this.Controls.Add(this.colorWheel);
       this.Controls.Add(this.colorEditor);
       this.Controls.Add(this.colorGrid);
       this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
       this.MaximizeBox = false;
       this.MinimizeBox = false;
       this.Name = "ColorPickerDialog";
       this.ShowIcon = false;
       this.ShowInTaskbar = false;
       this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
       this.Text = "Color Picker";
       this.ResumeLayout(false);
       this.PerformLayout();
 }