Example #1
0
        private static void LoadChildNode(WorkAreaModel workArea, XmlElement xmlElement)
        {
            XmlNodeList xmlNodeList = xmlElement.ChildNodes;

            foreach (XmlElement xe in xmlNodeList)                                                            //遍历模块节点
            {
                Assembly     assembly = Assembly.GetExecutingAssembly();                                      // 获取当前程序集
                BaseWorkFlow obj      = assembly.CreateInstance("WPFDrag.Themes." + xe.Name) as BaseWorkFlow; //反射新建实例
                Type         type     = obj.GetType();
                var          props    = type.GetProperties();
                foreach (var prop in props)
                {
                    if (xe.HasAttribute(prop.Name))                      //判断是否有该属性
                    {
                        if (prop.Name == "Points")
                        {
                            PointCollection pc = PointCollection.Parse(xe.GetAttribute("Points"));                              //设置复杂属性
                            prop.SetValue(obj, pc);
                        }
                        else
                        {
                            prop.SetValue(obj, Convert.ChangeType(xe.GetAttribute(prop.Name), prop.PropertyType));                              //根据类型设置属性
                        }
                    }
                }
                workArea.WorkAreaItems.Add(obj);
                workArea.RegistModelEvent(obj);
                if (xe.HasChildNodes)                   //如果有子节点,则递归读取
                {
                    obj.ChildWorkFlow = new WorkFlowModel();
                    LoadChildNode(obj.ChildWorkFlow.WorkArea, xe);
                }
            }
        }
Example #2
0
        private static PointCollection GetPointCollection(object parameter)
        {
            var s = parameter as String;

            if (!String.IsNullOrEmpty(s))
            {
                PointCollection c;
                if (!Cache.TryGetValue(s, out c))
                {
                    try
                    {
                        c = PointCollection.Parse(s);
                        if (c.Count < 2)
                        {
                            c = Default;
                        }
                    }
                    catch
                    {
                        c = Default;
                    }
                    Cache.Add(s, c);
                }
                return(c);
            }
            return(Default);
        }
Example #3
0
        private void RenderFrame(object sender, EventArgs e)
        {
            if (Star_list.Count == 0)
            {
                int ellipseCount = 5;
                for (int i = 0; i < ellipseCount; i++)
                {
                    //квадрат
                    Polygon polygon = new Polygon();
                    polygon.Points = PointCollection.Parse("126, 126, 174, 126, 174, 174, 126,174");
                    polygon.Fill   = Brushes.Black;
                    canvas.Children.Add(polygon);


                    //звездочка
                    Star star = new Star();
                    canvas.Children.Add(star.Polygon0);
                    Star_list.Add(star);
                }
            }
            else
            {
                for (int i = Star_list.Count - 1; i >= 0; i--)
                {
                    Star_list[i].Next();
                }
            }
        }
Example #4
0
        private Model3DGroup CopyToWPFThread(Model3DGroup src_model)
        {
            /** disassemble */
            var geometrymodel = src_model.Children[0] as GeometryModel3D;
            var geometry      = geometrymodel.Geometry as MeshGeometry3D;

            string str_vertices = geometry.Positions.ToString();
            string str_normals  = geometry.Normals.ToString();
            string str_indices  = geometry.TriangleIndices.ToString();
            string str_textures = geometry.TextureCoordinates.ToString();

            Model3DGroup result_model = null;

            Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
            {
                result_model = new Model3DGroup();
                result_model.Children.Add(new GeometryModel3D()
                {
                    Geometry = new MeshGeometry3D()
                    {
                        /** re-assemble */
                        Positions          = Point3DCollection.Parse(str_vertices),
                        Normals            = Vector3DCollection.Parse(str_normals),
                        TriangleIndices    = Int32Collection.Parse(str_indices),
                        TextureCoordinates = PointCollection.Parse(str_textures)
                    },
                    Material = new DiffuseMaterial(new ImageBrush(new BitmapImage(new Uri(@"image/marble.jpg", UriKind.Relative))))
                });
            }));

            return(result_model);
        }
Example #5
0
        public Volume(Instrument instrument, ChartControl chart)
        {
            Chart      = chart;
            Instrument = instrument;
            Cache      = new ChartGfxCache(CreatePiece);

            Label = new TextBlock
            {
                Text             = string.Empty,
                FontSize         = 10.0,
                IsHitTestVisible = false,
            };
            Icon = new Polygon
            {
                Points = PointCollection.Parse("0,0 5,5 5,-5"),
                Stroke = Brushes.Black,
                Fill   = Brushes.Black,
                Cursor = Cursors.SizeNS,
            };
            Icon.MouseLeftButtonDown += delegate
            {
                chart.MouseOperations.Pending[MouseButton.Left] = new DragVolumeSizeScaler(this)
                {
                    StartOnMouseDown = false
                };
            };

            Scale             = 1.0;
            IndicatorPosition = 0.25;
        }
Example #6
0
 public override Shape GetDrawingObject()
 {
     return(new Polygon
     {
         Fill = Brushes.BlueViolet,
         Points = PointCollection.Parse("-24, 50, 24, 1, 74, 50")
     });
 }
        /// <summary>
        /// Attempts to convert to a PointCollection from the given object.
        /// </summary>
        /// <returns>
        /// The PointCollection which was constructed.
        /// </returns>
        /// <exception cref="NotSupportedException">
        /// A NotSupportedException is thrown if the example object is null or is not a valid type
        /// which can be converted to a PointCollection.
        /// </exception>
        /// <param name="context"> The ITypeDescriptorContext for this call. </param>
        /// <param name="culture"> The requested CultureInfo.  Note that conversion uses "en-US" rather than this parameter. </param>
        /// <param name="value"> The object to convert to an instance of PointCollection. </param>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string source)
            {
                return(PointCollection.Parse(source));
            }

            throw GetConvertFromException(value);
        }
Example #8
0
 public static MeshGeometry3D CreateSquareGeometry(string positions)
 {
     return(new MeshGeometry3D
     {
         Positions = Point3DCollection.Parse(positions),
         TriangleIndices = Int32Collection.Parse("0,1,2 0,2,3"),
         TextureCoordinates = PointCollection.Parse("0,0 0,1 1,1 1,0"),
     });
 }
Example #9
0
        public override Shape GetDrawingObject()
        {
            return(new Polyline
            {
                Stroke = Brushes.BlueViolet,
                StrokeThickness = 2,

                Points = PointCollection.Parse(GetPoint())
            });
        }
Example #10
0
        public PointCollection PolygonPoints(double[] p)//Polygonの列幅行幅から,左上を原点とした適当なPoints文字列を返す
        {
            //PolygonのPointsは左下左上右上右下の順
            string leftbottom  = (rowSize * p[4]).ToString(format) + "," + (columnSize * (p[3] + p[5])).ToString(format) + " ";
            string lefttop     = "0,0 ";
            string righttop    = (rowSize * (p[2] + p[6])).ToString(format) + "," + (columnSize * p[7]).ToString(format) + " ";
            string rightbottom = (rowSize * (p[2] + p[8])).ToString(format) + "," + (columnSize * (p[3] + p[9])).ToString(format);

            return(PointCollection.Parse(leftbottom + lefttop + righttop + rightbottom));
        }
 /// <summary>
 /// Converts a string into a PointCollection.
 /// </summary>
 public override object ConvertFromString(string value, IValueSerializerContext context)
 {
     if (value != null)
     {
         return(PointCollection.Parse(value));
     }
     else
     {
         return(base.ConvertFromString(value, context));
     }
 }
Example #12
0
        void fiveTwelve()
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("65,65 45,85 65,105");
            minuteFace.Children.Add(line);
        }
Example #13
0
        void twoFiftySix()
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("45,85 25,65");
            minuteFace.Children.Add(line);
        }
Example #14
0
        void oneNintyTwo()//plus sixtyFour
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("105,105 65,145");
            minuteFace.Children.Add(line);
        }
Example #15
0
        void oneTwentyEight()
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("105,105 85,125 105,145");
            minuteFace.Children.Add(line);
        }
Example #16
0
        void fourtyEight()//plus sixteen
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("145,65 105,105");
            minuteFace.Children.Add(line);
        }
Example #17
0
        void sevenSixtyEight()//plus twoFiftySix
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("65,65 25,105");
            minuteFace.Children.Add(line);
        }
Example #18
0
        void twelve()//plus four
        {
            SolidColorBrush blueBrush = new SolidColorBrush();

            blueBrush.Color = Colors.Blue;
            Polyline line = new Polyline();

            line.Stroke          = blueBrush;
            line.StrokeThickness = 5;
            //points
            line.Points = PointCollection.Parse("105,65 85,45 105,25");
            minuteFace.Children.Add(line);
        }
        private void loadPolylineFrom(string filepath)
        {
            string readContents;

            using (StreamReader streamReader = new StreamReader(filepath, Encoding.UTF8))
            {
                readContents = streamReader.ReadToEnd();
            }
            PointCollection points = PointCollection.Parse(readContents);

            polylinePoints  = points;
            polyline.Points = polylinePoints;
        }
Example #20
0
        //display
        void Draw(string Points)
        {
            SolidColorBrush blueBrush = new SolidColorBrush
            {
                Color = Colors.Blue
            };
            var line = new Polyline
            {
                Stroke          = blueBrush,
                StrokeThickness = 5,
                Points          = PointCollection.Parse(Points)
            };

            minuteFace.Children.Add(line);
        }
Example #21
0
        public ChessBoard()
        {
            material                     = new GeometryModel3D();
            mesh                         = new MeshGeometry3D();
            material.Geometry            = mesh;
            this.Content                 = material;
            this.Mesh.Positions          = Point3DCollection.Parse(ChessBoard_Mesh.Positions);
            this.Mesh.TextureCoordinates = PointCollection.Parse(ChessBoard_Mesh.TextureCoordinates);
            this.Mesh.TriangleIndices    = Int32Collection.Parse(ChessBoard_Mesh.TriangleIndices);
            DiffuseMaterial mat = new DiffuseMaterial();

            mat.Brush         = Brushes.White;
            mat.AmbientColor  = Colors.Silver;
            mat.Color         = Colors.Chocolate;
            material.Material = mat;
        }
Example #22
0
 public Bishop()
 {
     try
     {
         this.Mesh.Normals            = Vector3DCollection.Parse(Bishop_Mesh.Normals);
         this.Mesh.Positions          = Point3DCollection.Parse(Bishop_Mesh.Positions);
         this.Mesh.TextureCoordinates = PointCollection.Parse(Bishop_Mesh.TextureCoordinates);
         this.Mesh.TriangleIndices    = Int32Collection.Parse(Bishop_Mesh.TriangleIndices);
         //initialize to default position
         TranslateTransform3D translate = new TranslateTransform3D(-3, 7, 0);
         this.Transformations.Children.Add(translate);
         this.UnmutableTransformations.Add(translate);
     }
     catch (Exception ex)
     {
     }
 }
Example #23
0
        public static void DrawSpline(this DrawingContext dc, PointCollection pointCollection, double offsetX, double offsetY, Format format)
        {
            pointCollection = PointCollection.Parse(
                string.Join(" ", pointCollection
                            .Select(x => new Point(x.X + offsetX, x.Y + offsetY))
                            .Select(x => $"{x.X},{x.Y}"))
                );

            StreamGeometry streamGeometry = new StreamGeometry();

            using (StreamGeometryContext gcx = streamGeometry.Open())
            {
                gcx.BeginFigure(pointCollection.First(), true, true);
                gcx.PolyLineTo(pointCollection, true, true);
            }

            dc.DrawGeometry(format.brushBackground, new Pen(format.brushForeground, format.penWidth), streamGeometry);
        }
Example #24
0
 /// <summary>
 /// Initializes a Pawn from its resource file
 /// </summary>
 public Pawn()
 {
     try
     {
         this.Mesh.Positions          = Point3DCollection.Parse(Pawn_Mesh.Positions);
         this.Mesh.TriangleIndices    = Int32Collection.Parse(Pawn_Mesh.TriangleIndices);
         this.Mesh.TextureCoordinates = PointCollection.Parse(Pawn_Mesh.TextureCoordinates);
         this.Mesh.Normals            = Vector3DCollection.Parse(Pawn_Mesh.Normals);
         //initialize pawn to default position, this centers the pawn in the middle of the board (0,0) and compensates obj imports deviations
         TranslateTransform3D translate = new TranslateTransform3D(-7, 5, 0);
         this.Transformations.Children.Add(translate);
         this.UnmutableTransformations.Add(translate);
         //RotateTransform3D rotate = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), 90));
         //this.Transformations.Children.Add(rotate);
         //this.UnmutableTransformations.Add(rotate);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Example #25
0
        public MarketDepth(CoinFlip.MarketDepth market, ChartControl chart)
        {
            Chart  = chart;
            Market = market;

            Icon = new Polygon
            {
                Points = PointCollection.Parse("0,5 5,0 -5,0"),
                Stroke = Brushes.Black,
                Fill   = Brushes.Black,
                Cursor = Cursors.SizeWE,
            };
            Label = new TextBlock
            {
                Text             = string.Empty,
                FontSize         = 10.0,
                IsHitTestVisible = false,
            };
            CursorVolume = new TextBlock
            {
                Text             = string.Empty,
                FontSize         = 10.0,
                Foreground       = Chart.Scene.BackgroundColour.ToMediaBrush(),
                Background       = Chart.Scene.BackgroundColour.InvertBW(0xFF333333, 0xFFCCCCCC).ToMediaBrush(),
                IsHitTestVisible = false,
                Margin           = new Thickness(2),
            };
            Icon.MouseLeftButtonDown += delegate
            {
                chart.MouseOperations.Pending[MouseButton.Left] = new DragMarketSizeScaler(this)
                {
                    StartOnMouseDown = false
                };
            };

            IndicatorPosition = 0.25;
        }
Example #26
0
        [FriendAccessAllowed] // Built into Core, also used by Framework.
#endif
        internal static bool SerializePoint(BinaryWriter writer, string stringValue)
        {
#if PBTCOMPILER
            List <Point> points = ParsePointCollection(stringValue, TypeConverterHelper.InvariantEnglishUS);
            Point        curPoint;
#else
            PointCollection points = PointCollection.Parse(stringValue);
            Point           curPoint;
#endif

            // Write out the size.
            writer.Write(( uint )points.Count);

            // Write out the doubles.
            for (int i = 0; i < points.Count; i++)
            {
                curPoint = points[i];

                WriteDouble(writer, curPoint.X);
                WriteDouble(writer, curPoint.Y);
            }

            return(true);
        }
Example #27
0
        private Geometry ReadSvgNode(XElement node)
        {
            Geometry result = null;

            switch (node.Name.LocalName.ToLower())
            {
            case "svg":
            {
                double?newwidth;
                double?newheight;
                Rect?  newviewbox;

                newwidth   = GetDoubleAttribute(node.Attribute("width"));
                newheight  = GetDoubleAttribute(node.Attribute("height"));
                newviewbox = GetRectAttribute(node.Attribute("viewBox"));

                Clip                  = newviewbox.HasValue ? new RectangleGeometry(newviewbox.Value) : null;
                Width                 = newviewbox.HasValue ? newviewbox.Value.Right : newwidth.HasValue ? newwidth.Value : double.NaN;
                Height                = newviewbox.HasValue ? newviewbox.Value.Bottom : newheight.HasValue ? newheight.Value : double.NaN;
                ViewBox               = newviewbox.HasValue ? newviewbox.Value : Rect.Empty;
                ViewBoxWidth          = newviewbox.HasValue ? newviewbox.Value.Width : double.NaN;
                ViewBoxHeight         = newviewbox.HasValue ? newviewbox.Value.Height : double.NaN;
                translateTransform.X  = newviewbox.HasValue ? -newviewbox.Value.X : 0;
                translateTransform.Y  = newviewbox.HasValue ? -newviewbox.Value.Y : 0;
                scaleTransform.ScaleX = newviewbox.HasValue ? newviewbox.Value.Right / (double)newviewbox.Value.Width : 1;
                scaleTransform.ScaleY = newviewbox.HasValue ? newviewbox.Value.Bottom / (double)newviewbox.Value.Height : 1;

                GeometryGroup geometrygroup = new GeometryGroup()
                {
                    FillRule = FillRule.Nonzero
                };
                if (node.HasElements)
                {
                    foreach (XElement child in node.Elements())
                    {
                        var geometry = ReadSvgNode(child);
                        if (geometry != null)
                        {
                            geometrygroup.Children.Add(geometry);
                        }
                    }
                }
                result = geometrygroup;
                break;
            }

            case "g":
            {
                GeometryGroup geometrygroup = new GeometryGroup()
                {
                    FillRule = FillRule.Nonzero
                };
                if (node.HasElements)
                {
                    foreach (XElement child in node.Elements())
                    {
                        var geometry = ReadSvgNode(child);
                        if (geometry != null)
                        {
                            geometrygroup.Children.Add(geometry);
                        }
                    }
                }
                result = geometrygroup;
                break;
            }

            case "path":
            {
                foreach (var attr in node.Attributes())
                {
                    if (attr.Name.LocalName == "d" && !string.IsNullOrEmpty(attr.Value))
                    {
                        try
                        {
                            return(Geometry.Parse(attr.Value));
                        }
                        catch { }
                    }
                }
                break;
            }

            case "line":
            {
                double x1, y1, x2, y2;
                if (GetDoubleAttribute(node.Attribute("x1"), out x1) && GetDoubleAttribute(node.Attribute("y1"), out y1) && GetDoubleAttribute(node.Attribute("x2"), out x2) && GetDoubleAttribute(node.Attribute("y2"), out y2))
                {
                    result = new LineGeometry(new Point(x1, y2), new Point(x2, y2));
                }
                break;
            }

            case "rect":
            {
                double x, y, w, h;
                if (GetDoubleAttribute(node.Attribute("x"), out x) && GetDoubleAttribute(node.Attribute("y"), out y) && GetDoubleAttribute(node.Attribute("width"), out w) && GetDoubleAttribute(node.Attribute("height"), out h))
                {
                    result = new RectangleGeometry(new Rect(x, y, w, h));
                }
                break;
            }

            case "ellipse":
            {
                double cx, cy, rx, ry;
                if (GetDoubleAttribute(node.Attribute("cx"), out cx) && GetDoubleAttribute(node.Attribute("cy"), out cy) && GetDoubleAttribute(node.Attribute("rx"), out rx) && GetDoubleAttribute(node.Attribute("ry"), out ry))
                {
                    result = new EllipseGeometry(new Point(cx, cy), rx, ry);
                }
                break;
            }

            case "circle":
            {
                double cx, cy, r;
                if (GetDoubleAttribute(node.Attribute("cx"), out cx) && GetDoubleAttribute(node.Attribute("cy"), out cy) && GetDoubleAttribute(node.Attribute("r"), out r))
                {
                    result = new EllipseGeometry(new Point(cx, cy), r, r);
                }
                break;
            }

            case "polyline":
            {
                try
                {
                    Polyline   polyline = new Polyline();
                    XAttribute attr     = node.Attribute("points");
                    if (attr != null && !string.IsNullOrEmpty(attr.Value))
                    {
                        polyline.Points = PointCollection.Parse(attr.Value);
                        polyline.Measure(ViewBox.Size);
                        polyline.Arrange(ViewBox);
                        result = polyline.RenderedGeometry;
                    }
                }
                catch { }
                break;
            }

            case "polygon":
            {
                try
                {
                    Polygon    polygon = new Polygon();
                    XAttribute attr    = node.Attribute("points");
                    if (attr != null && !string.IsNullOrEmpty(attr.Value))
                    {
                        polygon.Points = PointCollection.Parse(attr.Value);
                        polygon.Measure(ViewBox.Size);
                        polygon.Arrange(ViewBox);
                        result = polygon.RenderedGeometry;
                    }
                }
                catch { }
                break;
            }
            }

            if (result != null)
            {
                result.Transform = GetTransformAttribute(node.Attribute("transform"));
            }

            return(result);
        }
Example #28
0
        public MyWindow()
        {
            Width      = 1536;
            Height     = 768;
            Title      = "My window";
            Background = BGBrush;
            int   MoveX       = 200;
            int   MoveY       = 200;
            Point bufferPoint = new Point();

            Content = myGrid;
            //Считываю строку с точками из файла
            //PointCollection readPoints = PointCollection.Parse(ReadPoints());

            //Так как строку с точками мы больше не считываем из файла, строка будет храниться в таком виде, сразу считаем количество
            PointCollection readPoints = PointCollection.Parse("20,20 846,20 868,40 42,40  912,40 934,60 956,80 868,80 846,60 64,60  86,80  980,80 1002,100 1024,120 868,120 846,100 108,100  130,120 920,120 894,140  152,140 868,160 460,160 438,140");
            int             pCount     = readPoints.Count();

            //Этот цикл тут для того, чтобы можно было двигать всю структуру.
            for (int i = 0; i < pCount;)
            {
                bufferPoint.X = readPoints[i].X + MoveX;
                bufferPoint.Y = readPoints[i].Y + MoveY;
                points.Add(bufferPoint);
                i++;
            }

            fillComboBox.HorizontalAlignment  = HorizontalAlignment.Left;
            fillComboBox.VerticalAlignment    = VerticalAlignment.Top;
            colorComboBox.HorizontalAlignment = HorizontalAlignment.Left;
            colorComboBox.VerticalAlignment   = VerticalAlignment.Top;

            //Быстрый способ заполнить комбобоксы, сразу зададим выбор по умолчанию
            for (int i = 0; i < 9; i++)
            {
                colorComboBox.Items.Add("Цвет " + (i + 1));
            }
            colorComboBox.SelectedIndex = 0;
            colorComboBox.Margin        = new Thickness(100, 0, 0, 0);

            for (int i = 0; i < 9; i++)
            {
                fillComboBox.Items.Add("Заливка " + (i + 1));
            }
            fillComboBox.SelectedIndex = 0;

            //Просто текст. Отображается текст из комбобокса с вариантом заливки.
            label1.Content    = fillComboBox.Text;
            label1.FontSize   = 20;
            label1.Foreground = System.Windows.Media.Brushes.Black;
            label1.Margin     = new Thickness(550 + MoveX, 60 + MoveY, 0, 0);

            //Рисуем всё
            myGrid.Children.Add(fillComboBox);
            myGrid.Children.Add(colorComboBox);
            myGrid.Children.Add(label1);
            DrawLines();
            DrawDots();

            //Обрабатываем события при изменении выбранного пункта комбобоксов
            fillComboBox.SelectionChanged  += new SelectionChangedEventHandler(Event_Fill);
            colorComboBox.SelectionChanged += new SelectionChangedEventHandler(Event_Select_Color);
        }
Example #29
0
 private void dtmr_countdown_Tick(object sender, EventArgs e)
 {
     lbl_output.Content = "W:" + SensorA.Quaternion[0].ToString() + " X:" + SensorA.Quaternion[1].ToString() + " Y:" + SensorA.Quaternion[2].ToString() + " Z:" + SensorA.Quaternion[3].ToString();
     XY.Points          = PointCollection.Parse("50,250," + (50 - (50 * SensorA.Quaternion[1])).ToString() + "," + (250 - (50 * SensorA.Quaternion[2])).ToString());
     XZ.Points          = PointCollection.Parse("200,250," + (200 - (50 * SensorA.Quaternion[1])).ToString() + "," + (250 - (50 * SensorA.Quaternion[3])).ToString());
 }
Example #30
0
        void loadModel()
        {
            //读取数据
            curprjkey    = 13;
            dtallproject = DataLayer.DataProvider.getDataTableFromSQL("select * from map_project");
            dtproject    = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_project where id={0}", curprjkey));
            curprj       = dtproject.Rows[0];
            string sqlwhere  = PrjHelper.genProjectsExpress(curprjkey, dtallproject);
            string sqlwhere2 = PrjHelper.genProjectsExpress(curprjkey, dtallproject, "t1.");

            dtobject = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t1.*,t2.layer from map_object t1 join map_svg_layer t2 on t1.layerid=t2.id where points is not null and {0}", sqlwhere2));
            dtlayer  = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_svg_layer where {0}", sqlwhere));
            dttext   = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t1.*,t2.layer from map_svg_text t1 join map_svg_layer t2 on t1.layerid=t2.id where points is not null and {0}", sqlwhere2));
            dtsymbol = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select t2.svgsymbolid,t2.name,t2.viewbox,t2.preserveAspectRatio,t1.shapetype,t1.data,t1.fill,t1.stroke,t1.width from map_svg_symbolitem t1 join map_svg_symbol t2 on t1.symbolid=t2.id where t2.svgsymbolid in (select distinct replace(symbolid,'#','') from map_object where points is not null and ({0})) and ({0})", sqlwhere)); //仅使用了的图元

            dtstyle = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_svg_style where {0}", sqlwhere));
            int KGID = 11;

            dtshareobject = DataLayer.DataProvider.getDataTableFromSQL(string.Format("select * from map_share_object where prjid={0} or layername='区县图层'", KGID));

            //生成图元字典,图元字典内容会被传送到d3d生成公用材质,下面的厂站,将使用图元字典中的键值来决定在d3d中的材质
            genSymbolBrush();
            //另外直接添加材质, SubstationEntityDisH2为键值
            //uc.objManager.AddSymbol("","SubstationEntityDisH2", "SubstationEntityDisH2.dds");


            //生成几何体资源字典,几何体资源字典内容会被传送到d3d生成公用几何体数据,下面的数据呈现用的柱体,将使用几何体字典中的键值来决定在d3d中的形态
            genGeomeries();


            //添加对象层
            foreach (DataRow item in dtlayer.Rows)
            {
                uc.objManager.AddLayer(item["layer"].ToString(), item["id"].ToString(), item["layer"].ToString()); //示例中以层的名字为键值
            }
            int idx = 0;
            //对象
            bool             isfind;
            PowerBasicObject obj;
            pLayer           containerLayer;



            foreach (DataRow item in dtobject.AsEnumerable().OrderBy(p => p.Field <int>("prjid")))
            {
                obj = null;
                if (item["shapetype"].ToString() == "dot")
                {
                    isfind = uc.objManager.zLayers.TryGetValue(item["layer"].ToString(), out containerLayer);  //查找是否有对象所属层
                    if (isfind)
                    {
                        isfind = containerLayer.pModels.TryGetValue(item["id"].ToString(), out obj);
                        if (!isfind)
                        {
                            obj = new pSymbolObject(containerLayer)
                            {
                                id       = item["id"].ToString(),
                                name     = item["objname"].ToString(),
                                location = item["points"].ToString(),
                                symbolid = item["symbolid"].ToString().Replace("#", ""),  //材质Key
                                isH      = true
                            };
                            if ((obj as pSymbolObject).symbolid == "SwitchStationOpen")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "开关站";
                                (obj as pSymbolObject).color = Colors.Aqua;
                                obj.visualMaxDistance        = 10;
                            }
                            else if ((obj as pSymbolObject).symbolid == "SubstationEntityDisH")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "变电站";
                                (obj as pSymbolObject).color = Colors.Lime;
                            }
                            else if ((obj as pSymbolObject).symbolid == "Pole")
                            {
                                if (obj.busiData == null)
                                {
                                    obj.busiData = new busiBase(obj);
                                }
                                obj.busiData.busiSort        = "杆塔";
                                (obj as pSymbolObject).color = Color.FromRgb(0xCC, 0xFF, 0xFF);
                                obj.visualMaxDistance        = 5;
                            }

                            //(obj as pSymbolObject).aniTwinkle.isDoAni = true;


                            Regex regex = new Regex("translate\\(.*\\) ?rotate\\(.*\\) ?scale\\((\\d*.?\\d*), ?(\\d*.?\\d*)\\)", RegexOptions.Multiline);
                            Match m     = regex.Match(item["data"].ToString());
                            if (m.Success)
                            {
                                (obj as pSymbolObject).scaleX = (float)(uc.objManager.zSymbols[(obj as pSymbolObject).symbolid].sizeX * Math.Pow(double.Parse(m.Groups[1].Value), 0.7) / 400);
                                (obj as pSymbolObject).scaleY = (float)(uc.objManager.zSymbols[(obj as pSymbolObject).symbolid].sizeY * Math.Pow(double.Parse(m.Groups[1].Value), 0.7) / 400);
                            }
                            else
                            {
                                (obj as pSymbolObject).scaleX = (obj as pSymbolObject).scaleY = 0.025f;
                            }


                            containerLayer.AddObject(item["id"].ToString(), obj);//也可直接加如:containerLayer.pModels.Add(item["id"].ToString(), obj);
                        }
                    }
                    if (idx == 0)
                    {
                        obj = new pModel3D(containerLayer)  //测试实物模型用,暂无效
                        {
                            id          = item["id"].ToString() + "3d",
                            name        = item["objname"].ToString(),
                            location    = item["points"].ToString(),
                            Model3DType = EPowerModel3DType.风电
                        };
                        containerLayer.AddObject(item["id"].ToString() + "3d", obj);
                        idx++;
                    }
                }
                else if (item["shapetype"].ToString() == "path")
                {
                    isfind = uc.objManager.zLayers.TryGetValue(item["layer"].ToString(), out containerLayer);
                    if (isfind)
                    {
                        isfind = containerLayer.pModels.TryGetValue(item["id"].ToString(), out obj);
                        if (!isfind)
                        {
                            obj = new pPowerLine(containerLayer)
                            {
                                id         = item["id"].ToString(),
                                name       = item["objname"].ToString(),
                                strPoints  = item["points"].ToString(),
                                color      = Color.FromRgb(0xFF, 0xCC, 0x00),
                                arrowColor = Colors.Blue,
                                isFlow     = true,
                                thickness  = 0.002f
                            };
                            //(obj as pPowerLine).aniDraw.aniType=EAniType.绘制; //注意:只有aniDraw属性可以是擦除或绘制两者之一,其它的动画属性大多没有可选性,请不要更改它们的动画类型
                            //(obj as pPowerLine).aniDraw.isDoAni = true;
                            //(obj as pPowerLine).aniTwinkle.isDoAni = true;

                            //zh注:对不合理的过近的相邻点进行处理,这部分应放入位置数据入库前
                            PointCollection pc    = PointCollection.Parse(item["points"].ToString());
                            PointCollection newpc = new PointCollection();
                            newpc.Add(pc[0]);
                            for (int i = 1; i < pc.Count; i++)
                            {
                                if ((pc[i] - pc[i - 1]).Length > 0.00001)
                                {
                                    if (i < pc.Count - 1)
                                    {
                                        Vector v1 = pc[i] - pc[i - 1]; v1.Normalize();
                                        Vector v2 = pc[i + 1] - pc[i]; v2.Normalize();
                                        if (v1 != v2)
                                        {
                                            newpc.Add(pc[i]);
                                        }
                                    }
                                    else
                                    {
                                        newpc.Add(pc[i]);
                                    }
                                }
                            }
                            (obj as pPowerLine).strPoints = newpc.ToString();


                            if (newpc.Count > 1)
                            {
                                containerLayer.pModels.Add(item["id"].ToString(), obj);
                            }
                        }
                    }


                    idx++;
                }
            }
        }