public void DeSerialize() { DirectoryInfo di = new DirectoryInfo(kPath); if (di.Exists) { FileInfo[] fis = di.GetFiles(); foreach (FileInfo fi in fis) { IconEntry entry = new IconEntry(); try { entry.m_dirty = false; entry.DeSerialize(fi); } catch (Exception e) { Debug.LogError(e.Message); } finally { m_iconList.Add(entry); } } } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement != null || e.NewElement == null) { return; } element = (IconEntry)this.Element; Control.EditorAction += Control_EditorAction; var editText = this.Control; if (!string.IsNullOrEmpty(element.Image)) { switch (element.ImageAlignment) { case ImageAlignment.Left: editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null); break; case ImageAlignment.Right: editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null); break; } } editText.CompoundDrawablePadding = 25; Control.Background.SetColorFilter(element.LineColor.ToAndroid(), PorterDuff.Mode.SrcAtop); }
public FloatingIconGump( IconEntry entry ) : base(entry.Location.X, entry.Location.Y) { m_Entry = entry; this.Closable = false; this.Disposable = false; this.Dragable = false; this.Resizable = false; this.AddPage( 0 ); this.AddBackground( 0, 0, 64, 64, 9270 ); this.AddButton( 10, 10, m_Entry.IconID, m_Entry.IconID, 1, GumpButtonType.Reply, 0 ); }
/// <summary> /// Reads an icon resource entry from an input stream. /// </summary> /// <param name="reader">The input stream.</param> /// <returns>The parsed icon resource entry.</returns> public static IconEntry FromReader(IBinaryStreamReader reader) { var result = new IconEntry { Offset = reader.Offset, Rva = reader.Rva, RawIcon = new byte[reader.Length] }; reader.ReadBytes(result.RawIcon, 0, (int)reader.Length); return(result); }
private void buildLabelPage() { labelTreeView = new LabelTreeView(mainWindow, false); labelTreeView.sizeColumn.Visible = false; labelTreeView.Model = filterListStore; labelTreeView.Selection.Changed += OnLabelSelectionChanged; labelScrolledWindow.AddWithViewport(labelTreeView); labelScrolledWindow.ShowAll(); //iconButton.Image = new Gtk.Image(Gtk.IconTheme.Default.LoadIcon("gtk-about", 32, 0)); //iconButton.Sensitive = true; selectIcon = new IconEntry("", "Select an Icon"); iconEntryBox.Add(selectIcon); selectIcon.ShowAll(); }
public FloatingIconGump15( IconEntry entry ) : base(entry) { }
private void Initialize(string fileName) { if (fileName == null) throw new ArgumentNullException("fileName"); IntPtr hModule = IntPtr.Zero; try { hModule = NativeMethods.LoadLibraryEx(fileName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); if (hModule == IntPtr.Zero) throw new Win32Exception(); FileName = GetFileName(hModule); // Enumerate the icon resource and build .ico files in memory. var tmpData = new List<IconEntry>(); ENUMRESNAMEPROC callback = (h, t, name, l) => { var entry = new IconEntry(); entry.name = name; // Refer the following URL for the data structures used here: // http://msdn.microsoft.com/en-us/library/ms997538.aspx // RT_GROUP_ICON resource consists of a GRPICONDIR and GRPICONDIRENTRY's. var dir = GetDataFromResource(hModule, RT_GROUP_ICON, name); // Calculate the size of an entire .icon file. int count = BitConverter.ToUInt16(dir, 4); // GRPICONDIR.idCount int len = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count for (int i = 0; i < count; ++i) len += BitConverter.ToInt32(dir, 6 + 14 * i + 8); // GRPICONDIRENTRY.dwBytesInRes using (var dst = new BinaryWriter(new MemoryStream(len))) { // Copy GRPICONDIR to ICONDIR. dst.Write(dir, 0, 6); int picOffset = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count for (int i = 0; i < count; ++i) { // Load the picture. ushort id = BitConverter.ToUInt16(dir, 6 + 14 * i + 12); // GRPICONDIRENTRY.nID var pic = GetDataFromResource(hModule, RT_ICON, (IntPtr)id); // Copy GRPICONDIRENTRY to ICONDIRENTRY. dst.Seek(6 + 16 * i, SeekOrigin.Begin); dst.Write(dir, 6 + 14 * i, 8); // First 8bytes are identical. dst.Write(pic.Length); // ICONDIRENTRY.dwBytesInRes dst.Write(picOffset); // ICONDIRENTRY.dwImageOffset // Copy a picture. dst.Seek(picOffset, SeekOrigin.Begin); dst.Write(pic, 0, pic.Length); picOffset += pic.Length; } entry.data = ((MemoryStream)dst.BaseStream).ToArray(); tmpData.Add(entry); } return true; }; NativeMethods.EnumResourceNames(hModule, RT_GROUP_ICON, callback, IntPtr.Zero); iconData = tmpData.ToArray(); } finally { if (hModule != IntPtr.Zero) NativeMethods.FreeLibrary(hModule); } }
public ThemifyIconsInterop(string bowerJson, string configCss) { if (!File.Exists(bowerJson)) { throw new FileNotFoundException($"'{bowerJson}' file could not be found"); } if (!File.Exists(configCss)) { throw new FileNotFoundException($"'{configCss}' file could not be found"); } Container = new ConfigContainer(); using (var fileStream = new FileStream(bowerJson, FileMode.Open)) { using (var streamReader = new StreamReader(fileStream)) { var cfg = streamReader.ReadToEnd(); dynamic bower = JsonConvert.DeserializeObject <ExpandoObject>(cfg); Container.ThemifyIcons.DocBlob = bower.version.ToString(); Container.ThemifyIcons.Url = bower.homepage.ToString(); if (bower.keywords.Count > 0) { Container.ThemifyIcons.Tagline = string.Join(",", bower.keywords); } if (bower.license.Count > 0) { Container.ThemifyIcons.License = string.Join(",", bower.license); } if (bower.authors.Count > 0) { Container.ThemifyIcons.Authors = new List <Author>(); foreach (dynamic author in bower.authors) { var str = author.ToString() as string; if (str == null) { continue; } var infos = str.Split('<'); Container.ThemifyIcons.Authors.Add(new Author { Name = infos[0].Trim(), Contact = infos[1].Trim('<', '>').Trim() }); if (bower.repository != null && bower.repository.type != null && bower.repository.type == "git") { Container.ThemifyIcons.Github = new Github(); Container.ThemifyIcons.Github.Url = bower.repository.url.ToString(); } } } } } var parser = new Parser(); _iconContainer = new IconContainer(); using (var fileStream = new FileStream(configCss, FileMode.Open)) { using (var streamReader = new StreamReader(fileStream)) { var css = streamReader.ReadToEnd(); var styleSheet = parser.Parse(css); foreach (var styleRule in styleSheet.StyleRules.Where(s => s.Value.StartsWith(".ti-"))) { var selector = styleRule.Value; var id = selector.Replace(".ti-", string.Empty).Replace(":before", string.Empty); var strUnicode = styleRule.Declarations.First(d => d.Name.Equals("content", StringComparison.InvariantCultureIgnoreCase)).Term.ToString(); var unicode = $@"{(ushort) strUnicode[1]:x4}"; var iconEntry = new IconEntry { Id = id, Unicode = unicode }; _iconContainer.Icons.Add(iconEntry); } } } }
protected override void BuildGui() { entry = new IconEntry(); entry.Changed += OnEntryChanged; if (entry.IconsSupported) { Pixbuf pb = Gdk.Pixbuf.LoadFromResource("Basenji.images.calendar.png"); entry.SetIconFromPixbuf(pb, EntryIconPosition.Secondary); entry.IconPress += OnIconPressEvent; this.Add(entry); } else { // no icons inside entries supported -> // add a fallback button to the right of the entry HBox hbox = new HBox(); hbox.Spacing = 2; hbox.PackStart(entry, true, true, 0); btn = new ToggleButton(); btn.Add(new Arrow(ArrowType.Down, ShadowType.None)); hbox.PackStart(btn, false, false, 0); this.Add(hbox); btn.Toggled += OnBtnToggled; } }
/// <summary> /// this method update the view by adding a brick or incrementing its count /// </summary> /// <param name="brickOrGroup">the brick to add in the view</param> /// <param name="groupEntry">the concerned group in which adding the brick</param> private void addBrick(Layer.LayerItem brickOrGroup, GroupEntry groupEntry) { // get a pointer on the current brick entry list Dictionary<string, BrickEntry> brickEntryList = groupEntry.mBrickEntryList; // get the part number string partNumber = brickOrGroup.PartNumber; // try to get an entry in the image dictionary, else add it IconEntry iconEntry = null; if (!mThumbnailImage.TryGetValue(partNumber, out iconEntry)) { iconEntry = new IconEntry(partNumber, this.listView.SmallImageList); mThumbnailImage.Add(partNumber, iconEntry); } // try to get an entry in the dictionnary for the current brick // to get the previous count, then increase the count and store the new value BrickEntry brickEntry = null; if (!brickEntryList.TryGetValue(partNumber, out brickEntry)) { // create a new entry and add it brickEntry = new BrickEntry(partNumber, iconEntry.mImageIndex); brickEntryList.Add(partNumber, brickEntry); } // affect the correct group to the item brickEntry.Item.Group = groupEntry.Group; // add the item in the list view if not already in if (brickEntry.IsQuantityNull) this.listView.Items.Add(brickEntry.Item); // and increment its count brickEntry.incrementQuantity(); }
private void Initialize(string fileName) { if (fileName == null) { throw new ArgumentNullException("fileName"); } IntPtr hModule = IntPtr.Zero; try { hModule = NativeMethods.LoadLibraryEx(fileName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); if (hModule == IntPtr.Zero) { throw new Win32Exception(); } FileName = GetFileName(hModule); // Enumerate the icon resource and build .ico files in memory. var tmpData = new List <IconEntry>(); ENUMRESNAMEPROC callback = (h, t, name, l) => { var entry = new IconEntry(); entry.name = name; // Refer the following URL for the data structures used here: // http://msdn.microsoft.com/en-us/library/ms997538.aspx // RT_GROUP_ICON resource consists of a GRPICONDIR and GRPICONDIRENTRY's. var dir = GetDataFromResource(hModule, RT_GROUP_ICON, name); // Calculate the size of an entire .icon file. int count = BitConverter.ToUInt16(dir, 4); // GRPICONDIR.idCount int len = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count for (int i = 0; i < count; ++i) { len += BitConverter.ToInt32(dir, 6 + 14 * i + 8); // GRPICONDIRENTRY.dwBytesInRes } using (var dst = new BinaryWriter(new MemoryStream(len))) { // Copy GRPICONDIR to ICONDIR. dst.Write(dir, 0, 6); int picOffset = 6 + 16 * count; // sizeof(ICONDIR) + sizeof(ICONDIRENTRY) * count for (int i = 0; i < count; ++i) { // Load the picture. ushort id = BitConverter.ToUInt16(dir, 6 + 14 * i + 12); // GRPICONDIRENTRY.nID var pic = GetDataFromResource(hModule, RT_ICON, (IntPtr)id); // Copy GRPICONDIRENTRY to ICONDIRENTRY. dst.Seek(6 + 16 * i, SeekOrigin.Begin); dst.Write(dir, 6 + 14 * i, 8); // First 8bytes are identical. dst.Write(pic.Length); // ICONDIRENTRY.dwBytesInRes dst.Write(picOffset); // ICONDIRENTRY.dwImageOffset // Copy a picture. dst.Seek(picOffset, SeekOrigin.Begin); dst.Write(pic, 0, pic.Length); picOffset += pic.Length; } entry.data = ((MemoryStream)dst.BaseStream).ToArray(); tmpData.Add(entry); } return(true); }; NativeMethods.EnumResourceNames(hModule, RT_GROUP_ICON, callback, IntPtr.Zero); iconData = tmpData.ToArray(); } finally { if (hModule != IntPtr.Zero) { NativeMethods.FreeLibrary(hModule); } } }