private object CreateWire(object[] data, double x, double y, bool snap)
        {
            if (data == null || data.Length != 9)
            {
                return(null);
            }

            double x1           = (double)data[0];
            double y1           = (double)data[1];
            double x2           = (double)data[2];
            double y2           = (double)data[3];
            bool   startVisible = (bool)data[4];
            bool   endVisible   = (bool)data[5];
            bool   startIsIO    = (bool)data[6];
            bool   endIsIO      = (bool)data[7];
            int    id           = (int)data[8];

            var line = new LineEx()
            {
                Style          = Application.Current.Resources[ResourceConstants.KeyStyleWireLine] as Style,
                X1             = 0,       //X1 = x1,
                Y1             = 0,       //Y1 = y1,
                Margin         = new Thickness(x1, y1, 0, 0),
                X2             = x2 - x1, // X2 = x2,
                Y2             = y2 - y1, // Y2 = y2,
                IsStartVisible = startVisible,
                IsEndVisible   = endVisible,
                IsStartIO      = startIsIO,
                IsEndIO        = endIsIO,
                Uid            = Constants.TagElementWire + Constants.TagNameSeparator + id.ToString()
            };

            return(line);
        }
        private FrameworkElement CreateDiagramElement(string diagram,
                                                      Size areaExtent,
                                                      Point origin,
                                                      Rect area,
                                                      bool fixedStrokeThickness,
                                                      ResourceDictionary resources,
                                                      DiagramTable table)
        {
            var grid = new Grid()
            {
                ClipToBounds = true,
                Resources    = resources
            };

            var template = new Control()
            {
                Template = grid.Resources[ResourceConstants.KeyLandscapePageTemplate] as ControlTemplate
            };

            var canvas = new DiagramCanvas()
            {
                Width  = PageWidth,
                Height = PageHeight
            };

            ModelEditor.Parse(diagram,
                              canvas, this.DiagramCreator,
                              0, 0,
                              false, false, false, true);

            grid.Children.Add(template);
            grid.Children.Add(canvas);

            LineEx.SetShortenStart(grid, ShortenStart);
            LineEx.SetShortenEnd(grid, ShortenEnd);

            TableGrid.SetData(grid, table);

            return(grid);
        }