Example #1
0
        public void CreateNewLine()
        {
            My_Line line = new My_Line(this);

            UnselectAll();
            SelectedFigure = line;
            SelectedFigures.Add(line);
            picture.FigureList.Add(line);
            Lock = true;
        }
Example #2
0
        public My_Line(My_Line item)
            : base(item)
        {
            point1 = item.point1;
            point2 = item.point2;

            mouse_move = MouseMove;
            mouse_down = MouseDown;
            mouse_up   = MouseUp;
            draw       = Draw;
        }
Example #3
0
        private void GenerateFigures()
        {
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            int InPortsCount  = SelectedEntity.ports.Count((f) => f.inout == portInOut.In);
            int OutPortsCount = SelectedEntity.ports.Count - InPortsCount;

            int Max_Input_Port = 0;
            int Max_Out_Port   = 0;

            foreach (vhdPort p in SelectedEntity.ports)
            {
                if ((p.inout == portInOut.In) && (p.name.Length > Max_Input_Port))
                {
                    Max_Input_Port = p.name.Length;
                }
                if ((p.inout != portInOut.Out) && (p.name.Length > Max_Out_Port))
                {
                    Max_Out_Port = p.name.Length;
                }
            }

            int width  = (SelectedEntity.name.Length + Max_Input_Port + Max_Out_Port) * 10 + 10;
            int height = (Math.Max(InPortsCount, OutPortsCount)) * 15;

            Point Location = new Point(200, 200);

            My_Rectangle rect = new My_Rectangle(core, new Rectangle(200, 200, width, height));

            rect.zIndex--;
            My_Line line1 = new My_Line(core, new Point(200 + Max_Input_Port * 10, 200), new Point(200 + 10 * Max_Input_Port, 200 + height));

            line1.zIndex++;
            My_Line line2 = new My_Line(core, new Point(200 + width - 10 * Max_Out_Port, 200), new Point(200 + width - 10 * Max_Out_Port, 200 + height));

            line2.zIndex++;
            My_Text text = new My_Text(core, SelectedEntity.name, new Point(200 + (width / 2), 200 + (height / 2)));

            int delta = (InPortsCount != 0)?height / InPortsCount:0;
            int index = 0;

            foreach (vhdPort p in SelectedEntity.ports)
            {
                if (p.inout != portInOut.In)
                {
                    continue;
                }

                My_Port port = new My_Port(core, p.name, My_Port.PortType.Simple, false, p, new Point(190, 200 + delta / 2 + delta * index), new Point(200, 200 + delta / 2 + delta * index));
                port.TextLabel.CenterPoint = new Point(port.CenterPoint.X + Max_Input_Port * 5, port.CenterPoint.Y);
                port.zIndex++;
                figures.Add(port);
                index++;
            }

            delta = (InPortsCount != 0) ? height / OutPortsCount : 0;
            index = 0;
            foreach (vhdPort p in SelectedEntity.ports)
            {
                if (p.inout == portInOut.In)
                {
                    continue;
                }

                My_Port port = new My_Port(core, p.name, My_Port.PortType.Simple, false, p, new Point(200 + width + 10, 200 + delta / 2 + delta * index), new Point(200 + width, 200 + delta / 2 + delta * index));
                port.TextLabel.CenterPoint = new Point(port.CenterPoint.X - Max_Input_Port * 5, port.CenterPoint.Y);
                port.zIndex++;
                figures.Add(port);
                index++;
            }

            figures.Add(rect);
            figures.Add(line1);
            figures.Add(line2);
            figures.Add(text);
            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }