// // OnMouseMove event handler // protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // Keep track of the current mouse position so we can invalidate the region _mouseCellX = Math.Max(0, Math.Min(_cellsPerRow - 1, e.X / _cellWidth)); _mouseCellY = Math.Max(0, Math.Min((int)Math.Ceiling(_colorSwatch.ColorCount / (float)(_cellsPerRow)) - 1, e.Y / _cellHeight)); // Invalidate the mouse region Rectangle newCellRect = GetMouseCellArea(); if (newCellRect != _lastMouseCellArea) { Rectangle oldRec = _lastMouseCellArea; Rectangle newRec = newCellRect; oldRec.Inflate(2, 2); newRec.Inflate(2, 2); Invalidate(oldRec); Invalidate(newRec); if (_mouseDown && _mouseOver) { // Gets the color the user clicked on ColorSelect?.Invoke(this, new ColorSelectEventArgs(GetColorUnderMouse())); } } _lastMouseCellArea = newCellRect; }
public void Formatting(string widget = "") { if (widget == "Sparkline") { NumberFormat.SelectDropdown("Time"); } NumberFormat.SelectDropdown("Number"); Decimal.SelectDropdown("3"); ShowCommas.Clicks(); if (widget == "" || widget == "Heatmap") { AddCondition.Clicks(); AddConditionTo.EnterText("10000"); AddConditionFrom.EnterText("90000"); ColorSelect.Clicks(); SelectColor.Clicks(); } }
private void ColorBox_Click(object sender, EventArgs e) { if (ColorSelect.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ColorBox.BackColor = ColorSelect.Color; pencel.Color = ColorSelect.Color; } }
private void SVPanel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B)); ColorSelect.Invoke(Color.FromArgb(A, R, G, B), e); SVPanelDrag = false; }
private void backColors_Click(object sender, EventArgs e) { if (ColorSelect.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PaintBox.BackColor = ColorSelect.Color; g.Clear(ColorSelect.Color); PaintBox.Refresh(); } }
internal static void ShowColorSelect(Form form, Color color) { ColorSelect colorSelect = new ColorSelect { Owner = form }; colorSelect.InitializeForm(color); colorSelect.ShowDialog(form); }
private void UserControl_PreviewMouseUp(object sender, MouseButtonEventArgs e) { if (SVPanelDrag | HueBarDrag) { SVPanelDrag = false; HueBarDrag = false; LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B)); ColorSelect.Invoke(Color.FromArgb(A, R, G, B), e); } }
private void ColorPanel1_ColorSelect(object sender, EventArgs e) { var color = (sender as ColorPanel.ColorChunk).Color; controller.ToolSelection = new PenSelection(color.ToArgb()); ColorSelect.Invoke(sender, e); Close(); Dispose(); }
public HMIDigitalPanelMeterBlue() { this.LED = new Bitmap[12]; this.m_Resolution = decimal.One; this.m_DecimalPos = 0; this.m_BackLightColor = ColorSelect.Blue; if ((base.ForeColor == Color.LightGray) || (this.ForeColor == Color.FromArgb(0, 0, 0, 0))) { this.ForeColor = Color.Black; } this.Maximum = 0; this.Minimum = 0; }
// // OnMouseDown event handler // protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) { return; } // Gets the color the user clicked on ColorSelect?.Invoke(this, new ColorSelectEventArgs(GetColorUnderMouse())); _mouseDown = true; }
private void ColorRGBRefresh() { Color MainColor = Color.FromRgb(R, G, B); ColorToHSV(MainColor, ref Saturation, ref Value); // ColorHSVRefresh() double RealWidth = SVPanel.ActualWidth; double RealHeight = SVPanel.ActualHeight; PickerStylus.Margin = new Thickness(Saturation * RealWidth - 7, (1 - Value) * RealHeight - 7, 0, 0); CurrentColor.Background = new SolidColorBrush(MainColor); LastColor.Background = new SolidColorBrush(Color.FromArgb(A, R, G, B)); ColorSelect.Invoke(Color.FromArgb(A, R, G, B), new RoutedEventArgs()); }
private void BG_Click(object sender, RoutedEventArgs e) { _colorSelect = ColorSelect.Bg; ClrPcker_Background.Visibility = Visibility.Hidden; this.ClrPcker_Background.IsOpen = true; }
/// <summary> /// Fires the color change event with the given color /// </summary> /// <param name="color">The color to fire the event with</param> /// <param name="colorIndex">Which color index to fire the event fore. Defaults to the current color</param> public void FireColorChangeEvent(Color color, ColorPickerColor colorIndex = ColorPickerColor.CurrentColor) { ColorSelect?.Invoke(this, new ColorPickEventArgs(color, color, colorIndex)); }
//public double Value //{ // get { return SliderRGBControl.Value; } // // set { SliderRGBControl.Value = value; } //} public SliderRGB() { InitializeComponent(); SetBind(this, ColorProperty, ColorSelect.FindResource("SliderThumb.Static.Background") as SolidColorBrush, "Color"); }
void CreateUIElement(Type t, PropertyInfo p, string name) { DropdownAttribute dp = p.GetCustomAttribute <DropdownAttribute>(); LevelEditorAttribute le = p.GetCustomAttribute <LevelEditorAttribute>(); CurveEditorAttribute ce = p.GetCustomAttribute <CurveEditorAttribute>(); SliderAttribute sl = p.GetCustomAttribute <SliderAttribute>(); FileSelectorAttribute fsl = p.GetCustomAttribute <FileSelectorAttribute>(); HidePropertyAttribute hp = p.GetCustomAttribute <HidePropertyAttribute>(); ColorPickerAttribute cp = p.GetCustomAttribute <ColorPickerAttribute>(); TitleAttribute ti = p.GetCustomAttribute <TitleAttribute>(); TextInputAttribute tinp = p.GetCustomAttribute <TextInputAttribute>(); GraphParameterEditorAttribute gpe = p.GetCustomAttribute <GraphParameterEditorAttribute>(); ParameterMapEditorAttribute pme = p.GetCustomAttribute <ParameterMapEditorAttribute>(); PromoteAttribute pro = p.GetCustomAttribute <PromoteAttribute>(); //handle very special stuff //exposed constant parameter variable names if (gpe != null) { if (node is Graph) { Graph g = node as Graph; GraphParameterEditor inp = new GraphParameterEditor(g, g.Parameters); Stack.Children.Add(inp); elementLookup[name] = inp; } } //for graph instance exposed parameters from underlying graph else if (pme != null) { if (node is GraphInstanceNode) { GraphInstanceNode gin = node as GraphInstanceNode; ParameterMap pm = new ParameterMap(gin.GraphInst, gin.Parameters); Stack.Children.Add(pm); elementLookup[name] = pm; } } string title = name; if (ti != null) { title = ti.Title; } PropertyInfo op = null; //we don't create an element for this one //as it is hidden if (hp != null) { return; } try { if (ce != null) { op = node.GetType().GetProperty(ce.OutputProperty); } } catch (Exception e) { Console.WriteLine(e.StackTrace); } if (t.Equals(typeof(Vector4))) { if (cp != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); ColorSelect cs = new ColorSelect(p, node); Stack.Children.Add(cs); elementLookup[name] = cs; } } else if (t.Equals(typeof(string[]))) { if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); DropDown inp = new DropDown((string[])p.GetValue(node), node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(bool))) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); ToggleControl tg = new ToggleControl(name, p, node); Stack.Children.Add(tg); elementLookup[name] = tg; } else if (t.Equals(typeof(string))) { if (tinp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); PropertyInput ip = new PropertyInput(p, node); Stack.Children.Add(ip); elementLookup[name] = ip; } else if (fsl != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); FileSelector inp = new FileSelector(p, node, fsl.Filter); Stack.Children.Add(inp); elementLookup[name] = inp; } else if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); object[] names = dp.Values; DropDown inp = new DropDown(names, node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } } if (t.Equals(typeof(float))) { if (sl != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberSlider inp = new NumberSlider(sl, p, node); Stack.Children.Add(inp); elementLookup[name] = inp; } else { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberInput inp = new NumberInput(NumberInputType.Float, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(int))) { if (dp != null) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); //do a dropdown object[] names = dp.Values; DropDown inp = new DropDown(names, node, p, dp.OutputProperty); Stack.Children.Add(inp); elementLookup[name] = inp; } else if (sl != null) { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberSlider inp = new NumberSlider(sl, p, node); Stack.Children.Add(inp); elementLookup[name] = inp; } else { PropertyLabel l = null; if (pro != null && node is Node) { l = new PropertyLabel(title, node as Node, name); } else { l = new PropertyLabel(); l.Title = title; } labels.Add(l); Stack.Children.Add(l); NumberInput inp = new NumberInput(NumberInputType.Int, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } } else if (t.Equals(typeof(MultiRange))) { if (le != null) { UILevels lv = null; if (node is Node) { Node nd = (Node)node; if (nd.Inputs.Count > 0 && nd.Inputs[0].Input != null) { var n = nd.Inputs[0].Input.Node; byte[] result = n.GetPreview(n.Width, n.Height); RawBitmap bit = null; if (result != null) { bit = new RawBitmap(n.Width, n.Height, result); } lv = new UILevels(bit, node, p); } else { lv = new UILevels(null, node, p); } Stack.Children.Add(lv); elementLookup[name] = lv; } } } else if (op != null && ce != null) { UICurves cv = new UICurves(p, op, node); Stack.Children.Add(cv); elementLookup[name] = cv; } else if (t.IsEnum) { PropertyLabel l = new PropertyLabel(); l.Title = title; labels.Add(l); Stack.Children.Add(l); string[] names = Enum.GetNames(t); DropDown inp = new DropDown(names, node, p); Stack.Children.Add(inp); elementLookup[name] = inp; } }
public void ButtonClicked( Transform trans, Buttons button ) { var toolClicked = false; var colorClicked = false; var colorSelectClickedIndex = -1; switch ( button ) { case Buttons.Add: { SelectedTool = Tools.Add; toolClicked = true; break; } case Buttons.Remove: { SelectedTool = Tools.Remove; toolClicked = true; break; } case Buttons.Change: { SelectedTool = Tools.Change; toolClicked = true; break; } case Buttons.Color1: { SelectedColor = ColorSelect.Color1; colorClicked = true; break; } case Buttons.Color2: { SelectedColor = ColorSelect.Color2; colorClicked = true; break; } case Buttons.Color3: { SelectedColor = ColorSelect.Color3; colorClicked = true; break; } case Buttons.Color4: { SelectedColor = ColorSelect.Color4; colorClicked = true; break; } case Buttons.Color5: { SelectedColor = ColorSelect.Color5; colorClicked = true; break; } case Buttons.ColorSelect1: { SelectedColor = ColorSelect.Color1; colorSelectClickedIndex = 0; break; } case Buttons.ColorSelect2: { SelectedColor = ColorSelect.Color2; colorSelectClickedIndex = 1; break; } case Buttons.ColorSelect3: { SelectedColor = ColorSelect.Color3; colorSelectClickedIndex = 2; break; } case Buttons.ColorSelect4: { SelectedColor = ColorSelect.Color4; colorSelectClickedIndex = 3; break; } case Buttons.ColorSelect5: { SelectedColor = ColorSelect.Color5; colorSelectClickedIndex = 4; break; } case Buttons.Undo: { PixelManager.Undo(); break; } case Buttons.Redo: { PixelManager.Redo(); break; } case Buttons.CloseColorPicker: { HideableUIElement.Hide( ColorPicker.gameObject ); break; } case Buttons.Import: { ImportOrNewSelector.Hide(); break; } case Buttons.New: { ImportOrNewSelector.Hide(); break; } case Buttons.Login: { AzureHelper.Login(); if ( AzureHelper.IsLoggedIn() ) { LoginErrorDialog.Hide(); StopModal(); } break; } } if ( toolClicked ) { var args = new Hashtable() { { "position", trans.position }, { "time", 1 } }; iTween.MoveTo( ToolSelectBackground, args ); } if ( colorClicked ) { var args = new Hashtable() { { "position", trans.position }, { "time", 1 } }; iTween.MoveTo( ColorSelectBackground, args ); ColorPicker.SetColor( GetSelectedColor() ); } if ( colorSelectClickedIndex >= 0 ) { var args = new Hashtable() { { "position", ColorButtons[colorSelectClickedIndex].transform.position }, { "time", 1 } }; iTween.MoveTo( ColorSelectBackground, args ); HideableUIElement.Show( ColorPicker.gameObject ); ColorPicker.SetColor( GetSelectedColor() ); ColorButtons[colorSelectClickedIndex].transform.parent.SetAsLastSibling(); } }