public PackageMetadataMediaDownloadService(IApplicationCacheProvider appCacheProvider) { Argument.IsNotNull(() => appCacheProvider); _iconCache = appCacheProvider.EnsureIconCache(); _iconCache.FallbackValue = new System.Windows.Media.Imaging.BitmapImage(new Uri(_defaultIconUri)); }
public CommandForm() { InitializeComponent(); pictureBox.Image = IconCache.GetAppImage( Environment.ExpandEnvironmentVariables(@"%windir%\system32\cmd.exe"), IconCache.IconSize.Large); }
/// <summary>Attempts to load the icon if it has not already been loaded.</summary> public void LoadIcon() { if (cacheState == IconCacheState.NotCached) { cacheState = IconCacheState.Caching; IconCache.CacheFileTypeAsync(Extension, OnCacheIconAndTypeName); } }
public IconCache EnsureIconCache() { if (_iconCache is null) { _iconCache = new IconCache(); } return(_iconCache); }
public void Cache_equally_generated_bitmaps() { using (var sut = new IconCache()) { var bitmap1 = sut.Get(IconChar.AddressBook, 32, Color.Black, Color.Transparent); var bitmap2 = sut.Get(IconChar.AddressBook, 32, Color.Black, Color.Transparent); bitmap2.Should().BeSameAs(bitmap1, "bitmaps with equal keys should not be recreated"); } }
static Explorer() { var files = new DirectoryInfo(IconCachePath).EnumerateFiles(); foreach (var file in files) { IconCache.Add(file.Name.Split('.')[0], Image.FromFile(file.FullName)); } }
public void Cache_equally_generated_bitmaps() { using var sut = new IconCache <IconChar>(); const IconChar iconChar = IconChar.AddressBook; var font = iconChar.FontFamilyFor(); var bitmap1 = sut.Get(font, iconChar, 32, Color.Black, Color.Transparent); var bitmap2 = sut.Get(font, iconChar, 32, Color.Black, Color.Transparent); bitmap2.Should().BeSameAs(bitmap1, "bitmaps with equal keys should not be recreated"); }
// Use this for initialization void Start() { var config = GameObject.FindGameObjectsWithTag("ConfigObject"); iconCache = config[0].GetComponent <IconCache>(); image = GetComponent <Image>(); var parentImage = transform.parent.GetComponent <Image>(); icons = new EffectIcons(); parentImage.sprite = icons.icons[icon]; }
public static IIconCache Get(string path) { IconCache cache; if (!_icons.TryGetValue(path, out cache)) { cache = new IconCache(path); _icons[path] = cache; } return(cache); }
public static void Layout(string msg) { EditorGUILayout.BeginHorizontal(); GuiColorManager.New(Color.white); GUILayout.Label(IconCache.Get("warning").Texture, GUILayout.Width(64), GUILayout.Height(64)); GuiColorManager.Revert(); GuiColorManager.New(K10GuiStyles.RED_TINT_COLOR); GUILayout.Box(msg, GUILayout.ExpandWidth(true), GUILayout.MinHeight(59)); GuiColorManager.Revert(); EditorGUILayout.EndHorizontal(); }
public void OnNext(ShopData pData) { _item = pData.selectedItem; if (_item != null) { _itemTexture = IconCache.GetCachedTexture(_item.iconName); } else { _itemTexture = IconCache.GetCachedTexture("item"); } }
public ImageList ProtocolIconsImageList() { ImageList images = new ImageList(); images.ImageSize = new Size(16, 16); images.ColorDepth = ColorDepth.Depth32Bit; foreach (var icon in IconCache.GetProtocolIcons()) { images.Images.Add(icon.Key, icon.Value); } return(images); }
public EffectIcons() { var config = GameObject.FindGameObjectsWithTag("ConfigObject"); iconCache = config[0].GetComponent <IconCache>(); var data = TextReader.ReadSets("EffectIcons"); foreach (var item in data) { icons.Add(item[0], iconCache.icons[int.Parse(item[1])]); } }
public static bool Draw(Rect area, GameObject go) { if (go != null) { var t = AssetPreview.GetAssetPreview(go); if (IconButton.Draw(area, t ?? IconCache.Get("search").Texture)) { EditorGUIUtility.PingObject(go); } return(t != null); } return(false); }
private void btnSystrayIcon_Click(object sender, EventArgs e) { Button btn = sender as Button; var name = btn.Tag.ToString(); colorDialog1.Color = (Color)Settings.Default.PropertyValues[name].PropertyValue; if (DialogResult.OK == colorDialog1.ShowDialog()) { Color newColor = colorDialog1.Color; btn.Image = IconGenerator.GetImage(SIZE_ICON, newColor); Settings.Default.PropertyValues[name].PropertyValue = newColor; //Settings.Default.Save(); IconCache.Reload(); } }
public static void Layout <T>(SerializedProperty prop, string newFolderPath) where T : Behaviour { var obj = prop.objectReferenceValue; if (obj == null) { var create = GUILayout.Button(IconCache.Get("match").Texture, new GUIStyle(), GUILayout.Width(16)); if (create) { var go = K10EditorGUIUtils.CreateSequentialGO <T>(newFolderPath + prop.ToFileName()); prop.objectReferenceValue = go; prop.serializedObject.ApplyModifiedProperties(); } } Layout <T>(prop, false); }
/// <summary> /// Gets the image source for the specified path /// </summary> /// <param name="path">The path to get the image source for</param> /// <returns>The image source</returns> private static ImageSource GetImageSource(FileSystemPath path) { lock (IconCache) { if (IconCache.ContainsKey(path.FullPath)) { return(IconCache[path.FullPath]); } ImageSource image = WindowsHelpers.GetIconOrThumbnail(path, ShellThumbnailSize.Small).ToImageSource(); image.Freeze(); IconCache.Add(path.FullPath, image); return(image); } }
public TransferForm() { InitializeComponent(); MaximumSize = new Size(MaxWidth, MaxHeight); MinimumSize = new Size(MinWidth, MinHeight); ConfigureToolbar(); bandwidthSplitButton.Image = IconCache.IconForName("bandwidth", 16); showToolStripButton.Image = IconCache.IconForName("reveal"); connectionsSplitButton.Image = IconCache.IconForName("connection", 16); transferListView.FullRowSelect = false; transferListView.HeaderStyle = ColumnHeaderStyle.None; transferListView.ShowGroups = false; transferListView.View = View.Details; transferListView.RowHeight = 90; transferListView.MultiSelect = true; transferListView.GridLines = false; transferListView.UseOverlays = false; dummyColumn.Width = 0; transferColumn.FillsFreeSpace = true; transferListView.ItemSelectionChanged += delegate(object sender, ListViewItemSelectionChangedEventArgs e) { TransferControl uc = ((TransferControl)transferListView.GetEmbeddedControl(1, e.ItemIndex)); if (null != uc) { uc.Selected = e.IsSelected; if (e.IsSelected && uc.FocusRemoveAllowed) { transferListView.Select(); } } }; transferListView.ItemSelectionChanged += (sender, e) => SelectionChangedEvent(); transferListView.ItemsChanged += delegate { transferListView.GridLines = transferListView.GetItemCount() > 0; }; AddContextMenu(transcriptBox); //force handle creation IntPtr intPtr = Handle; }
public SceneTab(Context context, string title, Vector2?initialSize = null, string placeNextToDock = null, DockSlot slot = DockSlot.SlotNone) : base(context, title, initialSize, placeNextToDock, slot) { _iconCache = GetSubsystem <IconCache>(); WindowFlags = WindowFlags.NoScrollbar; _view = new SceneView(Context); _gizmo = new Gizmo(Context); _view.Scene.LoadXml(Cache.GetResource <XMLFile>("Scenes/SceneLoadExample.xml").GetRoot()); CreateObjects(); SubscribeToEvent <Update>(OnUpdate); SubscribeToEvent <PostUpdate>(args => RenderNodeContextMenu()); SubscribeToEvent <GizmoSelectionChanged>(args => { _selectedComponent = null; }); _eventArgs.Clear(); _eventArgs[InspectHierarchy.HierarchyProvider] = Variant.FromObject(this); SendEvent <InspectHierarchy>(_eventArgs); }
public NewDocumentDialog(Workbench workbench, Type type, String path) { if (!typeof(ISinapseConcept).IsAssignableFrom(type)) { throw new ArgumentException("Type must implement the ISinapseConcept interface", "type"); } this.directory = path ?? String.Empty; this.workbench = workbench; InitializeComponent(); IconCache.CreateList(smallIcons, largeIcons); this.ViewMode = View.LargeIcon; createListView(type); }
/// <summary>Constructs the see <see cref="DriveItemViewModel"/>.</summary> /// /// <param name="drives">The collection containing this drive item view model.</param> /// <param name="model">The model that this view model represents.</param> public DriveItemViewModel(DriveItemViewModelCollection drives, DriveItem model) { this.drives = drives; Model = model; IIconAndName iconName = IconCache.CacheIconAndDisplayName(Name); if (iconName != null) { Icon = iconName.Icon; DisplayName = iconName.Name; } else { Icon = IconCache.VolumeIcon; DisplayName = $"({PathUtils.TrimSeparatorEnd(Name)})"; } }
void CheckIcon() { Trace.Call(); var iconCache = new IconCache("server-icons"); // REMOTING CALL var protocol = ProtocolManager.Protocol; string iconName = String.Format("{0}.ico", ID); string iconPath; if (iconCache.TryGetIcon(protocol, iconName, out iconPath)) { UpdateServerIcon(iconPath); } string websiteUrl = null; lock (NetworkWebsiteUrls) { if (!NetworkWebsiteUrls.TryGetValue(ID, out websiteUrl) && !NetworkWebsiteUrls.TryGetValue(protocol, out websiteUrl)) { // unknown network and protocol, nothing to download return; } // download in background so Sync() doesn't get slowed down WebProxy proxy = null; // ignore the proxy settings of remote engines if (Frontend.IsLocalEngine) { proxy = ProxySettings.GetWebProxy(websiteUrl); if (proxy == null) { // HACK: WebClient will always use the system proxy if set to // null so explicitely override this by setting an empty proxy proxy = new WebProxy(); } } iconCache.Proxy = proxy; iconCache.BeginDownloadIcon(protocol, iconName, websiteUrl, UpdateServerIcon, null); } }
private void EnsureDBIconIsInKPRPCIconCache() { string cachedBase64 = IconCache <string> .GetIconEncoding(_host.Database.IOConnectionInfo.Path); if (string.IsNullOrEmpty(cachedBase64)) { // the icon wasn't in the cache so lets calculate its base64 encoding and then add it to the cache using (MemoryStream ms = new MemoryStream()) using (Image originalImage = _host.MainWindow.Icon.ToBitmap()) using (Image imgNew = new Bitmap(originalImage, new Size(16, 16))) { imgNew.Save(ms, System.Drawing.Imaging.ImageFormat.Png); string imageData = Convert.ToBase64String(ms.ToArray()); IconCache <string> .AddIcon(_host.Database.IOConnectionInfo.Path, imageData); } } }
/// <summary> /// Gets the image source for the specified path /// </summary> /// <param name="path">The path to get the image source for</param> /// <returns>The image source</returns> private static ImageSource GetImageSource(FileSystemPath path) { if (IconCache.ContainsKey(path.FullPath)) { return(IconCache[path.FullPath]); } // ReSharper disable once PossibleNullReferenceException return(Application.Current.Dispatcher.Invoke(() => { var image = path.GetIconOrThumbnail(ShellThumbnailSize.Small).ToImageSource(); image.Freeze(); RL.Logger?.LogDebugSource($"The link item image source has been created for the path '{path}'"); IconCache.Add(path.FullPath, image); return image; })); }
void ButtonAddEffect(SerializedProperty list, int id, string name) { var listId = -1; for (int i = 0; i < list.arraySize && listId == -1; i++) { if (list.GetArrayElementAtIndex(i).intValue == id) { listId = i; } } EditorGUILayout.BeginHorizontal(); var has = (listId != -1); if (EditorGUILayout.Toggle(has, GUILayout.MaxWidth(15)) != has) { if (!has) { listId = list.arraySize; list.arraySize++; list.GetArrayElementAtIndex(listId).intValue = id; } else { K10EditorGUIUtils.RemoveItemFromArray(list, listId); } } var icon = IconCache.Get(name.ToLower()).Texture; if (icon != null) { GUILayout.Label(icon, K10GuiStyles.basicCenterStyle, GUILayout.Width(ICON_SIZE)); } GUILayout.Label(name, K10GuiStyles.smallboldStyle); EditorGUILayout.EndHorizontal(); }
private ImageSource GetIconImageSource() { // Folders are easy if (this is Folder) { return(IconCache.GetIconForFolder()); } // Look up icon in cache ImageSource source = IconCache.GetIconForFile(this.FilePath, onLoaded: () => { // This will only get called if the icon needs to be loaded // Force a re-fetch of the Icon property. The icon should now be loaded in the cache. App.Current.Dispatcher.Invoke(() => { OnPropertyChanged(nameof(this.Icon)); }); }); // This may be null if icon is not yet available. return(source); }
public static bool Layout <T>(SerializedProperty prop, string newFolderPath, params GUILayoutOption[] options) where T : ScriptableObject { var createdNewSO = false; var obj = prop.objectReferenceValue; GUILayout.BeginHorizontal(); if (obj == null) { var icon = IconCache.Get("match").Texture; var slh = EditorGUIUtility.singleLineHeight; var create = GUILayout.Button(icon, new GUIStyle(), GUILayout.Width((icon.width / icon.height) * slh), GUILayout.Height(slh)); if (create) { var go = ScriptableObjectUtils.CreateSequential <T>(newFolderPath + prop.ToFileName()); prop.objectReferenceValue = go; prop.serializedObject.ApplyModifiedProperties(); createdNewSO = true; } } Layout <T>(prop, false, options); GUILayout.EndHorizontal(); return(createdNewSO); }
public MessageTextView() { Trace.Call(); _MessageTextTagTable = BuildTagTable(); _ThemeSettings = new ThemeSettings(); EmojiCache = new IconCache("emoji"); Buffer = new Gtk.TextBuffer(_MessageTextTagTable); MotionNotifyEvent += OnMotionNotifyEvent; PopulatePopup += OnPopulatePopup; ExposeEvent += OnExposeEvent; Realized += delegate { CheckStyle(); }; StyleSet += delegate(object o, Gtk.StyleSetArgs args) { if (!IsRealized) { // HACK: avoid GTK+ crash in gtk_text_attributes_copy_values() return; } CheckStyle(); }; }
public void Run(IconCache icons) { ImageSource icon = icons.CacheSpecialFolder(Folder, out string name); Callback(icon, name); }
public void Run(IconCache icons) { ImageSource icon = icons.CacheFileType(Extension, out string name); Callback(icon, name); }