Exemple #1
0
        public void rename_category(bool is_create)
        {
            Gtk.Entry rename_entry = new Gtk.Entry();
            rename_entry.Text = category.metalabel.label;
            rename_entry.Name = "rename_cat";
            rename_entry.AddEvents((int)Gdk.EventMask.KeyReleaseMask);
            rename_entry.KeyReleaseEvent += delegate (object sender, Gtk.KeyReleaseEventArgs e) {
                on_rename_cat_key_release(e, is_create);
            };

            int pos = 0;
            foreach (Widget w in representation) {
                if (w.Name == category.metalabel.label) {
                    w.Destroy();
                    break;
                } else
                    ++pos;
            }

            representation.PackStart(rename_entry, false, false, 6);
            representation.ReorderChild(rename_entry, pos);
            representation.ShowAll();

            rename_entry.GrabFocus();
        }
Exemple #2
0
        private void add_new_label()
        {
            System.Console.WriteLine("writing new label");

            Gtk.Entry new_label = new Gtk.Entry();
            new_label.Name = "new_label";
            new_label.AddEvents((int)Gdk.EventMask.KeyReleaseMask);
            new_label.KeyReleaseEvent += on_new_key_release;

            representation.Add(new_label);
            representation.ShowAll();

            new_label.GrabFocus();
        }
Exemple #3
0
        private void rename_label(UserLabel label)
        {
            renamed_label = label;

            Gtk.Entry rename_label = new Gtk.Entry();
            rename_label.Text = label.metalabel.label;
            rename_label.Name = "rename_label";
            rename_label.AddEvents((int)Gdk.EventMask.KeyReleaseMask);
            rename_label.KeyReleaseEvent += on_rename_key_release;

            int pos = 0;
            foreach (Widget w in representation) {
                if (w.Name == label.metalabel.label) {
                    w.Destroy();
                    break;
                } else
                    ++pos;
            }

            representation.Add(rename_label);
            representation.ReorderChild(rename_label, pos);
            representation.ShowAll();

            rename_label.GrabFocus();
        }
Exemple #4
0
        //Contains all of the components which are on the window
        private void setupWindow()
        {
            //Vertical box (3 sections) which is the main container
            VBox MainVBox = new VBox(false, 6);

            /*********************Start of menu bar components*********************/

            //Note: Flow of menus are:
            //Menubar contains MenuItems (e.g. File, Edit, About, etc...)
            //MenuItems contains one Menu (i.e. a Submenu)
            //Menu contains multiple MenuItems (e.g. Save, Save As, Load, etc...)
            MenuBar MainMenuBar = new MenuBar ();

            Menu FileMenu = new Menu ();
            MenuItem File = new MenuItem ("File");
            File.Submenu = FileMenu;

            MenuItem ExitItem = new MenuItem ("Exit");
            ExitItem.Activated += quitProgram;
            FileMenu.Append (ExitItem);

            Menu GestureMenu = new Menu ();
            MenuItem Gesture = new MenuItem ("Gestures");
            Gesture.Submenu = GestureMenu;

            MenuItem LoadGesture = new MenuItem ("Load Gesture");
            LoadGesture.Activated += openGesture;
            GestureMenu.Append (LoadGesture);

            MenuItem SaveGestureItem = new MenuItem ("Save Gesture");
            SaveGestureItem.Activated += createGesture;
            GestureMenu.Append (SaveGestureItem);

            Menu PointsMenu = new Menu ();
            MenuItem Points = new MenuItem ("Data Points");
            Points.Submenu = PointsMenu;

            MenuItem LoadPointsItem = new MenuItem ("Load Points");
            LoadPointsItem.Activated += loadDataPoints;
            PointsMenu.Append (LoadPointsItem);

            MenuItem RecordPointsItem = new MenuItem ("Record Points");
            RecordPointsItem.Activated += recordPoints;
            PointsMenu.Append (RecordPointsItem);

            MenuItem BatchRecognizeItem = new MenuItem ("Batch Recognize");
            BatchRecognizeItem.Activated += batchRecognize;
            PointsMenu.Append (BatchRecognizeItem);

            Menu HelpMenu = new Menu ();
            MenuItem Help = new MenuItem ("Help");
            Help.Submenu = HelpMenu;

            MenuItem AboutMenuItem = new MenuItem("About");
            HelpMenu.Append (AboutMenuItem);

            MainMenuBar.Append (File);
            MainMenuBar.Append (Gesture);
            MainMenuBar.Append (Points);
            MainMenuBar.Append (Help);

            /*********************End of menu bar components*********************/

            //Drawing area which is the core component of the application
            dArea = new DrawingArea ();
            dArea.SetSizeRequest (500, 500);

            //Horizontal box (4 sections) which contains all of the buttons along the
            //bottom of the window
            HBox ButtonHBox = new HBox (false, 6);

            /*********************Start of Buttons*********************/

            Button BtnCreateGesture = new Button ("Create");
            Button BtnRecognizeGesture = new Button ("Recognize");
            Button BtnClearScreen = new Button ("Clear");
            Button BtnRecordPoints = new Button ("Record points");
            Button BtnChangeColour = new Button ("Change colour");

            //Button functions
            BtnCreateGesture.Clicked += new EventHandler (createGesture);
            BtnRecognizeGesture.Clicked += new EventHandler (recognizeGesture);
            BtnClearScreen.Clicked += new EventHandler (clearScreen);
            BtnRecordPoints.Clicked += new EventHandler (recordPoints);
            BtnChangeColour.Clicked += changeColour;

            //Adding buttons to the current horizontal box
            ButtonHBox.PackStart (BtnCreateGesture, true, false, 0);
            ButtonHBox.PackStart (BtnRecognizeGesture, true, false, 0);
            ButtonHBox.PackStart (BtnClearScreen, true, false, 0);
            ButtonHBox.PackStart (BtnRecordPoints, true, false, 0);
            ButtonHBox.PackStart (BtnChangeColour, true, false, 0);
            /*********************End of Buttons*********************/

            //Status bar which shows the score and recognized gesture
            sBar = new Statusbar ();
            sBar.Push (1, "Ready");

            //Entry box for batch function name to be used on the files
            batchFunctionName = new Entry ("Recorded points function name");
            batchFunctionName.AddEvents (
                (int)Gdk.EventMask.ButtonPressMask
            );
            batchFunctionName.ButtonPressEvent += clearTextBox;

            //Adding all components to the Vertical box
            MainVBox.PackStart (MainMenuBar, false, false, 0);
            MainVBox.PackStart (dArea, false, false, 0);
            MainVBox.PackStart (ButtonHBox, false, false, 0);
            MainVBox.PackStart (batchFunctionName, false, false, 0);
            MainVBox.PackStart (sBar, false, false, 0);

            Add (MainVBox);

            ShowAll ();

            //Surface 'pattern' for area to be covered
            surface = new ImageSurface(Format.Argb32, 500, 500);

            //Adding mouse events to the drawing area and assigning functions
            dArea.AddEvents(
                //Mouse Related Events
                (int)Gdk.EventMask.PointerMotionMask
                |(int)Gdk.EventMask.ButtonPressMask
                |(int)Gdk.EventMask.ButtonReleaseMask
            );

            //Repaint the Canvas Internally.
            dArea.ExposeEvent += OnDrawingAreaExposed;
            //Do this on MousePress inside Area
            dArea.ButtonPressEvent += OnMousePress;
            //Do this on MouseReleased inside Area
            dArea.ButtonReleaseEvent += OnMouseRelease;
            //Do this if a Motion Occurs inside the Drawing Area
            dArea.MotionNotifyEvent += OnMouseMotion2;

            //Assigning close function to the window
            DeleteEvent += delegate { Application.Quit(); };

            //Checking to see if bool for using the dot function is true
            //And assigning the required function as the delegate's operation
            //Note: This will always be true, no current way to switch while
            //application is running, has not been needed as of yet
            if (isDot) {
                Painter = new DrawShape (DrawDot);
                myoPainter = new DrawShape (DrawDot);
            } else {
                Painter = new DrawShape (DrawLine);
            }
        }