public LoginFrame()
            : base("Account")
        {
            this.BorderWidth     = 10;
            this.loginBox        = new VBox();
            this.loginButtonBox  = new VButtonBox();
            this.loginButton     = new Button();
            this.subscribeButton = new Button();

            // Button Box
            this.Add(loginBox);
            loginBox.PackStart(loginButtonBox, false, false, 10);
            loginBox.Add(loginButtonBox);


            // Login button
            loginButtonBox.PackStart(loginButton, true, true, 0);
            loginButtonBox.Add(loginButton);

            // Login Image button
            this.imageBox     = new HBox();
            this.accountImage = new Image("../../icons/account.png");

            loginButton.Add(imageBox);
            imageBox.PackStart(accountImage, false, false, 3);
            imageBox.Add(accountImage);

            this.loginLabel = new Label(loginText);
            imageBox.PackStart(loginLabel, false, false, 0);
            imageBox.Add(loginLabel);

            // subscribe Button
            loginButtonBox.PackStart(subscribeButton, true, true, 0);
            loginButtonBox.Add(subscribeButton);

            // logout button
            this.logoutLabel  = new Label("Logout");
            this.logoutButton = new Button();
            logoutButton.Add(logoutLabel);

            // subscribe Label Button
            this.subscribeLabel = new Label(subscribeText);
            subscribeButton.Add(subscribeLabel);


            //Buttons
            loginButton.Clicked     += new EventHandler(OpenLoginWindow);
            subscribeButton.Clicked += new EventHandler(OpenSubscribeWindow);

            logoutButton.Clicked += new EventHandler(Logout);

            this.LoginWindow = new Authentication();
            this.LoginWindow.HideAll();

            this.SubscriptionWindow = new Subscription();
            this.SubscriptionWindow.HideAll();
        }
Exemplo n.º 2
0
        void PackButton(Editor editor)
        {
            var button = new Button(editor.Label);

            // FIXME, theme icon
            //if (editor.IconName != null)
            //	button.Image = new Image (GtkUtil.TryLoadIcon (FSpot.Settings.Global.IconTheme, editor.IconName, 22, (Gtk.IconLookupFlags)0));
            button.Clicked += (o, e) => { ChooseEditor(editor); };
            button.Show();
            buttons.Add(button);
            editor_buttons.Add(editor, button);
        }
Exemplo n.º 3
0
        void PackButton(Editor editor)
        {
            Button button = new Button(editor.Label);

            if (editor.IconName != null)
            {
                button.Image = new Image(GtkUtil.TryLoadIcon(FSpot.Global.IconTheme, editor.IconName, 22, (Gtk.IconLookupFlags) 0));
            }
            button.Clicked += delegate(object o, EventArgs e) { ChooseEditor(editor); };
            button.Show();
            buttons.Add(button);
            editor_buttons.Add(editor, button);
        }
Exemplo n.º 4
0
    public MainWindow() : base(WindowType.Toplevel)
    {
        GardenData.LoadedData = GardenData.LoadedData = new GardenData("new project");
        Title = "Garden project '" + GardenData.LoadedData.Name + "'";

        //GardenData.LoadedData = GardenPlanner.MainClass.TestData();


        PlantSideVPaned.Add1(FamilyPlantVarietySelector);


        PlantAreaInfoVPaned.Add1(PlantBox);
        PlantAreaInfoVPaned.Add2(AreaInfo);

        PlantSideVPaned.Add2(PlantAreaInfoVPaned);

        TopPanedToolboxVPaned.Add1(GraphicsSidebarHPaned);
        TopPanedToolboxVPaned.Add2(ToolBox);

        Frame frame;

        PlantBox.Add(PlantAddButton);
        PlantBox.Add(PlantInfoButton);
        PlantBox.Add(PlantEditButton);

        ToolBox.Add(AreaNewButton);
        ToolBox.Add(AreaCancelButton);
        ToolBox.Add(AreaTypeComboBox);
        ToolBox.Add(AreaEditButton);
        ToolBox.Add(AreaDeleteButton);

        frame = new Frame("Zoom");
        frame.Add(ZoomButton);
        ToolBox.Add(frame);

        frame = new Frame("Date");
        VButtonBox buttonBox = new VButtonBox();

        //yearButton = new SpinButton(GardenData.GetFirstYear(), GardenData.GetLastYear(), 1);
        yearButton = new SpinButton(settings.MinYear, settings.MaxYear, 1);
        buttonBox.Add(yearButton);
        buttonBox.Add(monthButton);

        frame.Add(buttonBox);
        ToolBox.Add(frame);

        foreach (Widget w in TopVBox.Children)
        {
            TopVBox.Remove(w);
        }
        TopVBox.Add(MenuBar);
        TopVBox.Add(TopPanedToolboxVPaned);

        if (this.Child == null)
        {
            this.Add(TopVBox);
        }


        ResetForNewData();

        FamilyPlantVarietySelector.SetSizeRequest(100, 400);

        AreaInfo.WrapMode = WrapMode.Word;
        AreaInfo.Editable = false;


        PlantAddButton.Sensitive = false;
        PlantAddButton.Clicked  += (sender, e) =>
        {
            GardenDrawingArea area = GardenDrawingArea.ActiveInstance;
            if (area.SelectedArea is Planting planting && SelectedEntry is PlantVariety variety)
            {
                EditPlantingInfoWindow.ShowPlantingInfoWindow((PlantingInfo plantingInfo) =>
                {
                    planting.AddVariety(variety, plantingInfo);
                    GardenDrawingArea.ActiveInstance.Draw();
                    ShowAreaSelectionInfo(area.SelectedArea);
                }, planting, variety.Name);
            }
            ;
        };

        PlantInfoButton.Clicked += (object sender, System.EventArgs e) =>
        {
            if (SelectedEntry is PlantFamily family)
            {
                InfoPlantFamilyWindow.ShowWindow(family, false);
            }
            else if (SelectedEntry is Plant plant)
            {
                InfoPlantWindow.ShowWindow(plant, false);
            }
            else if (SelectedEntry is PlantVariety variety)
            {
                InfoPlantVarietyWindow.ShowWindow(variety, false);
            }
        };


        PlantEditButton.Clicked += (object sender, System.EventArgs e) =>
        {
            if (SelectedEntry is PlantFamily family)
            {
                EditPlantFamilyWindow.ShowWindow(family);
            }
            else if (SelectedEntry is Plant plant)
            {
                EditPlantWindow.ShowWindow(plant);
            }
            else if (SelectedEntry is PlantVariety variety)
            {
                EditPlantVarietyWindow.ShowWindow(variety);
            }
        };


        ZoomButton.Value       = GardenDrawingArea.Zoom;
        ZoomButton.Events      = Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask | Gdk.EventMask.KeyPressMask | Gdk.EventMask.KeyReleaseMask;
        ZoomButton.TooltipText = "Zoom";



        AreaNewButton.Clicked += (object sender, System.EventArgs e) =>
        {
            if (AreaCancelButtonClicked)
            {
                AreaCancelButtonClicked    = false;
                AreaCancelButton.Sensitive = false;
                if (GardenDrawingArea.ActiveInstance != null)
                {
                    GardenDrawingArea.ActiveInstance.UndoSelection();
                    GardenDrawingArea.ActiveInstance.NewPoints.Clear();
                    GardenDrawingArea.ActiveInstance.Draw();
                }
            }
            else if (!AreaNewButton.Active)//deactivated
            {
                AreaCancelButton.Sensitive = false;
                if (GardenDrawingArea.ActiveInstance != null)
                {
                    List <GardenPoint> points = GardenDrawingArea.ActiveInstance.NewPoints;
                    switch (AreaTypeComboBox.Active)
                    {
                    case 0:    //garden
                        if (GardenDrawingArea.ActiveInstance.Garden.Shape.GetPoints().Count == 0)
                        {
                            GardenDrawingArea.ActiveInstance.Garden.Shape.AddPoints(points);
                            GardenDrawingArea.ActiveInstance.Garden.Shape.FinishPoints();
                            GardenDrawingArea.ActiveInstance.NewPoints.Clear();
                            GardenDrawingArea.ActiveInstance.Draw();
                        }
                        break;

                    case 1:    //planting
                        PlantingCreationDialog.ShowPlantingCreationDialog(new List <GardenPoint>(points), (Planting planting) =>
                        {
                            GardenDrawingArea.ActiveInstance.NewPoints.Clear();
                            GardenDrawingArea.ActiveInstance.Draw();
                            GardenDrawingArea.ActiveInstance.Garden.AddPlanting(GardenData.GenID(planting.Name), planting);
                        });


                        break;

                    case 2:    //method area
                        GardenAreaCreationDialog.ShowGardenAreaCreationDialog(new List <GardenPoint>(points), (GardenArea area) => {
                            GardenDrawingArea.ActiveInstance.NewPoints.Clear();
                            GardenDrawingArea.ActiveInstance.Draw();
                            GardenDrawingArea.ActiveInstance.Garden.AddMethodArea(GardenData.GenID(area.Name), area);
                        });

                        break;
                    }
                }
            }
            else //activated
            {
                if (AreaTypeComboBox.Active == 0) //garden
                {
                    if (GardenDrawingArea.ActiveInstance == null || GardenDrawingArea.ActiveInstance.Garden.Shape.GetPoints().Count > 0)
                    {
                        AreaNewButton.Active = false;
                        GardenCreationDialog.ShowGardenCreationDialog(new List <GardenPoint>(), ((Garden garden) =>
                        {
                            GardenData.LoadedData.AddGarden(GardenData.GenID(garden.Name), garden);
                            this.ResetForNewData();
                            GardenBedBook.Page = GardenBedBook.NPages - 1;
                            AreaNewButton.Active = true;
                        }));
                    }
                }

                AreaCancelButton.Sensitive = true;
            }
        };


        AreaCancelButton.Sensitive = false;
        AreaCancelButton.Clicked  += (object sender, System.EventArgs e) =>
        {
            AreaCancelButtonClicked    = true;
            AreaCancelButton.Sensitive = false;
            AreaNewButton.Active       = false;
        };


        AreaTypeComboBox.Active   = 0;
        AreaTypeComboBox.Changed += (object sender, System.EventArgs e) =>
        {
            switch (AreaTypeComboBox.Active)
            {
            case 0:
                AreaNewButton.Label = "New Garden";
                break;

            case 1:
                AreaNewButton.Label = "New Planting";
                break;

            case 2:
                AreaNewButton.Label = "New Method Area";
                break;
            }
        };

        AreaEditButton.Clicked += (object sender, System.EventArgs e) =>
        {
            GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance;

            if (gardenDrawingArea == null || gardenDrawingArea.Garden == null || gardenDrawingArea.SelectedArea == null)
            {
                return;
            }

            if (gardenDrawingArea.SelectedArea is Planting planting)
            {
                PlantingCreationDialog.ShowPlantingEditDialog(planting);
            }
            else if (gardenDrawingArea.SelectedArea is Garden)
            {
                GardenAreaCreationDialog.ShowGardenAreaEditDialog(gardenDrawingArea.SelectedArea);
            }
            else
            {
                GardenAreaCreationDialog.ShowGardenAreaEditDialog(gardenDrawingArea.SelectedArea);
            }
        };

        AreaDeleteButton.Clicked += (object sender, System.EventArgs e) =>
        {
            GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance;

            if (gardenDrawingArea == null || gardenDrawingArea.Garden == null)
            {
                return;
            }

            string name = gardenDrawingArea.SelectedArea != null ? gardenDrawingArea.SelectedArea.Name : gardenDrawingArea.Garden.Name;

            Dialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Warning, ButtonsType.OkCancel, "Do you want to delete '" + name + "'?", new { });

            int response = dialog.Run();
            //System.Console.WriteLine("response " + result);
            if (response == (int)ResponseType.Cancel)
            {
            }
            else if (response == (int)ResponseType.Ok)
            {
                if (gardenDrawingArea.Garden != null && (gardenDrawingArea.SelectedArea == null || gardenDrawingArea.SelectedArea is Garden))
                {
                    var garden = gardenDrawingArea.Garden;

                    GardenData.LoadedData.Gardens.Remove(garden.ID);
                    GardenBedBook.Remove(GardenBedBook.GetNthPage(GardenBedBook.CurrentPage));
                    //System.Console.WriteLine("delete garden");
                    GardenDrawingArea.ActiveInstance = null;
                    gardenDrawingArea.UndoSelection();
                    SelectGardenEntry(null);
                    if (GardenBedBook.Page >= 0 && GardenBedBook.GetNthPage(GardenBedBook.Page) is GardenDrawingArea drawingArea)
                    {
                        GardenDrawingArea.ActiveInstance = drawingArea;
                        drawingArea.Draw();
                    }
                    GardenData.unsaved = true;
                }
                else if (gardenDrawingArea.SelectedArea is Planting planting)
                {
                    gardenDrawingArea.Garden.RemovePlanting(planting);
                    gardenDrawingArea.UndoSelection();
                    SelectGardenEntry(null);
                    gardenDrawingArea.Draw();
                    GardenData.unsaved = true;
                }
                else if (gardenDrawingArea.SelectedArea is GardenArea area)
                {
                    gardenDrawingArea.Garden.RemoveMethodArea(area);
                    gardenDrawingArea.UndoSelection();
                    SelectGardenEntry(null);
                    gardenDrawingArea.Draw();
                    GardenData.unsaved = true;
                }
            }
            dialog.Destroy();
        };



        int yearValue = yearButton.ValueAsInt;

        yearButton.ValueChanged += (sender, e) =>
        {
            if (yearButton.ValueAsInt > yearValue)
            {
                monthButton.Value = 1;
            }
            else
            {
                monthButton.Value = 12;
            }
            yearValue = yearButton.ValueAsInt;
            DateChanged();
        };
        monthButton.Changed += (sender, e) =>
        {
            DateChanged();
        };

        void DateChanged()
        {
            GardenDrawingArea gardenDrawingArea = GardenDrawingArea.ActiveInstance;

            if (gardenDrawingArea == null)
            {
                return;
            }

            if (gardenDrawingArea.SelectedArea != null && (!gardenDrawingArea.SelectedArea.CheckDate(GetYear(), GetMonth()) || !gardenDrawingArea.Garden.CheckDate(GetYear(), GetMonth())))
            {
                gardenDrawingArea.UndoSelection();
            }
            gardenDrawingArea.Draw();
            ShowAreaSelectionInfo(gardenDrawingArea.SelectedArea);
        }

        //FamilyPlantVarietySelector.Add1(PopulateFamilies(GardenData.LoadedData));
        //RepopulateGrowables();



        //Build();
        this.DeleteEvent += (object o, DeleteEventArgs args) =>
        {
            TryToClose();
            args.RetVal = true;
        };

        this.Destroyed += (sender, e) =>
        {
            GardenPlannerSettings.Save();
            Application.Quit();
        };
    }
Exemplo n.º 5
0
        public override void LaunchDialogue()
        {
            //the Type in the collection
            IList  collection  = (IList)parentRow.PropertyValue;
            string displayName = parentRow.PropertyDescriptor.DisplayName;

            //populate list with existing items
            itemStore = new ListStore(typeof(object), typeof(int), typeof(string));
            for (int i = 0; i < collection.Count; i++)
            {
                itemStore.AppendValues(collection [i], i, collection [i].ToString());
            }

            #region Building Dialogue

            //dialogue and buttons
            Dialog dialog = new Dialog();
            dialog.Title       = displayName + " Editor";
            dialog.Modal       = true;
            dialog.AllowGrow   = true;
            dialog.AllowShrink = true;
            dialog.Modal       = true;
            dialog.AddActionWidget(new Button(Stock.Cancel), ResponseType.Cancel);
            dialog.AddActionWidget(new Button(Stock.Ok), ResponseType.Ok);

            //three columns for items, sorting, PropGrid
            HBox hBox = new HBox();
            dialog.VBox.PackStart(hBox, true, true, 5);

            //propGrid at end
            grid = new PropertyGrid(parentRow.ParentGrid.EditorManager);
            grid.CurrentObject = null;
            grid.WidthRequest  = 200;
            grid.ShowHelp      = false;
            hBox.PackEnd(grid, true, true, 5);

            //followed by item sorting buttons in ButtonBox
            VButtonBox sortButtonBox = new VButtonBox();
            sortButtonBox.LayoutStyle = ButtonBoxStyle.Start;
            Button upButton = new Button();
            Image  upImage  = new Image(Stock.GoUp, IconSize.Button);
            upImage.Show();
            upButton.Add(upImage);
            upButton.Show();
            sortButtonBox.Add(upButton);
            Button downButton = new Button();
            Image  downImage  = new Image(Stock.GoDown, IconSize.Button);
            downImage.Show();
            downButton.Add(downImage);
            downButton.Show();
            sortButtonBox.Add(downButton);
            hBox.PackEnd(sortButtonBox, false, false, 5);

            //Third column is a VBox
            VBox itemsBox = new VBox();
            hBox.PackStart(itemsBox, false, false, 5);

            //which at bottom has add/remove buttons
            HButtonBox addRemoveButtons = new HButtonBox();
            addRemoveButtons.LayoutStyle = ButtonBoxStyle.End;
            Button addButton = new Button(Stock.Add);
            addRemoveButtons.Add(addButton);
            if (types [0].IsAbstract)
            {
                addButton.Sensitive = false;
            }
            Button removeButton = new Button(Stock.Remove);
            addRemoveButtons.Add(removeButton);
            itemsBox.PackEnd(addRemoveButtons, false, false, 10);

            //and at top has list (TreeView) in a ScrolledWindow
            ScrolledWindow listScroll = new ScrolledWindow();
            listScroll.WidthRequest  = 200;
            listScroll.HeightRequest = 320;
            itemsBox.PackStart(listScroll, true, true, 0);

            itemTree = new TreeView(itemStore);
            itemTree.Selection.Mode = SelectionMode.Single;
            itemTree.HeadersVisible = false;
            listScroll.AddWithViewport(itemTree);

            //renderers and attribs for TreeView
            CellRenderer rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Index", rdr, "text", 1));
            rdr = new CellRendererText();
            itemTree.AppendColumn(new TreeViewColumn("Object", rdr, "text", 2));

            #endregion

            #region Events

            addButton.Clicked          += new EventHandler(addButton_Clicked);
            removeButton.Clicked       += new EventHandler(removeButton_Clicked);
            itemTree.Selection.Changed += new EventHandler(Selection_Changed);
            upButton.Clicked           += new EventHandler(upButton_Clicked);
            downButton.Clicked         += new EventHandler(downButton_Clicked);


            #endregion

            //show and get response
            dialog.ShowAll();
            ResponseType response = (ResponseType)dialog.Run();
            dialog.Destroy();

            //if 'OK' put items back in collection
            if (response == ResponseType.Ok)
            {
                DesignerTransaction tran = CreateTransaction(parentRow.ParentGrid.CurrentObject);
                object old = collection;

                try {
                    collection.Clear();
                    foreach (object[] o in itemStore)
                    {
                        collection.Add(o[0]);
                    }
                    EndTransaction(parentRow.ParentGrid.CurrentObject, tran, old, collection, true);
                }
                catch {
                    EndTransaction(parentRow.ParentGrid.CurrentObject, tran, old, collection, false);
                    throw;
                }
            }

            //clean up so we start fresh if launched again

            itemTree     = null;
            itemStore    = null;
            grid         = null;
            previousIter = TreeIter.Zero;
        }
Exemplo n.º 6
0
    public StryroDesign(string[] args)
    {
        Application.Init();
        store = new ListStore(typeof(string));

        window = new Window("Styro Design");
        window.SetSizeRequest(800, 600);
        window.DeleteEvent += new DeleteEventHandler(Window_Delete);

        vbox1 = new VBox();
        window.Add(vbox1);
        handlebox1 = new HandleBox();
        //vbox1.Add(handlebox1);
        menubar = new MenuBar();
        handlebox1.Add(menubar);
        hpan = new HPaned();
        vbox1.Add(hpan);

        vbox2 = new VBox();
        hpan.Add(vbox2);
        swin1 = new ScrolledWindow();
        vbox2.Add(swin1);
        vport1 = new Viewport();
        swin1.Add(vport1);
        treeview1 = new TreeView();
        vport1.Add(treeview1);
        vbuttonbox1             = new VButtonBox();
        vbuttonbox1.BorderWidth = 5;
        vbuttonbox1.Spacing     = 5;
        vbox2.Add(vbuttonbox1);
        vbox2.SetChildPacking(vbuttonbox1, false, false, 5, Gtk.PackType.Start);

        entry1 = new Entry();
        vbuttonbox1.Add(entry1);

        buttonAdd       = new Button();
        buttonAdd.Label = "Hinzufgen";
        vbuttonbox1.Add(buttonAdd);
        vbuttonbox1.Layout = ButtonBoxStyle.Start;

        swin = new ScrolledWindow();
        hpan.Add(swin);
        vport2 = new Viewport();
        swin.Add(vport2);
        drawing = new Display(0.3f, 2000, 2000, store);
        vport2.Add(drawing);

        treeview1.HeadersVisible = true;
        buttonAdd.Clicked       += new EventHandler(OnAddClicked);
        TreeViewColumn col  = new TreeViewColumn();
        CellRenderer   cell = new CellRendererText();

        col.Title = "Befehl";
        col.PackStart(cell, true);
        col.AddAttribute(cell, "text", 0);
        treeview1.AppendColumn(col);

        treeview1.Model = store;

        window.ShowAll();
        Application.Run();
    }