More colors event args
Inheritance: System.EventArgs
Exemplo n.º 1
0
        private void OnMoreColorsClick(object sender, RoutedEventArgs e)
        {
            if (this.MoreColorsExecuting != null)
            {
                var args = new MoreColorsExecutingEventArgs();
                this.MoreColorsExecuting(this, args);
                if (!args.Canceled)
                {
                    var color = args.Color;
                    if (RecentColors.Contains(color))
                    {
                        RecentColors.Remove(color);
                    }

                    RecentColors.Insert(0, color);
                    this.recentColorsListBox.SelectedIndex = 0;
                }
            }
            else
            {
#pragma warning disable 618
                var chooseColor = new CHOOSECOLOR();
                var wnd         = Window.GetWindow(this);
                if (wnd != null)
                {
                    chooseColor.hwndOwner = new WindowInteropHelper(wnd).Handle;
                }

                chooseColor.Flags = CC_ANYCOLOR;
                if (customColors == IntPtr.Zero)
                {
                    // Set custom colors)
                    for (var i = 0; i < this.colorsArray.Length; i++)
                    {
                        this.colorsArray[i] = 0x00FFFFFF;
                    }

                    customColors = GCHandle.Alloc(this.colorsArray, GCHandleType.Pinned).AddrOfPinnedObject();
                }

                chooseColor.lpCustColors = customColors;
                if (ChooseColor(chooseColor))
                {
                    var color = ConvertFromWin32Color(chooseColor.rgbResult);
                    if (RecentColors.Contains(color))
                    {
                        RecentColors.Remove(color);
                    }

                    RecentColors.Insert(0, color);
                    this.recentColorsListBox.SelectedIndex = 0;
                }
#pragma warning restore 618
            }
        }
Exemplo n.º 2
0
 private void OnMoreColorsClick(object sender, RoutedEventArgs e)
 {
     if (MoreColorsExecuting != null)
     {
         MoreColorsExecutingEventArgs args = new MoreColorsExecutingEventArgs();
         MoreColorsExecuting(this, args);
         if (!args.Canceled)
         {
             Color color = args.Color;
             if (RecentColors.Contains(color))
             {
                 RecentColors.Remove(color);
             }
             RecentColors.Insert(0, color);
             recentColorsListBox.SelectedIndex = 0;
         }
     }
     else
     {
         NativeMethods.CHOOSECOLOR chooseColor = new NativeMethods.CHOOSECOLOR();
         Window wnd = Window.GetWindow(this);
         if (wnd != null)
         {
             chooseColor.hwndOwner = new WindowInteropHelper(wnd).Handle;
         }
         chooseColor.Flags = NativeMethods.CC_ANYCOLOR;
         if (customColors == IntPtr.Zero)
         {
             // Set custom colors)
             for (int i = 0; i < colorsArray.Length; i++)
             {
                 colorsArray[i] = 0x00FFFFFF;
             }
             customColors = GCHandle.Alloc(colorsArray, GCHandleType.Pinned).AddrOfPinnedObject();
         }
         chooseColor.lpCustColors = customColors;
         if (NativeMethods.ChooseColor(chooseColor))
         {
             Color color = ConvertFromWin32Color(chooseColor.rgbResult);
             if (RecentColors.Contains(color))
             {
                 RecentColors.Remove(color);
             }
             RecentColors.Insert(0, color);
             recentColorsListBox.SelectedIndex = 0;
         }
     }
 }
Exemplo n.º 3
0
 private void OnMoreColorsClick(object sender, RoutedEventArgs e)
 {
     if (MoreColorsExecuting != null)
     {
         MoreColorsExecutingEventArgs args = new MoreColorsExecutingEventArgs();
         MoreColorsExecuting(this, args);
         if (!args.Canceled)
         {
             Color color = args.Color;
             if (RecentColors.Contains(color)) RecentColors.Remove(color);
             RecentColors.Insert(0, color);
             recentColorsListBox.SelectedIndex = 0;
         }
     }
     else
     {
         NativeMethods.CHOOSECOLOR chooseColor = new NativeMethods.CHOOSECOLOR();
         Window wnd = Window.GetWindow(this);
         if (wnd != null) chooseColor.hwndOwner = new WindowInteropHelper(wnd).Handle;
         chooseColor.Flags = NativeMethods.CC_ANYCOLOR;
         if (customColors == IntPtr.Zero)
         {
             // Set custom colors)
             for (int i = 0; i < colorsArray.Length; i++) colorsArray[i] = 0x00FFFFFF;
             customColors = GCHandle.Alloc(colorsArray, GCHandleType.Pinned).AddrOfPinnedObject();
         }
         chooseColor.lpCustColors = customColors;
         if (NativeMethods.ChooseColor(chooseColor))
         {
             Color color = ConvertFromWin32Color(chooseColor.rgbResult);
             if (RecentColors.Contains(color)) RecentColors.Remove(color);
             RecentColors.Insert(0, color);
             recentColorsListBox.SelectedIndex = 0;
         }
     }
 }