public MainWindow() { InitializeComponent(); drawingGroup = new DrawingGroup(); // Создаем объект для описания геометрической фигуры GeometryDrawing geometryDrawing = new GeometryDrawing(); // Описываем и сохраняем геометрию квадрата RectangleGeometry rectGeometry = new RectangleGeometry(); rectGeometry.Rect = new Rect(0, 0, 10, 10); geometryDrawing.Geometry = rectGeometry; // Настраиваем перо и кисть geometryDrawing.Pen = new Pen(Brushes.Red, 0.005);// Перо рамки geometryDrawing.Brush = Brushes.LightBlue;// Кисть закраски // Добавляем готовый слой в контейнер отображения drawingGroup.Children.Add(geometryDrawing); GeometryDrawing ellipsgeomy = new GeometryDrawing(); EllipseGeometry elgeometry = new EllipseGeometry(new Point(5, 5), 2, 2); ellipsgeomy.Geometry = elgeometry; ellipsgeomy.Brush = Brushes.White; drawingGroup.Children.Add(ellipsgeomy); }
/// <summary> /// This creates the circular clip around this control /// </summary> private void invalidate() { if (Radius >= 0 && Radius * 2 <= Width) { //decide the center of the circular region double centerX = this.Height / 2; double centerY = this.Width / 2; //create the clip geometry EllipseGeometry geom = new EllipseGeometry(); geom.RadiusY = Radius - thickness; geom.RadiusX = Radius - thickness; geom.Center = new Point(centerX, centerY); //apply the clip to this control image.Clip = geom; //now setup the shape outline outline.Width = Radius * 2; outline.Height = Radius * 2; //set the location of the notification double coord = (Width / 1.732) - Radius; notification.Margin = new Thickness(coord, coord, 0, 0); } }
static ResizeChrome() { TransparentBrush = Brushes.Transparent; TransparentBrush.Freeze(); var borderBrush = new LinearGradientBrush() { Opacity = 0.7, StartPoint = new Point(0, 0), EndPoint = new Point(1, 0.3), }; borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 0)); borderBrush.GradientStops.Add(new GradientStop(Colors.LightBlue, 0.5)); borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 1)); borderBrush.Freeze(); BorderBrush = borderBrush; var thumbBrush = new RadialGradientBrush() { Center = new Point(0.3, 0.3), GradientOrigin = new Point(0.3, 0.3), RadiusX = 0.7, RadiusY = 0.7, }; thumbBrush.GradientStops.Add(new GradientStop(Colors.White, 0)); thumbBrush.GradientStops.Add(new GradientStop(Colors.DarkSlateBlue, 0.9)); thumbBrush.Freeze(); ThumbBrush = thumbBrush; TransparentPen = new Pen(TransparentBrush, 3.5); BorderPen = new Pen(BorderBrush, 2); BorderPen.DashStyle = DashStyles.Dash; ThumbGeometry = new EllipseGeometry(); UpdateZoom(1); }
public Ellipse(Vector centerPt, int radius1, int radius2) { Geometry = new EllipseGeometry(centerPt.ToWindowsPt(), (double)radius1, (double)radius2); DrawMe = true; BoundingRectangle = Geometry.Bounds; CenterPoint = centerPt; }
public Ellipse(Vector centerPt, Tuple<int,int> radii) { Geometry = new EllipseGeometry(centerPt.ToWindowsPt(), (double)radii.Item1, (double)radii.Item2); DrawMe = true; BoundingRectangle = Geometry.Bounds; CenterPoint = centerPt; }
public Circle() { _Circle = new EllipseGeometry(); this.Height = 9; this.Width = 9; this.Fill = Brushes.Red; this.Stroke = Brushes.Black; }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); var ellipse = new EllipseGeometry(new Point(250, 50), 50, 50); var drawing = new GeometryDrawing(Brushes.BlueViolet, new Pen(Brushes.Bisque, 2), ellipse); drawingContext.DrawDrawing(drawing); }
public override Canvas DrawMenu() { Canvas canvas=new Canvas(); //draw inner circle EllipseGeometry center = new EllipseGeometry(new Point(0, 0), smlrad, smlrad); Path circle = new Path(); circle.Data = center; circle.Fill = children.Get(0).BackGroundBrush; circle.Stroke = Brushes.Black; canvas.Children.Add(circle); children.Get(0).Button.Content = circle; TextBlock MiddleText = children.Get(0).GetTextBlockNoTransform(); MiddleText.Width = smlrad * 2; MiddleText.RenderTransform = new TranslateTransform(-smlrad, 0); canvas.Children.Add(MiddleText); //draw outer ring for(int i=1;i<children.Count();i++) { Square block = children.Get(i); PathFigure figure = new PathFigure(); figure.StartPoint=new Point(smlrad*Math.Cos(baseAngle*i),smlrad*Math.Sin(baseAngle*i)); figure.Segments.Add(new LineSegment(new Point(lrgrad*Math.Cos(baseAngle*i),lrgrad*Math.Sin(baseAngle*i)),true)); figure.Segments.Add(new ArcSegment(new Point(lrgrad*Math.Cos(baseAngle*(i+1)),lrgrad*Math.Sin(baseAngle*(i+1))),new Size(lrgrad,lrgrad),0,false,SweepDirection.Clockwise,true)); figure.Segments.Add(new LineSegment(new Point(smlrad*Math.Cos(baseAngle*(i+1)),smlrad*Math.Sin(baseAngle*(1+i))),true)); figure.Segments.Add(new ArcSegment(new Point( smlrad * Math.Cos(baseAngle * i), smlrad * Math.Sin(baseAngle * i)), new Size(smlrad, smlrad), 0, false, SweepDirection.Counterclockwise, true)); PathGeometry geometry=new PathGeometry(); geometry.Figures.Add(figure); Path path = new Path(); path.Data = geometry; block.Button.Content = path; path.Fill = block.BackGroundBrush; path.Stroke = Brushes.Black; TextBlock text=block.GetTextBlockNoTransform(); TransformGroup transform = new TransformGroup(); //angle the text properly transform.Children.Add(new RotateTransform(- 0.5 * (baseAngle * 180 / Math.PI))); //move the text down into the right radious from center transform.Children.Add(new TranslateTransform(0,(lrgrad+smlrad)*0.5)); //rotate to the correct section - 0.5 * (baseAngle * 180 / Math.PI) transform.Children.Add(new RotateTransform((baseAngle *i* 180 / Math.PI) - 0.5 * (baseAngle * 180 / Math.PI))); text.RenderTransform = transform; text.Width = FindWidthOfTriangles(); // text.RenderTransform = new TranslateTransform(50, 200); canvas.Children.Add(path); canvas.Children.Add(text); } canvas.HorizontalAlignment = HorizontalAlignment.Center; canvas.VerticalAlignment = VerticalAlignment.Center; return canvas; }
public static void DrawCircle(this DrawingGroup drawingGroup, Point centerPoint, double radius, SolidColorBrush brush, Pen pen = null) { if (pen == null) pen = new Pen(brush, 1); var circle = new EllipseGeometry(centerPoint, radius, radius); var circleDrawing = new GeometryDrawing(brush, pen, circle); drawingGroup.Children.Add(circleDrawing); }
private void Hyperlink_Click(object sender, RoutedEventArgs e) { var hyperlink = (Hyperlink) sender; var vm = (TaskAreaItemsViewModel) hyperlink.DataContext; var contextMenu = new ContextMenu {PlacementTarget = (UIElement) hyperlink.Parent, Placement = PlacementMode.Right, HorizontalOffset = 14, DataContext = vm, Style = (Style) FindResource("TaskAreaContextMenuStyle")}; bool prevWasGroup = false; foreach (TaskAreaViewModelBase item in vm.Items) { var group = item as TaskAreaCommandGroupViewModel; if (group != null) { if (contextMenu.Items.Count > 0) contextMenu.Items.Add(new Separator {Style = (Style) FindResource("TaskAreaSeparatorStyle")}); foreach (TaskAreaCommandViewModel command in group.Commands) { var menuItem = new MenuItem {Header = command.DisplayName, Command = command.Command, DataContext = command, Tag = group, Style = (Style) FindResource("TaskAreaMenuItemStyle")}; menuItem.Click += menuItem_Click; if (command == group.SelectedCommand) { var geometry = new EllipseGeometry(new Point(0, 0), 3, 3); var drawingBrush = new DrawingBrush(new GeometryDrawing {Brush = Brushes.Black, Geometry = geometry}) {Stretch = Stretch.None}; menuItem.Icon = new Image {Source = new DrawingImage(drawingBrush.Drawing)}; } contextMenu.Items.Add(menuItem); } prevWasGroup = true; } else { if (prevWasGroup) contextMenu.Items.Add(new Separator {Style = (Style) FindResource("TaskAreaSeparatorStyle")}); prevWasGroup = false; var command = item as TaskAreaCommandViewModel; if (command != null) { var menuItem = new MenuItem {Header = command.DisplayName, Command = command.Command, DataContext = command, Style = (Style) FindResource("TaskAreaMenuItemStyle")}; contextMenu.Items.Add(menuItem); } else { var booleanItem = item as TaskAreaBooleanViewModel; if (booleanItem != null) { var menuItem = new MenuItem {Header = booleanItem.DisplayName, DataContext = booleanItem, Style = (Style) FindResource("TaskAreaMenuItemStyle"), IsCheckable = true}; menuItem.SetBinding(MenuItem.IsCheckedProperty, "Value"); contextMenu.Items.Add(menuItem); } } } } contextMenu.IsOpen = true; }
private void DoUpdateGeometry(Organism orgamism) { var radius = orgamism.Health / 4; this.geometry.RadiusX = radius; this.geometry.RadiusY = radius; this.frozenGeometry = this.geometry.Clone(); this.frozenGeometry.Freeze(); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); EllipseGeometry ellipse = new EllipseGeometry(new Point(150, 150), 50, 20); RectangleGeometry rect = new RectangleGeometry(new Rect(150, 150, 50, 20), 5, 5); //Geometry.Combin()静态方法与使用CombinedGeometry对象进行图形合并差不多 //其中Geometry.Combin()静态方法中有用于图形变换的参数(旋转,缩放等),如果不需要变换则填写null PathGeometry combin = Geometry.Combine(ellipse, rect, GeometryCombineMode.Xor, null); drawingContext.DrawGeometry(Brushes.LightBlue, new Pen(Brushes.Green, 2), combin); }
//Draws outline from inside line boundry to outside line boundry public void DrawCircleOutline(Color color) { using (DrawingContext dc = this.RenderOpen()) { EllipseGeometry bigEllips = new EllipseGeometry(centre, radius, radius); EllipseGeometry smallEllips = new EllipseGeometry(centre, radius - lineThickness, radius - lineThickness); CombinedGeometry ellipseOutline = new CombinedGeometry(GeometryCombineMode.Exclude, bigEllips, smallEllips); dc.DrawGeometry(new SolidColorBrush(color), new Pen(new SolidColorBrush(color), 1), ellipseOutline); } }
StackPanel BuildDrawing() { GeometryDrawing drawing = new GeometryDrawing(); // Use geometries to describe two overlapping ellipses. EllipseGeometry ellipse1 = new EllipseGeometry(); ellipse1.RadiusX = 20; ellipse1.RadiusY = 45; ellipse1.Center = new Point(50, 50); EllipseGeometry ellipse2 = new EllipseGeometry(); ellipse2.RadiusX = 45; ellipse2.RadiusY = 20; ellipse2.Center = new Point(50, 50); GeometryGroup ellipses = new GeometryGroup(); ellipses.Children.Add(ellipse1); ellipses.Children.Add(ellipse2); // Add the geometry to the drawing. drawing.Geometry = ellipses; // Specify the drawing's fill. drawing.Brush = Brushes.Blue; // Specify the drawing's stroke. Pen stroke = new Pen(); stroke.Thickness = 10.0; stroke.Brush = new LinearGradientBrush( Colors.Black, Colors.Gray, new Point(0, 0), new Point(1, 1)); drawing.Pen = stroke; // Create a DrawingBrush DrawingBrush myDrawingBrush = new DrawingBrush(); myDrawingBrush.Drawing = drawing; // Create a Rectangle element. Rectangle aRectangle = new Rectangle(); aRectangle.Width = 150; aRectangle.Height = 150; aRectangle.Stroke = Brushes.Black; aRectangle.StrokeThickness = 1.0; // Use the DrawingBrush to paint the rectangle's // background. aRectangle.Fill = myDrawingBrush; StackPanel mainPanel = new StackPanel(); mainPanel.Children.Add(aRectangle); mainPanel.Arrange(new Rect(100, 100, 500, 500)); //this.drawing2 = mainPanel; //this.Content = mainPanel; return mainPanel; }
public MainWindow() { InitializeComponent(); this.Loaded += (sender, e) =>{ EllipseGeometry elli = new EllipseGeometry(new Rect(new Size(100, 50))); //elli.Width = 50; //elli.Height = 100; recRed.Clip = elli; }; }
public void Wipe(TransitionerSlide fromSlide, TransitionerSlide toSlide, Point origin, IZIndexController zIndexController) { if (fromSlide == null) throw new ArgumentNullException(nameof(fromSlide)); if (toSlide == null) throw new ArgumentNullException(nameof(toSlide)); if (zIndexController == null) throw new ArgumentNullException(nameof(zIndexController)); var horizontalProportion = Math.Max(1.0 - origin.X, 1.0 * origin.X); var verticalProportion = Math.Max(1.0 - origin.Y, 1.0 * origin.Y); var radius = Math.Sqrt(Math.Pow(toSlide.ActualWidth * horizontalProportion, 2) + Math.Pow(toSlide.ActualHeight * verticalProportion, 2)); var scaleTransform = new ScaleTransform(0, 0); var translateTransform = new TranslateTransform(toSlide.ActualWidth * origin.X, toSlide.ActualHeight * origin.Y); var transformGroup = new TransformGroup(); transformGroup.Children.Add(scaleTransform); transformGroup.Children.Add(translateTransform); var ellipseGeomotry = new EllipseGeometry() { RadiusX = radius, RadiusY = radius, Transform = transformGroup }; toSlide.SetCurrentValue(UIElement.ClipProperty, ellipseGeomotry); zIndexController.Stack(toSlide, fromSlide); var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero); var midKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)); var endKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400)); var opacityAnimation = new DoubleAnimationUsingKeyFrames(); opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime)); opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, midKeyTime)); opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime)); opacityAnimation.Completed += (sender, args) => { fromSlide.BeginAnimation(UIElement.OpacityProperty, null); fromSlide.Opacity = 0; }; fromSlide.BeginAnimation(UIElement.OpacityProperty, opacityAnimation); var scaleAnimation = new DoubleAnimationUsingKeyFrames(); scaleAnimation.Completed += (sender, args) => { toSlide.SetCurrentValue(UIElement.ClipProperty, null); fromSlide.BeginAnimation(UIElement.OpacityProperty, null); fromSlide.Opacity = 0; }; scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, zeroKeyTime)); scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, endKeyTime)); scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation); scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation); }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); EllipseGeometry ellipse = new EllipseGeometry(new Point(350, 50), 50, 20); RectangleGeometry rect = new RectangleGeometry(new Rect(350, 50, 50, 20), 5, 5); GeometryGroup group = new GeometryGroup(); group.Children.Add(ellipse); group.Children.Add(rect); group.FillRule = FillRule.EvenOdd; drawingContext.DrawGeometry(Brushes.Black, new Pen(Brushes.Aqua, 3), group); }
/// <summary> /// Test whether object contains point /// </summary> public override bool Contains(Point point) { if ( IsSelected ) { return this.Rectangle.Contains(point); } else { EllipseGeometry g = new EllipseGeometry(Rectangle); return g.FillContains(point) || g.StrokeContains(new Pen(Brushes.Black, ActualLineWidth), point); } }
//添加单个检查井 /// <summary> /// 增加井盖 /// </summary> /// <param name="cover"></param> /// <param name="cp"></param> public void AddJunc(Cover cover, Point cp) { Path path = new Path(); path.Fill = cover.GetColorBrush(); path.Stroke = colorCenter.UnSelected_Border_Color; EllipseGeometry eg = new EllipseGeometry(); eg.Center = cp; eg.RadiusX = App.StrokeThinkness; eg.RadiusY = App.StrokeThinkness; path.Data = eg; path.ToolTip = cover; context.Children.Add(path); listpath.Add(path); }
public Path AddJunc(Cover cover) { Path path = new Path(); path.Fill = cover.GetColorBrush(); path.Stroke = colorCenter.UnSelected_Border_Color; EllipseGeometry eg = new EllipseGeometry(); eg.Center = Mercator2Screen(cover.Location); eg.RadiusX = App.StrokeThinkness; eg.RadiusY = App.StrokeThinkness; path.Data = eg; path.ToolTip = cover; context.Children.Add(path); listpath.Add(path); return path; }
protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); EllipseGeometry ellipse = new EllipseGeometry(new Point(50, 150), 50, 20); RectangleGeometry rect = new RectangleGeometry(new Rect(50, 150, 50, 20), 5, 5); //注意到GeometryCombineMode枚举,它有四个枚举值,如果我们有A,B分别表示两个图形的话 //GeometryCombineMode.Exclude: 合并结果为A-B //GeometryCombineMode.Intersect: 合并结果为A与B的相交部分 //GeometryCombineMode.Union: 合并结果为A+B //GeometryCombineMode.Xor: 合并结果为(A-B)+(B-A) CombinedGeometry combined = new CombinedGeometry(GeometryCombineMode.Xor, ellipse, rect); drawingContext.DrawGeometry(Brushes.Black, new Pen(Brushes.BlanchedAlmond, 2),combined); }
internal static Rect GetBoundsHelper(Pen pen, Matrix worldMatrix, Point center, double radiusX, double radiusY, Matrix geometryMatrix, double tolerance, ToleranceType type) { Rect rect; if ((pen == null || pen.DoesNotContainGaps) && worldMatrix.IsIdentity && geometryMatrix.IsIdentity) { double strokeThickness = 0.0; if (Pen.ContributesToBounds(pen)) { strokeThickness = Math.Abs(pen.Thickness); } rect = new Rect( center.X - Math.Abs(radiusX) - 0.5 * strokeThickness, center.Y - Math.Abs(radiusY) - 0.5 * strokeThickness, 2.0 * Math.Abs(radiusX) + strokeThickness, 2.0 * Math.Abs(radiusY) + strokeThickness); } else { unsafe { Point *pPoints = stackalloc Point[(int)c_pointCount]; EllipseGeometry.GetPointList(pPoints, c_pointCount, center, radiusX, radiusY); fixed(byte *pTypes = EllipseGeometry.s_roundedPathTypes) { rect = Geometry.GetBoundsHelper( pen, &worldMatrix, pPoints, pTypes, c_pointCount, c_segmentCount, &geometryMatrix, tolerance, type, false); // skip hollows - meaningless here, this is never a hollow } } } return(rect); }
/// <summary> /// 以指定的点为原点生成水波纹动画(调用前应先设置背景) /// </summary> public void ShowRipple(Point center) { GeometryGroup ripple = new GeometryGroup(); EllipseGeometry rippleOutside = new EllipseGeometry(); rippleOutside.RadiusX = rippleOutside.RadiusY = _maxSpacing; rippleOutside.Center = center; EllipseGeometry rippleInside = new EllipseGeometry(); rippleInside.RadiusX = rippleInside.RadiusY = 0; rippleInside.Center = center; ripple.Children.Add(rippleOutside); ripple.Children.Add(rippleInside); _rippleGroup.Children.Add(ripple); }
internal Particle(Point point, Random random) { size = 2.0 + random.NextDouble() * 2.0; alpha = 0.2 + random.NextDouble() * 0.8; xVelocity = (random.NextDouble() * 1.6) - 0.8; yVelocity = -(0.7 + random.NextDouble() * 2.0); yAcceleration = 0.02 + random.NextDouble() * 0.08; sizeVelocity = (random.NextDouble() * 1.2) - 0.6; alphaVelocity = -(random.NextDouble() * 0.05); geometry = new EllipseGeometry(point, size, size); brush = new SolidColorBrush(Color.FromArgb(PercentageToByte(alpha), 255, 200, 200)); Drawing = new GeometryDrawing(); Drawing.Brush = brush; Drawing.Geometry = geometry; }
private void CreateDeloneCirclesGeometric() { (gDeloneCircles as GeometryGroup).Children.Clear(); Triple<Circle, DeloneCircle> triple = vd.NextTriple(vd.NullTriple); while (triple != vd.NullTriple) { if (!double.IsInfinity(triple.Delone_Circle.R)) { EllipseGeometry ellipse = new EllipseGeometry(new System.Windows.Point(triple.Delone_Circle.X, triple.Delone_Circle.Y), triple.Delone_Circle.R, triple.Delone_Circle.R); (gDeloneCircles as GeometryGroup).Children.Add(ellipse); } else { LineGeometry line = new LineGeometry(new System.Windows.Point(triple.Delone_Circle.X - 1000 * triple.Delone_Circle.VX, triple.Delone_Circle.Y - 1000 * triple.Delone_Circle.VY), new System.Windows.Point(triple.Delone_Circle.X + 1000 * triple.Delone_Circle.VX, triple.Delone_Circle.Y + 1000 * triple.Delone_Circle.VY)); (gDeloneCircles as GeometryGroup).Children.Add(line); } triple = vd.NextTriple(triple); } }
public void MakeCircleAnimation(FrameworkElement animatedElement, double width, double height, TimeSpan timeSpan) { EllipseGeometry ellipseGeometry = new EllipseGeometry(); ellipseGeometry.RadiusX = 0; ellipseGeometry.RadiusY = 0; double centrex = width / 2; double centrey = height / 2; ellipseGeometry.Center = new Point(centrex, centrey); animatedElement.Clip = ellipseGeometry; //The most important line double halfWidth = width / 2; double halfheight = height / 2; DoubleAnimation a = new DoubleAnimation(); a.Completed += new EventHandler(a_Completed); a.From = 0; a.To = Math.Sqrt(halfWidth * halfWidth + halfheight * halfheight); a.Duration = new Duration(timeSpan); ellipseGeometry.BeginAnimation(EllipseGeometry.RadiusXProperty, a); ellipseGeometry.BeginAnimation(EllipseGeometry.RadiusYProperty, a); }
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value.GetType() == typeof(System.Collections.ObjectModel.ObservableCollection<ColoredPoint>)) { GeometryGroup myGeometryGroup = new GeometryGroup(); foreach (var coloredPoint in value as System.Collections.ObjectModel.ObservableCollection<ColoredPoint>) { if (coloredPoint.IsGuard == true) { EllipseGeometry myEllipseGeometry = new EllipseGeometry(); myEllipseGeometry.Center = new Point(coloredPoint.point.X, coloredPoint.point.Y); myEllipseGeometry.RadiusX = 4; myEllipseGeometry.RadiusY = 4; myGeometryGroup.Children.Add(myEllipseGeometry); } } return myGeometryGroup; } return null; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (Control != null && Control.Clip == null) { var min = Math.Min(Element.Width, Element.Height) / 2.0f; if (min <= 0) return; var clip = new EllipseGeometry { Center = new System.Windows.Point(min, min), RadiusX = min, RadiusY = min, }; Control.Clip = clip; } }
public Blotches(Canvas canvas, Window1 window, string key, float pressure, double x, double y, Color color) { this.canvas = canvas; geometry = new EllipseGeometry(); ellipse = new Path(); SolidColorBrush brush = new SolidColorBrush(); BlurEffect blurEffect = new BlurEffect(); blurEffect.Radius = 0; geometry.Center = new Point(x, y); geometry.RadiusX = (SIZE * pressure) / 50; geometry.RadiusY = (SIZE * pressure) / 50; brush.Color = color; ellipse.Fill = brush; ellipse.HorizontalAlignment = HorizontalAlignment.Center; ellipse.VerticalAlignment = VerticalAlignment.Center; ellipse.Effect = blurEffect; ellipse.Data = geometry; canvas.Children.Add(this.ellipse); this.ellipse.Loaded += new RoutedEventHandler(ellipse_Loaded); // init animation this.hoverAnimation = new PennerDoubleAnimation( Equations.ExpoEaseIn, 0, 0, new Duration(new TimeSpan(0, 0, 3))); NameScope.SetNameScope(ellipse, new NameScope()); ellipse.RegisterName("ellipse", blurEffect); // init storyboard Storyboard.SetTargetProperty(hoverAnimation, new PropertyPath(Canvas.TopProperty)); hoverObj.Children.Add(hoverAnimation); this.hoverAnimation.Completed += new EventHandler(hoverAnimation_Completed); }
public static void HitTesting(Visual hitObject, Point hitPoint) { // Expand the hit test area by creating a geometry centered on the hit test point. EllipseGeometry expandedHitTestArea = new EllipseGeometry(hitPoint, 10.0, 10.0); // Clear the contents of the list used for hit test results. hitResultsList.Clear(); // Set up a callback to receive the hit test result enumeration. VisualTreeHelper.HitTest(hitObject, null, new HitTestResultCallback(hitTestResultCallback), new GeometryHitTestParameters(expandedHitTestArea)); // Perform actions on the hit test results list. if (hitResultsList.Count > 0) { Path path = hitResultsList[0] as System.Windows.Shapes.Path; if (path != null) { selectedPath = path; UpdatePath(true); } } }
protected override Geometry GetOrCreateBoxGeometry(Size renderSize) { var ellipse = Ellipse.CreateFromSize(renderSize); this.SetCurrentValue(EllipseProperty, ellipse); if (ellipse.RadiusX <= 0 || ellipse.RadiusY <= 0) { return Geometry.Empty; } if (this.BoxGeometry is EllipseGeometry) { return this.BoxGeometry; } var geometry = new EllipseGeometry(); geometry.Bind(EllipseGeometry.CenterProperty) .OneWayTo(this, EllipseProperty, EllipseCenterConverter.Default); geometry.Bind(EllipseGeometry.RadiusXProperty) .OneWayTo(this, EllipseProperty, EllipseRadiusXConverter.Default); geometry.Bind(EllipseGeometry.RadiusYProperty) .OneWayTo(this, EllipseProperty, EllipseRadiusYConverter.Default); return geometry; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Window = ((Swing.Pendulum)(target)); return; case 2: this.tbMass = ((System.Windows.Controls.TextBox)(target)); return; case 3: this.tbLength = ((System.Windows.Controls.TextBox)(target)); return; case 4: this.tbDamping = ((System.Windows.Controls.TextBox)(target)); return; case 5: this.tbTheta0 = ((System.Windows.Controls.TextBox)(target)); return; case 6: this.tbAlpha0 = ((System.Windows.Controls.TextBox)(target)); return; case 7: #line 62 "..\..\Pendulum.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnStart_Click); #line default #line hidden return; case 8: #line 64 "..\..\Pendulum.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnStop_Click); #line default #line hidden return; case 9: #line 65 "..\..\Pendulum.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btnReset_Click); #line default #line hidden return; case 10: this.tbDisplay = ((System.Windows.Controls.TextBlock)(target)); return; case 11: this.canvasLeft = ((System.Windows.Controls.Canvas)(target)); return; case 12: this.line1 = ((System.Windows.Shapes.Line)(target)); return; case 13: this.ball = ((System.Windows.Media.EllipseGeometry)(target)); return; case 14: this.canvasRight = ((System.Windows.Controls.Canvas)(target)); return; } this._contentLoaded = true; }