• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Shapes.Polygon类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Shapes.Polygon的典型用法代码示例。如果您正苦于以下问题:C# Polygon类的具体用法?C# Polygon怎么用?C# Polygon使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Polygon类属于System.Windows.Shapes命名空间,在下文中一共展示了Polygon类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        public override void Draw(Canvas c)
        {
            base.Draw(c);

            Polygon polygon = new Polygon();
            polygon.Fill = Brushes.Red;
            polygon.Stroke = Brushes.Black;
            polygon.StrokeThickness = 1;

            PointCollection pointCollection = new PointCollection();
            pointCollection.Add(new Point(130, 162));

            pointCollection.Add(new Point(145, 158));
            pointCollection.Add(new Point(155, 155));
            pointCollection.Add(new Point(160, 160));
            pointCollection.Add(new Point(160, 165));
            pointCollection.Add(new Point(155, 170));
            pointCollection.Add(new Point(140, 177));

            pointCollection.Add(new Point(120, 177));
            pointCollection.Add(new Point(105, 170));
            pointCollection.Add(new Point(100, 165));
            pointCollection.Add(new Point(100, 160));
            pointCollection.Add(new Point(105, 155));
            pointCollection.Add(new Point(115, 158));

            polygon.Points = pointCollection;

            c.Children.Add(polygon);
        }
开发者ID:Chirimorin,项目名称:SWA_blok8,代码行数:30,代码来源:RoodOmMondDecorator.cs


示例2: AreaGraph

        /// <summary>
        /// Instantiates AreaGraph.
        /// </summary>
        public AreaGraph()
        {
            this.DefaultStyleKey = typeof(AreaGraph);
            _areaGraph = new Polygon();

            BindBrush();
        }
开发者ID:robinsedlaczek,项目名称:amCharts-Quick-Charts,代码行数:10,代码来源:AreaGraph.cs


示例3: MainWindow

        public MainWindow()
        {
            this.InitializeComponent();

            Func<int, int, int, double, Polygon> shape = (ox, oy, sides, angle) =>
            {
                Polygon polygon = new Polygon
                {
                    Fill = new SolidColorBrush(new Color { R = 64, G = 128, B = 0, A = 255 }),
                    Stroke = new SolidColorBrush(Colors.Black),
                    StrokeThickness = 1
                };
                angle *= Math.PI / 180.0;
                for (int i = 0; i < sides; i++)
                {
                    double theta = angle + Math.PI * 2 * i / sides;
                    polygon.Points.Add(new Point(ox + Math.Sin(theta) * 25, oy + Math.Cos(theta) * 25));
                }
                return polygon;
            };

            Func<IReadOnlyList<Element>> createElements = () => new[]
            {
                new Element("triangle",shape(50,50,3,180.0)),
                new Element("square",shape(125,50,4,225.0)),
                new Element("pentagon",shape(200,50,5,180.0)),
                new Element("hexagon",shape(50,125,6,210.0)),
                new Element("heptagon",shape(125,125,7,180.0)),
                new Element("octagon",shape(200,125,8,202.5))
            };

            this.ClassicPlaceholder.Child = new DocumentUserControl(this, this.ClassicPlaceholder, createElements(), new Classic(this.AddMessage));
            this.FrpPlaceholder.Child = new DocumentUserControl(this, this.FrpPlaceholder, createElements(), new Frp(this.AddMessage));
            this.ActorPlaceholder.Child = new DocumentUserControl(this, this.ActorPlaceholder, createElements(), new Actor(this.AddMessage, this.Dispatcher));
        }
开发者ID:Angeldude,项目名称:sodium,代码行数:35,代码来源:MainWindow.xaml.cs


示例4: OrganismVisual

        public OrganismVisual(Organism source, Ellipse organism, Polygon sight, PointCollection boundaries, TextBlock energy)
        {
            this.source = source;

            source.OnDeath += source_OnDeath;

            this.organism = organism;

            this.boundaries = boundaries;

            this.energy = energy;

            organism.Dispatcher.Invoke(new Action(() => organism.Fill = new SolidColorBrush(Colors.Red)));
            organism.Dispatcher.Invoke(new Action(() => organism.Height = source.getSize()));
            organism.Dispatcher.Invoke(new Action(() => organism.Width = source.getSize()));

            this.sight = sight;
            sight.Dispatcher.Invoke(new Action(() => sight.Fill = new SolidColorBrush(Color.FromArgb(50, 200, 200, 200))));
            sight.Dispatcher.Invoke(new Action(() => sight.Points = boundaries));

            energy.Dispatcher.Invoke(new Action(() => energy.Foreground = new SolidColorBrush(Colors.White)));
            energy.Dispatcher.Invoke(new Action(() => energy.HorizontalAlignment = HorizontalAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.VerticalAlignment = VerticalAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.TextAlignment = TextAlignment.Center));
            energy.Dispatcher.Invoke(new Action(() => energy.Height = 15));
            energy.Dispatcher.Invoke(new Action(() => energy.Width = 40));

            constructPointCollection();
        }
开发者ID:Spadar,项目名称:MachineLearning,代码行数:29,代码来源:OrganismVisual.cs


示例5: CreateNewPolygon

        private void CreateNewPolygon(Polygon oldPolygon)
        {
            i++;

            string nazwa = oldPolygon.Name;
            var newPolygon = new Polygon
            {

                Name = nazwa + i,
                Stroke = oldPolygon.Stroke,
                StrokeThickness = oldPolygon.StrokeThickness,
                Fill = oldPolygon.Fill,
                Points = oldPolygon.Points

            };
            newPolygon.MouseLeftButtonDown += new MouseButtonEventHandler(p_MouseLeftButtonDown);
            //utworzenie 'faktycznych' wymiarów, inaczej 0
            newPolygon.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            var polyWidth = newPolygon.DesiredSize.Width;

            _dropPoint.X = _dropPoint.X - (polyWidth) / 2;
            _dropPoint.Y = _dropArrow.Y2;

            //MessageBox.Show(newPolygon.Name);
            Console.Text += oldPolygon.Name + "\n";
            Console.ScrollToEnd();
            Canvas.SetLeft(newPolygon, _dropPoint.X);
            Canvas.SetTop(newPolygon, _dropPoint.Y);
            DropCanvas.Children.Add(newPolygon);
        }
开发者ID:211092,项目名称:FlowEdit,代码行数:30,代码来源:MainWindow.xaml.cs


示例6: SetUpMouseInteractions

        private void SetUpMouseInteractions()
        {
            var mouseClicks = Observable.FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>(
                h => canvas.MouseLeftButtonUp += h,
                h => canvas.MouseLeftButtonUp -= h)
                .Select(click => new { Position = click.EventArgs.GetPosition(canvas), TimeStamp = click.EventArgs.Timestamp })
                .Distinct(clickInfo => clickInfo.Position)
                .Buffer(3);

            mouseClicks.Subscribe(args =>
            {
                var first = args.First();
                var second = args.Skip(1).First();
                var third = args.Last();

                var p = new Polygon();
                p.Points.Add(first.Position);
                p.Points.Add(second.Position);
                p.Points.Add(third.Position);

                p.Stroke = Brushes.Red;
                p.StrokeThickness = 1;

                canvas.Children.Add(p);
                this.VM.AddGeometry(p.ToTriangle());

                if (this.LineDrawn != null)
                    LineDrawn(this, new LineDrawnEventArgs(first.Position, second.Position, DateTime.Now));
            });
        }
开发者ID:ZombineDev,项目名称:KDTreesWPF,代码行数:30,代码来源:DrawingCanvas.xaml.cs


示例7: AddArc

        public PathFigure AddArc(int start, int end)
        {
            int horizontalPostion = 100;

            var startPoint = new Point(horizontalPostion, start);
            var endPoint = new Point(horizontalPostion, end);

            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = startPoint;

            ArcSegment arcSeg = new ArcSegment();
            arcSeg.Point = endPoint;
            arcSeg.Size = new Size(25, 25);
            arcSeg.IsLargeArc = true;
            arcSeg.SweepDirection = SweepDirection.Clockwise;
            arcSeg.RotationAngle = 90;

            var arrowhead = new Polygon();
            arrowhead.Stroke = Brushes.Black;
            arrowhead.StrokeThickness = 2;
            arrowhead.Points.Add(new Point(endPoint.X - 4, endPoint.Y));
            arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y + 3));
            arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y - 3));
            arrowhead.Fill = Brushes.Black;

            PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
            myPathSegmentCollection.Add(arcSeg);
            pathFigure.Segments = myPathSegmentCollection;

            _pathFigureCollection.Add(pathFigure);

            _root.Children.Add(arrowhead);

            return pathFigure;
        }
开发者ID:pottereric,项目名称:Synopsis,代码行数:35,代码来源:ArcAdder.cs


示例8: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ExecutionState  tp = (ExecutionState) value;

            StackPanel pausePanel = new StackPanel();

            if (tp == ExecutionState.Running)
            {
                pausePanel.Orientation = Orientation.Horizontal;
                Polygon pause1 = new Polygon();
                pause1.Points = new PointCollection(new List<Point>() { new Point(0, 0), new Point(3, 0), new Point(3, 14), new Point(0, 14) });
                pause1.Fill = Brushes.Black;
                pause1.Stroke = Brushes.Black;
                Polygon pause2 = new Polygon();
                pause2.Points = new PointCollection(new List<Point>() { new Point(5, 0), new Point(8, 0), new Point(8, 14), new Point(5, 14) });
                pause2.Fill = Brushes.Black;
                pause2.Stroke = Brushes.Black;

                pausePanel.Children.Add(pause1);
                pausePanel.Children.Add(pause2);
            }

            else if (tp == ExecutionState.Paused || tp == ExecutionState.Void)
            {
                Polygon runIcon = new Polygon();
                runIcon.Points = new PointCollection(new List<Point>() { new Point(0, 0), new Point(11, 7), new Point(0, 14) });
                runIcon.Fill = Brushes.Black;
                runIcon.Stroke = Brushes.Black;
                pausePanel.Children.Add(runIcon);
            }
            return pausePanel;

        }
开发者ID:Lynxa,项目名称:Lambent,代码行数:33,代码来源:BooleanToStackPanel.cs


示例9: addLake

 private void addLake(object sender, RoutedEventArgs e)
 {
     try
     {
         Polygon lake = new Polygon();
         string[] points = lakeTextBox.Text.Split('\n');
         string[] xAndY = new string[2];
         List<Double> xOfPoint = new List<Double>();
         List<Double> yOfPoint = new List<Double>();
         for (int i = 0; i < points.Length; i++)
         {
             xAndY = points[i].Split(',');
             xOfPoint.Add(Convert.ToDouble(xAndY[0]));
             yOfPoint.Add(Convert.ToDouble(xAndY[1]));
             lake.Points.Add(new Point(xOfPoint[i], yOfPoint[i]));
         }
         lake.Fill = new SolidColorBrush(Color.FromRgb(100, 100, 255));
         lake.Name = "lake";
         var mainWindowInstant = (MainWindow)App.Current.MainWindow;
         MainWindow.polygonList.Add(lake);
         mainWindowInstant.mapCanvas.Children.Add(lake);
         mainWindowInstant.reprintItemList();
         landTextBox.Clear();
     }
     catch { }
 }
开发者ID:IAmTheBritton,项目名称:Project5-2,代码行数:26,代码来源:addWindow.xaml.cs


示例10: TriangleArrow

        public TriangleArrow()
        {
            polygonArrow = new Polygon();
            this.Children.Add(polygonArrow);

            SetAngleByPoint(new Point(0, 0), new Point(15, 0));
        }
开发者ID:SaintLoong,项目名称:TMFlow,代码行数:7,代码来源:TriangleArrow.cs


示例11: LTakt

        public LTakt(MainWindow wnd, Canvas Can, int Num, double LTaktWidth, double CanWidth)
        {
            TaktHeight = 0;
            if ((wnd!=null)&&(Can == wnd.CanTop))
                TaktHeight = 80;
            N = Num;
            //this.wnd = wnd;
            this.Can = Can;
            int TTakt = Project.TTakt;
            //double CanWidth = (Can.Parent as Grid).ColumnDefinitions[1].ActualWidth - 5;

            TaktText.Background = Brushes.Black;
            TaktText.Foreground = Brushes.LightGray;
            TaktText.Text = Num.ToString();
            TaktText.FontSize = 10;
            PGTakt = new Polygon();
            PGTakt.Stroke = StandartBrushes.TaktLine;
            double LeftX = N * LTaktWidth;
            double RightX = LeftX + LTaktWidth;
            if (RightX > CanWidth)
                RightX = CanWidth;
            PGTakt.Points.Add(new Point(LeftX, TaktHeight + 10));
            PGTakt.Points.Add(new Point(LeftX + 2, TaktHeight + 2));
            PGTakt.Points.Add(new Point(RightX - 2, TaktHeight + 2));
            PGTakt.Points.Add(new Point(RightX, TaktHeight + 10));
            PGTakt.Points.Add(new Point(RightX - 2, TaktHeight + 20 - 2));
            PGTakt.Points.Add(new Point(LeftX + 2, TaktHeight + 20 - 2));
            Can.Children.Add(PGTakt);
            Canvas.SetZIndex(PGTakt, -2);
        }
开发者ID:okunokao,项目名称:GEoS,代码行数:30,代码来源:TaktLine.cs


示例12: Rasterize

        public static bool[,] Rasterize(Point[] points, int width, int height)
        {
            Contract.Requires(points != null);
            Contract.Requires(width > 0);
            Contract.Requires(height > 0);
            Contract.Requires(width % 8 == 0);
            Contract.Ensures(Contract.Result<bool[,]>() != null);
            Contract.Ensures(Contract.Result<bool[,]>().GetLength(0) == width);
            Contract.Ensures(Contract.Result<bool[,]>().GetLength(1) == height);

            var canvas = new Canvas { Background = Brushes.White, Width = width, Height = height };
            var polygon = new Polygon { Stroke = Brushes.Black, Fill = Brushes.Black, StrokeThickness = 1, Points = new PointCollection(points) };
            canvas.Children.Add(polygon);
            RenderOptions.SetEdgeMode(canvas, EdgeMode.Aliased);

            canvas.Measure(new Size(width, height));
            canvas.Arrange(new Rect(0, 0, canvas.DesiredSize.Width, canvas.DesiredSize.Height));

            var rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default);
            rtb.Render(canvas);

            var fmb = new FormatConvertedBitmap(rtb, PixelFormats.BlackWhite, null, 0);
            var pixels = new byte[width * height / 8];
            fmb.CopyPixels(pixels, width / 8, 0);

            System.Collections.BitArray ba = new System.Collections.BitArray(pixels);

            var result = new bool[width, height];
            for (int i = 0, y = 0; y < height; ++y)
                for (int x = 0; x < width; ++x, ++i)
                    result[x, y] = !ba[i];

            return result;
        }
开发者ID:alexshtf,项目名称:Various-utility-projects,代码行数:34,代码来源:PolygonRasterizer.cs


示例13: PageLoaded

		public void PageLoaded (object o, EventArgs e)
		{
			Moonlight.Gtk.Desklet.SetupToolbox (this);
			
			secondsHand = FindName ("secondsHand") as RotateTransform;
			minuteHand  = FindName ("minuteHand")  as RotateTransform;
			hourHand    = FindName ("hourHand")    as RotateTransform;
			closeButton = FindName ("desklet-close") as Polygon;
			
			if (secondsHand == null || minuteHand == null || hourHand == null || closeButton == null)
				return;

			closeButton.MouseEnter += delegate {
				HighlightButton (closeButton);
			};

			closeButton.MouseLeave += delegate {
				UnhighlightButton (closeButton);
			};
			
			DateTime now = DateTime.Now;

			secondsHand.Angle = now.Second * 6;
			minuteHand.Angle  = now.Minute * 6;
			hourHand.Angle    = now.Hour * 30;
		}
开发者ID:dfr0,项目名称:moon,代码行数:26,代码来源:glassyclock.cs


示例14: CreatePushpinObject

        // creates object to be drawn on the map
        private Grid CreatePushpinObject()
        {
            //Creating a Grid element.
            Grid MyGrid = new Grid();
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.RowDefinitions.Add(new RowDefinition());
            MyGrid.Background = new SolidColorBrush(Colors.Transparent);

            //Creating a Rectangle
            Rectangle MyRectangle = new Rectangle();
            MyRectangle.Fill = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0x68, 0));
            MyRectangle.Height = 20;
            MyRectangle.Width = 20;
            MyRectangle.SetValue(Grid.RowProperty, 0);
            MyRectangle.SetValue(Grid.ColumnProperty, 0);

            //Adding the Rectangle to the Grid
            MyGrid.Children.Add(MyRectangle);

            //Creating a Polygon
            Polygon MyPolygon = new Polygon();
            MyPolygon.Points.Add(new Point(2, 0));
            MyPolygon.Points.Add(new Point(22, 0));
            MyPolygon.Points.Add(new Point(2, 40));
            MyPolygon.Stroke = new SolidColorBrush(Colors.Black);
            MyPolygon.Fill = new SolidColorBrush(Colors.Black);
            MyPolygon.SetValue(Grid.RowProperty, 1);
            MyPolygon.SetValue(Grid.ColumnProperty, 0);

            //Adding the Polygon to the Grid
            MyGrid.Children.Add(MyPolygon);
            return MyGrid;
        }
开发者ID:vladk1,项目名称:Kaizen,代码行数:34,代码来源:DrawUserPushPin.cs


示例15: HexRender

 private HexRender()
 {
     _r = GlobalConst.DEFAULT_r;
     _a = 2.0 / Math.Sqrt(3.0) * _r;
     hexGrid = HexGrid.I;
     polygon = new Polygon() { IsEnabled = false };
     for (int i = 0; i < 6; i++) polygon.Points.Add(new Point());
 }
开发者ID:Rupini,项目名称:HexEditor,代码行数:8,代码来源:HexRender.cs


示例16: GeneratePolygon

 protected Polygon GeneratePolygon()
 {
     Polygon myPolygon = new Polygon();
     myPolygon.Stroke = new SolidColorBrush(BorderColor);
     myPolygon.Fill = new SolidColorBrush(FillColor);
     myPolygon.StrokeThickness = 2;
     return myPolygon;
 }
开发者ID:krushank,项目名称:SharpShapes,代码行数:8,代码来源:Shape.cs


示例17: switch

 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.ethPort = ((System.Windows.Shapes.Polygon)(target));
     return;
     }
     this._contentLoaded = true;
 }
开发者ID:ychost,项目名称:uest-pcs,代码行数:9,代码来源:ethernetPort.g.cs


示例18: CreatePolygon

 // create a polygon based on a list of points
 static Polygon CreatePolygon(params double[] values)
 {
     var p = new Polygon();
     p.Points = new PointCollection();
     for (int i = 0; i < values.Length - 1; i += 2)
     {
         p.Points.Add(new Point(values[i], values[i + 1]));
     }
     return p;
 }
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:11,代码来源:ExcelCellFactory.cs


示例19: EditingQuad

 public EditingQuad(Quad quad)
 {
     Quad = quad;
     Polygon = new Polygon();
     Polygon.Fill = PolygonFillColor;
     Polygon.StrokeThickness = 1;
     Polygon.Points = Quad.Points;
     Polygon.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(Polygon_PreviewMouseLeftButtonDown);
     Selected = false;
 }
开发者ID:Kaftan777ski,项目名称:mapinect,代码行数:10,代码来源:EditingQuad.cs


示例20: GetKeyShape

        public static Polygon GetKeyShape(PianoKey.KeyTypes keyType, bool isLeftEdge, bool isRightEdge)
        {
            // White 10 width
            // Black 6 with
            // black 4 inside the white in the outside. (...?)

            Polygon p = new Polygon();
            p.Stroke = Brushes.Black;

            if (isLeftEdge)
            {
                return LeftKey();
            }
            if (isRightEdge)
            {
                return NormalKey();
            }

            switch (keyType)
            {
                case PianoKey.KeyTypes.C:
                    {
                        return LeftKey();
                    }
                case PianoKey.KeyTypes.D:
                    {
                        return MiddleKey();
                    }
                case PianoKey.KeyTypes.E:
                    {
                        return RightKey();
                    }
                case PianoKey.KeyTypes.F:
                    {
                        return LeftKey();
                    }
                case PianoKey.KeyTypes.G:
                    {
                        return G();
                    }
                case PianoKey.KeyTypes.A:
                    {
                        return A();
                    }
                case PianoKey.KeyTypes.B:
                    {
                        return RightKey();
                    }
                default:
                    {
                        return BlackKey();
                    }

            }
        }
开发者ID:tiddan,项目名称:SmoothChords,代码行数:55,代码来源:PianoGeometry.cs



注:本文中的System.Windows.Shapes.Polygon类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Shapes.Polyline类代码示例发布时间:2022-05-26
下一篇:
C# Shapes.Path类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap