示例#1
0
        public void Init()
        {
            gtkWin = new Window("DRAL Retag");
            var size = gtkWin.Display.PrimaryMonitor.Workarea.Size;

            gtkWin.Resize(size.Width, size.Width / 4 + 30);

            Box vbox    = new Box(Orientation.Vertical, 0);
            Box images  = new Box(Orientation.Horizontal, 2);
            Box buttons = new Box(Orientation.Horizontal, 2);

            buttons.BaselinePosition = BaselinePosition.Center;

            vbox.Add(images);
            vbox.Add(buttons);
            var siz = new MoyskleyTech.ImageProcessing.Image.Size(size.Width / 3, size.Width / 4);

            iOri        = new FixedSizeImage(siz);
            iActivation = new FixedSizeImage(siz);
            iActivated  = new FixedSizeImage(siz);
            images.Add(iOri);
            images.Add(iActivation);
            images.Add(iActivated);

            gtkWin.DeleteEvent += delegate { result.TrySetResult(false); };

            Button btnOK = new Button()
            {
                Label = "OK"
            };

            btnOK.Clicked += delegate
            {
                result.TrySetResult(true); gtkWin.Dispose();
            };
            Button btnCancel = new Button()
            {
                Label = "Cancel"
            };

            btnCancel.Clicked += delegate
            {
                result.TrySetResult(false); gtkWin.Dispose();
            };

            buttons.Add(btnOK);
            buttons.Add(btnCancel);

            gtkWin.Add(vbox);
        }
示例#2
0
        public void Init()
        {
            gtkWin = new Window("DRAL Retag");

            var size = gtkWin.Display.PrimaryMonitor.Workarea.Size;

            Image <Pixel> icon = new Image <Pixel>(32, 32);

            icon.ApplyFilter((_, _2) => Pixels.Black);
            Graphics.FromImage(icon).DrawString("DR", new FontSize(BaseFonts.Premia, 2), Pixels.Red, 0, 0);
            Graphics.FromImage(icon).DrawString("AL", new FontSize(BaseFonts.Premia, 2), Pixels.Red, 0, 16);
            gtkWin.Icon = GtkWrapper.ToPixbuf(icon);
            gtkWin.Resize(size.Width, size.Height);

            //Wfrm = 13/9 of Wimg
            //Wimg = 9*Wfrm/13
            int maxImageWidth  = 9 * size.Width / 13;
            int maxImageHeight = size.Height - 100;
            int maxImageWidthTakingImageHeight = maxImageHeight * 4 / 3;
            int maxImageHeightTakingImageWidth = maxImageWidth * 3 / 4;

            var imageWidth  = Math.Min(maxImageWidth, maxImageWidthTakingImageHeight);
            var imageHeight = Math.Min(maxImageHeight, maxImageHeightTakingImageWidth);

            Box    bx               = new Box(Orientation.Vertical, 1);
            Box    menu             = new Box(Orientation.Horizontal, 1);
            Button buttonLoadLabels = new Button()
            {
                Label = "Load labels"
            };

            buttonLoadLabels.Clicked += ButtonLoadLabels_Clicked;
            menu.Add(buttonLoadLabels);
            buttons.Add(buttonLoadLabels);
            Button buttonLoadImages = new Button()
            {
                Label = "Load Image"
            };

            buttonLoadImages.Clicked += ButtonLoadImages_Clicked;
            menu.Add(buttonLoadImages);
            buttons.Add(buttonLoadImages);
            Button buttonSave = new Button()
            {
                Label = "Save"
            };

            buttonSave.Clicked += ButtonSave_Clicked;
            menu.Add(buttonSave);
            buttons.Add(buttonSave);
            Button btnFixMissing = new Button()
            {
                Label = "Repair Dataset"
            };

            btnFixMissing.Clicked += BtnFixMissing_Clicked;
            menu.Add(btnFixMissing);
            buttons.Add(btnFixMissing);
            chkGenNow        = new CheckButton("Generate now");
            chkGenNow.Active = true;
            menu.Add(chkGenNow);

            lblCount = new Label("0");
            menu.Add(lblCount);
            Label lblImageInTraining = new Label("images in training");

            menu.Add(lblImageInTraining);

            Box      bottom = new Box(Orientation.Horizontal, 1);
            EventBox evt    = new EventBox();

            left = new Fixed();
            evt.Add(left);

            pictureBox = new FixedSizeImage(new MoyskleyTech.ImageProcessing.Image.Size(imageWidth, imageHeight));
            pictureBox.WidthRequest = imageWidth;
            left.Put(pictureBox, 0, 0);

            evt.AddEvents((int)Gdk.EventMask.AllEventsMask);
            evt.MotionNotifyEvent  += Left_MotionNotifyEvent;
            evt.ButtonPressEvent   += Evt_ButtonPressEvent;
            evt.ButtonReleaseEvent += Evt_ButtonReleaseEvent;

            right = new Box(Orientation.Vertical, 1);
            right.WidthRequest = 200;
            var siz = new MoyskleyTech.ImageProcessing.Image.Size(imageWidth * 4 / 9, imageHeight / 3);

            iOri        = new FixedSizeImage(siz);
            iActivated  = new FixedSizeImage(siz);
            iActivation = new FixedSizeImage(siz);
            right.Add(iOri);
            right.Add(iActivated);
            right.Add(iActivation);

            rectangle_top    = new DrawingArea();
            rectangle_left   = new DrawingArea();
            rectangle_right  = new DrawingArea();
            rectangle_bottom = new DrawingArea();

            rectangle_top.Drawn    += Black_Drawn;
            rectangle_left.Drawn   += Black_Drawn;
            rectangle_right.Drawn  += Black_Drawn;
            rectangle_bottom.Drawn += Black_Drawn;

            viewCircle = new DrawingArea();
            viewCircle.WidthRequest  = windowSize;
            viewCircle.HeightRequest = windowSize;
            viewCircle.Drawn        += Da_Drawn;

            left.Put(rectangle_top, 0, 0);
            left.Put(rectangle_left, 0, 0);
            left.Put(rectangle_right, 0, 0);
            left.Put(rectangle_bottom, 0, 0);
            left.Put(viewCircle, 0, 0);

            bottom.Add(evt);
            bottom.Add(right);

            menu.HeightRequest = 30;
            bx.Add(menu);
            bx.Add(bottom);
            gtkWin.KeyPressEvent += GtkWin_KeyPressEvent;
            gtkWin.Add(bx);
            //Show Everything
            gtkWin.DeleteEvent += delegate { Application.Quit(); };
        }