Beispiel #1
0
        public void listAddClick(int index)
        {
            Internet.send(new ExecutiveToServer()
            {
                requestType = RequestType.GetThird, searchString = textBox2.Text, equipmentId = list[index].id
            });
            ServerToExecutive response = Internet.receive();

            result = response.equipments[0];

            DialogResult = DialogResult.OK;
            Close();
        }
Beispiel #2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         Internet.send(new ExecutiveToServer()
         {
             requestType = RequestType.GetFirst, searchString = textBox2.Text
         });
         ServerToExecutive response = Internet.receive();
         if (response.success)
         {
             list = response.equipments;
             Searcher_Resize(null, null);
         }
     }catch (Exception ex)
     {
     }
 }
Beispiel #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     Internet.send(new ExecutiveToServer()
     {
         requestType = RequestType.AddInterface, interfaceType = new InterfaceType()
         {
             name = textBox1.Text, image = image
         }
     });
     if (Internet.receive().success)
     {
         MessageBox.Show("Получилось) теперь пробуйте найти свой порт");
         Close();
     }
     else
     {
         MessageBox.Show("Не получилось");
     }
 }
 private void textBox1_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         //send to server
         Internet.send(new ExecutiveToServer()
         {
             requestType = RequestType.GetInterfaces, searchString = textBox1.Text
         });
         response = Internet.receive();
         if (response.success)
         {
             panel1.Controls.Clear();
             int cols = (panel1.Width - 1) / 101;
             for (int i = 0; i < response.interfaceTypes.Count; i++)
             {
                 PictureBox box = new PictureBox()
                 {
                     Width = 100, Height = 120
                 };
                 box.SizeMode = PictureBoxSizeMode.StretchImage;
                 Bitmap   b = new Bitmap(100, 120);
                 Graphics g = Graphics.FromImage(b);
                 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                 g.DrawImage(Image.FromStream(new MemoryStream(Convert.FromBase64String(response.interfaceTypes[i].image))), 0, 20, 100, 100);
                 g.DrawString(response.interfaceTypes[i].name, new Font("Arial", 8), Brushes.Black, 4, 4);
                 int i_buf = i;
                 box.MouseDown += (aa, bb) => rebuildSelected(i_buf);
                 panel1.Controls.Add(box);
                 box.Location = new Point(101 * (i % cols), 121 * (i / cols));
                 box.Image    = b;
                 box.Refresh();
             }
             Refresh();
         }
     }
 }
        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Internet.send(new ExecutiveToServer()
                {
                    requestType = RequestType.GetEquipmentWithFamilies, searchString = textBox1.Text
                });
                response = Internet.receive();
                if (response.success)
                {
                    for (int i = 0; i < response.equipments.Count; i++)
                    {
                        TableLayoutPanel panel = new TableLayoutPanel();
                        panel.RowCount    = 2;
                        panel.ColumnCount = 3;
                        panel.RowStyles.Clear();
                        for (int j = 0; j < 2; j++)
                        {
                            panel.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
                        }
                        panel.ColumnStyles.Clear();
                        panel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150));
                        panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
                        panel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 150));

                        PictureBox box = new PictureBox()
                        {
                            Width = 150, Height = 150
                        };
                        box.Image = Image.FromStream(new MemoryStream(Convert.FromBase64String(response.equipments[i].preview)));
                        panel.Controls.Add(box, 0, 0);
                        panel.SetRowSpan(box, 2);

                        Label name = new Label()
                        {
                            Text = response.equipments[i].name, Dock = DockStyle.Fill
                        };
                        panel.Controls.Add(name, 1, 0);

                        Label desc = new Label()
                        {
                            Text = response.equipments[i].description, Dock = DockStyle.Fill
                        };
                        panel.Controls.Add(desc, 1, 1);

                        Button add = new Button()
                        {
                            Text = "Добавить"
                        };
                        int buff = i;
                        add.MouseClick += (a, b) =>
                        {
                            equipment    = response.equipments[i];
                            DialogResult = DialogResult.OK;
                            Close();
                        };
                        panel.Controls.Add(add, 2, 0);

                        panel1.Controls.Add(panel);
                        panel.Location = new Point(0, 151 * i);
                        Refresh();
                    }
                }
            }
        }
        private void добавитьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            result             = new Equipment();
            result.id          = Convert.ToInt32(textBox3.Text);
            result.name        = textBox1.Text;
            result.description = textBox2.Text;
            if (forFamilyId == null)
            {
                try
                {
                    result.bytedFile = File.ReadAllBytes(label12.Text);
                }
                catch (Exception ex) { }
            }
            else
            {
                result.familyID = forFamilyId.familyID;
            }
            result.compatibilities = list;
            Dictionary <string, string> slov = new Dictionary <string, string>();

            for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
            {
                slov.Add(dataGridView1.Rows[i].Cells[0].Value.ToString(), dataGridView1.Rows[i].Cells[1].Value.ToString());
            }
            result.properties = slov;
            result.PICS       = new List <string>();
            MemoryStream ms;

            for (int i = 0; i < photos.Count; i++)
            {
                if (photos[i] == null)
                {
                    break;
                }
                ms = new MemoryStream();
                photos[i].Save(ms, ImageFormat.Png);
                result.PICS.Add(Convert.ToBase64String(ms.ToArray()));
            }
            try
            {
                //result.inBox_v = Equipment.vectorization(images[0]);
                //result.inConnectionScheme_v = Equipment.vectorization(images[1]);
                //result.inStructural_v = Equipment.vectorization(images[2]);
                //result.placementScheme_v = Equipment.vectorization(images[3]);
                result.inBox = vectorImages[0];
                result.inConnectionScheme = vectorImages[1];
                result.inStructural       = vectorImages[2];
                result.inPlacementScheme  = vectorImages[3];
            }
            catch (Exception ex) { }

            result.isWire  = radioButton1.Checked;
            result.isBox   = radioButton3.Checked;
            result.isInBox = radioButton5.Checked;
            Internet.send(new ExecutiveToServer()
            {
                equipment = result, requestType = RequestType.AddEquipment
            });
            if (Internet.receive().success)
            {
                DialogResult = DialogResult.OK;
                MessageBox.Show("Все прошло успешно");
                Close();
            }
            status();
        }