Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            dc = new DBModelDataContext();
            cbViews.ItemsSource  = userViews;
            cbSpaces.ItemsSource = userSpaces;
            lvl2Controls         = new List <Control>();
            lvl2Controls.Add(btnNewSpace);

            lvl1Controls = new List <Control>();
            lvl1Controls.Add(cbViews);
            lvl1Controls.Add(cbSpaces);
            lvl1Controls.Add(btnOpenSpace);
            lvl1Controls.Add(btnOpenView);
            lvl1Controls.AddRange(lvl2Controls);
            SwitchControls(0);
            SwitchDrawControls(-1);
            currules = new DrawingRules();
            cbPointNormal.ItemsSource   = DrawingRules.AllColors;
            cbPointSelected.ItemsSource = DrawingRules.AllColors;
            cbLineNormal.ItemsSource    = DrawingRules.AllColors;
            cbLineNormal.ItemsSource    = DrawingRules.AllColors;
            cbFaceNormal.ItemsSource    = DrawingRules.AllColors;
            cbFaceSelected.ItemsSource  = DrawingRules.AllColors;
        }
Ejemplo n.º 2
0
        public void Draw(DrawingContext dc, Point center, Transform view, DrawingRules dr, int SelectedPoint = -1, int SelectedEdge = -1)
        {
            List <Point> _2dpoints = new List <Point>();

            foreach (var p in points)
            {
                var newp = view.ApplyTo(p);
                _2dpoints.Add(newp.ConvertTo2D(center));
            }
            for (int i = 0; i < _2dpoints.Count; i++)
            {
                if (i == SelectedPoint)
                {
                    dc.DrawEllipse(dr.SelPointBrush, null, _2dpoints[i], dr.SelPointWidth, dr.SelPointWidth);
                }
                else
                {
                    dc.DrawEllipse(dr.PointBrush, null, _2dpoints[i], dr.PointWidth, dr.PointWidth);
                }
            }
            for (int i = 0; i < edges.Count; i++)
            {
                if (i == SelectedEdge)
                {
                    dc.DrawLine(dr.SelLinePen, _2dpoints[edges[i].point1], _2dpoints[edges[i].point2]);
                }
                else
                {
                    dc.DrawLine(dr.LinePen, _2dpoints[edges[i].point1], _2dpoints[edges[i].point2]);
                }
            }
            foreach (var f in faces)
            {
                PathFigure pf = new PathFigure();
                for (int i = 1; i < f.points.Count; i++)
                {
                    pf.Segments.Add(new LineSegment(_2dpoints[f.points[i]], true));
                }
                pf.StartPoint = _2dpoints[f.points[0]];
                pf.IsClosed   = true;
                PathGeometry g = new PathGeometry(new[] { pf });
                dc.DrawGeometry(dr.FaceBrush, null, g);
            }

            //coordinate lines
            //base
            dc.DrawLine(dr.BaseCoordLinePen, center, new Point(1000 + center.X, center.Y));
            dc.DrawLine(dr.BaseCoordLinePen, center, new Point(center.X, center.Y - 1000));
            //orig
            for (int i = 0; i < dimnum; i++)
            {
                dc.DrawLine(dr.CoordLinePen, (view.ApplyTo(new DVector(dimnum)).ConvertTo2D(center)), (view.ApplyTo(1000 * DVector.GetOrt(i, dimnum))).ConvertTo2D(center));
            }
        }