SetValues() public method

public SetValues ( Gtk.TreeIter iter ) : void
iter Gtk.TreeIter
return void
 //Přídání eventu na kliknutí řádku v treeview
 private void appendEventHandlers()
 {
     this.treeview.RowActivated += (sender, e) =>
     {
         //Třída TreeIter je důležitá pro upravení hodnot řádku
         Gtk.TreeIter iterator;
         //Získa TreeIter z cesty řádku, na který bylo kliknuto
         foodTreeStore.GetIterFromString(out iterator, e.Path.ToString());
         //Kontola, jestli řádek na který bylo kliknuto je řádek, který se může upravovat, což jsou jen řádky s jídlem
         if (foodTreeStore.GetValue(iterator, 2) != null)
         {
             //Název jídla
             string label = foodTreeStore.GetValue(iterator, 0).ToString();
             //Najde index v listu jídla a podle toho je třída předána do dialogu, který přídává nebo upraví jídlo
             int result = food.FindFoodIndex(label);
             var dlg    = new AddFoodDialog(food[result]);
             //dlg.SetAllergenes(food[result].GetAllergenIds());
             if (dlg.Run() == (int)ResponseType.Ok)
             {
                 //Upraví data
                 foodTreeStore.SetValues(iterator, dlg.Values.ToArray().SubArray(1, 5));
                 food[result].SetValues(dlg.Values.ToArray());
                 //Clear all relations with allergens
                 food[result].Allergen.Clear();
                 //aId = allergen Id
                 foreach (int aId in dlg.Allergenes)
                 {
                     //Pole alergenů jsou ve výchozí hodnotě 0, opět aby se dali kontrolovat
                     if (aId == 0)
                     {
                         continue;
                     }
                     //Vezme se alergen přímo z databáze, aby se nevytvářel v DB nový záznam, ale aby vznikla vazba
                     var allergen = (from a in this.server.database.Allergenes.ToList() where a.Id == aId select a).First();
                     food[result].SetAllergen(allergen);
                 }
             }
         }
     };
 }
Beispiel #2
0
        /** Fill a tree model with the users. */
        public static TreeModel CreateUsers()
        {
            #if DEBUG
            Console.WriteLine("TreeViewHelper.CreateUsers");
            #endif
            TreeStore ls = new TreeStore(typeof(int), typeof(string), typeof(string), typeof(string));
            for (int i = 0; i < Variables.Users.Count; i++) {
                TreeIter iter = ls.AppendNode ();
                ls.SetValues (iter, i + 1, Variables.Users [i].Name, Variables.Users [i].Team.name);

                if (Variables.status [0] == StatusValue.STATUS_TEAM_SELECTION) {
                    if (Variables.Users [i].Scout == Quality.QUALITY_NONE) {
                        ls.SetValue (iter, 3, Variables.LeagueCupGetName(Variables.Users[i].Team.clid));
                    } else {
                        int index = (int)Variables.Users [i].Scout;
                        ls.SetValue (iter, 3, Variables.Country.Leagues[index].name);
                    }
                } else {
                    ls.SetValue (iter, 3, Variables.LeagueCupGetName(Variables.Users[i].Team.clid));
                }
            }
            return ls;
        }
Beispiel #3
0
 /**
  * Creates the model for the treeview in the team selection window.
  * The model contains a list of all the teams from the leagues in
  * the country::leagues array; if show_cup_teams is TRUE, the
  * teams from international cups are shown, too.
  * @param show_cup_teams Whether or not teams from international
  * cups are shown.
  * @param show_user_teams Whether or not user teams are shown.
  * @return The model containing the team names.
  **/
 public static TreeModel CreateTeamSelectionList(Country country, bool showCupTeams, bool showUserTeams)
 {
     #if DEBUG
     Console.WriteLine("TreeViewHelper.CreateTeamSelectionList");
     #endif
     int count = 1;
     TreeStore ls = new TreeStore(typeof(int), typeof(Gdk.Pixbuf), typeof(Team), typeof(string), typeof(Team));
     for (int i = 0; i < country.Leagues.Count; i++) {
         League league = country.Leagues [i];
         for (int j = 0; j < league.teams.Count; j++) {
             Team team = league.teams [j];
             if (!team.IsUserTeam())
             {
                 Pixbuf symbol = PixbufFromFilename (!string.IsNullOrEmpty (team.symbol) ? team.symbol : league.symbol);
                 TreeIter iter = ls.AppendNode();
                 ls.SetValues (iter, count++, symbol, team, league.name, team);
             }
         }
     }
     if (showCupTeams) {
     }
     return ls;
 }
Beispiel #4
0
        /** Create the model for the startup country files combo.
         * @param countryList The List of country files found */
        public static TreeModel CreateCountryList(string[] countryList)
        {
            #if DEBUG
            Console.WriteLine("TreeViewHelper.CreateCountryList");
            #endif
            TreeStore ls = new TreeStore(typeof(Pixbuf), typeof(string));
            TreeIter iterContinent = new TreeIter ();
            string currentContinent = string.Empty;
            foreach (string country in countryList) {
                string[] elements = country.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
                string continent = elements [0];
                if (continent != currentContinent) {
                    iterContinent = ls.AppendNode ();
                    ls.SetValue(iterContinent, 1, continent);
                    currentContinent = continent;
                }

                Pixbuf flag = PixbufFromFilename (string.Format ("flag_{0}.png", elements [1]));
                TreeIter iterCountry = ls.AppendNode (iterContinent);
                ls.SetValues(iterCountry, flag, elements[1]);
            }
            return ls;
        }
        public Order()
            : base(Gtk.WindowType.Toplevel)
        {
            this.Build();
            notebook1.CurrentPage = 0;
            ComboWorks.ComboFillReference(comboExhibition, "exhibition", ComboWorks.ListMode.WithNo, true, "ordinal");
            dateArrval.Date = DateTime.Today;

            //Создаем таблицу номенклатуры
            ComboBox TempCombo = new ComboBox();
            ComboWorks.ComboFillReference(TempCombo, "materials", ComboWorks.ListMode.WithNo, true, "ordinal");
            MaterialNameList = TempCombo.Model;
            TempCombo.Destroy ();

            TempCombo = new ComboBox();
            ComboWorks.ComboFillReference(TempCombo, "facing", ComboWorks.ListMode.WithNo, true, "ordinal");
            FacingNameList = TempCombo.Model;
            TempCombo.Destroy ();

            ComponentsStore = new TreeStore(
                typeof(long), //row_id
                typeof(Nomenclature.NomType), //nomenclature_type
                typeof(int), //nomenclature_id
                typeof(string), //nomenclature
                typeof(string), //nomenclature_title
                typeof(string), //nomenclature_description
                typeof(int), //count
                typeof(int), //material_id
                typeof(string), //material
                typeof(int), //facing_id
                typeof(string), //facing
                typeof(string), //comment
                typeof(string), //price
                typeof(string), //price_total
                typeof(bool), //editable_count
                typeof(bool), //editable_price
                typeof(bool), //editable_material
                typeof(bool), //editable_facing
                typeof(bool), //editable_comment
                typeof(bool), //editable_discount
                typeof(int), //discount
                typeof(bool)); //editable_name

            BasisIter = ComponentsStore.AppendValues (
                (long)-1,
                Enum.Parse(typeof(Nomenclature.NomType), "construct"),
                1,
                null,
                "Каркас",
                null,
                1,
                -1,
                "",
                -1,
                "",
                "",
                "",
                "",
                false,
                false,
                false,
                false,
                false,
                false,
                null,
                false);

            ServiceIter = ComponentsStore.InsertNodeAfter (BasisIter);

            ComponentsStore.SetValues (
                ServiceIter,
                (long)-1,
                Enum.Parse (typeof(Nomenclature.NomType), "other"),
                1,
                null,
                "Услуги",
                "Кликните правой кнопкой мышы для добавления услуги",
                0,
                -1,
                "",
                -1,
                "",
                "",
                "",
                "",
                false,
                false,
                false,
                false,
                false,
                false,
                null,
                false);

            ColumnCount = new Gtk.TreeViewColumn ();
            ColumnCount.Title = "Кол-во";
            Gtk.CellRendererText CellCount = new CellRendererText ();
            CellCount.Editable = true;
            CellCount.Edited += OnCountEdited;
            ColumnCount.PackStart (CellCount, true);
            ColumnCount.AddAttribute(CellCount, "text", (int)ComponentCol.count);
            ColumnCount.AddAttribute(CellCount, "editable", (int)ComponentCol.editable_count);

            ColumnMaterial = new Gtk.TreeViewColumn ();
            ColumnMaterial.Title = "Отделка кубов";
            ColumnMaterial.MinWidth = 180;
            Gtk.CellRendererCombo CellMaterial = new CellRendererCombo();
            CellMaterial.TextColumn = 0;
            CellMaterial.Editable = true;
            CellMaterial.Model = MaterialNameList;
            CellMaterial.HasEntry = false;
            CellMaterial.Edited += OnMaterialComboEdited;
            ColumnMaterial.PackStart (CellMaterial, true);
            ColumnMaterial.AddAttribute(CellMaterial, "text", (int)ComponentCol.material);
            ColumnMaterial.AddAttribute(CellMaterial, "editable", (int)ComponentCol.editable_material);

            ColumnFacing = new Gtk.TreeViewColumn ();
            ColumnFacing.Title = "Отделка фасада";
            ColumnFacing.MinWidth = 180;
            Gtk.CellRendererCombo CellFacing = new CellRendererCombo();
            CellFacing.TextColumn = 0;
            CellFacing.Editable = true;
            CellFacing.Model = FacingNameList;
            CellFacing.HasEntry = false;
            CellFacing.Edited += OnFacingComboEdited;
            ColumnFacing.PackStart (CellFacing, true);
            ColumnFacing.AddAttribute(CellFacing, "text", (int)ComponentCol.facing);
            ColumnFacing.AddAttribute(CellFacing, "editable", (int)ComponentCol.editable_facing);

            ColumnPrice = new Gtk.TreeViewColumn ();
            ColumnPrice.Title = "Цена";
            ColumnPrice.Visible = false;
            Gtk.CellRendererText CellPrice = new CellRendererText ();
            CellPrice.Editable = true;
            CellPrice.Edited += OnPriceEdited;
            ColumnPrice.PackStart (CellPrice, true);
            ColumnPrice.AddAttribute(CellPrice, "text", (int)ComponentCol.price);
            ColumnPrice.AddAttribute(CellPrice, "editable", (int)ComponentCol.editable_price);

            ColumnPriceTotal = new Gtk.TreeViewColumn ();
            ColumnPriceTotal.Title = "Сумма";
            ColumnPriceTotal.Visible = false;
            Gtk.CellRendererText CellPriceTotal = new CellRendererText ();
            CellPriceTotal.Editable = false;
            ColumnPriceTotal.PackStart (CellPriceTotal, true);
            ColumnPriceTotal.AddAttribute(CellPriceTotal, "text", (int)ComponentCol.price_total);

            ColumnComment = new Gtk.TreeViewColumn ();
            ColumnComment.Title = "Комментарий";
            Gtk.CellRendererText CellComment = new Gtk.CellRendererText ();
            CellComment.WrapMode = Pango.WrapMode.WordChar;
            CellComment.WrapWidth = 500;
            CellComment.Editable = true;
            CellComment.Edited += OnCommentTextEdited;
            ColumnComment.MaxWidth = 500;
            ColumnComment.PackStart (CellComment, true);
            ColumnComment.AddAttribute(CellComment, "text", (int)ComponentCol.comment);
            ColumnComment.AddAttribute(CellComment, "editable", (int)ComponentCol.editable_comment);

            ColumnDiscount = new Gtk.TreeViewColumn ();
            ColumnDiscount.Title = "Наценка";
            Gtk.CellRendererSpin CellDiscount = new Gtk.CellRendererSpin ();
            CellDiscount.Visible = false;
            CellDiscount.Edited += OnDiscountEdited;
            CellDiscount.Adjustment = new Adjustment (0, -100, 100, 1, 10, 0);
            ColumnDiscount.PackStart (CellDiscount, true);
            ColumnDiscount.AddAttribute (CellDiscount, "text", (int)ComponentCol.discount);
            ColumnDiscount.AddAttribute (CellDiscount, "visible", (int)ComponentCol.editable_discount);
            ColumnDiscount.AddAttribute (CellDiscount, "editable", (int)ComponentCol.editable_discount);

            ColumnName = new Gtk.TreeViewColumn ();
            ColumnName.Title = "Название";
            Gtk.CellRendererText CellName = new CellRendererText ();
            CellName.Edited += OnCellNameEdited;
            ColumnName.PackStart (CellName, true);
            ColumnName.AddAttribute (CellName, "editable", (int)ComponentCol.editable_name);
            ColumnName.AddAttribute (CellName, "text", (int)ComponentCol.nomenclature_title);

            treeviewComponents.AppendColumn(ColumnName);
            treeviewComponents.AppendColumn(ColumnCount);
            treeviewComponents.AppendColumn(ColumnPrice);
            treeviewComponents.AppendColumn(ColumnDiscount);
            treeviewComponents.AppendColumn(ColumnPriceTotal);
            treeviewComponents.AppendColumn(ColumnMaterial);
            treeviewComponents.AppendColumn(ColumnFacing);
            treeviewComponents.AppendColumn(ColumnComment);
            treeviewComponents.Model = ComponentsStore;
            treeviewComponents.TooltipColumn = (int)ComponentCol.nomenclature_description;
            treeviewComponents.ShowAll();

            spinbutton1.Sensitive = false;
            spinbutton1.Value = PriceCorrection;
            checkbuttonShowPrice.Active = false;

            CurrentDrag = new DragInformation();
            //Загрузка списка кубов
            CubeList = new List<Cube>();
            CubeWidgetList = new List<CubeListItem>();
            vboxCubeList = new VBox(false, 6);
            hboxCubeList = new HBox(false, 20);
            string sql = "SELECT * FROM cubes ORDER BY ordinal";

            SqliteCommand cmd = new SqliteCommand(sql, (SqliteConnection)QSMain.ConnectionDB);
            using (SqliteDataReader rdr = cmd.ExecuteReader()) {
                while(rdr.Read()) {
                    if (rdr["image"] == DBNull.Value)
                        continue;
                    Cube TempCube = new Cube();
                    TempCube.NomenclatureId = rdr.GetInt32(rdr.GetOrdinal("id"));
                    TempCube.Name = DBWorks.GetString(rdr, "name", "");
                    TempCube.Description = DBWorks.GetString(rdr, "description", "");
                    TempCube.Height = DBWorks.GetInt(rdr, "height", 0) * 400;
                    TempCube.Widht = DBWorks.GetInt(rdr, "width", 0) * 400;
                    byte[] ImageFile = (byte[])rdr[rdr.GetOrdinal("image")];
                    TempCube.LoadSvg(ImageFile);
                    CubeList.Add(TempCube);
                    MaxCubeVSize = Math.Max(MaxCubeVSize, TempCube.CubesV);
                    MaxCubeHSize = Math.Max(MaxCubeHSize, TempCube.CubesH);

                    //Добавляем виджеты в лист
                    CubeListItem TempWidget = new CubeListItem();
                    TempCube.Widget = TempWidget;
                    TempWidget.CubeItem = TempCube;
                    TempWidget.CubePxSize = CubePxSize;
                    TempWidget.DragInfo = CurrentDrag;
                    CubeWidgetList.Add(TempWidget);
                }
                UpdateCubeList();
                scrolledCubeListV.AddWithViewport(vboxCubeList);
                scrolledCubeListH.AddWithViewport(hboxCubeList);
            }

            //Загрузка Списка типов шкафов
            TypeWidgetList = new List<CupboardListItem>();
            hboxTypeList = new HBox(false, 2);
            Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( "CupboardDesigner.icons.Yes_check.svg" );
            byte[] temparray;
            using(MemoryStream mstream = new MemoryStream()) {
                stream.CopyTo(mstream);
                temparray = mstream.ToArray();
            }
            Rsvg.Handle CheckImage = new Rsvg.Handle(temparray);
            sql = "SELECT * FROM basis ORDER BY ordinal ";
            cmd = new SqliteCommand(sql, (SqliteConnection)QSMain.ConnectionDB);
            using (SqliteDataReader rdr = cmd.ExecuteReader()) {
                Gtk.RadioButton FirstButton = null;
                while(rdr.Read()) {
                    if (rdr["image"] == DBNull.Value)
                        continue;

                    //Добавляем виджеты в лист
                    CupboardListItem TempWidget = new CupboardListItem(CheckImage);
                    TempWidget.id = rdr.GetInt32(rdr.GetOrdinal("id"));
                    TempWidget.DeltaH = rdr.GetInt32(rdr.GetOrdinal("delta_h"));
                    TempWidget.DeltaL = rdr.GetInt32(rdr.GetOrdinal("delta_l"));
                    TempWidget.ItemName = DBWorks.GetString(rdr, "name", "");
                    TempWidget.CubePxSize = CubePxSize;
                    if (FirstButton == null)
                        FirstButton = TempWidget.Button;
                    else
                        TempWidget.Button.Group = FirstButton.Group;
                    int size = DBWorks.GetInt(rdr, "image_size", 0);
                    byte[] ImageFile = new byte[size];
                    rdr.GetBytes(rdr.GetOrdinal("image"), 0, ImageFile, 0, size);
                    TempWidget.Image = new SVGHelper();
                    if (!TempWidget.Image.LoadImage(ImageFile))
                        continue;
                    TempWidget.Button.Clicked += OnBasisChanged;
                    TypeWidgetList.Add(TempWidget);
                    hboxTypeList.Add(TempWidget);
                }
                scrolledTypesH.AddWithViewport(hboxTypeList);
                hboxTypeList.ShowAll();
            }

            OrderCupboard = new Cupboard();
            OnBasisChanged(null, EventArgs.Empty);

            //Настраиваем DND
            Gtk.Drag.DestSet(drawCupboard, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.SourceSet(drawCupboard, ModifierType.Button1Mask, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.DestSet(vboxCubeList, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            Gtk.Drag.DestSet(hboxCubeList, DestDefaults.Motion, TargetTable, Gdk.DragAction.Move);
            vboxCubeList.DragDrop += OnCubeListDragDrop;
            hboxCubeList.DragDrop += OnCubeListDragDrop;
        }
Beispiel #6
0
 private TreeStore populateTreeStoreFromSession()
 {
     TreeStore ts = new TreeStore(typeof(string), typeof(string));
     TreeIter iter;
     TreeIter parent = ts.AppendNode();
     iter = parent;
     ts.SetValues(iter, "Nanoc","Human, male");
     iter = ts.AppendNode(iter);
     ts.SetValues(iter, "Abilities", "");
     ts.AppendValues(iter, "Charisma","0");
     ts.AppendValues(iter, "Dexterity","+1");
     ts.AppendValues(iter, "Intelligence", "0");
     ts.AppendValues(iter, "Power","0");
     ts.AppendValues(iter, "Perception","+1");
     ts.AppendValues(iter, "Strength","+4");
     ts.AppendValues(iter, "Stamina","+2");
     ts.AppendValues(iter, "Willpower","+1");
     iter = ts.AppendNode(parent);
     ts.SetValues(iter, "Experience", "");
     ts.AppendValues(iter, "Level", "1");
     ts.AppendValues(iter, "Barbarian", "230");
     iter = ts.AppendNode(parent);
     ts.SetValues(iter, "Adventures", "");
     return ts;
 }
Beispiel #7
0
        private void ShowAdd2Page()
        {

            Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture);

            VBox layout_vertical   = new VBox (false, 12);

            Button cancel_button = new Button (cancelText);
            cancel_button.Clicked += delegate {
                Controller.PageCancelled ();
            };

            Button continue_button = new Button (continueText)
            {
                Sensitive = false
            };
            continue_button.Clicked += delegate {
                Controller.Add2PageCompleted(
                        Controller.saved_repository, Controller.saved_remote_path);
            };

            Button back_button = new Button (backText)
            {
                Sensitive = true
            };
            back_button.Clicked += delegate {
                Controller.BackToPage1();
            };

            TreeStore repoStore = new Gtk.TreeStore(typeof (string), typeof (SelectionTreeItem));
            TreeIter iter;
            foreach (KeyValuePair<String, String> repository in Controller.repositories)
            {
                iter = repoStore.AppendNode();
                repoStore.SetValues(iter, repository.Value , new SelectionTreeItem(repository.Key, "/"));
            }
            Gtk.TreeView treeView = new Gtk.TreeView(repoStore);
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;
            treeView.AppendColumn("Name", new CellRendererText(), "text", 0);
            treeView.CursorChanged += delegate(object o, EventArgs args) {
                TreeSelection selection = (o as TreeView).Selection;
                TreeModel model;
                if (selection.GetSelected(out model, out iter)) {
                    SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem;

                    // Identify the selected remote path.
                    Controller.saved_remote_path = sti.fullPath;

                    // Identify the selected repository.
                    TreeIter cnode = iter;
                    TreeIter pnode = iter;
                    while (model.IterParent(out pnode, cnode)) {
                        cnode = pnode;
                    }
                    Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository;

                    // Load sub-folders if it has not been done already.
                    // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                    if (sti.childrenLoaded == false)
                    {
                        this.GdkWindow.Cursor = wait_cursor;

                        // Get list of subfolders asynchronously
                        GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
                        IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository,
                                Controller.saved_remote_path, Controller.saved_address,
                                Controller.saved_user, Controller.saved_password, null, null);
                        while (!ar.AsyncWaitHandle.WaitOne(100)) {
                            while (Application.EventsPending()) {
                                Application.RunIteration();
                            }
                        }
                        string[] subfolders = dlgt.EndInvoke(ar);

                        TreePath tp = null;
                        // Create a sub-item for each subfolder
                        foreach (string subfolder in subfolders) {
                            TreeIter newchild = repoStore.AppendNode(iter);
                            repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder),
                                    new SelectionTreeItem(null, subfolder));
                            if (null == tp) {
                                tp = repoStore.GetPath(newchild);
                            }
                        }
                        sti.childrenLoaded = true;
                        if (null != tp) {
                            treeView.ExpandToPath(tp);
                        }
                        this.GdkWindow.Cursor = default_cursor;
                    }
                    continue_button.Sensitive = true;

                }
            };

            ScrolledWindow sw = new ScrolledWindow() {
                ShadowType = Gtk.ShadowType.In
            };
            sw.Add(treeView);

            layout_vertical.PackStart (new Label(""), false, false, 0);
            layout_vertical.PackStart (sw, true, true, 0);
            Add(layout_vertical);
            AddButton(back_button);
            AddButton(continue_button);
            AddButton(cancel_button);
        }
Beispiel #8
0
        private void ShowAdd2Page()
        {
            Header = CmisSync.Properties_Resources.ResourceManager.GetString("Which", CultureInfo.CurrentCulture);

            VBox layout_vertical = new VBox(false, 12);

            Button cancel_button = new Button(cancelText);

            cancel_button.Clicked += delegate {
                Controller.PageCancelled();
            };

            Button continue_button = new Button(continueText)
            {
                Sensitive = false
            };

            continue_button.Clicked += delegate {
                Controller.Add2PageCompleted(
                    Controller.saved_repository, Controller.saved_remote_path);
            };

            Button back_button = new Button(backText)
            {
                Sensitive = true
            };

            back_button.Clicked += delegate {
                Controller.BackToPage1();
            };

            TreeStore repoStore = new Gtk.TreeStore(typeof(string), typeof(SelectionTreeItem));
            TreeIter  iter;

            foreach (KeyValuePair <String, String> repository in Controller.repositories)
            {
                iter = repoStore.AppendNode();
                repoStore.SetValues(iter, repository.Value, new SelectionTreeItem(repository.Key, "/"));
            }
            Gtk.TreeView treeView = new Gtk.TreeView(repoStore);
            treeView.HeadersVisible = false;
            treeView.Selection.Mode = SelectionMode.Single;
            treeView.AppendColumn("Name", new CellRendererText(), "text", 0);
            treeView.CursorChanged += delegate(object o, EventArgs args) {
                TreeSelection selection = (o as TreeView).Selection;
                TreeModel     model;
                if (selection.GetSelected(out model, out iter))
                {
                    SelectionTreeItem sti = model.GetValue(iter, 1) as SelectionTreeItem;

                    // Identify the selected remote path.
                    Controller.saved_remote_path = sti.fullPath;

                    // Identify the selected repository.
                    TreeIter cnode = iter;
                    TreeIter pnode = iter;
                    while (model.IterParent(out pnode, cnode))
                    {
                        cnode = pnode;
                    }
                    Controller.saved_repository = (model.GetValue(cnode, 1) as SelectionTreeItem).repository;

                    // Load sub-folders if it has not been done already.
                    // We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
                    if (sti.childrenLoaded == false)
                    {
                        this.GdkWindow.Cursor = wait_cursor;

                        // Get list of subfolders asynchronously
                        GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
                        IAsyncResult          ar   = dlgt.BeginInvoke(Controller.saved_repository,
                                                                      Controller.saved_remote_path, Controller.saved_address.ToString(),
                                                                      Controller.saved_user, Controller.saved_password, null, null);
                        while (!ar.AsyncWaitHandle.WaitOne(100))
                        {
                            while (Application.EventsPending())
                            {
                                Application.RunIteration();
                            }
                        }
                        string[] subfolders = dlgt.EndInvoke(ar);

                        TreePath tp = null;
                        // Create a sub-item for each subfolder
                        foreach (string subfolder in subfolders)
                        {
                            TreeIter newchild = repoStore.AppendNode(iter);
                            repoStore.SetValues(newchild, System.IO.Path.GetFileName(subfolder),
                                                new SelectionTreeItem(null, subfolder));
                            if (null == tp)
                            {
                                tp = repoStore.GetPath(newchild);
                            }
                        }
                        sti.childrenLoaded = true;
                        if (null != tp)
                        {
                            treeView.ExpandToPath(tp);
                        }
                        this.GdkWindow.Cursor = default_cursor;
                    }
                    continue_button.Sensitive = true;
                }
            };

            ScrolledWindow sw = new ScrolledWindow()
            {
                ShadowType = Gtk.ShadowType.In
            };

            sw.Add(treeView);

            layout_vertical.PackStart(new Label(""), false, false, 0);
            layout_vertical.PackStart(sw, true, true, 0);
            Add(layout_vertical);
            AddButton(back_button);
            AddButton(continue_button);
            AddButton(cancel_button);
        }
Beispiel #9
0
        public DemoMain()
        {
            window = new Gtk.Window("TestForm1");
            Gtk.HBox hbox = new Gtk.HBox(false, 0);
            hbox1 = new Gtk.HBox(false, 0);
            Gtk.HBox hbox2 = new Gtk.HBox(false, 0);
            Gtk.HBox hbox3 = new Gtk.HBox(false, 0);
            hbox.Add(hbox1);
            window.SetDefaultSize(600, 400);
            window.DeleteEvent += new DeleteEventHandler(WindowDelete);

            button1          = new Gtk.Button("button1");
            button1.Clicked += Button1Clicked;
            button2          = new Gtk.Button("button2");
            button3          = new Gtk.Button("button3");
            Gtk.Button button4 = new Gtk.Button("button4");
            button4.Clicked += Button4Clicked;
            Gtk.Button button5 = new Gtk.Button("button5");
            Gtk.Button button6 = new Gtk.Button("button6");
            Gtk.Button button7 = new Gtk.Button("button7");
            button7.Sensitive = false;

            scaleButton1 = new Gtk.ScaleButton(0, 0, 100, 10, new string [0]);

            hbox1.Add(hbox3);
            hbox1.Add(hbox2);
            hbox1.Add(button3);
            hbox1.Add(button2);

            button3.Accessible.Description = "help text 3";
            button3.Sensitive = false;

            label1 = new Gtk.Label("label1");

            textBox1 = new Gtk.Entry();
            Gtk.Entry textBox2 = new Gtk.Entry();
            textBox2.Visibility = false;
            textBox2.Sensitive  = false;
            textBox2.IsEditable = false;
            textBox3            = new Gtk.TextView();
            // TODO: scrollbars
            Gtk.CheckButton checkbox1 = new Gtk.CheckButton("checkbox1");
            Gtk.CheckButton checkbox2 = new Gtk.CheckButton("checkbox2");
            checkbox2.Sensitive = false;

            Gtk.TreeStore   store = new Gtk.TreeStore(typeof(string), typeof(string));
            Gtk.TreeIter [] iters = new Gtk.TreeIter [2];
            iters [0] = store.AppendNode();
            store.SetValues(iters [0], "item 1", "item 1 (2)");
            iters [1] = store.AppendNode(iters [0]);
            store.SetValues(iters [1], "item 1a", "item 1a (2)");
            iters [0] = store.AppendNode();
            store.SetValues(iters [0], "item 2", "item 2 (2)");
            iters [1] = store.AppendNode(iters [0]);
            store.SetValues(iters [1], "item 2a", "item 2a (2)");
            iters [1] = store.AppendNode(iters [0]);
            store.SetValues(iters [1], "item 2b", "item 2b (2)");
            treeView1 = new Gtk.TreeView(store);
            AddTreeViewColumn(treeView1, 0, "column 1");
            treeView1.CollapseAll();

            treeView2 = new Gtk.TreeView(store);
            AddTreeViewColumn(treeView2, 0, "column 1");
            AddTreeViewColumn(treeView2, 1, "column 2");
            treeView2.CollapseAll();
            treeView2.Accessible.Name = "treeView2";

            tableStore = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string), typeof(string));
            iters [0]  = tableStore.AppendNode();
            tableStore.SetValues(iters [0], "False", "Alice", "24", "");
            iters [0] = tableStore.AppendNode();
            tableStore.SetValues(iters [0], "True", "Bob", "28", "");
            dataGridView1 = new Gtk.TreeView(tableStore);
            dataGridView1 = new Gtk.TreeView(tableStore);
            dataGridView1 = new Gtk.TreeView(tableStore);
            AddTreeViewColumn(dataGridView1, 0, "Gender");
            AddTreeViewColumn(dataGridView1, 1, "Name");
            AddTreeViewColumn(dataGridView1, 2, "Age");
            dataGridView1.Accessible.Name = "dataGridView1";

            hboxPanel = new Gtk.HBox();
            Gtk.Button btnRemoveTextBox = new Gtk.Button("Remove");
            btnRemoveTextBox.Clicked += RemoveTextBoxClicked;
            Gtk.Button btnAddTextBox = new Gtk.Button("Add");
            btnAddTextBox.Clicked     += AddTextBoxClicked;
            txtCommand                 = new Gtk.Entry();
            txtCommand.Accessible.Name = "txtCommand";
            Gtk.Button btnRun = new Gtk.Button("Run");
            btnRun.Clicked += btnRunClicked;
            hboxPanel.Add(btnRemoveTextBox);
            hboxPanel.Add(btnAddTextBox);

            Gtk.TreeStore treeStore = new Gtk.TreeStore(typeof(string));
            Gtk.TreeIter  iter      = treeStore.AppendNode();
            treeStore.SetValue(iter, 0, "Item 0");
            iter = treeStore.AppendNode();
            treeStore.SetValue(iter, 0, "Item 1");
            listView1 = new Gtk.TreeView(treeStore);
            AddTreeViewColumn(listView1, 0, "items");
            listView1.Accessible.Name = "listView1";
            listView1.ExpandAll();

            hbox2.Add(button5);
            hbox2.Add(checkbox1);
            hbox2.Add(checkbox2);
            hbox2.Add(button4);
            hbox2.Accessible.Name = "groupBox2";

            hbox3.Add(button7);
            hbox3.Add(button6);
            hbox3.Sensitive       = false;
            hbox3.Accessible.Name = "groupBox3";

            hbox.Add(textBox3);
            hbox.Add(textBox2);
            hbox.Add(textBox1);
            hbox.Add(label1);
            hbox.Add(button1);
            hbox.Add(treeView1);
            hbox.Add(treeView2);
            hbox.Add(listView1);
            hbox.Add(dataGridView1);
            hbox.Add(txtCommand);
            hbox.Add(btnRun);
            hbox.Add(hboxPanel);
            hbox.Add(scaleButton1);

            Gtk.Menu file = new Gtk.Menu();
            file.Append(new Gtk.MenuItem("_New"));
            file.Append(new Gtk.MenuItem("_Open"));
            file.Append(new Gtk.CheckMenuItem("Check"));
            Gtk.MenuItem fileItem = new Gtk.MenuItem("File");
            fileItem.Submenu = file;
            Gtk.Menu edit = new Gtk.Menu();
            edit.Append(new Gtk.MenuItem("_Undo"));
            edit.Append(new Gtk.SeparatorMenuItem());
            edit.Append(new Gtk.MenuItem("_Cut"));
            edit.Append(new Gtk.MenuItem("Copy"));
            edit.Append(new Gtk.MenuItem("_Paste"));
            Gtk.MenuItem editItem = new Gtk.MenuItem("Edit");
            editItem.Submenu = edit;
            Gtk.MenuBar menuBar = new Gtk.MenuBar();
            menuBar.Append(fileItem);
            menuBar.Append(editItem);
            hbox.Add(menuBar);

            hbox.Add(new Gtk.SpinButton(0, 100, 1));
            hbox.Add(new Gtk.ToggleButton("ToggleButton"));
            Gtk.Adjustment adj = new Gtk.Adjustment(50, 0, 100,
                                                    1, 10, 10);
            hbox.Add(new Gtk.VScrollbar(adj));

            window.Add(hbox);
            window.ShowAll();
        }
Beispiel #10
0
        private void btnRunClicked(object o, EventArgs args)
        {
            const string sampleText = "Lorem ipsum dolor sit amet";

            string cmd = txtCommand.Text;

            if (cmd == "click button1")
            {
                button1.Activate();
            }
            else if (cmd == "set textbox3 text")
            {
                textBox3.Buffer.Text = sampleText;
            }
            else if (cmd == "set textBox3 long text")
            {
                textBox3.Buffer.Text = "very very very very very very very very long text to enable the horizontal scroll bar";
            }
            else if (cmd.StartsWith("set textbox3 to "))
            {
                textBox3.Buffer.Text = cmd.Substring(16).
                                       Replace("\\n", "\n").
                                       Replace("\\r", "\r");
            }
            else if (cmd == "select textbox3")
            {
                if (textBox3.Buffer.Text.Length < 4)
                {
                    textBox3.Buffer.Text = sampleText;
                }
                Gtk.TextIter startIter, endIter;
                textBox3.Buffer.GetSelectionBounds(out startIter, out endIter);
                int start, end;
                start     = startIter.Offset;
                end       = endIter.Offset;
                end       = (end - start == 3? 4: 3);
                start     = 0;
                startIter = textBox3.Buffer.GetIterAtOffset(start);
                endIter   = textBox3.Buffer.GetIterAtOffset(end);
                textBox3.Buffer.MoveMark("selection_bound", startIter);
                textBox3.Buffer.MoveMark("insert", endIter);
            }
            else if (cmd == "add table row")
            {
                Gtk.TreeIter iter;
                iter = tableStore.AppendNode();
                tableStore.SetValues(iter, "true", "Mallory", "40");
            }
            else if (cmd == "add table column")
            {
                AddTreeViewColumn(treeView2, 3, "more");
            }
            else if (cmd == "enable multiselect")
            {
                listView1.Selection.Mode = Gtk.SelectionMode.Multiple;
            }
            else if (cmd == "disable multiselect")
            {
                listView1.Selection.Mode = Gtk.SelectionMode.Single;
            }
            else if (cmd == "change button3 name")
            {
                button3.Accessible.Name = "xyzzy";
            }
            else if (cmd == "change button3 helptext")
            {
                button3.Accessible.Description = "plugh";
            }
            else if (cmd == "enable button3")
            {
                button3.Sensitive = true;
            }
            else if (cmd == "disable button3")
            {
                button3.Sensitive = false;
            }
            else if (cmd == "focus textBox3")
            {
                textBox3.GrabFocus();
            }
            else if (cmd == "focus button2")
            {
                button2.GrabFocus();
            }
            else if (cmd.StartsWith("change title:"))
            {
                window.Title = cmd.Substring(cmd.IndexOf(':') + 1);
            }
            else if (cmd == "open FileChooser" && chooser == null)
            {
                chooser = new Gtk.FileChooserDialog("FileChooser", window, FileChooserAction.Open, "data", 0);
                chooser.Show();
            }
            else if (cmd == "close FileChooser" && chooser != null)
            {
                chooser.Destroy();
                chooser = null;
            }
        }
Beispiel #11
0
		public DemoMain ()
		{
			window = new Gtk.Window ("TestForm1");
			Gtk.HBox hbox = new Gtk.HBox (false, 0);
			hbox1 = new Gtk.HBox (false, 0);
			Gtk.HBox hbox2 = new Gtk.HBox (false, 0);
			Gtk.HBox hbox3 = new Gtk.HBox (false, 0);
			hbox.Add (hbox1);
			window.SetDefaultSize (600, 400);
			window.DeleteEvent += new DeleteEventHandler (WindowDelete);

			button1 = new Gtk.Button ("button1");
			button1.Clicked += Button1Clicked;
			button2 = new Gtk.Button ("button2");
			button3 = new Gtk.Button ("button3");
			Gtk.Button button4 = new Gtk.Button ("button4");
			button4.Clicked += Button4Clicked;
			Gtk.Button button5 = new Gtk.Button ("button5");
			Gtk.Button button6 = new Gtk.Button ("button6");
			Gtk.Button button7 = new Gtk.Button ("button7");
			button7.Sensitive = false;

			scaleButton1 = new Gtk.ScaleButton (0, 0, 100, 10, new string [0]);

			hbox1.Add (hbox3);
			hbox1.Add (hbox2);
			hbox1.Add (button3);
			hbox1.Add (button2);

			button3.Accessible.Description = "help text 3";
			button3.Sensitive = false;

			label1 = new Gtk.Label ("label1");

			textBox1 = new Gtk.Entry ();
			Gtk.Entry textBox2 = new Gtk.Entry ();
			textBox2.Visibility = false;
			textBox2.Sensitive = false;
			textBox2.IsEditable = false;
			textBox3 = new Gtk.TextView ();
			// TODO: scrollbars
			Gtk.CheckButton checkbox1 = new Gtk.CheckButton ("checkbox1");
			Gtk.CheckButton checkbox2 = new Gtk.CheckButton ("checkbox2");
			checkbox2.Sensitive = false;

			Gtk.TreeStore store = new Gtk.TreeStore (typeof (string), typeof (string));
			Gtk.TreeIter [] iters = new Gtk.TreeIter [2];
			iters [0] = store.AppendNode ();
			store.SetValues (iters [0], "item 1", "item 1 (2)");
			iters [1] = store.AppendNode (iters [0]);
			store.SetValues (iters [1], "item 1a", "item 1a (2)");
			iters [0] = store.AppendNode ();
			store.SetValues (iters [0], "item 2", "item 2 (2)");
			iters [1] = store.AppendNode (iters [0]);
			store.SetValues (iters [1], "item 2a", "item 2a (2)");
			iters [1] = store.AppendNode (iters [0]);
			store.SetValues (iters [1], "item 2b", "item 2b (2)");
			treeView1 = new Gtk.TreeView (store);
			AddTreeViewColumn (treeView1, 0, "column 1");
			treeView1.CollapseAll ();

			treeView2 = new Gtk.TreeView (store);
			AddTreeViewColumn (treeView2, 0, "column 1");
			AddTreeViewColumn (treeView2, 1, "column 2");
			treeView2.CollapseAll ();
			treeView2.Accessible.Name = "treeView2";

			tableStore = new Gtk.TreeStore (typeof (string), typeof (string), typeof (string), typeof (string));
			iters [0] = tableStore.AppendNode ();
			tableStore.SetValues (iters [0], "False", "Alice", "24", "");
			iters [0] = tableStore.AppendNode ();
			tableStore.SetValues (iters [0], "True", "Bob", "28", "");
			dataGridView1 = new Gtk.TreeView (tableStore);
			dataGridView1 = new Gtk.TreeView (tableStore);
			dataGridView1 = new Gtk.TreeView (tableStore);
			AddTreeViewColumn (dataGridView1, 0, "Gender");
			AddTreeViewColumn (dataGridView1, 1, "Name");
			AddTreeViewColumn (dataGridView1, 2, "Age");
			dataGridView1.Accessible.Name = "dataGridView1";

			hboxPanel = new Gtk.HBox ();
			Gtk.Button btnRemoveTextBox = new Gtk.Button ("Remove");
			btnRemoveTextBox.Clicked += RemoveTextBoxClicked;
			Gtk.Button btnAddTextBox = new Gtk.Button ("Add");
			btnAddTextBox.Clicked += AddTextBoxClicked;
			txtCommand = new Gtk.Entry ();
			txtCommand.Accessible.Name = "txtCommand";
			Gtk.Button btnRun = new Gtk.Button ("Run");
			btnRun.Clicked += btnRunClicked;
			hboxPanel.Add (btnRemoveTextBox);
			hboxPanel.Add (btnAddTextBox);

			Gtk.TreeStore treeStore = new Gtk.TreeStore (typeof (string));
			Gtk.TreeIter iter = treeStore.AppendNode ();
			treeStore.SetValue (iter, 0, "Item 0");
			iter = treeStore.AppendNode ();
			treeStore.SetValue (iter, 0, "Item 1");
			listView1 = new Gtk.TreeView (treeStore);
			AddTreeViewColumn (listView1, 0, "items");
			listView1.Accessible.Name = "listView1";
			listView1.ExpandAll ();

			hbox2.Add (button5);
			hbox2.Add (checkbox1);
			hbox2.Add (checkbox2);
			hbox2.Add (button4);
			hbox2.Accessible.Name = "groupBox2";

			hbox3.Add (button7);
			hbox3.Add (button6);
			hbox3.Sensitive = false;
			hbox3.Accessible.Name = "groupBox3";

			hbox.Add (textBox3);
			hbox.Add (textBox2);
			hbox.Add (textBox1);
			hbox.Add (label1);
			hbox.Add (button1);
			hbox.Add (treeView1);
			hbox.Add (treeView2);
			hbox.Add (listView1);
			hbox.Add (dataGridView1);
			hbox.Add (txtCommand);
			hbox.Add (btnRun);
			hbox.Add (hboxPanel);
			hbox.Add (scaleButton1);

			Gtk.Menu file = new Gtk.Menu ();
			file.Append (new Gtk.MenuItem ("_New"));
			file.Append (new Gtk.MenuItem ("_Open"));
			file.Append (new Gtk.CheckMenuItem ("Check"));
			Gtk.MenuItem fileItem = new Gtk.MenuItem ("File");
			fileItem.Submenu = file;
			Gtk.Menu edit = new Gtk.Menu ();
			edit.Append (new Gtk.MenuItem ("_Undo"));
			edit.Append (new Gtk.SeparatorMenuItem ());
			edit.Append (new Gtk.MenuItem ("_Cut"));
			edit.Append (new Gtk.MenuItem ("Copy"));
			edit.Append (new Gtk.MenuItem ("_Paste"));
			Gtk.MenuItem editItem = new Gtk.MenuItem ("Edit");
			editItem.Submenu = edit;
			Gtk.MenuBar menuBar = new Gtk.MenuBar ();
			menuBar.Append (fileItem);
			menuBar.Append (editItem);
			hbox.Add (menuBar);

		hbox.Add (new Gtk.SpinButton (0, 100, 1));
		hbox.Add (new Gtk.ToggleButton ("ToggleButton"));
			Gtk.Adjustment adj = new Gtk.Adjustment (50, 0, 100,
				1, 10, 10);
		hbox.Add (new Gtk.VScrollbar (adj));

			window.Add (hbox);
			window.ShowAll ();
		}
Beispiel #12
0
        public CoverageView(string fileName, ProgressBar status)
        {
            store = new TreeStore (typeof (string), typeof (string), typeof (string), typeof (string), typeof (object));
            tree = new TreeView (store);

            CellRendererText renderer = new CellRendererText ();
            CellRendererText coverageRenderer = new CellRendererText ();
            // LAME: Why is this property a float instead of a double ?
            renderer.Xalign = 0.5f;

            tree.AppendColumn ("Classes", new CellRendererText (), "text", 0);
            tree.AppendColumn ("Lines Hit", renderer, "text", 1);
            tree.AppendColumn ("Lines Missed", renderer, "text", 2);
            tree.AppendColumn ("Coverage", coverageRenderer, "text", 3);

            tree.GetColumn (0).Resizable = true;
            tree.GetColumn (1).Alignment = 0.0f;
            tree.GetColumn (1).Resizable = true;
            tree.GetColumn (2).Alignment = 0.0f;
            tree.GetColumn (2).Resizable = true;
            tree.GetColumn (3).Alignment = 0.0f;
            tree.GetColumn (3).Resizable = true;
            tree.GetColumn (3).SetCellDataFunc (coverageRenderer, new TreeCellDataFunc (RenderCoverage));

            tree.HeadersVisible = true;

            model = new CoverageModel ();
            foreach (string filter in DEFAULT_FILTERS) {
            model.AddFilter (filter);
            }
            this.status = status;
            model.Progress += Progress;
            model.ReadFromFile (fileName);

            TreeItem root = new TreeItem (store, null, model, "PROJECT");

            Hashtable classes2 = model.Classes;

            namespaces = new Hashtable ();
            string[] sorted_names = new string [classes2.Count];
            classes2.Keys.CopyTo (sorted_names, 0);
            Array.Sort (sorted_names);
            Progress ("Building tree", 0.95);
            foreach (string name in sorted_names) {
            ClassCoverageItem klass = (ClassCoverageItem)classes2 [name];

            if (klass.filtered)
                continue;

            string namespace2 = klass.name_space;
            TreeItem nsItem = (TreeItem)namespaces [namespace2];
            if (nsItem == null) {
                nsItem = new TreeItem (store, root, (CoverageItem)model.Namespaces [namespace2], namespace2);
                //				nsItem.SetPixmap (0, namespaceOpenPixmap);
                namespaces [namespace2] = nsItem;
            }

            if (nsItem.model.filtered)
                continue;

            ClassItem classItem = new ClassItem (store, nsItem, klass, klass.name);

            if (klass.ChildCount != 0) {
                TreeIter treeIter = store.AppendNode (classItem.iter);
                store.SetValues (treeIter, "<loading>");
            }
            }

            tree.ExpandRow (store.GetPath (root.Iter), false);

            // it becomes very hard to navigate if everything is expanded
            //foreach (string ns in namespaces.Keys)
            //	tree.ExpandRow (store.GetPath (((TreeItem)namespaces [ns]).Iter), false);

            tree.RowExpanded += new RowExpandedHandler (OnRowExpanded);
            tree.RowCollapsed += new RowCollapsedHandler (OnRowCollapsed);
            tree.ButtonPressEvent += new ButtonPressEventHandler (OnButtonPress);
            tree.Selection.Mode = SelectionMode.Single;

            source_views = new Hashtable ();
            window_maps = new Hashtable ();
            Progress ("Done", 1.0);
            // LAME: Why doesn't widgets visible by default ???
            tree.Show ();
        }