public PackageMetadataMediaDownloadService(IApplicationCacheProvider appCacheProvider)
        {
            Argument.IsNotNull(() => appCacheProvider);

            _iconCache = appCacheProvider.EnsureIconCache();
            _iconCache.FallbackValue = new System.Windows.Media.Imaging.BitmapImage(new Uri(_defaultIconUri));
        }
예제 #2
0
        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);
        }
예제 #5
0
 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");
     }
 }
예제 #6
0
        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");
        }
예제 #8
0
    // 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];
    }
예제 #9
0
파일: IconsManager.cs 프로젝트: k10czar/K10
    public static IIconCache Get(string path)
    {
        IconCache cache;

        if (!_icons.TryGetValue(path, out cache))
        {
            cache        = new IconCache(path);
            _icons[path] = cache;
        }
        return(cache);
    }
예제 #10
0
 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();
 }
예제 #11
0
 public void OnNext(ShopData pData)
 {
     _item = pData.selectedItem;
     if (_item != null)
     {
         _itemTexture = IconCache.GetCachedTexture(_item.iconName);
     }
     else
     {
         _itemTexture = IconCache.GetCachedTexture("item");
     }
 }
예제 #12
0
        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);
        }
예제 #13
0
    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])]);
        }
    }
예제 #14
0
 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);
 }
예제 #15
0
        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();
            }
        }
예제 #16
0
        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);
        }
예제 #17
0
    /// <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);
        }
    }
예제 #18
0
        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;
        }
예제 #19
0
        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);
        }
예제 #20
0
        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)})";
            }
        }
예제 #22
0
        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);
            }
        }
예제 #23
0
        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);
                        }
            }
        }
예제 #24
0
        /// <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;
            }));
        }
예제 #25
0
    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();
    }
예제 #26
0
        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);
        }
예제 #27
0
        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);
        }
예제 #28
0
        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();
            };
        }
예제 #29
0
            public void Run(IconCache icons)
            {
                ImageSource icon = icons.CacheSpecialFolder(Folder, out string name);

                Callback(icon, name);
            }
예제 #30
0
            public void Run(IconCache icons)
            {
                ImageSource icon = icons.CacheFileType(Extension, out string name);

                Callback(icon, name);
            }