/// <summary>${mapping_ShapeElement_Constructors_D}</summary> protected ShapeElement(Shape shape) { shape.Stretch = Stretch.None; shape.RenderTransform = new ScaleTransform(); base.Content = this.shape = shape; pathIsInvalid = true; this.ClipBox = Rectangle2D.Empty; }
public void Navigate(Shape From, Shape To) { Result = Relation.DFS(From.DataContext as Segment, To.DataContext as Segment); if(Result != null) foreach (Segment item in Result) { item.Color = new SolidColorBrush(Colors.CadetBlue); } }
public void Attach(DependencyObject associatedObject) { AssociatedObject = associatedObject; _shape = associatedObject as Shape; if (_shape != null) { _originalFillBrush = _shape.Fill; Messenger.Default.Register<DataReceivedMessage>(this, OnDateReceivedMessage); } }
public BubbleShape(Bubble parent) { this.parent = parent; double radius = parent.getRadius(); shape = new Ellipse() { Width = radius * 2, Height = radius * 2, Fill = new SolidColorBrush(ColorSettings.BubbleColor) }; BubbleContainer.canvas.Children.Add(shape); }
protected void AdjustLegendShape(Windows.UI.Xaml.Shapes.Shape shape) { if (shape != null) { if ((Size.Width <= 14.0) && (Size.Width > 0.0)) { shape.Width = Size.Width; } if ((Size.Height <= 14.0) && (Size.Height > 0.0)) { shape.Height = Size.Height; } } }
private void S_Tapped(object sender, TappedRoutedEventArgs e) { if (s == null) { s = sender as Shape; (s.DataContext as Segment).Color.Color = Colors.BlanchedAlmond; p.UndoNavigation(); } else { //Debug.WriteLine("p.AddRelation({0}, {1});",s.Name,(sender as Shape).Name); //(s.DataContext as Segment).Color.Color = Colors.DarkCyan; //s = sender as Shape; //(s.DataContext as Segment).Color.Color = Colors.BlanchedAlmond; p.Navigate(s, sender as Shape); s = null; } }
private void Replace(Shape s) { UIElement ui = null; foreach (UIElement uie in Children) { if ((uie is Shape) && (uie as Shape).Name == s.Name) { ui = uie; break; } } if (ui != null) { Children.Remove(ui); Children.Add(s); } else Children.Add(s); }
/// <summary> /// Sets the stroke of the specified shape. /// </summary> /// <param name="shape">The shape.</param> /// <param name="stroke">The stroke.</param> /// <param name="thickness">The thickness.</param> /// <param name="lineJoin">The line join.</param> /// <param name="dashArray">The dash array.</param> /// <param name="aliased">aliased if set to <c>true</c>.</param> private void SetStroke( Shape shape, OxyColor stroke, double thickness, OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter, IEnumerable<double> dashArray = null, bool aliased = false) { if (stroke.IsVisible() && thickness > 0) { shape.Stroke = this.GetCachedBrush(stroke); switch (lineJoin) { case OxyPenLineJoin.Round: shape.StrokeLineJoin = PenLineJoin.Round; break; case OxyPenLineJoin.Bevel: shape.StrokeLineJoin = PenLineJoin.Bevel; break; // The default StrokeLineJoin is Miter } shape.StrokeThickness = thickness; if (dashArray != null) { shape.StrokeDashArray = CreateDashArrayCollection(dashArray); } if (aliased) { // shape.UseLayoutRounding = aliased; } } }
int StrandOf(Shape l) { return (l.Tag as Tuple<int, int>).Item2; }
public void UpdateExtent(Shape s) { if (s is Polygon) { Polygon poly = s as Polygon; foreach (Point pt in poly.Points) PathExtent.Update(pt); } }
void DiagramCanvas_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { Point point = e.GetCurrentPoint(this).Position; if (_rubberBand != null) { this.Children.Remove(_rubberBand); _rubberBand = null; } e.Handled = true; this.ReleasePointerCaptures(); double left = Math.Min(point.X, _lastPoint.X); double top = Math.Min(point.Y, _lastPoint.Y); double width = Math.Abs(point.X - _lastPoint.X); double height = Math.Abs(point.Y - _lastPoint.Y); Document.Instance.SelectElementsInBound(left, top, width, height); }
void FormatShape(Shapes.Shape shape, Pen pen, Brush brush) { }
private void Replace(Shape s) { UIElement ui = null; foreach (UIElement uie in ProfileDisplayCanvas.Children) { if ((uie is Shape) && (uie as Shape).Name == s.Name) { ui = uie; break; } } if (ui != null) { ProfileDisplayCanvas.Children.Remove(ui); ProfileDisplayCanvas.Children.Add(s); } else ProfileDisplayCanvas.Children.Add(s); }
/// <summary> /// Initiates a spritesheet animation /// </summary> /// <param name="shape">Shape to animate on (will create an ImageBrush)</param> /// <param name="spriteSheetColumns">Spritesheet columns</param> /// <param name="spriteSheetRows">Spritesheet rows</param> /// <param name="image">The spritesheet image</param> /// <param name="width">Width of the sprite on the spritesheet</param> /// <param name="height">Height of the sprite on the spritesheet</param> /// <param name="keyframeTime">Time that each keyframe should have</param> /// <returns>Storyboard created</returns> public static Storyboard BeginSpriteSheetStoryboard(Shape shape, int spriteSheetColumns, int spriteSheetRows, BitmapImage image, double width, double height, int keyframeTime) { ImageBrush ib = new ImageBrush() { Stretch = Stretch.None, AlignmentX = AlignmentX.Left, AlignmentY = AlignmentY.Top }; ib.Transform = new CompositeTransform(); ib.ImageSource = image; shape.Fill = ib; Storyboard sb = new Storyboard(); sb.RepeatBehavior = RepeatBehavior.Forever; ObjectAnimationUsingKeyFrames frm = new ObjectAnimationUsingKeyFrames(); ObjectAnimationUsingKeyFrames frm2 = new ObjectAnimationUsingKeyFrames(); frm.BeginTime = new TimeSpan(0, 0, 0); frm2.BeginTime = new TimeSpan(0, 0, 0); int time = 0; for (int j = 0; j < spriteSheetRows; j++) { for (int i = 0; i < spriteSheetColumns; i++) { DiscreteObjectKeyFrame dokf = new DiscreteObjectKeyFrame(); dokf.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(time)); dokf.Value = -(i * width); frm.KeyFrames.Add(dokf); DiscreteObjectKeyFrame dokf2 = new DiscreteObjectKeyFrame(); dokf2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(time)); dokf2.Value = -(j * height); frm2.KeyFrames.Add(dokf2); time += keyframeTime; } } Storyboard.SetTarget(frm, shape.Fill); Storyboard.SetTarget(frm2, shape.Fill); Storyboard.SetTargetProperty(frm, "(ImageBrush.Transform).(CompositeTransform.TranslateX)"); Storyboard.SetTargetProperty(frm2, "(ImageBrush.Transform).(CompositeTransform.TranslateY)"); sb.Children.Add(frm); sb.Children.Add(frm2); sb.Begin(); return sb; }
protected override void OnApplyTemplate() { base.OnApplyTemplate(); _verticalThumb = GetTemplateChild(VerticalThumbName) as Thumb; _verticalDecreaseRect = GetTemplateChild(VerticalDecreaseRectName) as Shape; _horizontalThumb = GetTemplateChild(HorizontalThumbName) as Thumb; _horizontalDecreaseRect = GetTemplateChild(HorizontalDecreaseRectName) as Shape; }
private void S_Holding(object sender, HoldingRoutedEventArgs e) { if(s != null) (s.DataContext as Segment).Color.Color = Colors.DarkCyan; s = null; }
void DiagramCanvas_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { Document.Instance.UnSelectAllElements(); var point = e.GetCurrentPoint(this).Position; _lastPoint = point; if (_rubberBand == null) { _rubberBand = new Rectangle(); } _rubberBand.StrokeThickness = 2; _rubberBand.Stroke = new SolidColorBrush(Colors.DarkGray); var dc = new DoubleCollection(); dc.Add(4); dc.Add(1); _rubberBand.StrokeDashArray = dc; _rubberBand.Visibility = Visibility.Visible; _rubberBand.Width = 1; _rubberBand.Height = 1; Canvas.SetLeft(_rubberBand, point.X); Canvas.SetTop(_rubberBand, point.Y); this.Children.Add(_rubberBand); e.Handled = true; }
void UpdateFillColor(Shape shape) { if (this.FillColor == "fill1") { shape.Fill = new SolidColorBrush(Colors.Yellow); this.FillColor = "fill2"; } else { shape.Fill = new SolidColorBrush(Colors.Aqua); this.FillColor = "fill1"; } }
public int IndexOf(Shape p) { return Shapes.IndexOf(p); }
void UpdateStrokeColor(Shape shape) { if (StrokeColor == "stroke1") { shape.Stroke = new SolidColorBrush(Colors.Red); StrokeColor = "stroke2"; } else { shape.Stroke = new SolidColorBrush(Colors.Purple); StrokeColor = "stroke1"; } }
public void AddShape(Shape p) { if (p.Name == string.Empty) p.Name = nextPathName; Shapes.Add(p); p.Tag = IndexOf(p); // tag is position in collection UpdateExtent(p); }
//TODO add code for other shapes PointCollection GetPoints(Shape s) { if (s is Polygon) return (s as Polygon).Points; else return new PointCollection(); }
public void AddRelation(Shape From, Shape To) { Relation.AddEdge(From.DataContext as Segment, To.DataContext as Segment); }
public void AddSegment(Shape Segment) { Segment.DataContext = new Segment(Segment.Name); Relation.AddNode(Segment.DataContext as Segment); Segment.SetBinding(Shape.FillProperty, new Binding() { Path = new PropertyPath("Color") }); }
/// <summary> /// Sets the stroke properties of the specified shape. /// </summary> /// <param name="shape"> /// The shape. /// </param> /// <param name="stroke"> /// The stroke. /// </param> /// <param name="thickness"> /// The thickness. /// </param> /// <param name="lineJoin"> /// The line join. /// </param> /// <param name="dashArray"> /// The dash array. /// </param> /// <param name="aliased"> /// The aliased. /// </param> private void SetStroke( Shape shape, OxyColor stroke, double thickness, OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter, double[] dashArray = null, bool aliased = false) { if (stroke != null && thickness > 0) { shape.Stroke = this.GetCachedBrush(stroke); switch (lineJoin) { case OxyPenLineJoin.Round: shape.StrokeLineJoin = PenLineJoin.Round; break; case OxyPenLineJoin.Bevel: shape.StrokeLineJoin = PenLineJoin.Bevel; break; // The default StrokeLineJoin is Miter } if (!thickness.Equals(1.0)) { // default values is 1 shape.StrokeThickness = thickness; } if (dashArray != null) { shape.StrokeDashArray = CreateDashArrayCollection(dashArray); } } // shape.UseLayoutRounding = aliased; }
int PermOf(Shape l) { return (l.Tag as Tuple<int, int>).Item1; }