protected override void loadFromStream(Stream stream) { using (MemoryStream ms = new MemoryStream()) { stream.CopyTo(ms); hSVG = new Rsvg.Handle(ms.ToArray()); Dimensions = new Size(hSVG.Dimensions.Width, hSVG.Dimensions.Height); } }
public CupboardListItem(Rsvg.Handle checkimage) { this.Build(); Button = new RadioButton(""); Button.Toggled += HandleButtonToggled; this.State = Button.State; CheckImage = checkimage; drawImage.AddEvents((int)Gdk.EventMask.ButtonPressMask); }
public override void Load(Interface iface, string path) { Path = path; if (sharedResources.ContainsKey(path)) { sharedPicture sp = sharedResources [path]; hSVG = (Rsvg.Handle)sp.Data; Dimensions = sp.Dims; return; } using (Stream stream = iface.GetStreamFromPath(path)) { using (MemoryStream ms = new MemoryStream()) { stream.CopyTo(ms); hSVG = new Rsvg.Handle(ms.ToArray()); Dimensions = new Size(hSVG.Dimensions.Width, hSVG.Dimensions.Height); } } sharedResources [path] = new sharedPicture(hSVG, Dimensions); }
public void LoadSvgFragment(string fragment) { hSVG = new Rsvg.Handle(System.Text.Encoding.Unicode.GetBytes(fragment)); Dimensions = new Size(hSVG.Dimensions.Width, hSVG.Dimensions.Height); }
protected override void loadFromStream(Stream stream) { using (MemoryStream ms = new MemoryStream ()) { stream.CopyTo (ms); hSVG = new Rsvg.Handle (ms.ToArray ()); Dimensions = new Size (hSVG.Dimensions.Width, hSVG.Dimensions.Height); } }
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; }
protected void OnDrawCubeExposeEvent(object o, ExposeEventArgs args) { if (ImageFile == null) return; logger.Debug("Render Cairo"); using (Context cr = Gdk.CairoHelper.Create (args.Event.Window)) { int MaxWidth = args.Event.Area.Width; int MaxHeight = args.Event.Area.Height; logger.Debug("Image widget size W: {0} H: {1}", MaxWidth, MaxHeight); Rsvg.Handle svg = new Rsvg.Handle(ImageFile); double vratio = (double) MaxHeight / svg.Dimensions.Height; double hratio = (double) MaxWidth / svg.Dimensions.Width; double ratio = Math.Min(vratio, hratio); cr.Scale(ratio, ratio); svg.RenderCairo(cr); } }
public void LoadSvg(byte[] file) { ImageFile = file; SvgImage = new Rsvg.Handle(ImageFile); }
public static void Init() { hSVGsymbols = loadRessourceSvg("MagicCrow.images.abilities.svg"); hSVGManas = loadRessourceSvg("MagicCrow.images.Mana2.svg"); }
private void LoadGraphics() { String PiecesPath = "Pieces"; PieceGraphics[1] = new Rsvg.Handle(GetDataFile(PiecesPath, "fu.svg")); PieceGraphics[2] = new Rsvg.Handle(GetDataFile(PiecesPath, "tokin.svg")); PieceGraphics[3] = new Rsvg.Handle(GetDataFile(PiecesPath, "kyousha.svg")); PieceGraphics[4] = new Rsvg.Handle(GetDataFile(PiecesPath, "narikyou.svg")); PieceGraphics[5] = new Rsvg.Handle(GetDataFile(PiecesPath, "keima.svg")); PieceGraphics[6] = new Rsvg.Handle(GetDataFile(PiecesPath, "narikei.svg")); PieceGraphics[7] = new Rsvg.Handle(GetDataFile(PiecesPath, "gin.svg")); PieceGraphics[8] = new Rsvg.Handle(GetDataFile(PiecesPath, "narigin.svg")); PieceGraphics[9] = new Rsvg.Handle(GetDataFile(PiecesPath, "kin.svg")); PieceGraphics[10] = new Rsvg.Handle(GetDataFile(PiecesPath, "kakugyou.svg")); PieceGraphics[11] = new Rsvg.Handle(GetDataFile(PiecesPath, "ryuuma.svg")); PieceGraphics[12] = new Rsvg.Handle(GetDataFile(PiecesPath, "hisha.svg")); PieceGraphics[13] = new Rsvg.Handle(GetDataFile(PiecesPath, "ryuuou.svg")); PieceGraphics[14] = new Rsvg.Handle(GetDataFile(PiecesPath, "ou.svg")); GyokushouGraphic = new Rsvg.Handle(GetDataFile(PiecesPath, "gyokushou.svg")); //TODO check if pieces are correctly loaded }