Наследование: Shape, IPolygon
Пример #1
0
        public Hexagon(double radius, int xPos, int yPos)
        {
            UIElement = new Polygon();
            UIElement.Points = new Windows.UI.Xaml.Media.PointCollection();

            // Compute all 6 hexagon points based on radius
            for (int i = 0; i < _sides; i++)
            {
                double angle = i * (360 / _sides) * 2 * Math.PI / 360.0; // Angle in Rad
                double x = Math.Cos(angle) * radius;
                double y = Math.Sin(angle) * radius;

                UIElement.Points.Add(new Point(x, y));
            }

            // Default properties
            this.Color = new SolidColorBrush(Colors.DimGray);
            this.Rotation = _initialAngle;
            this.Top = 0;
            this.Left = 0;
            this.X = xPos;
            this.Y = yPos;

            // Set context
            this.UIElement.DataContext = this;
        }
Пример #2
0
        public DrawControl()
        {
            this.InitializeComponent();

            _redPolygon = new Polygon
            {
                FillRule = FillRule.EvenOdd,
                Points = new PointCollection(),
                Fill = new SolidColorBrush(Colors.Red)
            };
            RedCanvas.Children.Add(_redPolygon);
        }
Пример #3
0
		public CanvasEx()
		{
			this.InitializeComponent();

			palmBlock = new Polygon();
			rootCanvas.Children.Add(palmBlock);
			palmBlock.StrokeThickness = 3;
			palmBlock.FillRule = FillRule.Nonzero;
			palmBlock.Fill = new SolidColorBrush(Color.FromArgb(0x22, 0xff, 0, 0));

			Clip = clipRect;
			zoomLevel = 0;
		}
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            double valueAsDouble = DebugHelper.CastAndAssert<double>(value);

            double LeftBase = 20;

            double RightBase = 20;

            if (BaseShape == null)
            {
                BaseShape = new Polygon();

                BaseShape.Points.Add(new Point(-20,25));
                BaseShape.Points.Add(new Point(-20,20));
                BaseShape.Points.Add(new Point(0,0));
                BaseShape.Points.Add(new Point(20,20));
                BaseShape.Points.Add(new Point(20,25));
            }

            PointCollection newShape = new PointCollection();

            double maxValue = Windows.UI.Xaml.Window.Current.Bounds.Width;

            if (BaseShape != null)
            {
                foreach (Point j in BaseShape.Points)
                {
                    double shiftX = j.X;

                    if (valueAsDouble < LeftBase)
                    {
                        if (j.X < 0)
                        {
                            shiftX = j.X * valueAsDouble / LeftBase;
                        }
                    }
                    if ((maxValue - valueAsDouble) < RightBase)
                    {
                        if (j.X > 0)
                        {
                            shiftX = j.X * (maxValue - valueAsDouble) / RightBase;
                        }
                    }

                    newShape.Add(new Point(shiftX, j.Y));
                }
            }

            return newShape;
        }
Пример #5
0
 Windows.UI.Xaml.Shapes.Polygon Path(PathData pd, 
                                     double inc)
 {
     CompositeTransform ct = new CompositeTransform();
     ct.ScaleX = ct.ScaleY = 1;
     Windows.UI.Xaml.Shapes.Polygon p = new Windows.UI.Xaml.Shapes.Polygon();
     p.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
     p.RenderTransform = ct;
     if (!(pd is WheelsData))
         return p;
     WheelsData rd = (WheelsData)pd;
     p.Points = CalculateWheels(rd, inc);
     // now centre polygon 
     //CentrePolygon(ref p);
     return p;
 }
        private async void MapControl_Loaded(object sender, RoutedEventArgs e)
        {
            Geolocator geolocator = new Geolocator();
            geolocator.DesiredAccuracyInMeters = 50;

            try
            {
                Geoposition geoposition = await geolocator.GetGeopositionAsync(
                     maximumAge: TimeSpan.FromMinutes(5),
                     timeout: TimeSpan.FromSeconds(10)
                    );

                var geopoint = new Geopoint(new BasicGeoposition()
                {
                    Latitude = geoposition.Coordinate.Latitude,
                    Longitude = geoposition.Coordinate.Longitude
                });

                Map.Center = geopoint;
                Map.ZoomLevel = 15;

                var featureList = await Helper.NetworkHelper.GetData(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);

                foreach (var feature in featureList.Features)
                {
                    var tree = new TreeModel(feature);

                    Polygon polygon = new Polygon();
                    polygon.Points.Add(new Point(0, 0));
                    polygon.Points.Add(new Point(0, 50));
                    polygon.Points.Add(new Point(20, 35));
                    polygon.Points.Add(new Point(20, 0));
                    polygon.Fill = new SolidColorBrush(Colors.Black);

                    Map.Children.Add(polygon);
                    MapControl.SetLocation(polygon, new Geopoint(tree.Location.Position));
                    MapControl.SetNormalizedAnchorPoint(polygon, new Point(0.0, 1.0));
                    polygon.Tag = tree;
                    polygon.Tapped += Polygon_Tapped;
                }

            }
            catch (Exception ex)
            {
            }
        }
Пример #7
0
        public CanvasEx()
        {
            this.InitializeComponent();

            palmBlock = new Polygon();
            rootCanvas.Children.Add(palmBlock);
            palmBlock.StrokeThickness = 3;
            palmBlock.FillRule = FillRule.Nonzero;
            palmBlock.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(0x22, 0xff, 0, 0));

            //Network added start
            Network.connect();
            //Network added end

            Network.OnNetworkRecieved += Render;

            //Clip = clipRect;
        }
Пример #8
0
 Windows.UI.Xaml.Shapes.Polygon Path(PathData pd, double inc)
 {
     Windows.UI.Xaml.Shapes.Polygon p = new Windows.UI.Xaml.Shapes.Polygon();
     p.Tag = "Bazley";
     //Debug.WriteLine("BazelyEngine Polygon Created");
     p.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
     p.RenderTransform = new CompositeTransform();
     if (!(pd is BazelyChuck))
         return p;
     BazelyChuck chuck = (pd as BazelyChuck);
     //Debug.WriteLine("BazelyEngine Calc Points");
     if (chuck.Stages.Count == 1)
         p.Points = OneStagePath(chuck, inc);
     else
         p.Points = TwoStagePath(chuck, inc);
     //Debug.WriteLine("BazelyEngine Points created");
     CentrePolygon(ref p);
     return p;
 }
Пример #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="path"></param> 
 /// <param name="x"></param>  X coordinate of starting point
 /// <param name="y"></param>  Y coordinate of starting point
 /// <returns></returns>
 public Polygon CreatePolygonFrom(RadialOffsetPath path, double rstart = 0)
 {
     Polygon p = new Polygon();
     CompositeTransform ct = new CompositeTransform();
     p.Stroke = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));
     p.RenderTransform = ct;
     double lastR = rstart;
     for (int i = 0; i < path.NumPoints; i++)
     {
         double angle = i * path.Increment * 2 * Math.PI;
         double r = lastR + path[i];
         double x = Math.Round(r * Math.Cos(angle),3);
         double y = Math.Round(r * Math.Sin(angle), 3);
         Point nxtPoint = new Point(x,y );
         p.Points.Add(nxtPoint);
         lastR = r;
     }
     return p;
 }
Пример #10
0
        private static UIElement GetHexagon()
        {
            Polygon polygon = new Polygon();
            polygon.Points = new Windows.UI.Xaml.Media.PointCollection();

            int _sides = 6;
            int radius = 25;
            // Compute all 6 hexagon points based on radius
            for (int i = 0; i < _sides; i++)
            {
                double angle = i * (360 / _sides) * 2 * Math.PI / 360.0; // Angle in Rad
                double x = Math.Cos(angle) * radius;
                double y = Math.Sin(angle) * radius;

                polygon.Points.Add(new Point(x, y));
            }

            // Default properties
            polygon.Fill = new SolidColorBrush(Colors.DimGray);
            polygon.Margin = new Thickness(25, 25, 0, 0);

            return polygon;
        }
Пример #11
0
        private DependencyObject CriaMeuPin()
        {
            var MeuGrid = new Grid();
            MeuGrid.RowDefinitions.Add(new RowDefinition());
            MeuGrid.RowDefinitions.Add(new RowDefinition());
            MeuGrid.Background = new SolidColorBrush(Colors.Transparent);

            var MeuRetangulo = new Rectangle { Fill = new SolidColorBrush(Colors.Red), Height = 10, Width = 22 };
            MeuRetangulo.SetValue(Grid.RowProperty, 0);
            MeuRetangulo.SetValue(Grid.ColumnProperty, 0);
            MeuGrid.Children.Add(MeuRetangulo);

            var MeuPoligono = new Polygon()
            {
                Points = new PointCollection() { new Point(1, 0), new Point(22, 0), new Point(11, 40) },
                Stroke = new SolidColorBrush(Colors.Red),
                Fill = new SolidColorBrush(Colors.Red)
            };
            MeuPoligono.SetValue(Grid.RowProperty, 1);
            MeuPoligono.SetValue(Grid.ColumnProperty, 0);
            MeuGrid.Children.Add(MeuPoligono);

            return MeuGrid;
        }
Пример #12
0
 public void AddPoly(Polygon p)
 {
     if (p.Name == string.Empty)
         p.Name = nextPathName;
     Polygons.Add(p);
     UpdateExtent(p);
 }
Пример #13
0
        void GenerateSubFromPolygon(ref StringBuilder sb, Polygon poly)
        {
            BindableCodeTemplate tmpl;
            CurrentPathIndex = (int)poly.Tag;

            // add start of path 
            Bind(ref sb, PathStartTemplate());
            PathFragment points = new PathFragment(poly.Points);

            if (!_context.UseAbsoluteMoves)
                points = OffsetList(points);
            // loop round points in list
            _currentPoint =  _context.FirstPoint = points[0];
           
            tmpl = _context.Templates.FirstPointTemplate;
            Bind(ref sb, tmpl);

            for (int i = 1; i < points.Count - 1 ; i++)
            {
                _currentPoint = points[i];
                tmpl = (_context.UseRotaryTable)
                     ? _context.Templates.RA_Point_Template
                     : _context.Templates.XY_Point_Template;
                Bind(ref sb, tmpl);
            }
            _currentPoint =  _context.LastPoint = points[points.Count - 1];
            tmpl = _context.Templates.LastPointTemplate;
            Bind(ref sb, tmpl);
            // add end of path
            Bind(ref sb, PathEndTemplate());
        }
Пример #14
0
        private DependencyObject CreatePushPin() 
        {
            // Creating a Polygon Marker
            Polygon polygon = new Polygon();
            polygon.Points.Add(new Point(0, 0));
            polygon.Points.Add(new Point(0, 50));
            polygon.Points.Add(new Point(25, 0));
            polygon.Fill = new SolidColorBrush(Colors.Red);

            return polygon;
        }
Пример #15
0
 internal Polygon CreatePolygon(Brush brush, params double[] values)
 {
     var p = new Polygon();
     p.VerticalAlignment = VerticalAlignment.Center;
     p.Margin = new Thickness(4, 0, 4, 0);
     p.Fill = brush != null ? brush : _brOpaque;
     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;
 }
Пример #16
0
        private DependencyObject CreatePin()
        {
            //Creating a Grid element.
            var myGrid = new Grid();
            myGrid.RowDefinitions.Add(new RowDefinition());
            myGrid.RowDefinitions.Add(new RowDefinition());
            myGrid.Background = new SolidColorBrush(Colors.Transparent);

            //Creating a Rectangle
            var myRectangle = new Rectangle {Fill = new SolidColorBrush(Colors.Black), Height = 20, 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
            var myPolygon = new Polygon()
            {
                Points = new PointCollection() {new Point(2, 0), new Point(22, 0), new Point(2, 40)},
                Stroke = new SolidColorBrush(Colors.Black),
                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;
        }
Пример #17
0
        private void CreateSelectedElements()
        {
            _selectedBorderVisual = new Border();
            _selectedPathVisual = new Polygon();
            _selectedFontIconVisual = new FontIcon();
            var focusRectMargin = new Thickness(FocusRectPadding);

            _selectedBorderVisual.IsHitTestVisible = false;
            _selectedBorderVisual.Opacity = 0;
            _selectedBorderVisual.BorderBrush = SelectedBrush;
            _selectedBorderVisual.BorderThickness = new Thickness(SelectedRectThickness);
            _selectedBorderVisual.Margin = focusRectMargin;

            _selectedPathVisual.IsHitTestVisible = false;
            _selectedPathVisual.Opacity = 0;
            _selectedPathVisual.HorizontalAlignment = HorizontalAlignment.Right;
            _selectedPathVisual.Fill = SelectedBrush;
            _selectedPathVisual.Points.Add(new Point(0, 0));
            _selectedPathVisual.Points.Add(new Point(35, 0));
            _selectedPathVisual.Points.Add(new Point(35, 35));
            _selectedPathVisual.Margin = focusRectMargin;

            _selectedFontIconVisual.IsHitTestVisible = false;
            _selectedFontIconVisual.Opacity = 0;
            _selectedFontIconVisual.Margin = new Thickness(FocusRectPadding, FocusRectPadding + SelectedRectThickness, FocusRectPadding + SelectedRectThickness, FocusRectPadding);
            _selectedFontIconVisual.HorizontalAlignment = HorizontalAlignment.Right;
            _selectedFontIconVisual.VerticalAlignment = VerticalAlignment.Top;
            _selectedFontIconVisual.FontFamily = new FontFamily("Segoe MDL2 Assets");
            _selectedFontIconVisual.FontSize = 16;
            _selectedFontIconVisual.Foreground = new SolidColorBrush(Colors.White);
            _selectedFontIconVisual.Glyph = "\uE73E";

            _contentGrid.Children.Insert(0, _selectedFontIconVisual);
            _contentGrid.Children.Insert(0, _selectedBorderVisual);
            _contentGrid.Children.Insert(0, _selectedPathVisual);
        }
Пример #18
0
        /// <summary>
        /// 学期事项填充
        /// </summary>
        /// 跟当日事件填充除了判断条件基本一致 但是不太好合/头有点晕 有空再做优化
        private void SetTransactionAll(List<Transaction> transationList, List<ClassList> classlist)
        {
            Color[] Tcolor = new Color[]{
                   Color.FromArgb(255,232,245,254),
                   Color.FromArgb(255,255,245,233),
                   Color.FromArgb(255,230,255,251)
                };
            int RightC = 0;
            bool IsInClass = false;
            foreach (var transactionitem in transationList)
            {
                for (int i = 0; i < transactionitem.date.Count; i++)
                {
                    foreach (var classitem in classlist)
                    {
                        if (transactionitem.date[i]._class == classitem.Hash_lesson)
                        { IsInClass = true; break; }
                    }
                    switch (transactionitem.date[i]._class)
                    {
                        case 0:
                        case 1:
                            RightC = 0;
                            break;
                        case 2:
                        case 3:
                            RightC = 1;
                            break;
                        case 4:
                        case 5:
                            RightC = 2;
                            break;
                    }
                    if (transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] == null)
                    {
                        long[] tempstr = new long[1];
                        tempstr[0] = transactionitem.id;
                        transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = tempstr;
                    }
                    else if (Array.IndexOf(transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class], transactionitem.id) == -1)
                    {
                        long[] temp = transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class];
                        long[] templ = new long[temp.Length + 1];
                        for (int a = 0; a < temp.Length; a++)
                            templ[a] = temp[a];
                        //if (Array.IndexOf(templ, transactionitem.id) != -1)
                        templ[temp.Length] = transactionitem.id;
                        transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = templ;
                    }
                    if (IsInClass)
                    {
                        Grid transactionGrid = new Grid();
                        transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                        transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                        transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                        transactionGrid.Margin = new Thickness(2);

                        transactionGrid.HorizontalAlignment = HorizontalAlignment.Right;
                        transactionGrid.VerticalAlignment = VerticalAlignment.Top;
                        transactionGrid.Width = 8;
                        transactionGrid.Height = 8;
                        transactionGrid.BorderThickness = new Thickness(0);
                        transactionGrid.Background = new SolidColorBrush(Colors.Transparent);
                        Polygon pl = new Polygon();
                        PointCollection collection = new PointCollection();
                        collection.Add(new Point(0, 0));
                        collection.Add(new Point(10, 10));
                        collection.Add(new Point(10, 0));
                        pl.Points = collection;
                        pl.StrokeThickness = 0;
                        pl.Fill = new SolidColorBrush(Colors.White);
                        transactionGrid.Children.Add(pl);
                        IsInClass = false;
                        kebiaoGrid.Children.Add(transactionGrid);
                    }
                    else
                    {
                        Grid transactionGrid = new Grid();
                        transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                        transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                        transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                        transactionGrid.Background = new SolidColorBrush(Tcolor[RightC]);

                        Grid polygonGrid = new Grid();
                        polygonGrid.HorizontalAlignment = HorizontalAlignment.Right;
                        polygonGrid.VerticalAlignment = VerticalAlignment.Top;
                        polygonGrid.Height = 8;
                        polygonGrid.Width = 8;
                        polygonGrid.Background = new SolidColorBrush(Colors.Transparent);
                        polygonGrid.Margin = new Thickness(2);
                        Polygon pl = new Polygon();
                        PointCollection collection = new PointCollection();
                        collection.Add(new Point(0, 0));
                        collection.Add(new Point(10, 10));
                        collection.Add(new Point(10, 0));
                        pl.Points = collection;
                        pl.Fill = new SolidColorBrush(Colors.White);
                        pl.StrokeThickness = 0;
                        polygonGrid.Children.Add(pl);
                        transactionGrid.Children.Add(polygonGrid);

                        IsInClass = false;
                        transactionGrid.Margin = new Thickness(0.5);

                        transactionGrid.Tapped += BackGrid_Tapped;
                        kebiaoGrid.Children.Add(transactionGrid);
                    }
                }
            }
        }
Пример #19
0
        /// <summary>
        /// 当日事项填充
        /// </summary>
        private void SetTransactionDay(List<Transaction> transationList, List<ClassList> classlist, int week = 0, int weekOrAll = 0)
        {
            int nowWEEK;
            if (week == 0)
                nowWEEK = Int32.Parse(appSetting.Values["nowWeek"].ToString());
            else
                nowWEEK = week;
            //事项的背景颜色 略淡
            Color[] Tcolor = new Color[]{
                   Color.FromArgb(255,232,245,254),
                   Color.FromArgb(255,255,245,233),
                   Color.FromArgb(255,230,255,251)
                };
            //通过在某某节确定背景颜色
            int RightC = 0;
            bool isInClassGrid = false;
            foreach (var transactionitem in transationList)
            {
                for (int i = 0; i < transactionitem.date.Count; i++)
                {
                    if (Array.IndexOf(transactionitem.date[i].week, nowWEEK) != -1)
                    {
                        foreach (var classitem in classlist)
                        {
                            if (Array.IndexOf(classitem.Week, nowWEEK) != -1)
                            {
                                //当前课与当前时段的事件在同一周
                                //如果本周任意一节课与事件事件冲突 
                                if (transactionitem.date[i].day == classitem.Hash_day && transactionitem.date[i]._class == classitem.Hash_lesson)
                                { isInClassGrid = true; break; }
                            }
                        }
                        switch (transactionitem.date[i]._class)
                        {
                            case 0:
                            case 1:
                                RightC = 0;
                                break;
                            case 2:
                            case 3:
                                RightC = 1;
                                break;
                            case 4:
                            case 5:
                                RightC = 2;
                                break;
                        }
                        if (transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] == null)
                        {
                            long[] tempstr = new long[1];
                            tempstr[0] = transactionitem.id;
                            transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = tempstr;
                        }
                        else if (Array.IndexOf(transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class], transactionitem.id) == -1)
                        {
                            long[] temp = transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class];
                            long[] templ = new long[temp.Length + 1];
                            for (int a = 0; a < temp.Length; a++)
                                templ[a] = temp[a];
                            //if (Array.IndexOf(templ, transactionitem.id) != -1)
                            templ[temp.Length] = transactionitem.id;
                            transactiontime[transactionitem.date[i].day, transactionitem.date[i]._class] = templ;
                        }
                        if (isInClassGrid)
                        {
                            //事件与课程冲突 就不订阅tapped事件了
                            Grid transactionGrid = new Grid();
                            transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                            transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                            transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                            transactionGrid.Margin = new Thickness(2);

                            transactionGrid.HorizontalAlignment = HorizontalAlignment.Right;
                            transactionGrid.VerticalAlignment = VerticalAlignment.Top;
                            transactionGrid.Width = 8;
                            transactionGrid.Height = 8;
                            transactionGrid.BorderThickness = new Thickness(0);
                            transactionGrid.Background = new SolidColorBrush(Colors.Transparent);
                            Polygon pl = new Polygon();
                            PointCollection collection = new PointCollection();
                            collection.Add(new Point(0, 0));
                            collection.Add(new Point(10, 10));
                            collection.Add(new Point(10, 0));
                            pl.Points = collection;
                            pl.StrokeThickness = 0;
                            pl.Fill = new SolidColorBrush(Colors.White);
                            transactionGrid.Children.Add(pl);
                            isInClassGrid = false;
                            kebiaoGrid.Children.Add(transactionGrid);
                        }
                        else
                        {
                            Grid transactionGrid = new Grid();
                            transactionGrid.SetValue(Grid.RowProperty, System.Int32.Parse(transactionitem.date[i]._class * 2 + ""));
                            transactionGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(transactionitem.date[i].day + ""));
                            transactionGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(2 + ""));

                            transactionGrid.Background = new SolidColorBrush(Tcolor[RightC]);

                            Grid polygonGrid = new Grid();
                            polygonGrid.HorizontalAlignment = HorizontalAlignment.Right;
                            polygonGrid.VerticalAlignment = VerticalAlignment.Top;
                            polygonGrid.Height = 8;
                            polygonGrid.Width = 8;
                            polygonGrid.Background = new SolidColorBrush(Colors.Transparent);
                            polygonGrid.Margin = new Thickness(2);
                            Polygon pl = new Polygon();
                            PointCollection collection = new PointCollection();
                            collection.Add(new Point(0, 0));
                            collection.Add(new Point(10, 10));
                            collection.Add(new Point(10, 0));
                            pl.Points = collection;
                            pl.Fill = new SolidColorBrush(Colors.White);
                            pl.StrokeThickness = 0;
                            polygonGrid.Children.Add(pl);
                            transactionGrid.Children.Add(polygonGrid);

                            isInClassGrid = false;
                            transactionGrid.Margin = new Thickness(0.5);

                            transactionGrid.Tapped += BackGrid_Tapped;
                            kebiaoGrid.Children.Add(transactionGrid);
                        }
                    }
                }
            }
        }
Пример #20
0
 public void UpdateExtent(Polygon poly)
 {
     foreach (Point pt in poly.Points)
         PathExtent.Update(pt);
 }
Пример #21
0
        ShapeData ConstructAndAddShape(TypeId typeId)
        {
            UIElement element;

            if (typeId == TypeId.Line) {
                var line = new Line {StrokeEndLineCap = PenLineCap.Round};
                element = line;
            }
            else if (typeId == TypeId.Text) {
                element = new TextBlock ();
            }
            else if (typeId == TypeId.Oval) {
                element = new Ellipse ();
            }
            else if (typeId == TypeId.Arc) {
                element = new Path();
            }
            else if (typeId == TypeId.RoundedRect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Rect) {
                element = new Rectangle ();
            }
            else if (typeId == TypeId.Image) {
                element = new Image ();
            }
            else if (typeId == TypeId.Polygon) {
                element = new NativePolygon ();
            }
            else {
                throw new NotSupportedException ("Don't know how to construct: " + typeId);
            }

            var sd = new ShapeData {
                Element = element,
                TypeId = typeId,
            };

            _shapes.Add (sd);

            //
            // Insert it in the right place so it gets drawn in the right order
            //
            if (_lastAddElementIndex >= 0) {
                _lastAddElementIndex++;
                _canvas.Children.Insert(_lastAddElementIndex, element);
            }
            else {
                if (_lastShape != null) {
                    _lastAddElementIndex = _canvas.Children.IndexOf(_lastShape.Element) + 1;
                    _canvas.Children.Insert(_lastAddElementIndex, element);
                }
                else {
                    _lastAddElementIndex = _canvas.Children.Count;
                    _canvas.Children.Add(element);
                }
            }

            return sd;
        }
Пример #22
0
        private void MyCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            PointerPoint pt = e.GetCurrentPoint(MyCanvas);
            currentContactPt = pt.Position;
            if (!previewselected) { 
            if (penselected || rectangleselected || triangleselected || imageselected || tablelayoutinserted)
            {
                // Get information about the pointer location.
                
                _previousContactPt = pt.Position;

                // Accept input only from a pen or mouse with the left button pressed. 
                PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
//                if (pointerDevType == PointerDeviceType.Pen ||
  //                      pointerDevType == PointerDeviceType.Mouse &&
    //                    pt.Properties.IsLeftButtonPressed)
      //          {
                    // Pass the pointer information to the InkManager.
                    _inkKhaled.ProcessPointerDown(pt);
                    _penID = pt.PointerId;

                    e.Handled = true;
        //        }

          //      else if (pointerDevType == PointerDeviceType.Touch)
            //    {
                    // Process touch input
              //  }
                    if (tablelayoutinserted)
                        table_prevcount = -1;
            }

            ///////////////////////////////

          
            
            //////////////////////////////////////////

            if (polygonselected)
            {
                polygonPoints.Add(pt.Position);
                if (poly_previtem == -1 && poly_start == -1)
                {
                    if (poly_start == -1)
                        poly_startPoint = pt.Position;
                    _previousContactPt = pt.Position;
                    poly_start = 0;
                    poly_previtem = 0;

                    // Accept input only from a pen or mouse with the left button pressed. 
                    PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
//                    if (pointerDevType == PointerDeviceType.Pen ||
  //                          pointerDevType == PointerDeviceType.Mouse &&
    //                        current.Properties.IsLeftButtonPressed)
      //              {
                        // Pass the pointer information to the InkManager.
                        _inkKhaled.ProcessPointerDown(pt);
                        _penID = pt.PointerId;

                        e.Handled = true;
        //            }

          //          else if (pointerDevType == PointerDeviceType.Touch)
            //        {
                        // Process touch input
              //      }
                }
                else if (poly_previtem == 0)
                {

                    if (e.Pointer.PointerId == _penID)
                    {

                        // Pass the pointer information to the InkManager. 
                        _inkKhaled.ProcessPointerUp(pt);
                    }

                    else if (e.Pointer.PointerId == _touchID)
                    {
                        // Process touch input
                    }

                    _touchID = 0;
                    _penID = 0;

                    // Call an application-defined function to render the ink strokes.


                    e.Handled = true;
                    rec_prevcount = -1;

                    ///////////////////////////////////////////////////////////

                    // Accept input only from a pen or mouse with the left button pressed. 
                    PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
//                    if (pointerDevType == PointerDeviceType.Pen ||
  //                          pointerDevType == PointerDeviceType.Mouse &&
    //                        current.Properties.IsLeftButtonPressed)
      //              {
                        // Pass the pointer information to the InkManager.
                        _inkKhaled.ProcessPointerDown(pt);
                        _penID = pt.PointerId;

                        e.Handled = true;
        //            }

          //          else if (pointerDevType == PointerDeviceType.Touch)
            //        {
                        // Process touch input
              //      }
                    /////////////////////////////////////////////////////////////////
                    if (poly_startget)
                        currentContactPt = poly_startPoint;
                    else currentContactPt = pt.Position;
                    x1 = _previousContactPt.X;
                    y1 = _previousContactPt.Y;
                    x2 = currentContactPt.X;
                    y2 = currentContactPt.Y;
                    Line line = new Line()
                    {
                        X1 = x1,
                        Y1 = y1,
                        X2 = x2,
                        Y2 = y2,
                        StrokeThickness = 4.0,
                        Stroke = new SolidColorBrush(Colors.Black)
                    };

                    // Draw the line on the canvas by adding the Line object as
                    // a child of the Canvas object.
                    MyCanvas.Children.RemoveAt(MyCanvas.Children.Count - 1);
                    MyCanvas.Children.Add(line);

                    // Pass the pointer information to the InkManager.
                    _inkKhaled.ProcessPointerUpdate(pt);

                    poly_edgecount++;
                    if (poly_startPoint.X == currentContactPt.X && poly_startPoint.Y == currentContactPt.Y)
                    {
                        
                        Polygon newshape = new Polygon()
                            {
                                StrokeThickness = 2,
                                Stroke = new SolidColorBrush(Colors.Green)
                            };
                        int count = MyCanvas.Children.Count;
                        int i = MyCanvas.Children.Count - poly_edgecount,
                            j=0;
                        polygonPoints.RemoveAt(polygonPoints.Count - 1);
                        while (i != count)
                        {
                            newshape.Points.Add(polygonPoints.ElementAt(j));
                            MyCanvas.Children.RemoveAt(MyCanvas.Children.Count-1);
                            i++;
                            j++;
                        }
                        MyCanvas.Children.Add(newshape);
                        List_item.Add(new customitems(MyCanvas.Children.IndexOf(newshape), null));
                        newshape.PointerPressed += newshape_PointerPressed;
                        newshape.PointerEntered += newshape_PointerEntered;

                        TextBox newbox = new TextBox()
                        {
                            Width = 200,
                            Height = 16,
                            Background = new SolidColorBrush(Colors.LightGray),
                            BorderBrush = new SolidColorBrush(Colors.Black)
                        };
                        Canvas.SetLeft(newbox, currentContactPt.X + 10);
                        Canvas.SetTop(newbox, currentContactPt.Y - 10);

                        Button Okbtn = new Button()
                        {
                            Width = 60,
                            Height = 30,
                            FontSize = 10,
                            FontStyle = Windows.UI.Text.FontStyle.Normal,
                            Content="OK",
                            Background = new SolidColorBrush(Colors.LightGray),
                            BorderBrush = new SolidColorBrush(Colors.Black)
                        };
                        Canvas.SetLeft(Okbtn, currentContactPt.X + 220);
                        Canvas.SetTop(Okbtn, currentContactPt.Y - 10);
                        MyCanvas.Children.Add(newbox);
                        MyCanvas.Children.Add(Okbtn);
                        Okbtn.Click += Okbtn_Click;

                        polygonPoints.Clear();
                       
                        poly_start = -1;
                        poly_previtem = -1;
                        poly_edgecount = 0;
                        Drawing_Initialize(sender, e);
                        poly_startget = false;
                    }
                    else {
                        _previousContactPt = pt.Position;
                    }
                    poly_prevcount = -1;
                }
            }

            if (lineselected)
            {
                if (line_start == -1)
                {
                    _previousContactPt = pt.Position;
                    line_start = 0;

                    // Accept input only from a pen or mouse with the left button pressed. 
                    PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
//                    if (pointerDevType == PointerDeviceType.Pen ||
  //                          pointerDevType == PointerDeviceType.Mouse &&
    //                        current.Properties.IsLeftButtonPressed)
      //              {
                        // Pass the pointer information to the InkManager.
                        _inkKhaled.ProcessPointerDown(pt);
                        _penID = pt.PointerId;

                        e.Handled = true;
        //            }

          //          else if (pointerDevType == PointerDeviceType.Touch)
            //        {
                        // Process touch input
              //      }
                }
                else 
                {
                    if (e.Pointer.PointerId == _penID)
                    {

                        // Pass the pointer information to the InkManager. 
                        _inkKhaled.ProcessPointerUp(pt);
                    }

                    else if (e.Pointer.PointerId == _touchID)
                    {
                        // Process touch input
                    }

                    _touchID = 0;
                    _penID = 0;

                    // Call an application-defined function to render the ink strokes.

                    e.Handled = true;
                    rec_prevcount = -1;

                    ///////////////////////////////////////////////////////////

                    // Accept input only from a pen or mouse with the left button pressed. 
                    PointerDeviceType pointerDevType = e.Pointer.PointerDeviceType;
//                    if (pointerDevType == PointerDeviceType.Pen ||
  //                          pointerDevType == PointerDeviceType.Mouse &&
    //                        current.Properties.IsLeftButtonPressed)
      //              {
                        // Pass the pointer information to the InkManager.
                        _inkKhaled.ProcessPointerDown(pt);
                        _penID = pt.PointerId;

                        e.Handled = true;
        //            }

          //          else if (pointerDevType == PointerDeviceType.Touch)
            //        {
                        // Process touch input
              //      }
                    /////////////////////////////////////////////////////////////////
                    
                    x1 = _previousContactPt.X;
                    y1 = _previousContactPt.Y;
                    x2 = currentContactPt.X;
                    y2 = currentContactPt.Y;
                    Line line = new Line()
                    {
                        X1 = x1,
                        Y1 = y1,
                        X2 = x2,
                        Y2 = y2,
                        StrokeThickness = 4.0,
                        Stroke = new SolidColorBrush(Colors.Green)
                    };

                    // Draw the line on the canvas by adding the Line object as
                    // a child of the Canvas object.
                    MyCanvas.Children.RemoveAt(MyCanvas.Children.Count - 1);
                    MyCanvas.Children.Add(line);

                    // Pass the pointer information to the InkManager.
                    _inkKhaled.ProcessPointerUpdate(pt);

                    line_start = -1;
                    line_prevcount = -1;
                    Drawing_Initialize(sender, e);
                }
            }

            if (textboxselected)
            {
                TextBox text_box = new TextBox()
                {
                    Width = 200,
                    Height = 30,
                };
                Canvas.SetLeft(text_box, e.GetCurrentPoint(MyCanvas).Position.X);
                Canvas.SetTop(text_box, e.GetCurrentPoint(MyCanvas).Position.Y);
                text_box.Background = new SolidColorBrush(Colors.LightGray);
                
                Button Text_Okbtn = new Button()
                {
                    Width = 60,
                    Height = 30,
                    FontSize = 10,
                    FontStyle = Windows.UI.Text.FontStyle.Normal,
                    Content = "OK",
                    Background = new SolidColorBrush(Colors.LightGray),
                    BorderBrush = new SolidColorBrush(Colors.Black)
                };
                Canvas.SetLeft(Text_Okbtn, e.GetCurrentPoint(MyCanvas).Position.X + 210);
                Canvas.SetTop(Text_Okbtn, e.GetCurrentPoint(MyCanvas).Position.Y);
                
                Text_Okbtn.Click += Text_Okbtn_Click;

                Button Text_Cancelbtn = new Button()
                {
                    Width = 60,
                    Height = 30,
                    FontSize = 10,
                    FontStyle = Windows.UI.Text.FontStyle.Normal,
                    Content = "Cancel",
                    Background = new SolidColorBrush(Colors.LightGray),
                    BorderBrush = new SolidColorBrush(Colors.Black)
                };

                Canvas.SetLeft(Text_Cancelbtn, e.GetCurrentPoint(MyCanvas).Position.X + 275);
                Canvas.SetTop(Text_Cancelbtn, e.GetCurrentPoint(MyCanvas).Position.Y);

                Text_Cancelbtn.Click += Text_Cancelbtn_Click;

                MyCanvas.Children.Add(text_box);
                MyCanvas.Children.Add(Text_Okbtn);
                MyCanvas.Children.Add(Text_Cancelbtn);
                textbox_list.Add(text_box);
                //text_box.Focus(Windows.UI.Xaml.FocusState.Keyboard);
                textbox_list.Last().Focus(Windows.UI.Xaml.FocusState.Pointer);   
            }

            if (imageselected)
            {
                int count = MyCanvas.Children.Count;
                Image temp_img = (Image)MyCanvas.Children.Last();
                /*double top = ((Window.Current.Bounds.Height - temp_img.Height) / 2);
                double bottom = temp_img.Height + top;
                double left = ((Window.Current.Bounds.Width - temp_img.Width) / 2);
                double right = temp_img.Width + left;*/
                var location = temp_img.TransformToVisual(Window.Current.Content);
                Point location_img = location.TransformPoint(new Point(0, 0));
                double left = location_img.X,
                    right = location_img.X + temp_img.ActualWidth,
                    top = location_img.Y,
                    bottom = location_img.Y + temp_img.ActualHeight;

                if (Math.Abs(pt.Position.X - left) < 3) img_left = true;

                if (Math.Abs(pt.Position.X - right) < 3) img_right = true;

                if (Math.Abs(pt.Position.Y - top) < 3) img_top = true;

                if (Math.Abs(pt.Position.Y - bottom) < 3) img_bottom = true;

                if (((pt.Position.X - left >= 3) && (right - pt.Position.X >= 3))
                    && ((pt.Position.Y - top >= 3) && (bottom - pt.Position.Y >= 3)))
                    img_move = true;
                }   
            }
        }
        protected void SetPolygonPointsProperty(Polygon polygon, PointCollection pointCollection)
        {
            // Changing .Points during an Arrange pass can create a layout cycle on Silverlight
            if (!polygon.Points.SequenceEqual(pointCollection))
            {
                polygon.Points = pointCollection;
                // In rare cases, Silverlight doesn't update the line visual to match the new points;
                // calling InvalidateArrange works around that problem.
                polygon.InvalidateArrange();
            }

        }
Пример #24
0
        /// <summary>
        /// 周视图课程格子的填充
        /// </summary>
        /// <param name="item">ClassList类型的item</param>
        /// <param name="ClassColor">颜色数组,0~9</param>
        private void SetClassAll(ClassList item, int ClassColor)
        {
            //有事项的画个角- -
            //foreach (var transactionItem in transationList) {
            //    if (item.Week == transactionItem.week && item.Lesson == transactionItem.classToLesson)
            //    {

            //    }
            //}

            Color[] colors = new Color[]{
                   //Color.FromArgb(255,132, 191, 19),
                   //Color.FromArgb(255,67, 182, 229),
                   //Color.FromArgb(255,253, 137, 1),
                   //Color.FromArgb(255,128, 79, 242),
                   //Color.FromArgb(255,240, 68, 189),
                   //Color.FromArgb(255,229, 28, 35),
                   //Color.FromArgb(255,156, 39, 176),
                   //Color.FromArgb(255,3, 169, 244),
                   //Color.FromArgb(255,255, 193, 7),
                   //Color.FromArgb(255,255, 152, 0),
                   //Color.FromArgb(255,96, 125, 139),
                   Color.FromArgb(255,255, 161, 16),
                   Color.FromArgb(255,56, 188, 242),
                   Color.FromArgb(255,159, 213, 27),
                   Color.FromArgb(255,200, 200, 200), //灰色
                };

            //折叠角的颜色数组
            Color[] _color = new Color[] {
                Color.FromArgb(255,255,219,178),
                Color.FromArgb(255,162,229,255),
                Color.FromArgb(255,155,244,244),
            };

            TextBlock ClassTextBlock = new TextBlock();

            ClassTextBlock.Text = item.Course + "\n" + item.Classroom + "\n" + item.Teacher;
            ClassTextBlock.Foreground = new SolidColorBrush(Colors.White);
            ClassTextBlock.FontSize = 12;
            ClassTextBlock.TextWrapping = TextWrapping.WrapWholeWords;
            ClassTextBlock.VerticalAlignment = VerticalAlignment.Center;
            ClassTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            ClassTextBlock.Margin = new Thickness(3);
            ClassTextBlock.MaxLines = 6;

            Grid BackGrid = new Grid();
            BackGrid.Background = new SolidColorBrush(colors[ClassColor]);
            BackGrid.SetValue(Grid.RowProperty, System.Int32.Parse(item.Hash_lesson * 2 + ""));
            BackGrid.SetValue(Grid.ColumnProperty, System.Int32.Parse(item.Hash_day + ""));
            BackGrid.SetValue(Grid.RowSpanProperty, System.Int32.Parse(item.Period + ""));
            BackGrid.Margin = new Thickness(0.5);
            BackGrid.Children.Add(ClassTextBlock);

            //TODO:新增 折叠三角
            if (classtime[item.Hash_day, item.Hash_lesson] != null)
            {
                Image img = new Image();
                img.Source = new BitmapImage(new Uri("ms-appx:///Assets/shape.png", UriKind.Absolute));
                img.VerticalAlignment = VerticalAlignment.Bottom;
                img.HorizontalAlignment = HorizontalAlignment.Right;
                img.Width = 10;

                //他要折叠..我画一个三角好了..
                Grid _grid = new Grid();
                Polygon pl = new Polygon();
                PointCollection collection = new PointCollection();
                collection.Add(new Point(0, 0));
                collection.Add(new Point(10, 0));
                collection.Add(new Point(0, 10));
                pl.Points = collection;
                pl.Stroke = new SolidColorBrush(Colors.Black);
                pl.StrokeThickness = 0;
                _grid.Children.Add(pl);
                _grid.Background = new SolidColorBrush(_color[ClassColor]);
                _grid.Width = 10;
                _grid.Height = 10;
                _grid.VerticalAlignment = VerticalAlignment.Bottom;
                _grid.HorizontalAlignment = HorizontalAlignment.Right;
                BackGrid.Children.Add(_grid);

                BackGrid.Children.Add(img);

                string[] temp = classtime[item.Hash_day, item.Hash_lesson];
                string[] tempnew = new string[temp.Length + 1];
                for (int i = 0; i < temp.Length; i++)
                    tempnew[i] = temp[i];
                tempnew[temp.Length] = item._Id;
                Debug.WriteLine("if~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }
            else
            {
                string[] tempnew = new string[1];
                tempnew[0] = item._Id;
                Debug.WriteLine("else~id->" + item._Id);
                classtime[item.Hash_day, item.Hash_lesson] = tempnew;
            }

            BackGrid.Tapped += BackGrid_Tapped;
            kebiaoGrid.Children.Add(BackGrid);
        }
Пример #25
0
        private void MyCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            if (polygonselected)
            {
                Polygon newshape = new Polygon()
                {
                    StrokeThickness = 2,
                    Stroke = new SolidColorBrush(Colors.Green)
                };
                int count = MyCanvas.Children.Count;
                int i = MyCanvas.Children.Count - poly_edgecount,
                    j = 0;
                polygonPoints.RemoveAt(polygonPoints.Count - 1);
                while (i != count)
                {
                    newshape.Points.Add(polygonPoints.ElementAt(j));
                    MyCanvas.Children.RemoveAt(MyCanvas.Children.Count - 1);
                    i++;
                    j++;
                }
                MyCanvas.Children.Add(newshape);
                List_item.Add(new customitems(MyCanvas.Children.IndexOf(newshape), null));
                newshape.PointerPressed += newshape_PointerPressed;
                newshape.PointerEntered += newshape_PointerEntered;

                TextBox newbox = new TextBox()
                {
                    Width = 200,
                    Height = 16,
                    Background = new SolidColorBrush(Colors.LightGray),
                    BorderBrush = new SolidColorBrush(Colors.Black)
                };
                Canvas.SetLeft(newbox, currentContactPt.X + 10);
                Canvas.SetTop(newbox, currentContactPt.Y - 10);

                Button Okbtn = new Button()
                {
                    Width = 60,
                    Height = 30,
                    FontSize = 10,
                    FontStyle = Windows.UI.Text.FontStyle.Normal,
                    Content = "OK",
                    Background = new SolidColorBrush(Colors.LightGray),
                    BorderBrush = new SolidColorBrush(Colors.Black)
                };
                Canvas.SetLeft(Okbtn, currentContactPt.X + 220);
                Canvas.SetTop(Okbtn, currentContactPt.Y - 10);
                MyCanvas.Children.Add(newbox);
                MyCanvas.Children.Add(Okbtn);
                Okbtn.Click += Okbtn_Click;

                polygonPoints.Clear();

                poly_start = -1;
                poly_previtem = -1;
                poly_edgecount = 0;
                //Drawing_Initialize(sender, e);
                poly_startget = false;
            }
        }
Пример #26
0
        private void DrawDistribution(IList<int> values)
        {
            double w = _canvasWidth;
            double wx = w/values.Count;
            int h = 47;

            var valuesLogged = new List<float>(values.Count);
            foreach (int value in values)
            {
                if (value == 0)
                    valuesLogged.Add(0);
                else if (value == 1)
                    valuesLogged.Add(0.1f);
                else
                    valuesLogged.Add((float) Math.Log10(value));
            }
            IList<float> valuesNormalized = MathUtil.Normalize(valuesLogged);

            var pc = new PointCollection();
            pc.Add(new Point(0, h));
            for (int i = 0; i < valuesNormalized.Count; ++i)
            {
                pc.Add(new Point(i*wx, (1 - valuesNormalized[i])*h));
            }
            pc.Add(new Point(w, h));
            pc.Add(new Point(0, h));

            var p = new Polygon
            {
                Fill = new SolidColorBrush(Colors.DimGray),
                Points = pc
            };

            Canvas.Children.Add(p);
        }
Пример #27
0
        private static Polygon RenderHighlight(BookmarkModel bookmarkModel, Panel canvas, PageRenderData context)
        {
            int tokenID = bookmarkModel.TokenID;
            TextRenderData firstHighlightedText = context.Texts.FirstOrDefault(t => t.TokenID == tokenID) ??
                                        (context.Texts).FirstOrDefault();

            if (firstHighlightedText == null) 
                return null;

            int endTokenID = bookmarkModel.EndTokenID;
            TextRenderData lastHighlightedText = context.Texts.LastOrDefault(t => t.TokenID == endTokenID) ??
                                                    (context.Texts).LastOrDefault();
            if (lastHighlightedText == null) 
                return null;

            Rect firtstRect = firstHighlightedText.Rect;
            Rect lastRect = lastHighlightedText.Rect;
            var pointCollection = SelectionHelper.GetSelectionPolygon(
                firtstRect, 
                lastRect,
                canvas.ActualWidth, 
                context.OffsetX,
                Convert.ToDouble(AppSettings.Default.FontSettings.FontInterval));

            var polygon = new Polygon
                              {
                                  Width = canvas.ActualWidth,
                                  Height = canvas.ActualHeight,
                                  Fill = new SolidColorBrush(ColorHelper.ToColor(bookmarkModel.Color)) {Opacity = 0.3},
                                  Points = pointCollection,
                                  Visibility = Visibility.Visible
                              };
            return polygon;
            
        }
Пример #28
0
 /// <summary>
 /// Utility method that makes directionals for the bus stop.
 /// </summary>
 private void MakeDirectional(Thickness margin, double angle)
 {
     Polygon polygon = new Polygon();
     polygon.Points = new PointCollection() { new Point(0, 0), new Point(8, 5), new Point(0, 10) };
     polygon.Fill = crimsonBrush;
     polygon.Margin = margin;
     polygon.RenderTransformOrigin = new Point(.5, .5);
     polygon.RenderTransform = new RotateTransform() { Angle = angle };
     this.canvas.Children.Add(polygon);
 }
        /// <summary>
        /// The draw polygon.
        /// </summary>
        /// <param name="points">
        /// The points.
        /// </param>
        /// <param name="fill">
        /// The fill.
        /// </param>
        /// <param name="stroke">
        /// The stroke.
        /// </param>
        /// <param name="thickness">
        /// The thickness.
        /// </param>
        /// <param name="dashArray">
        /// The dash array.
        /// </param>
        /// <param name="lineJoin">
        /// The line join.
        /// </param>
        /// <param name="aliased">
        /// The aliased.
        /// </param>
        public void DrawPolygon(
            IList<ScreenPoint> points,
            OxyColor fill,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPenLineJoin lineJoin,
            bool aliased)
        {
            var po = new Polygon();
            this.SetStroke(po, stroke, thickness, lineJoin, dashArray, aliased);

            if (fill != null)
            {
                po.Fill = this.GetCachedBrush(fill);
            }

            var pc = new PointCollection();
            foreach (ScreenPoint p in points)
            {
                pc.Add(p.ToPoint(aliased));
            }

            po.Points = pc;

            this.Add(po);
        }
Пример #30
0
 public int IndexOf(Polygon p)
 {
     return Polygons.IndexOf(p); 
 }