コード例 #1
0
 protected virtual void SetValues(GardenArea area)
 {
     area.Name        = this.NameEntry.Text;
     area.Description = this.DescrEntry.Text;
     area.SetCreated(CreatedDateBox.GetYear(), CreatedDateBox.GetMonth());
     area.SetRemoved(RemovedDateBox.GetYear(), RemovedDateBox.GetMonth());
 }
コード例 #2
0
 protected void SetValuesForCreation(GardenArea area, List <Garden.GardenPoint> points)
 {
     area.Shape.AddPoints(points);
     area.Shape.FinishPoints();
     area.SetCreated(CreatedDateBox.GetYear(), CreatedDateBox.GetMonth());
     area.SetRemoved(RemovedDateBox.GetYear(), RemovedDateBox.GetMonth());
     GardenData.unsaved = true;
 }
コード例 #3
0
        public GardenDrawingArea(Garden.Garden garden, SpinButton zoomButton, int width = 800, int height = 600)
        {
            this.Garden = garden;
            this.SetSizeRequest(width, height);
            this.AddEvents((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.PointerMotionMask
                                 | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask | Gdk.EventMask.AllEventsMask));


            this.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args)
            {
                if (args.Event.Button == 1)
                {
                    if (MainWindow.GetInstance().AreaNewButton.Active)
                    {
                        UndoSelection();
                        GardenPoint gridPoint = SnapToGrid((int)(args.Event.X), (int)(args.Event.Y));
                        NewPoints.Add(gridPoint);
                        Draw();
                    }
                    else if (CheckAreaClick((int)args.Event.X, (int)args.Event.Y))
                    {
                        MakeSelection();
                    }
                    else
                    {
                        UndoSelection();
                    }
                }
                else if (args.Event.Button == 3 || args.Event.Button == 2)
                {
                    if (CheckAreaClick((int)args.Event.X, (int)args.Event.Y) && SelectedArea != null)
                    {
                        MakeSelection();

                        MenuItem item1 = new MenuItem("Set created date");
                        item1.Activated += (sender, e) => DateInputWindow.ShowWindow("Set created date", (int y, int m) => { SelectedArea.SetCreated(y, m); });
                        MenuItem item2 = new MenuItem("Set removed date");
                        item2.Activated += (sender, e) => DateInputWindow.ShowWindow("Set removed date", (int y, int m) => { SelectedArea.SetRemoved(y, m); });
                        MenuItem item3 = new MenuItem("Edit area");
                        item3.Activated += (sender, e) => MainWindow.GetInstance().AreaEditButton.Activate();
                        MenuItem item4 = new MenuItem("Remove area");
                        item4.Activated += (sender, e) => MainWindow.GetInstance().AreaDeleteButton.Activate();
                        MenuItem item5 = new MenuItem("Edit point");
                        item5.Sensitive  = SelectedPoint != null;
                        item5.Activated += (sender, e) => PointInputWindow.ShowWindow("Set new point", Math.Min(SelectedPoint.X, SelectedPoint.Y) - 100, Math.Max(SelectedPoint.X, SelectedPoint.Y) + 100, SelectedPoint.X, SelectedPoint.Y,
                                                                                      (int x, int y) => { SelectedArea.Shape.ModPoint(SelectedPoint, new GardenPoint(x, y), true); SelectedPoint = null; Draw(); });

                        Menu menu = new Menu()
                        {
                            item1, item2, item3, item4, item5
                        };

                        menu.AttachToWidget(this, null);
                        menu.ShowAll();
                        menu.Popup();
                    }
                }
            };

            zoomButton.ValueChanged += (object sender, System.EventArgs e) =>
            {
                Zoom = zoomButton.Value;
                if (IsDrawable)
                {
                    Draw();
                }
            };

            this.QueryTooltip += (object o, QueryTooltipArgs args) =>
            {
                System.Console.WriteLine("tooltip drawing area");
            };
            zoomButton.QueryTooltip += (object o, QueryTooltipArgs args) =>
            {
                System.Console.WriteLine("tooltip zoom button");
            };
        }