Beispiel #1
0
        public DiagramControlUI()
        {
            InitializeComponent();

            ClientSize = new Size(640, 480);

            var node0 = new DiagramControl.BoxNode("Node0")
            {
                Position = m4x4.Translation(0, 0, 0)
            };
            var node1 = new DiagramControl.BoxNode {
                Text = "Node1 is really long\nand contains new lines", Position = m4x4.Translation(100, 100, 0)
            };
            var node2 = new DiagramControl.BoxNode("Node2 - Paul Rulz")
            {
                Position = m4x4.Translation(-100, -50, 0)
            };

            node1.Style = new DiagramControl.NodeStyle {
                Text = Color.Red
            };

            m_diag.Elements.Add(node0);
            m_diag.Elements.Add(node1);
            m_diag.Elements.Add(node2);

            node2.Enabled = false;

            m_diag.DefaultConnectorStyle.Smooth = true;
            var conn_type = DiagramControl.Connector.EType.BiDir;

            m_diag.Elements.Add(new DiagramControl.Connector(node0, node1)
            {
                Type = conn_type
            });
            m_diag.Elements.Add(new DiagramControl.Connector(node1, node2)
            {
                Type = conn_type
            });
            m_diag.Elements.Add(new DiagramControl.Connector(node2, node0)
            {
                Type = conn_type
            });

            var node4 = new DiagramControl.BoxNode("Node4")
            {
                PositionXY = new v2(-80, 60)
            };
            var node5 = new DiagramControl.BoxNode("Node5")
            {
                PositionXY = new v2(80, -60)
            };

            node4.Diagram = m_diag;
            node5.Diagram = m_diag;

            var combo = new ComboBox {
                DataSource = new[] { "Paul", "Was", "Here" }
            };

            node4.EditControl = new DiagramControl.EditingControl(combo
                                                                  , (elem, form) => combo.SelectedItem       = ((DiagramControl.Node)elem).Text
                                                                  , elem => ((DiagramControl.Node)elem).Text = (string)combo.SelectedItem);

            var conn4 = new DiagramControl.Connector(node4, node2)
            {
                Type = conn_type
            };
            var conn5 = new DiagramControl.Connector(node5, node4)
            {
                Type = conn_type
            };
            var conn6 = new DiagramControl.Connector(node1, node4)
            {
                Type = conn_type
            };

            conn4.Diagram = m_diag;
            conn5.Diagram = m_diag;
            conn6.Diagram = m_diag;

            node5.Dispose();
            node5 = null;

            var lbl1 = new Joypad();

            lbl1.Elem    = conn5;
            lbl1.Diagram = m_diag;

            m_diag.ResetView();

            node0.BringToFront();

            m_menu_tools_clear.Click        += (s, a) => m_diag.ResetDiagram();
            m_menu_tools_load.Click         += (s, a) => m_diag.ImportXml(m_diag_xml, m_diag.Elements.Count != 0);
            m_menu_tools_save.Click         += (s, a) => m_diag_xml = m_diag.ExportXml().ToString();
            m_menu_tools_loadmmapdiag.Click += (s, a) => m_diag.ImportXml(XDocument.Load("\\dump\\mmap_diag.xml").Root, true);
            m_menu_tools_load_options.Click += (s, a) => m_diag.Options = XDocument.Load("\\dump\\diag_options.xml").Root.Element("options").As <DiagramControl.DiagramOptions>();
            m_menu_tools_allowediting.Click += (s, a) => m_menu_tools_allowediting.Checked = m_diag.AllowChanges = !m_diag.AllowChanges;

            m_toolstripcont.TopToolStripPanel.Controls.Add(m_diag.EditToolstrip);
            m_diag.EditToolstrip.Visible          = true;
            m_diag.EditToolstrip.ImageScalingSize = new Size(22, 22);
            m_diag.EditToolstrip.AutoSize         = true;

            m_filter    = new Filter(this);
            Load       += (s, a) => Application.AddMessageFilter(m_filter);
            FormClosed += (s, a) => Application.RemoveMessageFilter(m_filter);

            m_diag.DiagramChanged += (s, a) =>
            {
                //switch (a.ChgType)
                //{
                //case DiagramControl.EDiagramChangeType.MoveLinkBegin:
                //	a.Cancel = true;
                //	break;
                //}
            };

            //const string options_filepath = ;
            //var xml = new XDocument();
            //xml.Add2(new XElement("root")).Add2("options", m_diag.Options, false);
            //xml.Save(options_filepath);

            //var tim = new System.Windows.Forms.Timer{Interval = 10};
            //tim.Tick += (s,a) =>
            //	{
            //		try
            //		{
            //			m_diag.Options = XDocument.Load(options_filepath).Root.Element("options").As<DiagramControl.DiagramOptions>();
            //			m_diag.ScatterNodes();
            //		}
            //		catch (Exception)
            //		{}
            //	};
            //tim.Start();
        }
Beispiel #2
0
        public DiagramUI()
        {
            InitializeComponent();

            var node0 = new DiagramControl.BoxNode("Node0")
            {
                Position = m4x4.Translation(0, 0, 0)
            };
            var node1 = new DiagramControl.BoxNode {
                Text = "Node1 is really long\nand contains new lines", Position = m4x4.Translation(100, 100, 0)
            };
            var node2 = new DiagramControl.BoxNode("Node2 - Paul Rulz")
            {
                Position = m4x4.Translation(-100, -50, 0)
            };

            node1.Style = new DiagramControl.NodeStyle {
                Text = System.Drawing.Color.Red
            };

            m_diag.Elements.Add(node0);
            m_diag.Elements.Add(node1);
            m_diag.Elements.Add(node2);

            node2.Enabled = false;

            m_diag.DefaultConnectorStyle.Smooth = true;
            var conn_type = DiagramControl.Connector.EType.BiDir;

            m_diag.Elements.Add(new DiagramControl.Connector(node0, node1)
            {
                Type = conn_type
            });
            m_diag.Elements.Add(new DiagramControl.Connector(node1, node2)
            {
                Type = conn_type
            });
            m_diag.Elements.Add(new DiagramControl.Connector(node2, node0)
            {
                Type = conn_type
            });

            var node4 = new DiagramControl.BoxNode("Node4")
            {
                PositionXY = new v2(-80, 60)
            };
            var node5 = new DiagramControl.BoxNode("Node5")
            {
                PositionXY = new v2(80, -60)
            };

            node4.Diagram = m_diag;
            node5.Diagram = m_diag;

            var combo = new System.Windows.Forms.ComboBox {
                DataSource = new[] { "Paul", "Was", "Here" }
            };

            node4.EditControl = new DiagramControl.EditingControl(combo
                                                                  , (elem, form) => combo.SelectedItem       = ((DiagramControl.Node)elem).Text
                                                                  , elem => ((DiagramControl.Node)elem).Text = (string)combo.SelectedItem);

            var conn4 = new DiagramControl.Connector(node4, node2)
            {
                Type = conn_type
            };
            var conn5 = new DiagramControl.Connector(node5, node4)
            {
                Type = conn_type
            };
            var conn6 = new DiagramControl.Connector(node1, node4)
            {
                Type = conn_type
            };

            conn4.Diagram = m_diag;
            conn5.Diagram = m_diag;
            conn6.Diagram = m_diag;

            node5.Dispose();
            node5 = null;

            var lbl1 = new Joypad();

            lbl1.Elem    = conn5;
            lbl1.Diagram = m_diag;

            m_diag.ResetView();

            node0.BringToFront();

            m_menu_file_clear.Click        += (s, a) => m_diag.ResetDiagram();
            m_menu_file_load.Click         += (s, a) => m_diag.ImportXml(m_diag_xml, m_diag.Elements.Count != 0);
            m_menu_file_save.Click         += (s, a) => m_diag_xml = m_diag.ExportXml().ToString();
            m_menu_file_load_options.Click += (s, a) => m_diag.Options = XDocument.Load("\\dump\\diag_options.xml").Root.Element("options").As <DiagramControl.DiagramOptions>();
            m_menu_file_editable.Click     += (s, a) => m_menu_file_editable.IsChecked = m_diag.AllowChanges = !m_diag.AllowChanges;

            //	m_toolstripcont.Controls.Add(m_diag.EditToolstrip);
            m_diag.EditToolstrip.Visible          = true;
            m_diag.EditToolstrip.ImageScalingSize = new System.Drawing.Size(22, 22);
            m_diag.EditToolstrip.AutoSize         = true;

            m_diag.DiagramChanged += (s, a) =>
            {
                //switch (a.ChgType)
                //{
                //case DiagramControl.EDiagramChangeType.MoveLinkBegin:
                //	a.Cancel = true;
                //	break;
                //}
            };
        }