public bool Create_Poscard()
 {
     try
     {
         int     index = tabs.Items.Count;
         TabItem ti    = new TabItem();
         ti.Header = "Postcard " + (index + 1).ToString();
         StackPanel stp = new StackPanel();
         ti.Content = stp;
         tabs.Items.Add(ti);
         tabs.SelectedIndex = index;
         tabs.Items.MoveCurrentToLast();
         Canvas canva = new Canvas();
         canva.Width      = tabs.ActualWidth;
         canva.Height     = tabs.ActualHeight;
         canva.Background = new SolidColorBrush(Colors.MediumTurquoise);
         (ti.Content as StackPanel).Children.Add(canva);
         //Background
         Label l = new Label();
         l.Content = "Background";
         Background.Children.Add(l);
         Xceed.Wpf.Toolkit.ColorPicker cp = new Xceed.Wpf.Toolkit.ColorPicker();
         cp.Height = 30;
         cp.Name   = ti.Name;
         //cp.ShowAdvancedButton = true;
         cp.SelectedColor         = Colors.MediumTurquoise;
         cp.SelectedColorChanged += cp_SelectedColorChanged_Background;
         Background.Children.Add(cp);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemple #2
0
 public void onColorPick(InkCanvas _InkCanvas, Xceed.Wpf.Toolkit.ColorPicker _colorPicker, Polygon _polygon)
 {
     if (_colorPicker.SelectedColor.HasValue)
     {
         setColorFill(_colorPicker.SelectedColor.ToString());
         fillPolygon(_InkCanvas, _polygon);
         _InkCanvas.Children.Remove(_polygon);
     }
 }
Exemple #3
0
        private void ClrPcker_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs <Color?> e)
        {
            Xceed.Wpf.Toolkit.ColorPicker picker = (Xceed.Wpf.Toolkit.ColorPicker)sender;
            string          resource             = picker.Name.Substring(picker.Name.IndexOf("_", StringComparison.Ordinal) + 1);
            SolidColorBrush color = new SolidColorBrush(picker.SelectedColor.Value);

            color.Freeze();
            CustomMethods.ChangeBrushResource(color, resource);
            color = null;
        }
Exemple #4
0
        private void ColorPickerEditPhase_SelectedColorChanged(object sender, RoutedEventArgs e)
        {
            Xceed.Wpf.Toolkit.ColorPicker colorPicker = sender as Xceed.Wpf.Toolkit.ColorPicker;
            Color color = colorPicker.SelectedColor;

            Phase selectedPhase = _domain.GetPhase(_selectedPhaseName);

            selectedPhase.Color[0] = color.A;
            selectedPhase.Color[1] = color.R;
            selectedPhase.Color[2] = color.G;
            selectedPhase.Color[3] = color.B;
            UpdatePlot();
        }
 private void AddColorPicker(Grid grid, Color color)
 {
     Xceed.Wpf.Toolkit.ColorPicker colorPicker = new Xceed.Wpf.Toolkit.ColorPicker
     {
         SelectedColor       = color,
         HorizontalAlignment = HorizontalAlignment.Left,
         VerticalAlignment   = VerticalAlignment.Center,
         Width   = 50,
         Margin  = new Thickness(10, 5, 5, 5),
         Padding = new Thickness(5),
     };
     colorPicker.SelectedColorChanged += (sender, e) => UpdateColor(colorPicker);
     grid.Children.Add(colorPicker);
 }
        private void FontColorPicker_Loaded(object sender, RoutedEventArgs e)
        {
            if (sender is Xceed.Wpf.Toolkit.ColorPicker cp)
            {
                colorPicker = cp;

                colorPicker.Focusable = false;

                var children = colorPicker.FindVisualChildren <Control>();
                foreach (var child in children)
                {
                    child.Focusable = false;
                }
            }
        }
        // create editor
        void mytext_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Edit.Children.Clear();
            TextBox text = new TextBox();
            Label   l    = new Label();

            l.Content         = "Text Editor";
            text.TextChanged += text_TextChanged;
            text.Text         = (sender as TextBlock).Text;
            text.Name         = (sender as TextBlock).Name;
            Edit.Children.Add(l);
            Edit.Children.Add(text);

            Xceed.Wpf.Toolkit.ColorPicker cp = new Xceed.Wpf.Toolkit.ColorPicker();
            cp.Height = 30;
            cp.DisplayColorAndName = true;
            cp.Name = (sender as TextBlock).Name;
            //cp.ShowAdvancedButton = true;
            cp.SelectedColor         = ((sender as TextBlock).Foreground as SolidColorBrush).Color;
            cp.SelectedColorChanged += cp_SelectedColorChanged;
            Edit.Children.Add(cp);

            System.Windows.Controls.Button newBtn = new Button();

            newBtn.Content = "Changed Font";
            newBtn.Name    = (sender as TextBlock).Name;;
            newBtn.Click  += newBtn_Click;
            Edit.Children.Add(newBtn);

            Button b = new Button();

            b.Content = "Delete";
            b.Name    = (sender as TextBlock).Name;
            b.Click  += b_text_Click;
            Edit.Children.Add(b);

            mouseClick = e.GetPosition(null);
            canvasLeft = Canvas.GetLeft(((TextBlock)sender));
            canvasTop  = Canvas.GetTop(((TextBlock)sender));
            ((TextBlock)sender).CaptureMouse();
        }
        private void AddControlPoint(double pos, System.Windows.Media.Color color)
        {
            StackPanel stack = new StackPanel();

            stack.Orientation = Orientation.Horizontal;

            TextBox text = new TextBox();

            text.Text              = pos.ToString();
            text.MinWidth          = 50;
            text.VerticalAlignment = VerticalAlignment.Center;
            text.Margin            = new Thickness(5, 2, 5, 2);
            text.Name              = $"TextBox_CP{ListBox_ControlPoints.Items.Count}";


            Xceed.Wpf.Toolkit.ColorPicker colorPicker = new Xceed.Wpf.Toolkit.ColorPicker();
            colorPicker.MinWidth      = 150;
            colorPicker.Margin        = new Thickness(5, 2, 5, 2);
            colorPicker.SelectedColor = color;
            colorPicker.Closed       += ColorPicker_Closed;

            Button destroyer = new Button();

            destroyer.Name    = $"Button_CP{ListBox_ControlPoints.Items.Count}";
            destroyer.Content = "X";
            destroyer.Width   = 20;
            destroyer.Margin  = new Thickness(5, 2, 5, 2);
            destroyer.Click  += Button_DeleteCP_Click;

            stack.Children.Add(text);
            stack.Children.Add(colorPicker);
            stack.Children.Add(destroyer);

            stack.Name = $"StackPanel_CP{ListBox_ControlPoints.Items.Count}";

            ListBox_ControlPoints.Items.Add(stack);

            SetRectGradient();
        }
 void fill()
 {
     controlStack.Children.Clear();
     foreach (PropertyInfo pi in type_.GetProperties()) {
         Label lbl = new Label { Content = pi.Name };
         lbl.FontWeight = FontWeights.DemiBold;
         lbl.MinWidth = 120;
         StackPanel pnl = new StackPanel { Orientation = Orientation.Horizontal };
         pnl.Margin = new Thickness(5);
         if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(float)) {
             TextBox tb = new TextBox();
             tb.MinWidth = 240;
             tb.SetBinding(TextBox.TextProperty, new Binding(pi.Name));
             tb.Tag = pi;
             pnl.Children.Add(lbl);
             pnl.Children.Add(tb);
             controls_.Add(tb);
         } else if (pi.PropertyType == typeof(bool)) {
             CheckBox cb = new CheckBox();
             cb.Content = pi.Name;
             Binding binding = new Binding(pi.Name);
             if (!pi.CanWrite)
                 binding.Mode = BindingMode.OneWay;
             cb.SetBinding(CheckBox.IsCheckedProperty, binding);
             cb.Tag = pi;
             pnl.Children.Add(cb);
             controls_.Add(cb);
         } else if (pi.PropertyType == typeof(string)) {
             Urho.Resource res = pi.GetCustomAttribute<Urho.Resource>();
             if (res != null) {
                 ComboBox cb = new ComboBox();
                 if (res.Type == typeof(Urho.Material)) {
                     cb.ItemsSource = UrhoPaths.inst().GetList(UrhoPaths.PATH_MATERIALS, false);
                 } else if (res.Type == typeof(Urho.Shader)) {
                     cb.ItemsSource = UrhoPaths.inst().GetList(UrhoPaths.PATH_SHADERS, false);
                 } else if (res.Type == typeof(Urho.Technique)) {
                     cb.ItemsSource = UrhoPaths.inst().GetList(UrhoPaths.PATH_TECHNIQUES, false);
                 } else if (res.Type == typeof(Urho.BaseTexture) || res.Type == typeof(Urho.Texture)) {
                     cb.ItemsSource = UrhoPaths.inst().GetList(UrhoPaths.PATH_TEXTURES, true);
                 }
                 cb.SetBinding(ComboBox.SelectedItemProperty, new Binding(pi.Name));
                 cb.MinWidth = 240;
                 cb.Tag = pi;
                 pnl.Children.Add(lbl);
                 pnl.Children.Add(cb);
                 controls_.Add(cb);
             } else {
                 TextBox tb = new TextBox();
                 tb.MinWidth = 240;
                 tb.SetBinding(TextBox.TextProperty, new Binding(pi.Name));
                 tb.Tag = pi;
                 pnl.Children.Add(lbl);
                 pnl.Children.Add(tb);
                 controls_.Add(tb);
             }
         } else if (pi.PropertyType == typeof(Urho.MinMax)) {
             MinMaxEditor tb = new MinMaxEditor(pi.Name);
             tb.Tag = pi;
             tb.SetBinding(MinMaxEditor.DataContextProperty, new Binding(pi.Name));
             pnl.Children.Add(lbl);
             pnl.Children.Add(tb);
             controls_.Add(tb);
         } else if (pi.PropertyType == typeof(Urho.Vector2)) {
             Vector2Editor tb = new Vector2Editor(pi.Name);
             tb.Tag = pi;
             tb.SetBinding(Vector2Editor.DataContextProperty, new Binding(pi.Name));
             pnl.Children.Add(lbl);
             pnl.Children.Add(tb);
             controls_.Add(tb);
         } else if (pi.PropertyType == typeof(Urho.Vector3)) {
             Vector3Editor tb = new Vector3Editor(pi.Name);
             tb.SetBinding(Vector3Editor.DataContextProperty, new Binding(pi.Name));
             tb.Tag = pi;
             pnl.Children.Add(lbl);
             pnl.Children.Add(tb);
             controls_.Add(tb);
         } else if (pi.PropertyType == typeof(Urho.Vector4)) {
             Vector4Editor tb = new Vector4Editor(pi.Name);
             tb.SetBinding(Vector4Editor.DataContextProperty, new Binding(pi.Name));
             tb.Tag = pi;
             pnl.Children.Add(lbl);
             pnl.Children.Add(tb);
             controls_.Add(tb);
         } else if (pi.PropertyType == typeof(Urho.UColor)) {
             //TODO show a color picker
             Xceed.Wpf.Toolkit.ColorPicker col = new Xceed.Wpf.Toolkit.ColorPicker();
             Binding binding = new Binding(pi.Name);
             binding.Converter = new ColorToColorConverter();
             col.SetBinding(Xceed.Wpf.Toolkit.ColorPicker.SelectedColorProperty, binding);
             col.Tag = pi;
             pnl.Children.Add(lbl);
             pnl.Children.Add(col);
             controls_.Add(col);
         } else if (pi.PropertyType.IsEnum) {
             ComboBox cb = new ComboBox();
             cb.ItemsSource = Enum.GetValues(pi.PropertyType);
             cb.SetBinding(ComboBox.SelectedItemProperty, new Binding(pi.Name));
             cb.Tag = pi;
             pnl.Children.Add(lbl);
             pnl.Children.Add(cb);
             controls_.Add(cb);
         } else {
             try {
                 if (pi.PropertyType.GetGenericTypeDefinition() == typeof(ObservableCollection<>)) { //LIST
                     GridEditor dg = new GridEditor(pi.PropertyType.GetGenericArguments()[0]);
                     dg.Grid.SetBinding(DataGrid.ItemsSourceProperty, new Binding(pi.Name));
                     pnl.Children.Add(lbl);
                     pnl.Children.Add(dg);
                     controls_.Add(dg);
                 } else {
                     ReflectiveForm form = new ReflectiveForm(pi.PropertyType);
                     form.Tag = pi;
                     pnl.Children.Add(lbl);
                     pnl.Children.Add(form);
                     controls_.Add(form);
                 }
             } catch (Exception ex) {
                 ReflectiveForm form = new ReflectiveForm(pi.PropertyType);
                 pnl.Children.Add(lbl);
                 pnl.Children.Add(form);
                 controls_.Add(form);
             }
         }
         controlStack.Children.Add(pnl);
     }
 }
Exemple #10
0
 // ==================
 // = Event Handlers =
 // ==================
 private void colorLabelClick(object sender, EventArgs e, SolidColorBrush solidColorBrush)
 {
     // Create Color Picker Dialog in WinForms since WPF doesn't have one.
     Xceed.Wpf.Toolkit.ColorPicker colorPicker = new Xceed.Wpf.Toolkit.ColorPicker();
     colorPicker.SelectedColor = solidColorBrush.Color;
 }
Exemple #11
0
        public TreeViewItem SpecialCaseChecker(Object value)
        {
            // Create TreeViewItem for the Special Case to use
            TreeViewItem root = new TreeViewItem();

            // Handle Vectors
            if (value.GetType().ToString().Contains("Vector"))
            {
                IOrderedEnumerable <FieldInfo> fields = value.GetType().GetFields().OrderBy(field => field.MetadataToken);
                if (fields.Count() <= 5)
                {
                    StackPanel headerPanel = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };

                    foreach (FieldInfo f in fields)
                    {
                        Debug.WriteLine($"type = {f.FieldType}, name = {f.Name}, value = {f.GetValue(value)}");    //write all fields to debug

                        TextBox txtBox = new TextBox();
                        txtBox.Text = f.GetValue(value).ToString();
                        headerPanel.Children.Add(CreateStackPanel(f.Name, txtBox));
                    }
                    root.Header = headerPanel;
                }
                else
                {
                    Debug.WriteLine("There's too many field in this Vector, not adding them to the Header");
                }
                return(root);
            }

            // Handle NMS Colour
            else if (value.GetType() == typeof(Colour))
            {
                // Watch the spelling here as the NMS Color type is spelled with the u (Colour) while the normal one is without (Color)
                Colour color = (Colour)value;

                // And the headerPanel background as well
                SolidColorBrush solidColorBrush = new SolidColorBrush();
                Label           colorLabel      = new Label();
                solidColorBrush.Color = (Color)ConvertNMSColorToColor(color);
                Xceed.Wpf.Toolkit.ColorPicker colorPicker = new Xceed.Wpf.Toolkit.ColorPicker();
                colorPicker.SelectedColor = solidColorBrush.Color;
                root.Header = colorPicker;
                //colorLabel.Background = solidColorBrush;
                //colorLabel.Content = "(R:" + color.R.ToString() + " G:" + color.G.ToString() + "B: " + color.B.ToString() + "A: " + color.A.ToString() + ")";
                //colorLabel.MouseDoubleClick += new MouseButtonEventHandler(colorLabelClick);
                //colorLabel.MouseDoubleClick += (sender, e) => colorLabelClick(sender, e, solidColorBrush);      //Honestly don't konw what's happening here but it works?
                //root.Header = colorLabel;
                return(root);
            }

            // No Special Case Found, return regular TreeViewItem
            else
            {
                root.Header = value.GetType();
                return(root);
            }
        }
 private void UpdateColor(Xceed.Wpf.Toolkit.ColorPicker colorPicker)
 {
     Data.DisplayColor = (Color)colorPicker.SelectedColor;
     new CategoryModel(Data).Save();
 }
Exemple #13
0
        private void GenerateHostControl(object DefaultValue, Type CurrentType)
        {
            if (DefaultValue != null)
            {
                HostType = DefaultValue.GetType();
            }
            else
            {
                HostType = CurrentType;
            }

            LastValue = DefaultValue;

            if (HostType == typeof(byte))
            {
                ByteNumericControl = new Xceed.Wpf.Toolkit.ByteUpDown();
                ByteNumericControl.UpdateValueOnEnterKey = true;
                ByteNumericControl.Value = (byte)DefaultValue;
                ValueControl.Value1Host.Children.Add(ByteNumericControl);
            }
            else if (HostType == typeof(ushort))
            {
                UShortNumericControl = new Xceed.Wpf.Toolkit.UShortUpDown();
                UShortNumericControl.UpdateValueOnEnterKey = true;
                UShortNumericControl.Value = (ushort)DefaultValue;
                ValueControl.Value1Host.Children.Add(UShortNumericControl);
            }
            else if (HostType == typeof(uint))
            {
                UIntNumericControl = new Xceed.Wpf.Toolkit.UIntegerUpDown();
                UIntNumericControl.UpdateValueOnEnterKey = true;
                UIntNumericControl.Value = (uint)DefaultValue;
                ValueControl.Value1Host.Children.Add(UIntNumericControl);
            }
            else if (HostType == typeof(sbyte))
            {
                SByteNumericControl = new Xceed.Wpf.Toolkit.SByteUpDown();
                SByteNumericControl.UpdateValueOnEnterKey = true;
                SByteNumericControl.Value = (sbyte)DefaultValue;
                ValueControl.Value1Host.Children.Add(SByteNumericControl);
            }
            else if (HostType == typeof(short))
            {
                ShortNumericControl = new Xceed.Wpf.Toolkit.ShortUpDown();
                ShortNumericControl.UpdateValueOnEnterKey = true;
                ShortNumericControl.Value = (short)DefaultValue;
                ValueControl.Value1Host.Children.Add(ShortNumericControl);
            }
            else if (HostType == typeof(int))
            {
                IntNumericControl = new Xceed.Wpf.Toolkit.IntegerUpDown();
                IntNumericControl.UpdateValueOnEnterKey = true;
                IntNumericControl.Value = (int)DefaultValue;
                ValueControl.Value1Host.Children.Add(IntNumericControl);
            }
            else if (HostType == typeof(bool))
            {
                BoolCheckboxControl                            = new System.Windows.Controls.CheckBox();
                BoolCheckboxControl.IsChecked                  = (bool)DefaultValue;
                BoolCheckboxControl.VerticalAlignment          = System.Windows.VerticalAlignment.Center;
                BoolCheckboxControl.HorizontalAlignment        = System.Windows.HorizontalAlignment.Left;
                BoolCheckboxControl.VerticalContentAlignment   = System.Windows.VerticalAlignment.Center;
                BoolCheckboxControl.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left;
                ValueControl.Value1Host.Children.Add(BoolCheckboxControl);
            }
            else if (HostType == typeof(string))
            {
                StringTextboxControl = new System.Windows.Controls.TextBox()
                {
                    IsInactiveSelectionHighlightEnabled = true
                };
                StringTextboxControl.Text = (string)DefaultValue;
                TextBoxLastString         = (string)DefaultValue;

                ValueControl.Value1Host.Children.Add(StringTextboxControl);
            }
            else if (HostType == typeof(float))
            {
                FloatNumericControl = new Xceed.Wpf.Toolkit.SingleUpDown();
                FloatNumericControl.UpdateValueOnEnterKey = true;
                FloatNumericControl.Value = (float)DefaultValue;
                ValueControl.Value1Host.Children.Add(FloatNumericControl);
            }
            else if (HostType == typeof(System.Drawing.Color))
            {
                ColorPickerControl = new Xceed.Wpf.Toolkit.ColorPicker();
                System.Drawing.Color initalColor = (System.Drawing.Color)DefaultValue;
                ColorPickerLastColor = new System.Windows.Media.Color()
                {
                    A = initalColor.A, R = initalColor.R, G = initalColor.G, B = initalColor.B
                };
                ColorPickerControl.SelectedColor = ColorPickerLastColor;
                ValueControl.Value1Host.Children.Add(ColorPickerControl);
            }

            EnableEvents();
        }
Exemple #14
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Xceed.Wpf.Toolkit.ColorPicker picker = new Xceed.Wpf.Toolkit.ColorPicker();
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Xceed.Wpf.Toolkit.ColorPicker picker = new Xceed.Wpf.Toolkit.ColorPicker();
 }