本文整理汇总了C#中System.Windows.Media.EllipseGeometry类的典型用法代码示例。如果您正苦于以下问题:C# EllipseGeometry类的具体用法?C# EllipseGeometry怎么用?C# EllipseGeometry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EllipseGeometry类属于System.Windows.Media命名空间,在下文中一共展示了EllipseGeometry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ellipse
public Ellipse(Vector centerPt, int radius1, int radius2)
{
Geometry = new EllipseGeometry(centerPt.ToWindowsPt(), (double)radius1, (double)radius2);
DrawMe = true;
BoundingRectangle = Geometry.Bounds;
CenterPoint = centerPt;
}
示例2: MainWindow
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);
}
示例3: ResizeChrome
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);
}
示例4: invalidate
/// <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);
}
}
示例5: Circle
public Circle()
{
_Circle = new EllipseGeometry();
this.Height = 9;
this.Width = 9;
this.Fill = Brushes.Red;
this.Stroke = Brushes.Black;
}
示例6: OnRender
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);
}
示例7: DrawMenu
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;
}
示例8: Hyperlink_Click
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;
}
示例9: DrawCircle
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);
}
示例10: OnRender
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);
}
示例11: MainWindow
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;
};
}
示例12: DrawCircleOutline
//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);
}
}
示例13: BuildDrawing
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;
}
示例14: Wipe
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);
}
示例15: OnRender
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);
}