Exemple #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            FlowChart flowchart = new FlowChart();

            Config config = new Config();

            if (config.TestUrl(new System.Uri("ipc://SysCAD.Service/Global")))
            {
                config.Syncxxx();

                Dictionary <String, Bitmap> modelThumbnails   = new Dictionary <String, Bitmap>();
                Dictionary <String, Bitmap> graphicThumbnails = new Dictionary <String, Bitmap>();

                foreach (String key in config.ModelStencils.Keys)
                {
                    ModelStencil stencil = config.ModelStencils[key];
                    flowchart.DocExtents   = flowchart.ClientToDoc(new System.Drawing.Rectangle(0, 0, 17, 17));
                    flowchart.ShadowsStyle = ShadowsStyle.None;
                    flowchart.BackColor    = System.Drawing.SystemColors.Window;
                    flowchart.AntiAlias    = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    RectangleF boxRect = flowchart.ClientToDoc(new System.Drawing.Rectangle(1, 1, 13, 13));
                    Box        box     = flowchart.CreateBox(boxRect.X, boxRect.Y, boxRect.Width, boxRect.Height);
                    box.Style      = BoxStyle.Shape;
                    box.Shape      = GetShapeTemplate(stencil);
                    box.FillColor  = System.Drawing.Color.FromArgb(150, System.Drawing.Color.BurlyWood);
                    box.FrameColor = System.Drawing.Color.FromArgb(255, System.Drawing.Color.BurlyWood);
                    box.Locked     = true;
                    modelThumbnails.Add(key, flowchart.CreateImage());
                    flowchart.DeleteObject(box);
                }

                Application.Run(new TestAppForm(modelThumbnails, config.ModelStencils));
            }
        }
Exemple #2
0
        private void OnDocumentDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(typeof(ShapeTemplate)))
            {
                return;
            }
            if (document == null)
            {
                return;
            }

            ShapeTemplate template = (ShapeTemplate)e.Data.GetData(typeof(ShapeTemplate));

            Point  ptClient = document.PointToClient(new Point(e.X, e.Y));
            PointF ptDoc    = document.ClientToDoc(ptClient);
            Box    box      = document.CreateBox(ptDoc.X, ptDoc.Y,
                                                 defaultBoxSize.Width, defaultBoxSize.Height);

            box.Style = BoxStyle.Shape;
            box.Shape = template;
        }
Exemple #3
0
        public void LoadProject(ClientProtocol clientProtocol, Config config)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new LoadProjectDelegate(LoadProject), new object[] { clientProtocol, config });
            }
            else
            {
                // Close the one selected.
                if (frmFlowChart != null)
                {
                    FileCloseProject();
                }

                clientProtocol.Connect("SysCAD10\nConnection: Client");
                config.Syncxxx();

                Refresh();

                frmFlowChart = new FrmFlowChart(this);

                SuspendLayout();
                frmFlowChart.SuspendLayout();
                frmFlowChart.FlowChart.SuspendLayout();
                NavigationTreeView.SuspendLayout();

                frmFlowChart.WindowState = System.Windows.Forms.FormWindowState.Maximized;

                frmFlowChart.MdiParent = this;
                frmFlowChart.Text      = clientProtocol.Name;

                frmFlowChart.SetProject(clientProtocol, config, NavigationTreeView);

                ovOverview.Document = frmFlowChart.FlowChart;

                frmFlowChart.FlowChart.SelectionChanged += new SelectionEvent(this.frmFlowChart_fcFlowChart_SelectionChanged);

                graphicPropertyGrid.LinkChanged += frmFlowChart.PropertyGridLinkChanged;
                graphicPropertyGrid.NodeChanged += frmFlowChart.PropertyGridNodeChanged;

                {
                    Dictionary <String, Bitmap> modelThumbnails = new Dictionary <String, Bitmap>();
                    //Dictionary<String, Bitmap> graphicThumbnails = new Dictionary<String, Bitmap>();

                    FlowChart thumbnailFlowchart = new FlowChart();

                    foreach (String key in frmFlowChart.State.Config.ModelStencils.Keys)
                    {
                        ModelStencil stencil = config.ModelStencils[key];
                        thumbnailFlowchart.DocExtents   = frmFlowChart.FlowChart.ClientToDoc(new System.Drawing.Rectangle(0, 0, 17, 17));
                        thumbnailFlowchart.ShadowsStyle = ShadowsStyle.None;
                        thumbnailFlowchart.BackColor    = System.Drawing.SystemColors.Window;
                        thumbnailFlowchart.AntiAlias    = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        RectangleF boxRect = thumbnailFlowchart.ClientToDoc(new System.Drawing.Rectangle(1, 1, 13, 13));
                        Box        box     = thumbnailFlowchart.CreateBox(boxRect.X, boxRect.Y, boxRect.Width, boxRect.Height);
                        box.Style      = BoxStyle.Shape;
                        box.Shape      = State.GetShapeTemplate(stencil, false, false);
                        box.FillColor  = System.Drawing.Color.FromArgb(220, 222, 184, 136);
                        box.FrameColor = System.Drawing.Color.FromArgb(255, 111, 92, 68);
                        box.Locked     = true;
                        modelThumbnails.Add(key, thumbnailFlowchart.CreateImage());
                        thumbnailFlowchart.DeleteObject(box);
                    }

                    stencilChooser1.PopulateTree(modelThumbnails, config.ModelStencils);
                }

                frmFlowChart.State.ProjectAttached = true;
                SetButtonStates();

                frmFlowChart.Show();

                this.NavigationTreeView.NodeSelectionChange     += new System.EventHandler(this.tvNavigation_NodeSelectionChange);
                this.NavigationTreeView.AfterNodePositionChange += new PureComponents.TreeView.TreeView.AfterNodePositionChangeEventHandler(this.tvNavigation_AfterNodePositionChange);
                this.NavigationTreeView.NodeMouseClick          += new PureComponents.TreeView.TreeView.NodeMouseClickEventHandler(this.tvNavigation_NodeMouseClick);

                NavigationTreeView.ClearNodeSelection();

                foreach (PureComponents.TreeView.Node node in NavigationTreeView.Nodes)
                {
                    node.Select();
                    node.Expand();
                    SelectSubNodes(node);
                }

                NavigationTreeView.ResumeLayout(true);
                frmFlowChart.FlowChart.ResumeLayout(true);
                frmFlowChart.ResumeLayout(true);
                ResumeLayout(true);

                frmFlowChart.ZoomToVisible();
            }
        }
Exemple #4
0
        private void DrawPicture(Graphics g, Image pict, RectangleF rect, ImageAlign pos)
        {
            float xoff = 0, yoff = 0;
            int   xc = 0, yc = 0;

            // get image logical size in document coordinates
            float  docZoom = document.ZoomFactor / 100.0f;
            float  picw    = (float)pict.Width / pict.HorizontalResolution * g.DpiX * docZoom;
            float  pich    = (float)pict.Height / pict.VerticalResolution * g.DpiY * docZoom;
            PointF ptLT    = document.ClientToDoc(new Point(0, 0));
            PointF ptRB    = document.ClientToDoc(new Point((int)picw, (int)pich));

            picw = ptRB.X - ptLT.X;
            pich = ptRB.Y - ptLT.Y;

            switch (pos)
            {
            case ImageAlign.TopLeft:
                xoff = rect.Left;
                yoff = rect.Top;
                xc   = yc = 1;
                break;

            case ImageAlign.BottomLeft:
                xoff = rect.Left;
                yoff = rect.Bottom - pich;
                xc   = yc = 1;
                break;

            case ImageAlign.TopRight:
                xoff = rect.Right - picw;
                yoff = rect.Top;
                xc   = yc = 1;
                break;

            case ImageAlign.BottomRight:
                xoff = rect.Right - picw;
                yoff = rect.Bottom - pich;
                xc   = yc = 1;
                break;

            case ImageAlign.Center:
                xoff = (rect.Right + rect.Left - picw) / 2;
                yoff = (rect.Bottom + rect.Top - pich) / 2;
                xc   = yc = 1;
                break;

            case ImageAlign.Fit:
            {
                xc = yc = 1;
                float h = rect.Bottom - rect.Top;
                float w = rect.Right - rect.Left;
                if (h == 0)
                {
                    break;
                }

                float ratioCtrl = w / h;
                float ratioPic  = picw / pich;

                if (ratioCtrl > ratioPic)
                {
                    //stretch vertically
                    pich = (int)h;
                    picw = (int)(ratioPic * pich);
                    yoff = rect.Top;
                    xoff = (rect.Right + rect.Left - picw) / 2;
                }
                else
                {
                    //stretch horizontally
                    picw = (int)w;
                    if (ratioPic == 0)
                    {
                        break;
                    }
                    pich = (int)(picw / ratioPic);
                    xoff = rect.Left;
                    yoff = (rect.Bottom + rect.Top - pich) / 2;
                }
            }
            break;

            case ImageAlign.Stretch:
            {
                picw = rect.Right - rect.Left;
                pich = rect.Bottom - rect.Top;
                xoff = rect.Left; yoff = rect.Top;
                xc   = yc = 1;
            }
            break;

            case ImageAlign.Tile:
            {
                xoff = rect.Left; yoff = rect.Top;
                xc   = (int)((rect.Right - rect.Left) / picw) + 1;
                yc   = (int)((rect.Bottom - rect.Top) / pich) + 1;
            }
            break;
            }

            if (pos != ImageAlign.Tile)
            {
                for (int x = 0; x < xc; x++)
                {
                    for (int y = 0; y < yc; y++)
                    {
                        g.DrawImage(pict, xoff + x * picw, yoff + y * pich, picw, pich);
                    }
                }
            }
            else
            {
                PointF ptLT2 = document.ClientToDoc(new Point(0, 0));
                PointF ptRB2 = document.ClientToDoc(new Point(
                                                        (int)(1 + (float)Math.Ceiling((double)pict.Size.Width /
                                                                                      pict.HorizontalResolution * g.DpiX * docZoom)),
                                                        (int)(1 + (float)Math.Ceiling((double)pict.Size.Height /
                                                                                      pict.VerticalResolution * g.DpiY * docZoom))));
                float picw2 = ptRB2.X - ptLT.X;
                float pich2 = ptRB2.Y - ptLT.Y;

                for (int x = 0; x < xc; x++)
                {
                    for (int y = 0; y < yc; y++)
                    {
                        g.DrawImage(pict, xoff + x * picw, yoff + y * pich, picw2, pich2);
                    }
                }
            }
        }