Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override void Configure(
            StreamVisualizationObjectCanvasView <LabeledRectangleListVisualizationObject, List <Tuple <System.Drawing.Rectangle, string, string> > > canvasView,
            LabeledRectangleListVisualizationObject visualizationObject)
        {
            this.Rectangle.Data.Transform = canvasView.TransformGroup;

            // Create bindings for lines
            var binding = new Binding(nameof(LabeledRectangleListVisualizationObject.Color))
            {
                Source    = visualizationObject,
                Converter = new Converters.ColorConverter(),
            };

            BindingOperations.SetBinding(this.Label, Grid.BackgroundProperty, binding);

            binding = new Binding(nameof(LabeledRectangleListVisualizationObject.Color))
            {
                Source    = visualizationObject,
                Converter = new Converters.ColorConverter(),
            };
            BindingOperations.SetBinding(this.Rectangle, Shape.StrokeProperty, binding);

            binding = new Binding(nameof(LabeledRectangleListVisualizationObject.LineWidth))
            {
                Source = visualizationObject,
            };
            BindingOperations.SetBinding(this.Rectangle, Shape.StrokeThicknessProperty, binding);
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public override void UpdateView(
            Tuple <System.Drawing.Rectangle, string, string> item,
            StreamVisualizationObjectCanvasView <LabeledRectangleListVisualizationObject, List <Tuple <System.Drawing.Rectangle, string, string> > > canvasView,
            LabeledRectangleListVisualizationObject visualizationObject)
        {
            var rectangle = item.Item1;
            var label     = item.Item2;
            var tooltip   = item.Item3;

            this.RectangleFigure.StartPoint = new System.Windows.Point(rectangle.Left, rectangle.Top);
            (this.RectangleFigure.Segments[0] as LineSegment).Point = new System.Windows.Point(rectangle.Left + rectangle.Width, rectangle.Top);
            (this.RectangleFigure.Segments[1] as LineSegment).Point = new System.Windows.Point(rectangle.Left + rectangle.Width, rectangle.Top + rectangle.Height);
            (this.RectangleFigure.Segments[2] as LineSegment).Point = new System.Windows.Point(rectangle.Left, rectangle.Top + rectangle.Height);
            (this.RectangleFigure.Segments[3] as LineSegment).Point = new System.Windows.Point(rectangle.Left, rectangle.Top);

            // update the label
            (this.Label.Children[0] as TextBlock).Text = label;
            this.Label.Width      = rectangle.Width * canvasView.ScaleTransform.ScaleX;
            this.Label.Height     = 30;
            this.Label.ToolTip    = tooltip;
            this.Label.Visibility = (label == default) ? Visibility.Collapsed : Visibility.Visible;

            // update the render transform for the label
            (this.Label.RenderTransform as TranslateTransform).X = (rectangle.Left + canvasView.TranslateTransform.X) * canvasView.ScaleTransform.ScaleX;
            (this.Label.RenderTransform as TranslateTransform).Y = (rectangle.Bottom + canvasView.TranslateTransform.Y) * canvasView.ScaleTransform.ScaleY;
        }