Exemplo n.º 1
0
        public Plate_Window()
        {
            InitializeComponent();

            timer_PlateLink          = new System.Threading.Timer(PlateTimeLink, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10));
            OnLineLable.BackColor    = Color.DarkRed;
            Plate_.PlateCallBack     = new Action <string, uint>(PlateCallBack);
            PlateStar               += Plate_.CallbackFuntion;
            Plate_.GetmessageAction  = new Action <string>(Message);
            Plate_.PlateDataCallBack = new Action <string, string, string, string>(PlateDataInfoOut);
            Plate_.JpegCallBack      = new Action <byte[]>(JpegCallBack);
            Plate_.DataJpegCallBack  = new Action <byte[]>(DataJpeg);
            setRelayClose           += Plate_.SetRelayClose;
            PlateSettiger           += Plate_.SetTrigger;
            PlateQuitDevice         += Plate_.QuitDevice;
            PlayAction               = new Action <bool>(Plate_.Play);
            Send485Action            = new Action <string>(Plate_.RS485Send);
            SetIpAction              = new Action <string>(Plate_.SetIpNetwork);
            SetSaveImg               = new Action <string>(Plate_.SetSavrImagePath);
            PlateSearchDevice       += Plate_.SearchDeviceList;

            PlateIpTextBox.Text   = Properties.Settings.Default.PlateIPAddr;
            PlatePortTextBox.Text = Properties.Settings.Default.PlatePort.ToString();
            PlateSetIp();
            PlateSetPath();

            LinkButton.Hide();
            AbortButton.Hide();
            TiggerButton.Hide();
            LinkButton.Hide();
            LiftingButton.Hide();
            TransmissionButton.Hide();
            SearchButton.Hide();
            SetIpButton.Hide();
            SetPathButton.Hide();
            OpenButton.Hide();
            CloseButton.Hide();
            OnLineLable.Hide();
        }
Exemplo n.º 2
0
        private void SquezeButton_Click(object sender, EventArgs e)
        {
            if (selectedState == null)
            {
                DialogResult rezult = MessageBox.Show("Choose image fourth.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else if (SourceImage.Image == null)
            {
                DialogResult rezult = MessageBox.Show("Choose image.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else
            {
                SaveButton.Location = new Point(OpenButton.Location.X, OpenButton.Location.Y);
                SaveButton.Show();
                FileName.Text = "File path ...";
                OpenButton.Hide();

                for (int i = 0; i < 256; i++)
                {
                    ArrR[i]  = new double[256];
                    ArrG[i]  = new double[256];
                    ArrB[i]  = new double[256];
                    ArrR1[i] = new double[256];
                    ArrG1[i] = new double[256];
                    ArrB1[i] = new double[256];
                }

                code.ImageToArray(image, ref ArrR, ref ArrG, ref ArrB, sFileName);
                code.Fragmentation(ArrR, ArrG, ArrB, coordX, coordY);
                code.Comprassion(ref timeMain, ref timeBg);
                code.Merge(ref ArrR1, ref ArrG1, ref ArrB1);
                code.Calculation(ref SKO, ref PSNR, ArrR, ArrG, ArrB, ArrR1, ArrG1, ArrB1);
                code.ArrayToImage(ref image, ArrR1, ArrG1, ArrB1);
                ResultImage.Image = image;
                ResultImage.Invalidate();
                sFileName = "C:\\Users\\Public\\Documents\\AdaptiveComprassion\\tmp";
                System.IO.Directory.CreateDirectory("C:\\Users\\Public\\Documents\\AdaptiveComprassion");
                if (System.IO.File.Exists(sFileName))
                {
                    do
                    {
                        sFileName += DateTime.Now.Minute;
                    } while (System.IO.File.Exists(sFileName));
                }
                image.Save(sFileName, System.Drawing.Imaging.ImageFormat.Png);
                FileInfo imageInfo = new FileInfo(sFileName);
                resultSizeInKBytes = Convert.ToInt32(imageInfo.Length / 1024);
                File.Delete("C:\\Users\\Public\\Documents\\AdaptiveComprassion\\tmp");
                sFileName = null;

                conn.Open();
                string insert = "INSERT INTO Characteristics (Data, InputS, OutputS, RatioMain, RatioBg, TimeMain, TimeBg, NN1, NN2, SKO, PSNR) VALUES ( ";
                insert += "'" + Dat.ToString() + "', " + sourceSizeInKBytes + ", " + resultSizeInKBytes + ", 2 , 4, " + timeMain + ", " + timeBg + ", '{64;32;64}', '{64;16;64}', " + "'" + SKO.ToString() + "', " + "'" + PSNR.ToString() + "')";
                SQLiteCommand ins = new SQLiteCommand(insert, conn);
                ins.ExecuteNonQuery();
                conn.Close();

                SquezeButton.Enabled = false;
            }
        }