예제 #1
0
 public static void exit(this Form f)
 {
     F.runAsync(() => {
         Thread.Sleep(100);
         f.runOnUiThread(() => { f.Close(); });
         StudioContext.getCurrentInstance().formClosed(f);
     });
 }
예제 #2
0
 /// <summary>
 /// Open a window to open a file, then handle that file
 /// </summary>
 public static void f(this Form f, object ob = null, EventArgs args = null)
 {
     f._(() => {
         OpenFileDialog o   = new OpenFileDialog();
         o.InitialDirectory = @"C:\";
         o.Multiselect      = false;
         if (o.ShowDialog() == DialogResult.OK)
         {
             StudioContext.getCurrentInstance().openFile(o.FileName, f);
             f.Close();
         }
     });
 }
예제 #3
0
        public PhotoEditor(string filename)
        {
            loadingImage       = new PictureBox();
            loadingImage.Image = Properties.Resources.material_loading;
            loadingImage.BackgroundImageLayout = ImageLayout.Zoom;
            loadingImage.BackColor             = Color.Transparent;
            loadingImage.Location = new Point(0, 0);
            loadingImage.Size     = new Size(100, 100);
            loadingImage.SizeMode = PictureBoxSizeMode.Zoom;
            Controls.Add(loadingImage);

            pic          = new PictureBox();
            pic.Location = new Point(10, 100);
            pic.SizeMode = PictureBoxSizeMode.Zoom;
            pic.BackgroundImageLayout = ImageLayout.Zoom;
            Controls.Add(pic);

            colors             = new ListBox();
            colors.Location    = new Point(500, 150);
            colors.Size        = new Size(250, 500);
            colors.Font        = new Font("Arial", 12f);
            colors.MinimumSize = new Size(100, 100);
            colors.MouseDown  += itemClick;
            Controls.Add(colors);

            colorsLabel           = new Label();
            colorsLabel.Font      = new Font("Arial", 12f);
            colorsLabel.Location  = new Point(500, 100);
            colorsLabel.ForeColor = Color.White;
            colorsLabel.AutoSize  = false;
            colorsLabel.Height    = colorsLabel.PreferredHeight;
            colorsLabel.Width     = 250;
            colorsLabel.Text      = "Colors present in image";
            Controls.Add(colorsLabel);

            selectedColorLabel           = new Label();
            selectedColorLabel.AutoSize  = false;
            selectedColorLabel.Font      = new Font("Arial", 12f);
            selectedColorLabel.Width     = 250;
            selectedColorLabel.Location  = new Point(700, 100);
            selectedColorLabel.ForeColor = Color.White;
            selectedColorLabel.Text      = "Selected Color";
            Controls.Add(selectedColorLabel);

            selectedColor           = new Panel();
            selectedColor.Size      = new Size(100, 100);
            selectedColor.Location  = new Point(700, 175);
            selectedColor.BackColor = Color.White;
            Controls.Add(selectedColor);

            MinimumSize = new Size(500, 500);

            pic.MouseClick += delegate(object o, MouseEventArgs args) {
                Color c = new Bitmap(pic.BackgroundImage).GetPixel(args.Location.X, args.Location.Y);
                selectedColor.BackColor = c;
                selectedColor.Invalidate();
                selectedColorLabel.Text   = string.Format("Selected Color {0}{1}{0}[{2},{3}]", "\n    ", c.toHex(), args.Location.X, args.Location.Y);
                selectedColorLabel.Height = selectedColorLabel.PreferredHeight;
            };

            Resize += delegate {
                int left = pic.Left + pic.Width + 100;
                colors.Left             = left;
                colorsLabel.Left        = left;
                selectedColorLabel.Left = selectedColor.Left = left + 300;
                colors.Height           = (int)(pic.Height * .75);
            };

            FormClosed += delegate {
                StudioContext.getCurrentInstance().formClosed(this);
            };

            LoadImage(filename);
        }