Esempio n. 1
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            Ubit          = new Bitmap(myPictureBox.Size.Width, myPictureBox.Size.Height);
            LoadBar.Value = 0;

            for (int i = 0; i < 50; i++)
            {
                //while (true)
                //{
                CntrLbl.Text = poligonList.Count.ToString();
                try
                {
                    poligon = new Triangle(myPictureBox, Dbit);
                }
                catch (ArgumentOutOfRangeException)
                {
                    continue;
                }

                foreach (Triangle t in poligonList)
                {
                    PointF[] points = new PointF[3];
                    points = t.InitPoligon();

                    g = Graphics.FromImage(Ubit);
                    g.FillPolygon(new SolidBrush(t.color), points);
                }
                myPictureBox.Refresh();
                myPictureBox.Image = Ubit;


                //PixelCntr[1] = 0;
                //for (int x = 0; x < 574; x++)
                //    for (int y = 0; y < 558; y++)
                //    {
                //        try
                //        {
                //            if (Dbit.GetPixel(x, y) == Ubit.GetPixel(x, y))
                //            {
                //                PixelCntr[1]++;
                //            }
                //        }
                //        catch (ArgumentOutOfRangeException)
                //        {
                //            continue;
                //        }

                //    }

                //if (PixelCntr[0] <= PixelCntr[1])
                //{
                poligonList.Add(poligon);
                //    PixelCntr[0] = PixelCntr[1];
                LoadBar.Increment(1);

                //    break;
                //}
                //}
            }
        }
 private void timer1_Tick(object sender, EventArgs e)
 {
     LoadBar.Increment(1);
     if (LoadBar.Value == 100)
     {
         timer1.Stop(); // if progressbar reaches 100 timer will stop
     }
 }
Esempio n. 3
0
        private async void ButtonInversion_Click(object sender, EventArgs e)
        {
            // Will be called everyone inversion step
            var progressIndecator = new Progress <int>(i =>
            {
                LoadBar.Increment(1);

                var percent           = (int)(((double)(LoadBar.Value - LoadBar.Minimum) / (double)(LoadBar.Maximum - LoadBar.Minimum)) * 100);
                labelLoadPercent.Text = percent == 100 ? "" : $"{percent} %";

                if (LoadBar.Value == LoadBar.Maximum)
                {
                    LoadBar.Value = 0;
                }
            });

            await _invert.ChangePictureAsync(progressIndecator);
        }