public override void OnApplyTemplate() { base.OnApplyTemplate(); if (this.ScrollViewer == null) return; if(this.ScrollViewer.Content is Border) this.designerCanvas = (this.ScrollViewer.Content as Border).Child as DesignerCanvas; else this.designerCanvas = this.ScrollViewer.Content as DesignerCanvas; if (this.designerCanvas == null) throw new Exception("DesignerCanvas must not be null!"); this.zoomThumb = Template.FindName("PART_ZoomThumb", this) as Thumb; if (this.zoomThumb == null) throw new Exception("PART_ZoomThumb template is missing!"); this.zoomCanvas = Template.FindName("PART_ZoomCanvas", this) as Canvas; if (this.zoomCanvas == null) throw new Exception("PART_ZoomCanvas template is missing!"); this.zoomSlider = Template.FindName("PART_ZoomSlider", this) as Slider; if (this.zoomSlider == null) throw new Exception("PART_ZoomSlider template is missing!"); this.designerCanvas.LayoutUpdated += new EventHandler(this.DesignerCanvas_LayoutUpdated); this.zoomThumb.DragDelta += new DragDeltaEventHandler(this.Thumb_DragDelta); this.zoomSlider.ValueChanged += new RoutedPropertyChangedEventHandler<double>(this.ZoomSlider_ValueChanged); this.scaleTransform = new ScaleTransform(); this.designerCanvas.LayoutTransform = this.scaleTransform; }
private void MoveThumb_DragStarted(object sender, DragStartedEventArgs e) { this.designerItem = DataContext as DesignerItem; if (this.designerItem != null) { this.designerCanvas = VisualTreeHelper.GetParent(this.designerItem) as DesignerCanvas; } }
public RubberbandAdorner(DesignerCanvas designerCanvas, Point? dragStartPoint) : base(designerCanvas) { this.designerCanvas = designerCanvas; this.startPoint = dragStartPoint; this.adornerCanvas = new Canvas(); this.adornerCanvas.Background = Brushes.Transparent; this.visuals = new VisualCollection(this); this.visuals.Add(this.adornerCanvas); this.rubberband = new Rectangle(); this.rubberband.Stroke = Brushes.Navy; this.rubberband.StrokeThickness = 1; this.rubberband.StrokeDashArray = new DoubleCollection(new double[] { 2 }); this.adornerCanvas.Children.Add(this.rubberband); }
public EnemyPropertiesWindow(Enemy enemy, DesignerCanvas canvas, DesignerItem item, Level level) : base() { InitializeComponent(); item.PropertyWindow = this; Ellipse rangeFinder = new Ellipse(); Canvas.SetZIndex(rangeFinder, -10); var fadedRed = System.Windows.Media.Color.FromArgb(0, 255, 0, 50); rangeFinder.Fill = new RadialGradientBrush(System.Windows.Media.Colors.Red, fadedRed); rangeFinder.Stroke = Brushes.Green; rangeFinder.IsHitTestVisible = false; canvas.Children.Add(rangeFinder); DataContext = new EnemyModel(enemy, rangeFinder, item, level); }