System.Drawing.Icon.Dispose()

Here are the examples of the csharp api class System.Drawing.Icon.Dispose() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

37 Examples 7

1. Example

Project: Baka-MPlayer-old
Source File: TabbedThumbnail.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _taskbarWindow = null;

                if (Icon != null) { Icon.Dispose(); }
                Icon = null;

                _title = null;
                _tooltip = null;
                WindowsControl = null;
            }

            if (CurrentHBitmap != IntPtr.Zero)
            {
                ShellNativeMethods.DeleteObject(CurrentHBitmap);
                CurrentHBitmap = IntPtr.Zero;
            }
        }

2. Example

Project: Baka-MPlayer-old
Source File: ThumbnailButton.cs
public void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Dispose managed resources
                Icon.Dispose();
                tooltip = null;
            }
        }

3. Example

Project: SylphyHorn
Source File: TaskTrayIcon.cs
private void ChangeIcon(Icon newIcon)
		{
			if (this._icon != this._defaultIcon)
			{
				this._icon?.Dispose();
			}

			this._icon = newIcon;
			this._notifyIcon.Icon = newIcon;
		}

4. Example

Project: StarryEyes
Source File: WinFormsIcon.cs
public void Dispose()
        {
            this.winFormsIcon.Dispose();
        }

5. Example

Project: ShareX
Source File: IconContainer.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (icon != null)
                {
                    icon.Dispose();
                }
            }
            icon = null;
            base.Dispose(disposing);
        }

6. Example

Project: log2console
Source File: TabbedThumbnail.cs
public void Dispose(bool disposing)
        {
            if (disposing)
            {
                taskbarWindow = null;

                if (Icon != null)
                    Icon.Dispose();
                Icon = null;

                title = null;
                tooltip = null;
                WindowsControl = null;
            }

            if (CurrentHBitmap != IntPtr.Zero)
            {
                ShellNativeMethods.DeleteObject(CurrentHBitmap);
                CurrentHBitmap = IntPtr.Zero;
            }
        }

7. Example

Project: log2console
Source File: ThumbnailButton.cs
public void Dispose(bool disposing)
        {
            if (disposing)
            {
                // Dispose managed resources
                Icon.Dispose();
                tooltip = null;
            }
        }

8. Example

Project: log2console
Source File: ThumbnailToolbarButton.cs
void Dispose(bool disposing)
    {
      if (!disposing) return;

      if (_icon != null)
        _icon.Dispose();
      _tooltip = null;
    }

9. Example

Project: ShareX
Source File: IconContainer.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (icon != null)
                {
                    icon.Dispose();
                }
            }
            icon = null;
            base.Dispose(disposing);
        }

10. Example

Project: SylphyHorn
Source File: TaskTrayIcon.cs
public void Dispose()
		{
			this._notifyIcon?.Dispose();
			this._icon?.Dispose();

			VirtualDesktop.CurrentChanged -= this.OnCurrentDesktopChanged;
		}

11. Example

Project: nbfc
Source File: BindableTaskbarIcon.cs
private static void UpdateTaskbarIcon(TaskbarIcon icon, Icon newIcon)
        {
            Icon oldIcon = icon.Icon;
            IntPtr handle = oldIcon.Handle;

            icon.Icon = newIcon;

            oldIcon.Dispose();
            NativeMethods.DestroyIcon(handle);
        }

12. Example

Project: roslyn
Source File: NavigateToIconFactory.cs
public void Dispose()
        {
            foreach (var icon in _iconCache.Values)
            {
                icon.Dispose();
            }

            _iconCache.Clear();
        }

13. Example

Project: SystemEx
Source File: ExplorerBarOffice2003Renderer.cs
protected override void OnRenderGrip(ExplorerBarRenderEventArgs e)
        {
            var brush = new LinearGradientBrush(
                e.ExplorerBar.GripBounds,
                Color.FromArgb(89, 135, 214),
                Color.FromArgb(0, 45, 150),
                LinearGradientMode.Vertical
            );

            e.Graphics.FillRectangle(brush, e.ExplorerBar.GripBounds);

            Icon icon = Properties.Resources.Grip2003;

            var iconRect = new Rectangle(
                (e.ExplorerBar.Width / 2) - (icon.Width / 2),
                ((e.ExplorerBar.GripBounds.Height / 2) - (icon.Height / 2)) + 1,
                icon.Width,
                icon.Height
            );

            e.Graphics.DrawIcon(icon, iconRect);

            icon.Dispose();
        }

14. Example

Project: SystemEx
Source File: ExplorerBarOffice2007Renderer.cs
protected override void OnRenderGrip(ExplorerBarRenderEventArgs e)
        {
            var brush = new LinearGradientBrush(
                e.ExplorerBar.GripBounds,
                Color.FromArgb(227, 239, 255),
                Color.FromArgb(179, 212, 255),
                LinearGradientMode.Vertical
            );

            e.Graphics.FillRectangle(brush, e.ExplorerBar.GripBounds);

            Icon icon = Properties.Resources.Grip2007;

            var iconRect = new Rectangle(
                (e.ExplorerBar.Width / 2) - (icon.Width / 2),
                ((e.ExplorerBar.GripBounds.Height / 2) - (icon.Height / 2)) + 1,
                icon.Width,
                icon.Height
            );

            e.Graphics.DrawIcon(icon, iconRect);

            icon.Dispose();
        }

15. Example

Project: ShareX
Source File: WindowCapture.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_image != null)
                {
                    _image.Dispose();
                }
                if (_cursor != null)
                {
                    _cursor.Dispose();
                }
            }
            _image = null;
            _cursor = null;
        }

16. Example

Project: Gmail-Notifier-Plus
Source File: ImageHelper.cs
public static void Cleanup() {
			foreach(var kvp in _iconCache) {
				kvp.Value.Dispose();
			}
			_iconCache.Clear();
		}

17. Example

Project: ShareX
Source File: WindowCapture.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (image != null)
                {
                    image.Dispose();
                }
                if (cursor != null)
                {
                    cursor.Dispose();
                }
            }
            image = null;
            cursor = null;
        }

18. Example

Project: slimCat
Source File: IconService.cs
public void Dispose(bool isManagedDispose)
        {
            if (!isManagedDispose)
                return;

            icon.Dispose();
            catIcon.Dispose();
            balloonIcon.Dispose();
        }

19. Example

Project: dotnet-samples
Source File: ScaleButtonImages.cs
private Bitmap GetScaledBitmapFromIcon(Icon icon)
        {
            Icon scaledIcon = new Icon(icon, GetScaledSize());
            Bitmap bitmap = scaledIcon.ToBitmap();
            scaledIcon.Dispose();

            return bitmap;
        }

20. Example

Project: Gmail-Notifier-Plus
Source File: Toast.cs
protected override void Dispose(bool disposing) {
			if(disposing && (components != null)) {
				components.Dispose();
			}

			_closeTimer.Dispose();

			this.Icon.Dispose();
			this.Icon = null;

			_iconPrev.Dispose();
			_iconInbox.Dispose();
			_iconNext.Dispose();

			if(_PictureOpen != null) {
				_PictureOpen.Image.Dispose();
			}

			if(_openTip != null) {
				_openTip.Dispose();
			}
			

			base.Dispose(disposing);
		}

21. Example

Project: slimCat
Source File: IconService.cs
public void ShutDown()
        {
            icon.Dispose();
            catIcon.Dispose();
            balloonIcon.Dispose();
            Dispatcher.InvokeShutdown();
        }

22. Example

Project: scallion
Source File: WinGLNative.cs
void Dispose(bool calledManually)
        {
            if (!disposed)
            {
                if (calledManually)
                {
                    // Safe to clean managed resources
                    DestroyWindow();
                    if (Icon != null)
                        Icon.Dispose();
                }
                else
                {
                    Debug.Print("[Warning] INativeWindow leaked ({0}). Did you forget to call INativeWindow.Dispose()?", this);
                }

                Disposed(this, EventArgs.Empty);
                disposed = true;
            }
        }

23. Example

Project: OpenLiveWriter
Source File: BlogClientLoginControl.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (_domainIcon != null)
                    _domainIcon.Dispose();
                if (_domainImage != null)
                    _domainImage.Dispose();
            }
            base.Dispose(disposing);
        }

24. Example

Project: ultraviolet
Source File: DesktopIconLoader.cs
public override Surface2D LoadIcon()
        {
            var assembly = Assembly.GetEntryAssembly();
            var assemblyLocation = (assembly == null) ? typeof(UltravioletContext).Assembly.Location : assembly.Location;

            /* HACK: Trying to load an icon from a network path throws an exception, which is a problem
             * given the way the test servers are currently configured. So just skip loading it. */
            var uri = new Uri(assemblyLocation);
            if (uri.IsUnc)
                return null;

            var icon = System.Drawing.Icon.ExtractAssociatedIcon(assemblyLocation);
            if (icon == null)
            {
                throw new InvalidOperationException();
            }

            try
            {
                using (var iconbmp = icon.ToBitmap())
                {
                    using (var source = new DesktopSurfaceSource(iconbmp))
                    {
                        return Surface2D.Create(source);
                    }
                }
            }
            finally
            {
                icon.Dispose();
            }
        }

25. Example

Project: TileIconifier
Source File: FrmIconSelector.cs
private void BuildListView()
        {
            //reset the list view items
            lvwIcons./n ..... /n //View Source file for more details /n }

26. Example

Project: KeeThief
Source File: UIUtil.cs
public static Image GetFileIcon(string strFilePath, int w, int h)
		{
			Image img = null;
			try
			{
				Icon ico = Icon.ExtractAssociatedIcon(strFilePath);
				if(ico == null) return null;

				img = new Bitmap(w, h, PixelFormat.Format32bppArgb);
				using(Graphics g = Graphics.FromImage(img))
				{
					g.Clear(Color.Transparent);
					g.InterpolationMode = InterpolationMode.HighQualityBicubic;
					g.SmoothingMode = SmoothingMode.HighQuality;
					g.DrawIcon(ico, new Rectangle(0, 0, img.Width, img.Height));
				}

				ico.Dispose();
			}
			catch(Exception) { Debug.Assert(NativeLib.IsUnix()); }

			return img;
		}

27. Example

Project: Solutionizer
Source File: Icons.cs
public static ImageSource GetImageFromFileAndIndex(string file, int iconIndex) {
            return _imagesForFileAndIndex.GetOrAdd(file + "-" + iconIndex, _ => {
                var icon = ExtractIconFromExe(file, iconIndex, false);
                if (icon != null) {
                    try {
                        ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
                            icon.Handle,
                            Int32Rect.Empty,
                            BitmapSizeOptions.FromEmptyOptions());
                        imageSource.Freeze();
                        return imageSource;
                    } finally {
                        icon.Dispose();
                    }
                }
                return null;
            });
        }

28. Example

Project: IconExtractor
Source File: Form1.cs
private void btnPickFile_Click(object sender, EventArgs e)
        {
            var result = iconPi/n ..... /n //View Source file for more details /n }

29. Example

Project: circuitdiagram
Source File: TaskDialogViewModel.cs
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExpose/n ..... /n //View Source file for more details /n }

30. Example

Project: TraceLab
Source File: native.cs
[System.Security.SecuritySafeCritical]
        public static Bitmap getStandardViewButton0(int iconIndex)
        {
            Bitmap result = null;
            using (new ThemingActivationContext())
            {
                // Create a toolbar
                IntPtr hWndToolbar = CreateWindowEx(0, "ToolbarWindow32", null, 0, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                if (hWndToolbar != IntPtr.Zero)
                {
                    SendMessage(hWndToolbar, TB_LOADIMAGES, IDB_VIEW_SMALL_COLOR, HINST_COMMCTRL);

                    IntPtr hImageList = SendMessage(hWndToolbar, TB_GETIMAGELIST, 0, 0);
                    if (hImageList != IntPtr.Zero)
                    {
                        IntPtr hIcon = ImageList_GetIcon(hImageList, iconIndex, ILD_TRANSPARENT);
                        if (hIcon != IntPtr.Zero)
                        {
                            Icon icon = Icon.FromHandle(hIcon);
                            result = icon.ToBitmap();
                            icon.Dispose();
                            DestroyIcon(hIcon);
                        }
                        ImageList_Destroy(hImageList);
                    }
                    DestroyWindow(hWndToolbar);
                }
            }
            return result;
        }

31. Example

Project: KeeThief
Source File: GfxUtil.cs
private static Image ExtractBestImageFromIco(byte[] pb)
		{
			List<GfxImage> l = UnpackIco(pb/n ..... /n //View Source file for more details /n }

32. Example

Project: ClevoECView
Source File: AppContext.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                timerUI.Stop();
                timerUI.Dispose();
                notifyIcon.Visible = false;
                notifyIcon.Dispose();
                canvas.Dispose();
                icon.Dispose();
                iconBitmap.Dispose();
                font.Dispose();
                brushBg.Dispose();
                brushFg.Dispose();
                brushText.Dispose();
                brushDrop.Dispose();
                penLine.Dispose();
                clevoControlWorker.Dispose();
            }
            base.Dispose(disposing);
        }

33. Example

Project: ClevoECView
Source File: AppContext.cs
private void UpdateIcon()
        {
            var currentRpms = clevoControlWorker.CurrentRpms;
  /n ..... /n //View Source file for more details /n }

34. Example

Project: Aurora
Source File: ConfigUI.xaml.cs
private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Micro/n ..... /n //View Source file for more details /n }

35. Example

Project: KeeThief
Source File: MainForm_Functions.cs
private void UpdateUIState(bool bSetModified, Control cOptFocus)
		{
			// For instance when running/n ..... /n //View Source file for more details /n }

36. Example

Project: byteflood
Source File: FileNameToIcon.cs
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!App.Settings.ShowFileIcons)
                return null;

            string path = value.ToString();

            int dot = path.LastIndexOf('.');

            string ext = "";

            if (dot >= 0)
            {
                ext = path.Substring(dot).ToLower();
            }

            if (Utility.IconCache.ContainsKey(ext))
            {
                return Utility.IconCache[ext];
            }
            else
            {
                string temp_file = Path.Combine(Path.GetTempPath(), "temp" + ext);

                File.Open(temp_file, FileMode.OpenOrCreate).Close();
                
                path = temp_file;

                Icon i = Icon.ExtractAssociatedIcon(path);

                File.Delete(temp_file);

                MemoryStream m = new MemoryStream();

                i.Save(m);
                i.Dispose();

                BitmapImage bi = new BitmapImage();

                bi.BeginInit();
                bi.CacheOption = BitmapCacheOption.Default;
                bi.StreamSource = m;
                bi.EndInit();
                bi.Freeze();

                Utility.IconCache.Add(ext, bi);

                return bi;
            }

        }

37. Example

Project: KeeThief
Source File: UIUtil.cs
public static Icon CreateColorizedIcon(Icon icoBase, Color clr, int qSize)
		{
			if(icoBase == null/n ..... /n //View Source file for more details /n }