public Cube Clone() { Cube NewCube = new Cube(); NewCube.Name = Name; NewCube.Description = Description; NewCube.Widht = Widht; NewCube.Height = Height; NewCube.NomenclatureId = NomenclatureId; NewCube.LoadSvg(ImageFile); return NewCube; }
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 bool TestPutCube(Cube cube, int x, int y) { if (cube == null) return false; //Проверяем соответствие границам. if (x < 0 || y < 0) return false; if (x + cube.CubesH > this.CubesH || y + cube.CubesV > this.CubesV) return false; logger.Debug("Testcubes"); //Проверяем на свободно ли место foreach(Cube item in Cubes) { if ((x <= item.BoardPositionX + item.CubesH - 1 && item.BoardPositionX <= x + cube.CubesH - 1) && (y <= item.BoardPositionY + item.CubesV - 1 && item.BoardPositionY <= y + cube.CubesV - 1)) return false; } return true; }