Browse Source

use WpfDesigner color picker in ColorPicker button

pull/14/head
Siegfried Pammer 15 years ago
parent
commit
bbe1cdb13a
  1. 29
      src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs

29
src/Main/Base/Project/Src/Gui/Components/ColorPicker.xaml.cs

@ -2,15 +2,14 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Widgets = ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Gui
{ {
/// <summary> /// <summary>
@ -60,14 +59,22 @@ namespace ICSharpCode.SharpDevelop.Gui
void ButtonClick(object sender, RoutedEventArgs e) void ButtonClick(object sender, RoutedEventArgs e)
{ {
e.Handled = true; var control = new Widgets.ColorPicker();
using (SharpDevelopColorDialog dlg = new SharpDevelopColorDialog()) { Popup popup = new Popup() {
dlg.WpfColor = this.Value; Child = control,
if (dlg.ShowWpfDialog() == true) { Placement = PlacementMode.Bottom,
// use SetCurrentValue instead of SetValue so that two-way data binding can be used PlacementTarget = this,
SetCurrentValue(ValueProperty, dlg.WpfColor); IsOpen = true,
StaysOpen = false
};
control.SetBinding(
Widgets.ColorPicker.ColorProperty,
new Binding("Value") {
Source = this,
Mode = BindingMode.TwoWay
} }
} );
} }
} }
} }

Loading…
Cancel
Save