Esempio n. 1
0
            public TestingObject(string __text, Image __image, Object __resourceObject, TestForm __testForm)
            {
                this.Text  = __text;
                this.Image = __image;

                this.Dock      = DockStyle.Top;
                this.Height    = 50;
                this.BackColor = Color.FromArgb(40, 43, 51);
                this.ForeColor = Color.White;
                this.Font      = new Font("Microsoft YaHei", 10F, FontStyle.Regular);
                this.FlatStyle = FlatStyle.Flat;
                this.FlatAppearance.BorderColor        = Color.FromArgb(35, 38, 46);
                this.FlatAppearance.MouseOverBackColor = Color.FromArgb(0, 195, 165);
                this.Cursor     = Cursors.Hand;
                this.ImageAlign = ContentAlignment.MiddleLeft;
                this.Content    = __resourceObject;
                this.Click     += TestingObject_Click;
                this.tf         = __testForm;
            }
Esempio n. 2
0
        public void goTest_Click(object sender, EventArgs e)
        {
            sidePanelHide();
            // Otworz okno z scenariuszami testowymi
            TestForm testForm = new TestForm();

            // Otworz jako okno dialogowe (blokuj interakcje z tlem)
            testForm.ShowDialog();

            // Jesli wybrano jakis element
            if (testForm.objectReference is null)
            {
                // Wcisnieto przycisk Close w TestForm
                Debug.WriteLine("Nie wybrano nic.");
            }
            else
            {
                // Wybrano jakis obiekt
                Object objectSelected = testForm.objectReference;
                string objectName     = testForm.objectName;
                Debug.WriteLine($"Wybrano {objectName}, {objectSelected.ToString()}!");

                // Okresl typ obiektu wybranego
                if (objectSelected is System.Byte[])
                {
                    // Obiekt to System.Byte[] czyli lancuch znakow
                    // Konwertuj `Byte[]` do `string`
                    string objectSelectedToString = System.Text.Encoding.Default.GetString((Byte[])objectSelected);
                    // Konwertuj `string` do `List<string>`
                    List <string> objectSelectedToGCode = objectSelectedToString.Split(new char[] { '\n' }).ToList();
                    // Zamknij otwarty serialPort
                    CloseSerialPort();
                    // Wylacz kontrole panelu na MainForm
                    setControlPanelDisabled();
                    // Rozlacz laser
                    SetLaserDisconnected();
                    // Ustaw StatusBox na busy
                    setStatusBoxStatus(StatusBoxStatus.Busy, serialPort.PortName);

                    // Inicjalizacja procesu grawerowania, okno EngravingForm
                    try
                    {
                        EngravingForm engravingForm = new EngravingForm(
                            $"obrazu testowego {objectName}", objectSelectedToGCode
                            );
                        // Otworz jako okno dialogowe
                        engravingForm.ShowDialog();
                    }
                    catch
                    {
                        DialogResult messageBox = MessageBox.Show("Proces anulowano!",
                                                                  "Grawerowanie",
                                                                  MessageBoxButtons.OK,
                                                                  MessageBoxIcon.Warning
                                                                  );
                    }
                }
                else if (testForm.objectReference is System.Drawing.Bitmap)
                {
                    // :)
                }
            }
        }