private static void IsSelectedChangedHandler(DependencyObject d, DependencyPropertyChangedEventArgs e) { var obj = d as OperatorWidget; if (obj != null) { if (obj.IsSelected) { foreach (Path nosePath in obj.XOutputThumbGrid.Children.OfType <Path>()) { nosePath.Fill = Brushes.White; } } else { int outputIdx = 0; foreach (Path nosePath in obj.XOutputThumbGrid.Children.OfType <Path>()) { nosePath.Fill = new SolidColorBrush(UIHelper.ColorFromType(obj.Operator.Outputs[outputIdx].Type)); nosePath.Fill.Freeze(); ++outputIdx; } } } }
private void UpdateColor() { operatorContent.Background = new SolidColorBrush(UIHelper.ColorFromType(OperatorPart.Type)); operatorContent.Background.Freeze(); NameLabel.Foreground = new SolidColorBrush(UIHelper.BrightColorFromType(OperatorPart.Type)); NameLabel.Foreground.Freeze(); }
internal void UpdateColors() { XOperatorContent.Background = new SolidColorBrush(UIHelper.ColorFromType(Type)) { Opacity = 0.6 }; XOperatorContent.Background.Freeze(); XOperatorLabel.Foreground = new SolidColorBrush(UIHelper.BrightColorFromType(Type)); XOperatorLabel.Foreground.Freeze(); }
private void OnMouseLeaveOutputNose(object sender, MouseEventArgs e) { if (IsSelected) { MyOutputNose.Fill = Brushes.White; } else { MyOutputNose.Fill = new SolidColorBrush(UIHelper.ColorFromType(Type)); MyOutputNose.Fill.Freeze(); } }
private void UpdateOutputNoses() { XOutputThumbGrid.Children.Clear(); XOutputThumbGrid.ColumnDefinitions.Clear(); for (var i = 0; i < Operator.Outputs.Count; ++i) { var cd = new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }; XOutputThumbGrid.ColumnDefinitions.Add(cd); var nosePath = new Path { HorizontalAlignment = System.Windows.HorizontalAlignment.Center, StrokeThickness = 0.5, Stroke = Brushes.Black, Data = Geometry.Parse("M 3, 10 L 8,5 13,10") }; if (IsSelected) { nosePath.Fill = Brushes.White; } else { nosePath.Fill = new SolidColorBrush(UIHelper.ColorFromType(Operator.Outputs[i].Type)); nosePath.Fill.Freeze(); } Grid.SetColumn(nosePath, i); XOutputThumbGrid.Children.Add(nosePath); var nose = new Thumb { HorizontalAlignment = System.Windows.HorizontalAlignment.Center, Opacity = 0.0, Focusable = true }; // FIXME ME: assigning these handlers without unloading them might // cause memory leaks nose.DragStarted += NoseThumb_DragStarted; nose.MouseEnter += MouseEnterOutputNoseHandler; nose.MouseLeave += MouseLeaveOutputNoseHandler; nose.Width = 16; nose.ToolTip = String.Format("{0}", Operator.Outputs[i].Name); Grid.SetColumn(nose, i); XOutputThumbGrid.Children.Add(nose); } }
public InputWidget(OperatorPart opPart) { InitializeComponent(); OperatorPart = opPart; m_MoveHandler = new MoveHandler(this); Height = CompositionGraphView.GRID_SIZE; Width = CompositionGraphView.GRID_SIZE * 3; operatorContent.Background = new SolidColorBrush(UIHelper.ColorFromType(OperatorPart.Type)); operatorContent.Background.Freeze(); NameLabel.Foreground = new SolidColorBrush(UIHelper.BrightColorFromType(OperatorPart.Type)); NameLabel.Foreground.Freeze(); }
public OperatorWidget(Operator op) { Operator = op; _outputs = Operator.Outputs; _inputs = Operator.Inputs; InitializeComponent(); CreateBindingsToOperator(); var outputFunctions = from output in _outputs where output.Func is Utilities.ValueFunction select output.Func as Utilities.ValueFunction; foreach (var func in outputFunctions) { func.EvaluatedEvent += OperatorOutputFunction_EvaluatedHandler; } _snapHandler = new OperatorSnappingHelper(this); Height = CompositionGraphView.GRID_SIZE; Width = Operator.Width; var inputZones = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this); UpdateInputRanges(inputZones); UpdateColors(); UpdateOutputNoses(); int outputIdx = 0; foreach (Path nosePath in XOutputThumbGrid.Children.OfType <Path>()) { nosePath.Fill = new SolidColorBrush(UIHelper.ColorFromType(Operator.Outputs[outputIdx].Type)); nosePath.Fill.Freeze(); ++outputIdx; } if (!op.Visible) { Opacity = 0; IsHitTestVisible = false; } }
private void MouseLeaveOutputNoseHandler(object sender, MouseEventArgs e) { int outputIdx = FindIndexOfNoseThumb((Thumb)e.Source); if (outputIdx < 0) { return; } Path nosePath = XOutputThumbGrid.Children.OfType <Path>().ToArray()[outputIdx]; if (IsSelected) { nosePath.Fill = Brushes.White; } else { nosePath.Fill = new SolidColorBrush(UIHelper.ColorFromType(Operator.Outputs[outputIdx].Type)); nosePath.Fill.Freeze(); } }
public OperatorTypeButton(MetaOperator metaOp, bool namespaceVisible = true) { InitializeComponent(); _namespaceVisible = namespaceVisible; MetaOp = metaOp; var nameBinding = new Binding { UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Source = metaOp, Path = new PropertyPath("Name") }; var combinedBinding = new MultiBinding { Converter = new BindingConverter() }; combinedBinding.Bindings.Add(nameBinding); SetBinding(ContentProperty, combinedBinding); ToolTip = metaOp.Namespace; Click += OperatorButton_ClickHandler; MouseUp += OperatorButton_MouseUpHandler; if (metaOp.Outputs.Count > 0) { Background = new SolidColorBrush(UIHelper.ColorFromType(metaOp.Outputs[0].OpPart.Type)) { Opacity = 0.6 }; Background.Freeze(); Foreground = new SolidColorBrush(UIHelper.BrightColorFromType(metaOp.Outputs[0].OpPart.Type)); Foreground.Freeze(); } }
public void UpdateInputZonesUIFromDescription(IEnumerable <OperatorWidgetInputZone> inputZones) { XInputZoneIndicators.Children.Clear(); foreach (var zone in inputZones) { // Required but missing inputs if (zone.MetaInput.Relevance == MetaInput.RelevanceType.Required && !zone.Input.Connections.Any()) { var inputBg = new Rectangle(); Canvas.SetLeft(inputBg, zone.LeftPosition + 1); Canvas.SetBottom(inputBg, -2); inputBg.Height = 2; inputBg.Width = zone.Width - 1; // don't overlap range separator inputBg.Fill = zone.IsBelowMouse ? new SolidColorBrush(UIHelper.BrightColorFromType(zone.Input.Type)) : new SolidColorBrush(UIHelper.ColorFromType(zone.Input.Type)); inputBg.Fill.Freeze(); XInputZoneIndicators.Children.Add(inputBg); } else if (zone.IsBelowMouse) { var inputBg = new Rectangle(); Canvas.SetLeft(inputBg, zone.LeftPosition + 1); Canvas.SetBottom(inputBg, 1); inputBg.Height = 3; inputBg.Width = zone.Width - 1; // don't overlap range separator inputBg.Fill = zone.IsBelowMouse ? new SolidColorBrush(UIHelper.BrightColorFromType(zone.Input.Type)) : new SolidColorBrush(UIHelper.ColorFromType(zone.Input.Type)); inputBg.Fill.Freeze(); XInputZoneIndicators.Children.Add(inputBg); } } }
private void CreateLineGeometry() { //GradientPath = new GradientPath(); //GradientStop s2= new GradientStop(Colors.BrightColorFromType(Source.Type), offset:0.95); //GradientStop s1= new GradientStop(Colors.ColorFromType(Source.Type), offset: 0.8); //GradientPath.GradientStops.Add(s1); //GradientPath.GradientStops.Add(s2); //GradientPath.GradientMode = GradientMode.Parallel; //GradientPath.StrokeThickness = 0.5; //GradientPath.Tolerance= 0.2; //GradientPath.IsHitTestVisible= false; ConnectionPath = new Path(); //ConnectionPath.IsHitTestVisible = false; ConnectionPath.Stroke = new SolidColorBrush(UIHelper.BrightColorFromType(Output.Type)); ConnectionPath.Stroke.Freeze(); ConnectionPath.StrokeThickness = 3; ConnectionPath.StrokeEndLineCap = PenLineCap.Triangle; this.Children.Add(ConnectionPath); ConnectionPath2 = new Path(); //ConnectionPath2.IsHitTestVisible = false; ConnectionPath2.Stroke = new SolidColorBrush(UIHelper.ColorFromType(Output.Type)); ConnectionPath2.Stroke.Freeze(); ConnectionPath2.StrokeThickness = 2.0; ConnectionPath2.StrokeEndLineCap = PenLineCap.Triangle; this.Children.Add(ConnectionPath2); //this.Children.Add(GradientPath); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.FillRule = FillRule.Nonzero; // Spline curve m_PathFigure = new PathFigure(); m_PathFigure.StartPoint = new Point(10, 10); pathGeometry.Figures.Add(m_PathFigure); m_CurveSegment = new BezierSegment(); m_CurveSegment.Point1 = new Point(10, 10); m_CurveSegment.Point2 = new Point(10, 10); m_CurveSegment.Point3 = new Point(10, 10); m_PathFigure.Segments.Add(m_CurveSegment); ConnectionPath.Data = pathGeometry; ConnectionPath2.Data = pathGeometry; //GradientPath.Data = pathGeometry; // ArrowHead m_ArrowHeadPath = new Path(); m_ArrowHeadPath.IsHitTestVisible = false; m_ArrowHeadPath.Stroke = new SolidColorBrush(UIHelper.BrightColorFromType(Output.Type)); m_ArrowHeadPath.Stroke.Freeze(); m_ArrowHeadPath.StrokeThickness = 14; m_ArrowHeadPath.StrokeEndLineCap = PenLineCap.Triangle; this.Children.Add(m_ArrowHeadPath); PathGeometry ArrowHeadPathGeometry = new PathGeometry(); ArrowHeadPathGeometry.FillRule = FillRule.Nonzero; m_ArrowHeadPathFigure = new PathFigure(); m_ArrowHeadPathFigure.StartPoint = new Point(10, 10); ArrowHeadPathGeometry.Figures.Add(m_ArrowHeadPathFigure); m_ArrowHeadLineSegment = new LineSegment(); m_ArrowHeadLineSegment.Point = new Point(10, -10); m_ArrowHeadPathFigure.Segments.Add(m_ArrowHeadLineSegment); m_ArrowHeadPath.Data = ArrowHeadPathGeometry; // Head thumb _thumb = new Thumb(); _thumb.Opacity = 0; this.Children.Add(_thumb); Canvas.SetTop(_thumb, -0.5 * CONNECTION_ARROW_THUMB_SIZE); _thumb.Width = CONNECTION_ARROW_THUMB_SIZE; Canvas.SetLeft(_thumb, -0.5 * CONNECTION_ARROW_THUMB_SIZE); _thumb.Height = CONNECTION_ARROW_THUMB_SIZE; _thumb.Loaded += Thumb_LoadedHandler; this.Unloaded += Thumb_UnloadEventHandler; }