示例#1
0
        /// <summary>
        /// Custom Control initialization
        /// </summary>
        protected void  CustomInit()
        {
            // Subscribe to the palette buttons' events
            FieldInfo[] Fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (FieldInfo Field in Fields)
            {
                if (Field.FieldType != typeof(PaletteButton))
                {
                    continue;
                }
                if (Field.Name.IndexOf("radioButtonPalette") == -1)
                {
                    continue;
                }

                PaletteButton Button = Field.GetValue(this) as PaletteButton;
                Button.DoubleClick     += new EventHandler(RadioButtonPalette_DoubleClick);
                Button.SelectedChanged += new EventHandler(RadioButtonPalette_SelectedChanged);
            }

            // Setup the palette buttons' back colors
            for (int PaletteIndex = 0; PaletteIndex < PALETTE_ENTRIES; PaletteIndex++)
            {
                UpdatePaletteButtonColor(PaletteIndex);
            }
        }
示例#2
0
        // Retrieves the index of the selected palette button
        //
        protected void  SetSelectedPaletteButton(PaletteButton _Button)
        {
            FieldInfo[] Fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (FieldInfo Field in Fields)
            {
                if (Field.FieldType != typeof(PaletteButton))
                {
                    continue;
                }
                if (Field.Name.IndexOf("radioButtonPalette") == -1)
                {
                    continue;
                }

                // Check the button's is checked
                PaletteButton Button = Field.GetValue(this) as PaletteButton;
                Button.Selected = Button == _Button;
            }
        }
示例#3
0
        // Retrieves the index of the palette entry given a palette radio button
        //
        protected PaletteButton GetPaletteButton(int _PaletteIndex)
        {
            FieldInfo[] Fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (FieldInfo Field in Fields)
            {
                if (Field.FieldType != typeof(PaletteButton))
                {
                    continue;
                }
                if (Field.Name.IndexOf("radioButtonPalette") == -1)
                {
                    continue;
                }

                PaletteButton Button = Field.GetValue(this) as PaletteButton;

                if (GetPaletteButtonIndex(Button) == _PaletteIndex)
                {
                    return(Button);
                }
            }

            return(null);
        }
示例#4
0
        // Updates the palette button's back color based on the associated palette entry
        //
        protected void  UpdatePaletteButtonColor(int _PaletteIndex)
        {
            PaletteButton Button = GetPaletteButton(_PaletteIndex);

            Button.Vector = GetPaletteColor(_PaletteIndex);
        }
示例#5
0
 // Retrieves the index of the palette entry given a palette radio button
 //
 protected int   GetPaletteButtonIndex(PaletteButton _Button)
 {
     return(int.Parse(_Button.Name.Replace("radioButtonPalette", "")));
 }