示例#1
0
        public Schemes_Editor()
        {
            InitializeComponent();



            pictureBox3.MouseDown += new System.Windows.Forms.MouseEventHandler(PlacementController.DOWN);
            pictureBox3.MouseMove += new System.Windows.Forms.MouseEventHandler(PlacementController.MOVE);
            pictureBox3.MouseUp   += new System.Windows.Forms.MouseEventHandler(PlacementController.UP);

            pictureBox2.MouseDown += new System.Windows.Forms.MouseEventHandler(ConnectionController.DOWN);
            pictureBox2.MouseMove += new System.Windows.Forms.MouseEventHandler(ConnectionController.MOVE);
            pictureBox2.MouseUp   += new System.Windows.Forms.MouseEventHandler(ConnectionController.UP);

            pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(BoxController.DOWN);
            pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(BoxController.MOVE);
            pictureBox1.MouseUp   += new System.Windows.Forms.MouseEventHandler(BoxController.UP);

            strct.MouseDown += new System.Windows.Forms.MouseEventHandler(StructuralController.DOWN);
            strct.MouseMove += new System.Windows.Forms.MouseEventHandler(StructuralController.MOVE);
            strct.MouseUp   += new System.Windows.Forms.MouseEventHandler(StructuralController.UP);


            BoxController.father        = this;
            ConnectionController.father = this;
            PlacementController.father  = this;
            StructuralController.father = this;

            bitmaps[0] = new Bitmap(pictureBox3.Width, pictureBox3.Height);
            bitmaps[1] = new Bitmap(pictureBox2.Width, pictureBox2.Height);
            bitmaps[2] = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            bitmaps[3] = new Bitmap(strct.Width, strct.Height);
            sheets     = new PictureBox[] { pictureBox3, pictureBox2, pictureBox1, strct };
            for (int i = 0; i < 4; i++)
            {
                gr[i] = Graphics.FromImage(bitmaps[i]);
                gr[i].SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            }

            RevitProvider.synchronizer();
        }
示例#2
0
        public void copy(int globalID, drawer elem = null)
        {
            int id = -1;

            if (elem != null)
            {
                var target = mainList.Find(x => x.id == elem.globalId);

                id = RevitProvider.copy(target);


                if (target.isBox)
                {
                    mainWorkList.Add(new boxes()
                    {
                        localID = id, globalId = elem.globalId, locations = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) }, scales = new List <Point>(elem.scales).ToArray()
                    });
                }
                else if (target.isInBox)
                {
                    mainWorkList.Add(new inboxes()
                    {
                        numberOfUnits = Convert.ToInt32(target.properties["Занимаемых юнитов (шт)"]),
                        localID       = id,
                        globalId      = elem.globalId,
                        locations     = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) },
                        scales        = new List <Point>(elem.scales).ToArray()
                    });
                }
                else
                {
                    mainWorkList.Add(new free()
                    {
                        localID   = id,
                        globalId  = elem.globalId,
                        locations = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) },
                        scales    = new List <Point>(elem.scales).ToArray()
                    });
                }
            }
            else
            {
                var target = mainList.Find(x => x.id == globalID);

                int current = -1;
                foreach (var i in mainWorkList)
                {
                    if (i.localID > current)
                    {
                        current = i.localID;
                    }
                }
                current++;


                if (target.compatibilities.Count == 1)
                {
                    wires.Add(new Wire()
                    {
                        MyOwnFirst = target.compatibilities[0], MyOwnSecond = target.compatibilities[0]
                    });
                }
                else
                {
                    wires.Add(new Wire()
                    {
                        MyOwnFirst = target.compatibilities[0], MyOwnSecond = target.compatibilities[1]
                    });
                }
                tabControl1.SelectedIndex = 1;
                //      MessageBox.Show("выберите начальное оборудование");
                ConnectionController.targetWire = wires[wires.Count - 1];
                ConnectionController.Mode       = modeConnection.buildConnection;
            }
        }
示例#3
0
        private void добавитьСхемуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Searcher searcher = new Searcher();

            if (searcher.ShowDialog() == DialogResult.OK)
            {
                Equipment result            = searcher.result;
                List <Equipment.Point> fake = new List <Equipment.Point>();
                radiusesFixer(ref result, ref fake);
                if (result.isBox)
                {
                    mainList.RemoveAll(x => x.id == result.id);
                    mainList.Add(result);



                    List <Point> real = new List <Point>();
                    for (int i = 0; i < 4; i++)
                    {
                        if (fake[i] == null)
                        {
                            real.Add(new Point(100, 100)); continue;
                        }
                        float x = (float)Math.Sqrt(10000 / (fake[i].X * fake[i].Y));
                        real.Add(new Point()
                        {
                            X = (int)(fake[i].X * x), Y = (int)(fake[i].Y * x)
                        });
                    }


                    int    id        = RevitProvider.createInstance(result.bytedFile, result.name);
                    bool   hasFamily = id != -1;
                    Random r         = new Random();
                    if (!hasFamily)
                    {
                        id = -1 * r.Next(0, int.MaxValue);
                        while (mainWorkList.Exists(x => x.localID == id))
                        {
                            id = -1 * r.Next(0, int.MaxValue);
                        }
                    }
                    mainWorkList.Add(new boxes()
                    {
                        hasFamily = hasFamily, localID = id, globalId = result.id, locations = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) }, scales = real.ToArray()
                    });
                    List <drawer> sortedList = new List <drawer>();
                    sortedList.AddRange(mainWorkList.FindAll(x => x is boxes));
                    sortedList.AddRange(mainWorkList.FindAll(x => !(x is boxes)));
                    mainWorkList = sortedList;
                }
                else if (result.isInBox)
                {
                    mainList.RemoveAll(x => x.id == result.id);
                    mainList.Add(result);


                    //calculate proportions for 10 000


                    List <Point> real = new List <Point>();
                    for (int i = 0; i < 4; i++)
                    {
                        if (fake[i] == null)
                        {
                            real.Add(new Point(100, 100));
                            continue;
                        }
                        float x = (float)Math.Sqrt(10000 / (fake[i].X * fake[i].Y));
                        real.Add(new Point()
                        {
                            X = (int)(fake[i].X * x), Y = (int)(fake[i].Y * x)
                        });
                    }


                    int    id        = RevitProvider.createInstance(result.bytedFile, result.name);
                    bool   hasFamily = id != -1;
                    Random r         = new Random();
                    if (!hasFamily)
                    {
                        id = -1 * r.Next(0, int.MaxValue);
                        while (mainWorkList.Exists(x => x.localID == id))
                        {
                            id = -1 * r.Next(0, int.MaxValue);
                        }
                    }

                    mainWorkList.Add(new inboxes()
                    {
                        hasFamily     = hasFamily,
                        numberOfUnits = Convert.ToInt32(result.properties["Занимаемых юнитов (шт)"]),
                        localID       = id,
                        globalId      = result.id,
                        locations     = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) },
                        scales        = real.ToArray()
                    });
                }
                else if (result.isWire)
                {
                    int current = -1;
                    foreach (var i in wires)
                    {
                        if (i.localID > current)
                        {
                            current = i.localID;
                        }
                    }
                    current++;
                    if (!mainList.Exists(x => x.id == result.id))
                    {
                        mainList.Add(result);
                    }


                    if (result.compatibilities.Count == 1)
                    {
                        wires.Add(new Wire()
                        {
                            localID = current, globalId = result.id, MyOwnFirst = result.compatibilities[0], MyOwnSecond = result.compatibilities[0]
                        });
                    }
                    else
                    {
                        wires.Add(new Wire()
                        {
                            localID = current, globalId = result.id, MyOwnFirst = result.compatibilities[0], MyOwnSecond = result.compatibilities[1]
                        });
                    }
                    tabControl1.SelectedIndex = 1;
                    //      MessageBox.Show("выберите начальное оборудование");
                    ConnectionController.targetWire = wires[wires.Count - 1];
                    ConnectionController.Mode       = modeConnection.buildConnection;
                }
                else
                {
                    mainList.RemoveAll(x => x.id == result.id);
                    mainList.Add(result);
                    //calculate proportions for 10 000

                    List <Point> real = new List <Point>();
                    for (int i = 0; i < 4; i++)
                    {
                        if (fake[i] == null)
                        {
                            real.Add(new Point(100, 100)); continue;
                        }
                        float x = (float)Math.Sqrt(10000 / (fake[i].X * fake[i].Y));
                        real.Add(new Point()
                        {
                            X = (int)(fake[i].X * x), Y = (int)(fake[i].Y * x)
                        });
                    }

                    int    id        = RevitProvider.createInstance(result.bytedFile, result.name);
                    bool   hasFamily = id != -1;
                    Random r         = new Random();
                    if (!hasFamily)
                    {
                        id = -1 * r.Next(0, int.MaxValue);
                        while (mainWorkList.Exists(x => x.localID == id))
                        {
                            id = -1 * r.Next(0, int.MaxValue);
                        }
                    }

                    mainWorkList.Add(new free()
                    {
                        hasFamily = hasFamily,
                        localID   = id,
                        globalId  = result.id,
                        locations = new Point[] { new Point(0, 0), new Point(0, 0), new Point(0, 0), new Point(0, 0) },
                        scales    = real.ToArray()
                    });
                }
                foreach (var i in mainWorkList)
                {
                    i.drawBox(gr[sheetIndex]);
                }
                pictureBox3.Image = bitmaps[0];
                pictureBox2.Image = bitmaps[1];
                pictureBox1.Image = bitmaps[2];
                strct.Image       = bitmaps[3];
                Refresh();
            }
        }