public PayFromMeter() { this.Build (); //Main meters ReadingListStore = new Gtk.ListStore (typeof (int), // 0 - meter id typeof (int), // 1 - tariff id typeof (double), // 2 - value typeof(int), // 3 - current reading id typeof (string), // 4 - meter name typeof(string), // 5 - date of last reading typeof (int), // 6 - Last reading value typeof (int), // 7 - delta of value typeof(string), // 8 - current reading date typeof(bool) // 9 - take next as PreValue (for fill only) ); Gtk.CellRendererSpin CellValue = new CellRendererSpin(); CellValue.Editable = true; Adjustment adjValue = new Adjustment(0,0,1000000,1,10,0); CellValue.Adjustment = adjValue; CellValue.Edited += OnValueSpinEdited; treeviewMeters.AppendColumn ("Тип счетчика/тариф", new Gtk.CellRendererText (), "text", 4); treeviewMeters.AppendColumn ("Дата", new Gtk.CellRendererText (), "text", 5); treeviewMeters.AppendColumn ("Предыдущие", new Gtk.CellRendererText (), RenderPreValueColumn); treeviewMeters.AppendColumn ("Дата", new Gtk.CellRendererText (), "text", 8); treeviewMeters.AppendColumn ("Текущие", CellValue, RenderValueColumn); treeviewMeters.AppendColumn ("Расход", new Gtk.CellRendererText (), RenderDeltaColumn); treeviewMeters.Model = ReadingListStore; treeviewMeters.ShowAll (); //Child meters ChildListStore = new Gtk.ListStore (typeof (string), // 0 - meter name typeof (string), // 1 - date typeof (int) // 2 - value ); treeviewChilds.AppendColumn ("Тип счетчика/тариф", new Gtk.CellRendererText (), "text", 0); treeviewChilds.AppendColumn ("Дата", new Gtk.CellRendererText (), "text", 1); treeviewChilds.AppendColumn ("Расход", new Gtk.CellRendererText (), RenderChildValueColumn); treeviewChilds.Model = ChildListStore; treeviewChilds.ShowAll (); pendingReadings = new List<PendingMeterReading>(); }
public Basis() { this.Build(); drawBasis.SetSizeRequest(250, 250); //Создаем таблицу номенклатур NomenclatureStore = new ListStore(typeof(long), typeof(bool), typeof(int), typeof(string), typeof(int)); CellRendererToggle CellSelected = new CellRendererToggle(); CellSelected.Activatable = true; CellSelected.Toggled += onCellSelectToggled; Gtk.CellRendererSpin CellCount = new CellRendererSpin(); CellCount.Editable = true; Adjustment adjCost = new Adjustment(0,0,100,1,5,0); CellCount.Adjustment = adjCost; CellCount.Edited += OnCountSpinEdited; treeviewNomenclature.AppendColumn("", CellSelected, "active", (int)NomenclatureCol.selected); treeviewNomenclature.AppendColumn("Название", new CellRendererText(), "text", (int)NomenclatureCol.nomenclature); treeviewNomenclature.AppendColumn("Количество", CellCount, "text", (int)NomenclatureCol.count); treeviewNomenclature.Model = NomenclatureStore; treeviewNomenclature.ShowAll(); //Загрузка списка номенклатур string sql = "SELECT id, name FROM nomenclature WHERE type = 'construct'"; SqliteCommand cmd = new SqliteCommand(sql, (SqliteConnection)QSMain.ConnectionDB); using (SqliteDataReader rdr = cmd.ExecuteReader()) { while(rdr.Read()) { NomenclatureStore.AppendValues((long) -1, false, DBWorks.GetInt(rdr, "id", -1), DBWorks.GetString(rdr, "name", ""), 1 ); } } }
private void AddColumns(TreeView treeView) { { var column = new TreeViewColumn(); var cell = new CellRendererText(); cell.Editable = true; cell.Edited += this.TextStringEdited; column.Title = Column.TextString.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.TextString); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererText(); cell.Editable = true; cell.Edited += this.TextDoubleEdited; column.Title = Column.TextDouble.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.TextDouble); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererText(); column.Title = Column.TextBool.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.TextBool); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererToggle(); cell.Toggled += this.ToggleCheckBoxToggled; cell.Active = true; cell.Activatable = true; column.Title = Column.ToggleCheckBox.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "active", (int)Column.ToggleCheckBox); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererToggle(); cell.Toggled += this.ToggleRadioButtonToggled; cell.Active = true; cell.Activatable = true; cell.Radio = true; column.Title = Column.ToggleRadioButton.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "active", (int)Column.ToggleRadioButton); this.treeview1.AppendColumn(column); } { // Note: the text in this renderer has to be parseable as a floating point number var column = new TreeViewColumn(); var cell = new CellRendererSpin(); cell.Editable = true; cell.Edited += this.SpinTest1Edited; // Adjustment - Contains the range information for the cell. // Value: Must be non-null for the cell to be editable. cell.Adjustment = new Adjustment(0, 0, float.MaxValue, 1, 2, 0); // ClimbRate - Provides the acceleration rate for when the button is held down. // Value: Defaults to 0, must be greater than or equal to 0. cell.ClimbRate = 0; // Digits - Number of decimal places to display (seems to only work while editing the cell?!?). // Value: An integer between 0 and 20, default value is 0. cell.Digits = 3; column.Title = Column.Spin.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.Spin); this.treeview1.AppendColumn(column); } { ListStore model = new ListStore(typeof(string)); model.AppendValues("Value1"); model.AppendValues("Value2"); model.AppendValues("Value3"); var column = new TreeViewColumn(); var cell = new CellRendererCombo(); cell.Width = 75; cell.Editable = true; cell.Edited += this.ComboEdited; // bool. Whether to use an entry. // If true, the cell renderer will include an entry and allow to // enter values other than the ones in the popup list. cell.HasEntry = true; // TreeModel. Holds a tree model containing the possible values for the combo box. // Use the CellRendererCombo.TextColumn property to specify the column holding the values. cell.Model = model; // int. Specifies the model column which holds the possible values for the combo box. // Note: this refers to the model specified in the model property, not the model // backing the tree view to which this cell renderer is attached. cell.TextColumn = 0; column.Title = Column.Combo.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.Combo); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererAccel(); cell.AccelMode = CellRendererAccelMode.Other; cell.Editable = true; cell.AccelEdited += new AccelEditedHandler(this.OnAccelEdited); cell.AccelCleared += new AccelClearedHandler(this.OnAccelCleared); column.Title = Column.Accel.ToString(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.Accel); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererProgress(); column.Title = Column.Progress.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.ProgressText); column.AddAttribute(cell, "value", (int)Column.Progress); this.treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererText(); column.Title = Column.PixbufStockLabel.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "text", (int)Column.PixbufStockLabel); treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererPixbuf(); column.Title = Column.PixbufStockIcon.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "stock-id", (int)Column.PixbufStockIcon); treeview1.AppendColumn(column); } { var column = new TreeViewColumn(); var cell = new CellRendererPixbuf(); column.Title = Column.PixbufCustom.GetDescription(); column.PackStart(cell, true); column.AddAttribute(cell, "pixbuf", (int)Column.PixbufCustom); treeview1.AppendColumn(column); } }
public LocationsBox (Locations locations, UIManager uiManager) : this(new Builder("locations_box.ui")) { Locations = locations; // create the actions Gtk.Action create = new Gtk.Action("createLocation","Create Location","",Stock.Add); create.Activated += OnCreateLocation; Gtk.Action delete = new Gtk.Action("deleteLocation","Delete Location","",Stock.Remove); delete.Activated += OnDeleteLocation; Gtk.Action gotoItem = new Gtk.Action("gotoLocationItem","Goto Item","",Stock.GoForward); gotoItem.Activated += OnGotoLocationItem; Gtk.Action action = new Gtk.Action("location","Location"); ActionGroup group = new ActionGroup("location"); group.Add(create); group.Add(delete); group.Add(gotoItem); group.Add(action); uiManager.InsertActionGroup(group,0); // create item column with id TreeViewColumn col = new TreeViewColumn (); locationsItemColumn = col; col.Title = "Item"; col.Expand = true; CellRenderer render; render = new CellRendererPixbuf (); col.PackStart (render, false); col.AddAttribute (render, "pixbuf", 1); render = new CellRendererText (); (render as CellRendererText).Editable = true; render.EditingStarted += OnStartLocationItemEdit; col.PackStart (render, true); col.AddAttribute (render, "text", 2); locationsView.AppendColumn(col); locationsView.AppendColumn ("ID", new Gtk.CellRendererText (), "text", 3); // create the labeled column col = new TreeViewColumn (); col.Title = "Labeled"; render = new CellRendererToggle (); (render as CellRendererToggle).Toggled += OnLabeledToggle; col.PackStart (render, false); col.AddAttribute (render, "active", 4); col.AddAttribute (render, "activatable", 5); locationsView.AppendColumn(col); // create the amount column col = new TreeViewColumn (); col.Title = "Amount"; render = new CellRendererSpin (); (render as CellRendererText).Editable = true; (render as CellRendererText).Edited += OnAmountEdited; Adjustment adj = new Adjustment(0, 0, 0, 0, 0, 0); //set all limits etc to 0 adj.Upper = 1000000000; // assign some special values, that aren't 0 adj.PageIncrement = 10; adj.StepIncrement = 1; (render as CellRendererSpin).Adjustment = adj; col.PackStart (render, false); col.AddAttribute (render, "text", 6); locationsView.AppendColumn (col); //set model etc locations.CollectionChanged += OnLocationCreation; TreeModelFilter filter = new LocationsFilter ( new LocationsModel( locations )); filter.Model.RowInserted += OnRowInserted; filter.VisibleFunc = new TreeModelFilterVisibleFunc (FilterLocations); locationsView.Model = filter; locationsView.Reorderable = true; // create the items chooser completion locationCompletion = new LocationItemChooser(); TreeModel compModel = new TreeModelAdapter( new ItemsModel(locations.Inventory.Items)); locationCompletion.Model = compModel; locationCompletion.MatchFunc = LocationItemCompletionMatch; locationCompletion.MinimumKeyLength = 0; // add the item info cell renderer to the completion render = new CellRendererText (); locationCompletion.PackStart (render, true); locationCompletion.AddAttribute (render, "text", 2); // create the popups uiManager.AddUiFromResource("locations_box_menues.xml"); locationPopup = (Menu) uiManager.GetWidget("/locationPopup"); }
public Order(OrderType Type) { this.Build(); CurrentType = Type; QSMain.CheckConnectionAlive(); string sql = "SELECT name, id FROM status WHERE usedtypes LIKE '%" + CurrentType.ToString() + "%'"; ComboWorks.ComboFillUniversal(comboStatus, sql, "{0}", null, 1, ComboWorks.ListMode.OnlyItems); ComboWorks.ComboFillReference(comboMark, "marks", ComboWorks.ListMode.OnlyItems); if(CurrentType == OrderType.install) { ComboWorks.ComboFillReference(comboManufacturer, "manufacturers", ComboWorks.ListMode.WithNo); ComboWorks.ComboFillReference(comboStock, "stocks", ComboWorks.ListMode.WithNo); } else { labelGlass.Visible = labelManufacturer.Visible = comboManufacturer.Visible = labelStock.Visible = comboStock.Visible = labelEurocode.Visible = entryEurocode.Visible = false; } //Загрузка списка стекл sql = "SELECT id, name FROM glass"; MySqlCommand cmd = new MySqlCommand(sql, QSMain.connectionDB); GlassInDB = new Dictionary<string, bool>(); using (MySqlDataReader rdr = cmd.ExecuteReader()) { while(rdr.Read()) { checksGlass.AddCheckButton(rdr["id"].ToString(), rdr["name"].ToString()); GlassInDB.Add(rdr["id"].ToString(), false); } } //Загрузка списка услуг ServiceListStore = new Gtk.ListStore (typeof(int), // 0 - service id typeof(bool), // 1 - Активно typeof(string), // 2 - Наименование typeof(double), // 3 - Цена typeof(long) // 4 - order_pay id ); CellRendererToggle CellPay = new CellRendererToggle(); CellPay.Activatable = true; CellPay.Toggled += onCellPayToggled; Gtk.CellRendererSpin CellCost = new CellRendererSpin(); CellCost.Editable = true; CellCost.Digits = 2; Adjustment adjCost = new Adjustment(0,0,100000000,100,1000,0); CellCost.Adjustment = adjCost; CellCost.Edited += OnCostSpinEdited; treeviewCost.AppendColumn ("", CellPay, "active", 1); treeviewCost.AppendColumn ("Название", new CellRendererText(), "text", 2); treeviewCost.AppendColumn ("Стоимость", CellCost, RenderPriceColumn); ((CellRendererToggle)treeviewCost.Columns[0].CellRenderers[0]).Activatable = true; treeviewCost.Model = ServiceListStore; treeviewCost.ShowAll(); sql = "SELECT id, name, price FROM services WHERE order_type = @order_type ORDER BY ordinal"; cmd = new MySqlCommand(sql, QSMain.connectionDB); cmd.Parameters.AddWithValue("@order_type", CurrentType.ToString()); using (MySqlDataReader rdr = cmd.ExecuteReader()) { while(rdr.Read()) { ServiceListStore.AppendValues(rdr.GetInt32("id"), false, rdr.GetString("name"), DBWorks.GetDouble(rdr, "price", 0), (long)-1 ); } } }
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; }
public DialogNewGame() { this.Build(); // ==================== // Pixel Initialization // ==================== pixelGrid.CenterGridHorizontally = false; pixelGrid.HeightRequest = 150; tablePixel.Add(pixelGrid); var pixelGridChild = (Gtk.Table.TableChild)tablePixel[pixelGrid]; pixelGridChild.LeftAttach = 1; pixelGridChild.RightAttach = 3; pixelGridChild.TopAttach = 3; pixelGridChild.BottomAttach = 4; pixelGrid.Tiles = 12; pixelGrid.Show(); // ======================= // Flatland Initialization // ======================= treeViewFlatlandTeams.Model = flatlandTeamStore; treeViewFlatlandTeams.AppendColumn("Team", new CellRendererText(), delegate(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) { var teamIndex = (int)model.GetValue(iter, 0); ((CellRendererText)cell).Text = ((char)(((int)'A') + teamIndex)).ToString(); } ); // Set up "Color" column var themeModel = new ListStore(typeof(string)); foreach (var colorName in Enum.GetNames(typeof(ThemeColor)).OrderBy(x => x)) { themeModel.AppendValues(colorName); } var colorColumnRenderer = new CellRendererCombo() { Model = themeModel, TextColumn = 0, Editable = true, HasEntry = false, }; colorColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 1, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Color", colorColumnRenderer, "text", 1); treeViewFlatlandTeams.Columns[1].MinWidth = 100; // Set up "Kind" column var kindModel = new ListStore(typeof(string)); kindModel.AppendValues("Normal"); kindModel.AppendValues("Predator"); kindModel.AppendValues("Prey"); var kindColumnRenderer = new CellRendererCombo() { Model = kindModel, TextColumn = 0, Editable = true, HasEntry = false }; kindColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 2, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Kind", kindColumnRenderer, "text", 2); treeViewFlatlandTeams.Columns[2].MinWidth = 100; // Set up "Move Delay" column var moveDelayColumnRenderer = new CellRendererSpin(); moveDelayColumnRenderer.Editable = true; moveDelayColumnRenderer.Adjustment = new Adjustment(3, 1, 9999, 1, 5, 1); moveDelayColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 3, Convert.ToInt32(de.NewText)); } }; treeViewFlatlandTeams.AppendColumn("Move Delay", moveDelayColumnRenderer, "text", 3); // Set up "Wrap" column var wrapColumnRenderer = new CellRendererToggle() { Activatable = true }; wrapColumnRenderer.Toggled += delegate(object ds, ToggledArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 4, !Convert.ToBoolean(flatlandTeamStore.GetValue(iter, 4))); } }; treeViewFlatlandTeams.AppendColumn("Wrap", wrapColumnRenderer, "active", 4); // Set up "Scoring" column var scoringModel = new ListStore(typeof(string)); scoringModel.AppendValues("None"); scoringModel.AppendValues("Selfish"); scoringModel.AppendValues("Communal"); var scoringColumnRenderer = new CellRendererCombo() { Model = scoringModel, TextColumn = 0, Editable = true, HasEntry = false }; scoringColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (flatlandTeamStore.GetIterFromString(out iter, de.Path)) { flatlandTeamStore.SetValue(iter, 5, de.NewText); } }; treeViewFlatlandTeams.AppendColumn("Scoring", scoringColumnRenderer, "text", 5); treeViewFlatlandTeams.Columns[2].MinWidth = 100; // Add default team flatlandTeamStore.AppendValues(0, "Black", "Normal", 3, false, "None"); // ====================== // Forager Initialization // ====================== treeViewForagerProbabilities.Model = foragerProbabilityStore; treeViewForagerProbabilities.AppendColumn("Plot", new CellRendererText(), "text", 0); // Probability column var probabilityColumnRenderer = new CellRendererSpin(); probabilityColumnRenderer.Editable = true; probabilityColumnRenderer.Adjustment = new Adjustment(1, 0, 100, 1, 5, 1); probabilityColumnRenderer.Edited += delegate(object ds, EditedArgs de) { TreeIter iter; if (foragerProbabilityStore.GetIterFromString(out iter, de.Path)) { var setIndex = comboBoxForagerProbabilitySet.Active; var plotNumber = (int)foragerProbabilityStore.GetValue(iter, 0); var newProbability = Convert.ToInt32(de.NewText); foragerProbabilities[setIndex][plotNumber - 1] = newProbability; foragerProbabilityStore.SetValue(iter, 1, newProbability); } }; treeViewForagerProbabilities.AppendColumn("Probability", probabilityColumnRenderer, "text", 1); // Add default probability set foragerProbabilities.Add(GetDefaultForagerProbabilitySet()); comboBoxForagerProbabilitySet.AppendText("1"); comboBoxForagerProbabilitySet.Active = 0; }
public static void CreateNodeViewColumns(NodeView view) { view.AppendColumn("Poz.", new CellRendererText(), "text", 0); CellRendererToggle toggle_visible = new CellRendererToggle(); toggle_visible.Activatable = true; toggle_visible.Toggled += delegate(object o, ToggledArgs args) { TreePath path = new TreePath(args.Path); ConfigurableColumn cc = ((ConfigurableColumn)view.NodeStore.GetNode(path)); cc.Conf_Visible = !cc.Conf_Visible; }; view.AppendColumn("Viditelný", toggle_visible, "active", 2); view.AppendColumn("Nadpis", new CellRendererText(), "text", 1); CellRendererSpin col_width = new CellRendererSpin(); col_width.Editable = false; col_width.Digits = 0; col_width.ClimbRate = 2; col_width.Edited += HandleCol_widthEdited; view.AppendColumn("Šířka", col_width, "adjustment", 3, "text", 4); }