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)
     {
     }
 }
 public CreateInterface(Creator a, Equipment.Compatibility com = null)
 {
     InitializeComponent();
     father = a;
     if (com != null)
     {
         isRepl        = true;
         textBox3.Text = com.count.ToString();
         response      = new ServerToExecutive()
         {
             interfaceTypes = new InterfaceType[] { com.interfaceType }.ToList(), success = true, responseType = RequestType.GetInterfaces
         };
         if (com.isMama)
         {
             radioButton2.Checked = true;
         }
         else
         {
             radioButton1.Checked = true;
         }
         rebuildSelected(0);
     }
 }
 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();
                    }
                }
            }
        }