示例#1
0
        private void LoadLayerDiagrams(DrawingGroup layerGroup)
        {
            this.UnloadDiagrams();

            DrawingCollection drawings = layerGroup.Children;

            DrawingGroup    drawGroup    = null;
            GeometryDrawing drawGeometry = null;

            for (int i = 0; i < drawings.Count; i++)
            {
                Drawing drawing = drawings[i];
                if (TryCast(drawing, out drawGroup))
                {
                    string groupName = SvgLink.GetKey(drawGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        groupName = SvgObject.GetId(drawGroup);
                    }
                    //string groupName = SvgObject.GetName(childGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        LoadLayerGroup(drawGroup);
                    }
                    else
                    {
                        SvgObjectType elementType = SvgObject.GetType(drawGroup);

                        if (elementType == SvgObjectType.Text)
                        {
                            this.AddTextDrawing(drawGroup, groupName);
                        }
                        else
                        {
                            if (drawGroup.Children != null && drawGroup.Children.Count == 1)
                            {
                                this.AddDrawing(drawGroup, groupName);
                            }
                            else
                            {
                                //throw new InvalidOperationException(
                                //    String.Format("Error: The link group is in error - {0}", groupName));
                            }
                        }
                    }
                }
                else if (TryCast(drawing, out drawGeometry))
                {
                    this.AddGeometryDrawing(drawGeometry);
                }
            }

            if (_drawingCanvas != null)
            {
                _displayTransform = _drawingCanvas.DisplayTransform;
            }
        }
示例#2
0
        private void LoadLayerGroup(DrawingGroup group)
        {
            DrawingCollection drawings = group.Children;

            DrawingGroup    drawGroup    = null;
            GeometryDrawing drawGeometry = null;

            for (int i = 0; i < drawings.Count; i++)
            {
                Drawing drawing = drawings[i];
                if (TryCast(drawing, out drawGroup))
                {
                    string groupName = SvgLink.GetKey(drawGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        groupName = SvgObject.GetId(drawGroup);
                    }
                    //string groupName = childGroup.GetValue(FrameworkElement.NameProperty) as string;
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        LoadLayerGroup(drawGroup);
                    }
                    else
                    {
                        SvgObjectType elementType = SvgObject.GetType(drawGroup);

                        if (elementType == SvgObjectType.Text)
                        {
                            this.AddTextDrawing(drawGroup, groupName);
                        }
                        else
                        {
                            if (drawGroup.Children != null && drawGroup.Children.Count == 1)
                            {
                                this.AddDrawing(drawGroup, groupName);
                            }
                            else
                            {
                                //throw new InvalidOperationException(
                                //    String.Format("Error: The link group is in error - {0}", groupName));
                            }
                        }
                    }
                }
                else if (TryCast(drawing, out drawGeometry))
                {
                    this.AddGeometryDrawing(drawGeometry);
                }
            }
        }
示例#3
0
        public void RenderDiagrams(DrawingGroup renderedGroup)
        {
            DrawingCollection drawings = renderedGroup.Children;
            int linkIndex = -1;
            int drawIndex = -1;

            for (int i = 0; i < drawings.Count; i++)
            {
                Drawing drawing = drawings[i];
                //string drawingName = SvgObject.GetName(drawing);
                string drawingName = SvgLink.GetKey(drawing);
                if (!string.IsNullOrWhiteSpace(drawingName) &&
                    string.Equals(drawingName, SvgObject.DrawLayer))
                {
                    drawIndex = i;
                }
                else if (!string.IsNullOrWhiteSpace(drawingName) &&
                         string.Equals(drawingName, SvgObject.LinksLayer))
                {
                    linkIndex = i;
                }
            }

            DrawingGroup mainGroups = null;

            if (drawIndex >= 0)
            {
                mainGroups = drawings[drawIndex] as DrawingGroup;
            }
            DrawingGroup linkGroups = null;

            if (linkIndex >= 0)
            {
                linkGroups = drawings[linkIndex] as DrawingGroup;
            }

            this.LoadDiagrams(renderedGroup, linkGroups, mainGroups);

            if (linkGroups != null)
            {
                _animationCanvas.LoadDiagrams(linkGroups, renderedGroup);
            }

            _bounds = _wholeDrawing.Bounds;

            this.InvalidateMeasure();
            this.InvalidateVisual();
        }
示例#4
0
        public void RenderDiagrams(DrawingGroup renderedGroup)
        {
            DrawingCollection drawings = renderedGroup.Children;
            int linkIndex = -1;
            int drawIndex = -1;

            for (int i = 0; i < drawings.Count; i++)
            {
                Drawing drawing = drawings[i];
                //string drawingName = drawing.GetValue(FrameworkElement.NameProperty) as string;
                string drawingName = SvgLink.GetKey(drawing);
                if (!String.IsNullOrEmpty(drawingName) &&
                    String.Equals(drawingName, SvgObject.DrawLayer))
                {
                    drawIndex = i;
                }
                else if (!String.IsNullOrEmpty(drawingName) &&
                         String.Equals(drawingName, SvgObject.LinksLayer))
                {
                    linkIndex = i;
                }
            }

            DrawingGroup mainGroups = null;

            if (drawIndex >= 0)
            {
                mainGroups = drawings[drawIndex] as DrawingGroup;
            }
            DrawingGroup linkGroups = null;

            if (linkIndex >= 0)
            {
                linkGroups = drawings[linkIndex] as DrawingGroup;
            }

            this.LoadDiagrams(renderedGroup, linkGroups, mainGroups);

            if (linkGroups != null)
            {
                _animationCanvas.LoadDiagrams(linkGroups, renderedGroup);
            }

            this.InvalidateMeasure();
            this.InvalidateVisual();
        }
示例#5
0
        public void LoadDiagrams(DrawingGroup linkGroups, DrawingGroup wholeGroup)
        {
            if (linkGroups == null)
            {
                return;
            }
            DrawingCollection drawings = linkGroups.Children;

            if (drawings == null || drawings.Count == 0)
            {
                return;
            }
            else if (drawings.Count == 1)
            {
                DrawingGroup layerGroup = drawings[0] as DrawingGroup;
                if (layerGroup != null)
                {
                    string elementId = SvgObject.GetId(layerGroup);
                    if (!string.IsNullOrWhiteSpace(elementId) &&
                        string.Equals(elementId, "IndicateLayer", StringComparison.OrdinalIgnoreCase))
                    {
                        this.LoadLayerDiagrams(layerGroup);

                        _wholeDrawing = wholeGroup;
                        _linksDrawing = linkGroups;

                        return;
                    }
                }
            }

            this.UnloadDiagrams();

            for (int i = 0; i < drawings.Count; i++)
            {
                DrawingGroup childGroup = drawings[i] as DrawingGroup;
                if (childGroup != null)
                {
                    string groupName = SvgLink.GetKey(childGroup);
                    //string groupName = SvgObject.GetName(childGroup);
                    if (string.IsNullOrWhiteSpace(groupName))
                    {
                        if (childGroup.Children != null && childGroup.Children.Count == 1)
                        {
                            this.AddDrawing(childGroup);
                        }
                        else
                        {
                            throw new InvalidOperationException("Error: The link group is in error.");
                        }
                    }
                    else
                    {
                        if (childGroup.Children != null && childGroup.Children.Count == 1)
                        {
                            this.AddDrawing(childGroup, groupName);
                        }
                        else
                        {
                            throw new InvalidOperationException(
                                      String.Format("Error: The link group is in error - {0}", groupName));
                        }
                    }
                }
            }

            _wholeDrawing = wholeGroup;
            _linksDrawing = linkGroups;

            if (_drawingCanvas != null)
            {
                _displayTransform = _drawingCanvas.DisplayTransform;
            }
        }