Пример #1
0
        //MOUSE BUTTONS CLICK PICTUREBOX
        private void pictureBox1_MouseDoubleClick(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 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))
                            {
                                connection tmp_con = schematic_nodes[i].connections[j];

                                for (int k = 0; k < connection_list.Count; k++)
                                {
                                    if (tmp_con.con_type == type.output)
                                    {
                                        if (tmp_con.connection_id == connection_list[k].source.connection_id && tmp_con.parent_node_id == connection_list[k].source.parent_node_id)
                                        {
                                            connection_list.Remove(connection_list[k]);
                                        }
                                    }
                                    else if (tmp_con.con_type == type.input)
                                    {
                                        if (tmp_con.connection_id == connection_list[k].target.connection_id && tmp_con.parent_node_id == connection_list[k].target.parent_node_id)
                                        {
                                            connection_list.Remove(connection_list[k]);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public void create_drawable()
        {
            int rect_width   = 3 * distance_betewenn_con_text;
            int recht_height = 3 * headline_text_distance;

            int intput_con_amount = 0;
            int output_con_amount = 0;

            for (int i = 0; i < connections.Count; i++)
            {
                connection tmp_con = connections[i];

                if (tmp_con.con_type == type.input)
                {
                    intput_con_amount++;
                    if ((tmp_con.description.Length * char_lenght_multiplier) > distance_between_border_and_inputtext_end)
                    {
                        distance_between_border_and_inputtext_end = (tmp_con.description.Length * char_lenght_multiplier);
                    }
                }

                if (tmp_con.con_type == type.output)
                {
                    output_con_amount++;
                    if ((tmp_con.description.Length * char_lenght_multiplier) > distance_between_border_and_outputtext_end)
                    {
                        distance_between_border_and_outputtext_end = (tmp_con.description.Length * char_lenght_multiplier);
                    }
                }
            }
            //CALC BASE RECT
            if (output_con_amount > intput_con_amount)
            {
                recht_height = (distance_between_connections * output_con_amount) + headline_text_distance;
            }
            else
            {
                recht_height = (distance_between_connections * intput_con_amount) + headline_text_distance;
            }

            rect_width         = distance_betewenn_con_text + distance_between_border_and_outputtext_end + distance_between_border_and_inputtext_end;
            base_rect.Size     = new Size(rect_width, recht_height);
            base_rect.Location = new Point(pos.x, pos.y);
            //CALC CLIPPING RECT
            clipping_recht.Location = new Point(pos.x - connection_rect_widht, pos.y);
            clipping_recht.Size     = new Size(rect_width + (2 * connection_rect_widht), recht_height);

            //CALC HEADLINE TEXT RECT
            headline_rect.Location = base_rect.Location; //TODO: center it
            headline_rect.Size     = new Size(title.Length * char_lenght_multiplier, headline_text_distance);

            Point input_cons_start_point  = new Point(base_rect.X, base_rect.Y + headline_text_distance);
            Point output_cons_start_point = new Point(base_rect.X + base_rect.Width, base_rect.Y + headline_text_distance);

            intput_con_amount = 0;
            output_con_amount = 0;

            for (int i = 0; i < connections.Count; i++)
            {
                connection tmp_con = connections[i];
                if (tmp_con.con_type == type.input)
                {
                    tmp_con.drawable_rect.Location = new Point(input_cons_start_point.X - connection_rect_widht, input_cons_start_point.Y + (intput_con_amount * distance_between_connections));
                    tmp_con.drawable_rect.Size     = new Size(connection_rect_widht, connection_rect_height);

                    tmp_con.text_rect.Location = new Point(input_cons_start_point.X + connection_rect_widht, tmp_con.drawable_rect.Location.Y);
                    tmp_con.text_rect.Size     = new Size(tmp_con.description.Length * char_lenght_multiplier, connection_rect_height);


                    connections[i] = tmp_con;
                    intput_con_amount++;
                }


                if (tmp_con.con_type == type.output)
                {
                    tmp_con.drawable_rect.Location = new Point(output_cons_start_point.X, output_cons_start_point.Y + (output_con_amount * distance_between_connections));
                    tmp_con.drawable_rect.Size     = new Size(connection_rect_widht, connection_rect_height);

                    tmp_con.text_rect.Location = new Point(tmp_con.drawable_rect.Location.X - (tmp_con.description.Length * char_lenght_multiplier), tmp_con.drawable_rect.Location.Y);
                    tmp_con.text_rect.Size     = new Size(tmp_con.description.Length * char_lenght_multiplier, connection_rect_height);


                    connections[i] = tmp_con;
                    output_con_amount++;
                }
            }
        }
Пример #3
0
        public void create_connection_list()
        {
            connections.Clear();
            {
                if (input_con_string != "")
                {
                    string[] splitted_input_string = input_con_string.Split('%');
                    if (splitted_input_string.Length > 0)
                    {
                        for (int i = 0; i < splitted_input_string.Length; i++)
                        {
                            if (splitted_input_string[i] == "")
                            {
                                break;
                            }
                            string[]   one_input_string = splitted_input_string[i].Substring(1, splitted_input_string[i].Length - 2).Split(',');
                            connection tmp_con          = new connection();
                            tmp_con.parent_node_id = nid;
                            tmp_con.con_type       = type.input;
                            tmp_con.connection_id  = Int32.Parse(one_input_string[0]);
                            tmp_con.description    = one_input_string[2];

                            if (one_input_string[1] == "" || one_input_string[1].ToLower() == "none")
                            {
                                tmp_con.con_dtype = datatype._none; tmp_con.con_color = Color.Black;
                            }
                            if (one_input_string[1].ToLower() == "string")
                            {
                                tmp_con.con_dtype = datatype._string; tmp_con.con_color = Color.OrangeRed;
                            }
                            if (one_input_string[1].ToLower() == "float")
                            {
                                tmp_con.con_dtype = datatype._float; tmp_con.con_color = Color.Cyan;
                            }
                            if (one_input_string[1].ToLower() == "special")
                            {
                                tmp_con.con_dtype = datatype._special; tmp_con.con_color = Color.Yellow;
                            }
                            if (one_input_string[1].ToLower() == "generic")
                            {
                                tmp_con.con_dtype = datatype._generic; tmp_con.con_color = Color.Violet;
                            }
                            if (one_input_string[1].ToLower() == "color")
                            {
                                tmp_con.con_dtype = datatype._color; tmp_con.con_color = Color.Plum;
                            }
                            if (one_input_string[1].ToLower() == "bool")
                            {
                                tmp_con.con_dtype = datatype._bool; tmp_con.con_color = Color.DarkSeaGreen;
                            }
                            if (one_input_string[1].ToLower() == "int")
                            {
                                tmp_con.con_dtype = datatype._int; tmp_con.con_color = Color.Azure;
                            }
                            connections.Add(tmp_con);
                        }
                    }
                }
            }



            {
                if (output_con_string != "")
                {
                    string[] splitted_input_string = output_con_string.Split('%');
                    if (splitted_input_string.Length > 0)
                    {
                        for (int i = 0; i < splitted_input_string.Length; i++)
                        {
                            if (splitted_input_string[i] == "")
                            {
                                break;
                            }
                            string[]   one_input_string = splitted_input_string[i].Substring(1, splitted_input_string[i].Length - 2).Split(',');
                            connection tmp_con          = new connection();
                            tmp_con.parent_node_id = nid;


                            tmp_con.con_type      = type.output;
                            tmp_con.connection_id = Int32.Parse(one_input_string[0]);
                            tmp_con.description   = one_input_string[2];
                            if (one_input_string[1].ToLower() == "string")
                            {
                                tmp_con.con_dtype = datatype._string; tmp_con.con_color = Color.OrangeRed;
                            }
                            if (one_input_string[1].ToLower() == "float")
                            {
                                tmp_con.con_dtype = datatype._float; tmp_con.con_color = Color.Cyan;
                            }
                            if (one_input_string[1].ToLower() == "special")
                            {
                                tmp_con.con_dtype = datatype._special; tmp_con.con_color = Color.Yellow;
                            }
                            if (one_input_string[1].ToLower() == "generic")
                            {
                                tmp_con.con_dtype = datatype._generic; tmp_con.con_color = Color.Violet;
                            }
                            if (one_input_string[1].ToLower() == "color")
                            {
                                tmp_con.con_dtype = datatype._color; tmp_con.con_color = Color.Plum;
                            }
                            if (one_input_string[1].ToLower() == "bool")
                            {
                                tmp_con.con_dtype = datatype._bool; tmp_con.con_color = Color.DarkSeaGreen;
                            }
                            if (one_input_string[1].ToLower() == "int")
                            {
                                tmp_con.con_dtype = datatype._int; tmp_con.con_color = Color.Azure;
                            }
                            connections.Add(tmp_con);
                        }
                    }
                }
            }
            //den connectionstring druchgehen und passend splitten
        }
Пример #4
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
        }