Exemple #1
0
        //LOAD NODE CONFIG
        private void nodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter      = "Implemented Node List (.csv)|*.csv";
            openFileDialog1.FilterIndex = 1;
            openFileDialog1.Multiselect = false;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                root_node        = null;
                loaded_node_list = openFileDialog1.FileName;
                try
                {
                    string[] lines = System.IO.File.ReadAllLines(openFileDialog1.FileName);
                    treeView1.BeginUpdate();
                    treeView1.Nodes.Clear();
                    treeView1.EndUpdate();

                    loaded_nodes.Clear();
                    //begin loading nodes to tree view
                    //the 1 to skip the headline
                    for (int i = 1; i < lines.Length; i++)
                    {
                        string   sel_line         = lines[i];
                        string[] splitted_content = sel_line.Split(';');

                        TreeNode tn = new TreeNode();
                        tn.Name = splitted_content[1];
                        tn.Text = splitted_content[2];

                        if (treeView1.Nodes["__cat__" + splitted_content[3]] == null)
                        {
                            TreeNode tmp_tn = new TreeNode();
                            tmp_tn.Name = "__cat__" + splitted_content[3];
                            tmp_tn.Text = splitted_content[3];
                            treeView1.Nodes.Add(tmp_tn);
                            treeView1.Nodes["__cat__" + splitted_content[3]].Nodes.Add(tn);
                            if (root_node != null)
                            {
                                root_node = tn;
                            }
                        }
                        else
                        {
                            treeView1.Nodes["__cat__" + splitted_content[3]].Nodes.Add(tn);
                        }

                        //CREATE PRPERTY CLASS
                        node tnode = new node();
                        tnode.category          = splitted_content[3];
                        tnode.xml_name          = splitted_content[1];
                        tnode.title             = splitted_content[2];
                        tnode.description       = splitted_content[13];
                        tnode.param_properties  = splitted_content[12];
                        tnode.output_con_string = splitted_content[11];
                        tnode.input_con_string  = splitted_content[10];
                        tnode.extention_name    = splitted_content[9];
                        tnode.class_name        = splitted_content[0];


                        if (splitted_content[4].ToLower().Contains("true"))
                        {
                            tnode.use_serial = true;
                        }
                        else
                        {
                            tnode.use_serial = false;
                        }


                        if (splitted_content[5].ToLower().Contains("true"))
                        {
                            tnode.is_static = true;
                        }
                        else
                        {
                            tnode.is_static = false;
                        }

                        if (splitted_content[14].ToLower().Contains("true"))
                        {
                            tnode.use_timer = true;
                        }
                        else
                        {
                            tnode.use_timer = false;
                        }

                        if (splitted_content[15].ToLower().Contains("true"))
                        {
                            tnode.is_lua_node = true;
                        }
                        else
                        {
                            tnode.is_lua_node = false;
                        }


                        if (splitted_content[8].ToLower().Contains("true"))
                        {
                            tnode.requires_extention = true;
                        }
                        else
                        {
                            tnode.requires_extention = false;
                        }


                        if (splitted_content[7].ToLower().Contains("true"))
                        {
                            tnode.pass_though = true;
                        }
                        else
                        {
                            tnode.pass_though = false;
                        }
                        tnode.idnr           = i;
                        tnode.extention_name = splitted_content[9];
                        loaded_nodes.Add(tnode);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Error while loading ");
                }
            }
        }
Exemple #2
0
 //MOUSE BUTTON UP PICTUREBOX
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     drag_node = null;
 }
Exemple #3
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            mouse_pos_rect.Location = e.Location;
            mouse_pos_rect.Size     = new Size(1, 1);
            if (mouse_pos_rect.IntersectsWith(new Rectangle(0, 0, drawing_bitmap.Width, drawing_bitmap.Height)))
            {
                for (int i = 0; i < schematic_nodes.Count; i++)
                {
                    if (schematic_nodes[i].clipping_recht.IntersectsWith(mouse_pos_rect))
                    {
                        //check if is in base rect
                        if (schematic_nodes[i].base_rect.IntersectsWith(mouse_pos_rect))
                        {
                            selected_connection = null;
                            drag_node           = schematic_nodes[i];
                            drag_node_offset.X  = (schematic_nodes[i].pos.x - mouse_pos_rect.Location.X);
                            drag_node_offset.Y  = (schematic_nodes[i].pos.y - mouse_pos_rect.Location.Y);
                            //switch to property plane
                            drag_node.create_property_plane(ref parameter_panel_form, ref node_title_text, ref node_nid_text, ref node_nsi_text);
                            if (selected_history_node != null)
                            {
                                //  selected_history_node.save_parameters(ref parameter_panel_form);
                            }
                            selected_history_node     = drag_node;
                            tabControl1.SelectedIndex = 2;
                        }
                        else
                        {
                            //check if mouse on a connector
                            for (int j = 0; j < schematic_nodes[i].connections.Count; j++)
                            {
                                if (schematic_nodes[i].connections[j].drawable_rect.IntersectsWith(mouse_pos_rect))
                                {
                                    //WENN NICHT LERR DANN VERBINFUNG MACHEN
                                    if (selected_connection == null)
                                    {
                                        selected_connection = schematic_nodes[i].connections[j];
                                    }
                                    else
                                    {
                                        connection second_clicked_connection = schematic_nodes[i].connections[j];
                                        if (second_clicked_connection.con_type == type.input && selected_connection.con_type == type.output)
                                        {
                                            connection_pair tmp_cpair = new connection_pair();
                                            tmp_cpair.source = selected_connection;
                                            tmp_cpair.target = second_clicked_connection;

                                            bool exits = false;
                                            for (int k = 0; k < connection_list.Count; k++)
                                            {
                                                if (connection_list[k].source.connection_id == tmp_cpair.source.connection_id && connection_list[k].source.parent_node_id == tmp_cpair.source.parent_node_id)
                                                {
                                                    if (connection_list[k].target.connection_id == tmp_cpair.target.connection_id && connection_list[k].target.parent_node_id == tmp_cpair.target.parent_node_id)
                                                    {
                                                        exits = true;
                                                    }
                                                }
                                            }

                                            if (!exits)
                                            {
                                                connection_list.Add(tmp_cpair);
                                            }
                                        }
                                        else if (second_clicked_connection.con_type == type.output && selected_connection.con_type == type.input)
                                        {
                                            connection_pair tmp_cpair = new connection_pair();
                                            tmp_cpair.source = second_clicked_connection;
                                            tmp_cpair.target = selected_connection;
                                            bool exits = false;
                                            for (int k = 0; k < connection_list.Count; k++)
                                            {
                                                if (connection_list[k].source.connection_id == tmp_cpair.source.connection_id && connection_list[k].source.parent_node_id == tmp_cpair.source.parent_node_id)
                                                {
                                                    if (connection_list[k].target.connection_id == tmp_cpair.target.connection_id && connection_list[k].target.parent_node_id == tmp_cpair.target.parent_node_id)
                                                    {
                                                        exits = true;
                                                    }
                                                }
                                            }

                                            if (!exits)
                                            {
                                                connection_list.Add(tmp_cpair);
                                            }
                                        }

                                        selected_connection = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //create 1x1 mouse click rect
            //fist is mouse on image
            //deltapos von der geklickten zur xy des nodes dmit es nicht springt
        }