ToBitmap() 공개 메소드

public ToBitmap ( ) : Image
리턴 Image
        private void showDetails()
        {
            // show the link's details:
            lblShortCut.Text = System.IO.Path.GetFileName(link.ShortCutFile);

            txtTarget.Text      = link.Target;
            txtArguments.Text   = link.Arguments;
            txtDescription.Text = link.Description;
            txtIconFile.Text    = link.IconPath;
            txtIconIndex.Text   = (link.IconPath.Length > 0 ? link.IconIndex.ToString() : "");
            System.Drawing.Icon linkIcon = link.LargeIcon;
            if (linkIcon != null)
            {
                picIcon.Image = linkIcon.ToBitmap();
                linkIcon.Dispose();
            }
            else
            {
                picIcon.Image = null;
            }
            linkIcon = link.SmallIcon;
            if (linkIcon != null)
            {
                picSmallIcon.Image = linkIcon.ToBitmap();
                linkIcon.Dispose();
            }
            else
            {
                picSmallIcon.Image = null;
            }
        }
예제 #2
0
		private void OnFormLoad(object sender, EventArgs e)
		{
			GlobalWindowManager.AddWindow(this, this);

			m_lblCopyright.Text = PwDefs.Copyright + ".";

			string strTitle = PwDefs.ProductName;
			string strDesc = KPRes.Version + " " + PwDefs.VersionString;

			Icon icoNew = new Icon(Properties.Resources.KeePass, 48, 48);

			m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width,
				m_bannerImage.Height, BannerStyle.Default,
				icoNew.ToBitmap(), strTitle, strDesc);
			this.Icon = Properties.Resources.KeePass;

			m_lvComponents.Columns.Add(KPRes.Components, 100, HorizontalAlignment.Left);
			m_lvComponents.Columns.Add(KPRes.Version, 100, HorizontalAlignment.Left);

			try { GetAppComponents(); }
			catch(Exception) { Debug.Assert(false); }

			int nWidth = m_lvComponents.ClientRectangle.Width / 2;
			int nMod = m_lvComponents.ClientRectangle.Width % 2;
			m_lvComponents.Columns[0].Width = nWidth;
			m_lvComponents.Columns[1].Width = nWidth + nMod;

			UIUtil.SetExplorerTheme(m_lvComponents.Handle);
		}
예제 #3
0
        protected void GetIconFromPath(string path)
        {
            if (File.Exists(path))
            {
                System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(path);
                Bitmap bitmap            = icon.ToBitmap();

                using (MemoryStream memory = new MemoryStream())
                {
                    bitmap.Save(memory, ImageFormat.Png);
                    memory.Position = 0;
                    BitmapImage bitmapimage = new BitmapImage();
                    bitmapimage.BeginInit();
                    bitmapimage.StreamSource = memory;
                    bitmapimage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapimage.EndInit();

                    this.Icon = bitmapimage;
                }
            }
            else
            {
                this.Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("../Resources/missing-file.png", UriKind.Relative));
            }
        }
예제 #4
0
        public static System.Drawing.Bitmap ToBitmap(System.Drawing.Icon icon, Skybound.Drawing.Design.IconFormat iconFormat)
        {
            Skybound.Drawing.Design.IconFile.BITMAP   bitmap;
            Skybound.Drawing.Design.IconFile.ICONINFO iconinfo;

            System.Drawing.Bitmap bitmap1 = null;
            if (icon != null)
            {
                if (iconFormat.ColorDepth == System.Windows.Forms.ColorDepth.Depth32Bit)
                {
                    Skybound.Drawing.Design.IconFile.GetIconInfo(icon.Handle, out iconinfo);
                    bitmap = new Skybound.Drawing.Design.IconFile.BITMAP();
                    Skybound.Drawing.Design.IconFile.GetObjectBitmap(iconinfo.hbmColor, System.Runtime.InteropServices.Marshal.SizeOf(typeof(Skybound.Drawing.Design.IconFile.BITMAP)), ref bitmap);
                    int   i    = bitmap.bmWidthBytes * bitmap.bmHeight;
                    int[] iArr = new int[(i / 4)];
                    Skybound.Drawing.Design.IconFile.GetBitmapBits(iconinfo.hbmColor, i, iArr);
                    System.Runtime.InteropServices.GCHandle gchandle = System.Runtime.InteropServices.GCHandle.Alloc(iArr, System.Runtime.InteropServices.GCHandleType.Pinned);
                    System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap(bitmap.bmWidth, bitmap.bmHeight, bitmap.bmWidthBytes, System.Drawing.Imaging.PixelFormat.Format32bppArgb, System.Runtime.InteropServices.Marshal.UnsafeAddrOfPinnedArrayElement(iArr, 0));
                    bitmap1 = new System.Drawing.Bitmap(bitmap2.Width, bitmap2.Height);
                    using (System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap1))
                    {
                        graphics.DrawImage(bitmap2, 0, 0, bitmap2.Width, bitmap2.Height);
                    }
                    gchandle.Free();
                    Skybound.Drawing.Design.IconFile.DeleteObject(iconinfo.hbmMask);
                    Skybound.Drawing.Design.IconFile.DeleteObject(iconinfo.hbmColor);
                }
                else
                {
                    bitmap1 = icon.ToBitmap();
                }
            }
            return(bitmap1);
        }
예제 #5
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="AppIcon">The icon of the host application.</param>
		public UnrealAboutBox(Icon AppIcon, EngineVersioning Versioning)
		{
			InitializeComponent();

			Assembly EntryAssembly = Assembly.GetEntryAssembly();
			
			mLabel_AppVersion.Text = mLabel_AppVersion.Text.Replace("N/A", EntryAssembly.GetName().Version.ToString());

			if( Versioning == null )
			{
				Versioning = new EngineVersioning();
			}

			if( Versioning.Changelist > -1 )
			{
				mLabel_Changelist.Text = mLabel_Changelist.Text.Replace( "N/A", Versioning.Changelist.ToString() );
			}

			if( Versioning.EngineVersion > -1 )
			{
				mLabel_EngineVersion.Text = mLabel_EngineVersion.Text.Replace( "N/A", Versioning.EngineVersion.ToString() );
			}

			mPictureBox_AppIcon.Image = AppIcon.ToBitmap();
		}
예제 #6
0
        public MessageForm(string caption, string message, string[] buttons, Icon icon)
        {
            InitializeComponent();

            int width = icon.Width;
            if (icon != null)
            {
                image_box.Image = (Image)icon.ToBitmap();
                int w = image_box.Image.Width - width;
                if (w > 0)
                {
                    this.Width += w;
                    this.message.Left += w;
                }
            }

            this.Text = caption;
            this.message.Text = message;

            for (int i = buttons.Length - 1; i >= 0; i--)
            {
                Button b = new Button();
                b.Tag = i;
                b.Text = buttons[i];
                b.Click += b_Click;
                flowLayoutPanel1.Controls.Add(b);
                if (i == 0)
                    b.Select();
            }
        }
예제 #7
0
        public Form2()
        {
            InitializeComponent();
            Icon i = new System.Drawing.Icon(LogViewer.Properties.Resources.Actions_configure1, new System.Drawing.Size(48, 48));

            button1.Image = i.ToBitmap();
        }
예제 #8
0
 public PostHttp()
 {
     this.settings = new Settings(AddonPath + "/settings.txt");
       Icon icon = new Icon(AddonPath + "/Icon.ico");
       this.bmpIcon = icon.ToBitmap();
       this.bmpIcon16 = new Icon(icon, new Size(16, 16)).ToBitmap();
 }
예제 #9
0
		private void OnFormLoad(object sender, EventArgs e)
		{
			GlobalWindowManager.AddWindow(this, this);

			m_lblCopyright.Text = PwDefs.Copyright + ".";

			string strTitle = PwDefs.ProductName;
			string strDesc = KPRes.Version + " " + PwDefs.VersionString;

			Icon icoNew = new Icon(Properties.Resources.KeePass, 48, 48);

			BannerFactory.CreateBannerEx(this, m_bannerImage, icoNew.ToBitmap(),
				strTitle, strDesc);
			this.Icon = Properties.Resources.KeePass;

			m_lvComponents.Columns.Add(KPRes.Component, 100, HorizontalAlignment.Left);
			m_lvComponents.Columns.Add(KPRes.Status + " / " + KPRes.Version, 100,
				HorizontalAlignment.Left);

			try { GetAppComponents(); }
			catch(Exception) { Debug.Assert(false); }

			UIUtil.SetExplorerTheme(m_lvComponents, false);
			UIUtil.ResizeColumns(m_lvComponents, true);
		}
예제 #10
0
파일: Win32.cs 프로젝트: fire-eggs/igorary
        public static Image GetFileIconAsImage(string fullpath, FileIconSize size)
        {
            SHFILEINFO info = new SHFILEINFO();

            uint flags = SHGFI_USEFILEATTRIBUTES | SHGFI_ICON;

            if (size == FileIconSize.Small)
            {
                flags |= SHGFI_SMALLICON;
            }

            int retval = SHGetFileInfo(fullpath, FILE_ATTRIBUTE_NORMAL, ref info, System.Runtime.InteropServices.Marshal.SizeOf(info), flags);

            if (retval == 0)
            {
                return(null);    // error occured
            }

            System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(info.hIcon);

            //ImageList imglist = new ImageList();
            //imglist.ImageSize = icon.Size;
            //imglist.Images.Add(icon);

            //Image image = imglist.Images[0];
            //icon.Dispose();
            //return image;
            return(icon.ToBitmap());
        }
예제 #11
0
		void ReadFilesProperties(object sender, DoWorkEventArgs e)
		{
			while(_itemsToRead.Count > 0)
			{
				BaseItem item = _itemsToRead[0];
				_itemsToRead.RemoveAt(0);

				Thread.Sleep(50); //emulate time consuming operation
				if (item is FolderItem)
				{
					DirectoryInfo info = new DirectoryInfo(item.ItemPath);
					item.Date = info.CreationTime;
				}
				else if (item is FileItem)
				{
					FileInfo info = new FileInfo(item.ItemPath);
					item.Size = info.Length;
					item.Date = info.CreationTime;
					if (info.Extension.ToLower() == ".ico")
					{
						Icon icon = new Icon(item.ItemPath);
						item.Icon = icon.ToBitmap();
					}
					else if (info.Extension.ToLower() == ".bmp")
					{
						item.Icon = new Bitmap(item.ItemPath);
					}
				}
				_worker.ReportProgress(0, item);
			}
		}
예제 #12
0
        public IconMenuItem(string text, Icon icon)
        {
            bitmap = icon.ToBitmap();
            Text = text;

            Init();
        }
예제 #13
0
 private static BitmapSource LoadBitmap(Icon icon)
 {
     return (icon == null) ? null :
         System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
             icon.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
             System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
 }
 private byte[] ComputeIconHash(Icon icon)
 {
     ImageConverter converter = new ImageConverter();
     byte[] rawIcon = converter.ConvertTo(icon.ToBitmap(), typeof(byte[])) as byte[];
     MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
     return md5.ComputeHash(rawIcon);
 }
        public EditSimpleListPage(
                string pageID,
                string subjectName,
                Icon displayIcon,
                string ownerType,
                string subjectListRelationship,
                string memberType,
                GetSubjectDescriptionDelegate getSubjectDescription,
                GetListMembersDelegate getListMembers,
                DoAddMemberDelegate addMember,
                DoDelMemberDelegate delMember,
                EditDialog editDialog)
        {
            this.pageID = pageID;
            InitializeComponent();
            lbSubject.Text = String.Format(lbSubject.Text, subjectName);
            lbSubjectListRelationship.Text = String.Format(lbSubjectListRelationship.Text, subjectListRelationship);
            pbSubjectImage.Image = displayIcon.ToBitmap();
            this.getSubjectDescription = getSubjectDescription;
            this.getListMembers = getListMembers;
            this.addMember = addMember;
            this.delMember = delMember;

            this.listOwnerType = ownerType;
            this.listMemberType = memberType;

            this.editDialog = editDialog;

            this.tbDescription.Select();
        }
        private static Bitmap CaptureCursor(ref int x, ref int y)
        {
            Bitmap bmp;
            IntPtr hicon;

            Win32Stuff.CURSORINFO ci = new Win32Stuff.CURSORINFO();
            Win32Stuff.ICONINFO   icInfo;
            ci.cbSize = Marshal.SizeOf(ci);
            if (Win32Stuff.GetCursorInfo(out ci))
            {
                if (ci.flags == Win32Stuff.CURSOR_SHOWING)
                {
                    hicon = Win32Stuff.CopyIcon(ci.hCursor);
                    if (Win32Stuff.GetIconInfo(hicon, out icInfo))
                    {
                        x = ci.ptScreenPos.x - ((int)icInfo.xHotspot);
                        y = ci.ptScreenPos.y - ((int)icInfo.yHotspot);
                        System.Drawing.Icon ic = System.Drawing.Icon.FromHandle(hicon);
                        bmp = ic.ToBitmap();

                        return(bmp);
                    }
                }
            }
            return(null);
        }
예제 #17
0
        private void Icon_Load(object sender, EventArgs e)
        {
            try
            {
                if (innerContent == null) return;

                Icon ic = null;

                byte[] imageBytes = Convert.FromBase64String(innerContent);
                using (MemoryStream ms = new MemoryStream(imageBytes))
                {
                    ic = new Icon(ms);
                }

                pictureBox1.Image = ic.ToBitmap();

                pictureBox1.Height = pictureBox1.Image.Size.Height;
                pictureBox1.Width = pictureBox1.Image.Size.Width;

                if (pictureBox1.Width > panel1.Width)
                    pictureBox1.Width = panel1.Width;

                pictureBox1.Location = new Point(
                    Width / 2 - pictureBox1.Width / 2,
                    Height / 2 - pictureBox1.Height / 2);
            }
            catch (Exception error)
            {
                MessageBox.Show("An error occured while loading this web resource: " + error.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #18
0
        /// <summary>
        /// Displays the icon in the system tray.
        /// </summary>
        public void Display()
        {
            ContextMenuStrip  objMenu = new ContextMenuStrip();
            ToolStripMenuItem item;

            //string strFolder = AppDomain.CurrentDomain.BaseDirectory.ToString();

            if (!File.Exists((strFolder + "iconfile.xml")))
            {
                MessageBox.Show("File 'iconfile.xml' does not exist.", "NotificationIcon", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            else
            {
                XmlTextReader reader = new XmlTextReader(strFolder + "iconfile.xml");
                int           i      = 0;
                while (reader.Read())
                {
                    if ((reader.NodeType == XmlNodeType.Element) && ((reader.Name.ToString().ToLower() == "default") || (reader.Name.ToString().ToLower() == "icon")))
                    {
                        item      = new ToolStripMenuItem();
                        item.Text = reader.GetAttribute("icontext").ToString();
                        item.Name = i.ToString() + "-" + DateTime.Now.Millisecond.ToString();
                        item.Tag  = i;
                        objIcons.Add(reader.GetAttribute("program").ToString() + "@" + reader.GetAttribute("params").ToString());
                        item.Click += new EventHandler(itm_MouseClick);
                        Icon iIco = new System.Drawing.Icon(strFolder + reader.GetAttribute("iconfile").ToString());
                        item.Image = iIco.ToBitmap();

                        if (reader.GetAttribute("bold").ToString().ToLower() == "true")
                        {
                            item.Font = new Font(item.Font.FontFamily, item.Font.Size, FontStyle.Bold);
                            objNotificationIcon.Icon = iIco;
                            objNotificationIcon.Text = item.Text;
                        }
                        objMenu.Items.Add(item);
                        i++;
                    }
                }
            }

            // Separator.
            objMenu.Items.Add(new ToolStripSeparator());

            // About.
            item        = new ToolStripMenuItem();
            item.Text   = "About";
            item.Click += new System.EventHandler(About_Click);
            objMenu.Items.Add(item);

            // Exit.
            item        = new ToolStripMenuItem();
            item.Text   = "Exit";
            item.Click += new System.EventHandler(Exit_Click);
            objMenu.Items.Add(item);

            objNotificationIcon.ContextMenuStrip = objMenu;
            objNotificationIcon.Visible          = true;
        }
예제 #19
0
 private void SetIconImage()
 {
     using (var stream = new MemoryStream(Configuration.MainIcon))
     using (var icon = new Icon(stream, new Size(32, 32)))
     {
         _icon.Image = icon.ToBitmap();
     }
 }
예제 #20
0
        /// <summary> 获取一个文件的图标
        /// </summary>
        /// <param name="Filepath">文件路径</param>
        /// <returns>获取到的图标</returns>
        public static Image GetImageByFileName(string Filepath)
        {
            SHFILEINFO SHFILEINFOTemp = new SHFILEINFO();

            WindowsAPI.SHGetFileInfo(Filepath, 0, ref SHFILEINFOTemp, (uint)System.Runtime.InteropServices.Marshal.SizeOf(SHFILEINFOTemp), (uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_USEFILEATTRIBUTES | (uint)FileInfoFlags.SHGFI_OPENICON);
            System.Drawing.Icon IconImage = System.Drawing.Icon.FromHandle(SHFILEINFOTemp.hIcon);
            return(Image.FromHbitmap(IconImage.ToBitmap().GetHbitmap()));
        }
예제 #21
0
        public static Image GetImage( string iconfilename , Data.DataType datatype , string softwaredir )
        {
            String fullpathsoftware = MultiplePathCombine( new String [ ] { Settings.startpath , Settings.iconspath , iconfilename } );
            String fullpathicons = MultiplePathCombine( new String [ ] { Settings.startpath , Settings.setupspath , softwaredir , iconfilename } );
            if ( iconfilename.Length > 4 )
            {
                if ( iconfilename.Contains( "." ) )
                {

                    try
                    {
                        if ( File.Exists( iconfilename ) )
                        {
                            if ( Path.GetExtension( iconfilename ).ToLower( ) == ".ico" )
                            {
                                Icon a1 = new Icon( iconfilename );
                                return ( Image ) a1.ToBitmap( );
                            }
                            else
                            {
                                return new Bitmap( new Bitmap( iconfilename ) , new Size( 32 , 32 ) );
                            }
                        }
                        else if ( File.Exists( fullpathsoftware ) )
                        {
                            if ( Path.GetExtension( fullpathsoftware ).ToLower( ) == ".ico" )
                            {
                                Icon a1 = new Icon( fullpathsoftware );
                                return ( Image ) a1.ToBitmap( );
                            }
                            else
                            {
                                return new Bitmap( new Bitmap( fullpathsoftware ) , new Size( 32 , 32 ) );
                            }
                        }
                        else if ( File.Exists( fullpathicons ) )
                        {
                            if ( Path.GetExtension( fullpathicons ).ToLower( ).TrimEnd( ' ' ) == ".ico" )
                            {
                                Icon a1 = new Icon( fullpathicons );
                                return ( Image ) a1.ToBitmap( );
                            }
                            else
                            {
                                return new Bitmap( new Bitmap( fullpathicons ) , new Size( 32 , 32 ) );
                            }
                        }

                    }
                    catch ( Exception ex )
                    {

                        Debug.WriteLine( ex.ToString( ) );
                    }
                }
            }
            return null;
        }
예제 #22
0
        private static Icon GetIcon_InternalWithOverlay(Icon baseIcon, Icon overlayIcon)
        {
            // overlay custom icon with overlay icon
              Bitmap iconBitmap = baseIcon.ToBitmap();
              Graphics graphics = Graphics.FromImage(iconBitmap);
              graphics.DrawIcon(overlayIcon, new Rectangle(0, 0, iconBitmap.Width, iconBitmap.Height));
              graphics.Save();

              return Icon.FromHandle(iconBitmap.GetHicon());
        }
예제 #23
0
        private void GeneratingForm_Load(object sender, EventArgs e)
        {
            string strTitle = "StrengthReport: Generating";
            string strDesc = "Generating the report you requested";
            Icon icoNew = new Icon(Resources.StrengthReportPrinting, 48, 48);

            m_bannerImage.Image = BannerFactory.CreateBanner(m_bannerImage.Width,
                m_bannerImage.Height, BannerStyle.Default,
                icoNew.ToBitmap(), strTitle, strDesc);
        }
예제 #24
0
 /// <summary>
 /// Returns a 16X16 bitmap of an Icon
 /// </summary>
 private static Image Bitmap16(Icon aIcon)
 {
     Bitmap Result = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
     using (Graphics Gr = Graphics.FromImage(Result))
     {
         Gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
         Gr.DrawImage(aIcon.ToBitmap(), 0, 0, 16, 16);
     }
     return Result;
 }
예제 #25
0
 public virtual void AppentMenuStripItem(string text, Icon icon, EventHandler clickHandler, IDynamicStateProvider dynamicStateProvider = null)
 {
     if (text.IsNullOrEmpty() || icon == null || clickHandler == null)
       {
     return;
       }
       EventHandler asyncClickHandler = (sender, args) => Task.Factory.StartNew(() => clickHandler(sender, args));
       var menuItem = new ExtendedToolStripMenuItem(text, icon.ToBitmap(), asyncClickHandler) { DymamicStateProvider = dynamicStateProvider };
       this.OutputItems.Add(menuItem);
 }
예제 #26
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="items">List of updates to show</param>
        /// <param name="applicationIcon"></param>
        public NetSparkleForm(NetSparkleAppCastItem[] items, Icon applicationIcon = null)
        {
            _updates = items;

            SeparatorTemplate = "<div style=\"border: #ccc 1px solid;\"><div style=\"background: {3}; padding: 5px;\"><span style=\"float: right; display:float;\">{1}</span>{0}</div><div style=\"padding: 5px;\">{2}</div></div><br>";

            InitializeComponent();

            // init ui
            try
            {
                NetSparkleBrowser.AllowWebBrowserDrop = false;
                NetSparkleBrowser.AllowNavigation = false;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error in browser init: " + ex.Message);
            }

            NetSparkleAppCastItem item = items[0];

            lblHeader.Text = lblHeader.Text.Replace("APP", item.AppName);
            lblInfoText.Text = lblInfoText.Text.Replace("APP", item.AppName + " " + item.Version);
            lblInfoText.Text = lblInfoText.Text.Replace("OLDVERSION", item.AppVersionInstalled);

            if (items.Length == 0)
            {
                RemoveReleaseNotesControls();
            }
            else
            {
                NetSparkleAppCastItem latestVersion = _updates.OrderByDescending(p => p.Version).FirstOrDefault();

                StringBuilder sb = new StringBuilder("<html><head><meta http-equiv='Content-Type' content='text/html;charset=UTF-8'></head><body>");
                foreach (NetSparkleAppCastItem castItem in items)
                {
                    sb.Append(string.Format(SeparatorTemplate, castItem.Version,
                                            castItem.PublicationDate.ToString("dd MMM yyyy"),
                                            GetReleaseNotes(castItem),
                                            latestVersion.Version.Equals(castItem.Version) ? "#ABFF82" : "#AFD7FF"));
                }
                sb.Append("</body>");

                string releaseNotes = sb.ToString();
                NetSparkleBrowser.DocumentText = releaseNotes;
            }

            if (applicationIcon != null)
            {
                imgAppIcon.Image = applicationIcon.ToBitmap();
                Icon = applicationIcon;
            }

            TopMost = true;
        }
예제 #27
0
        private static Image GetFileIcon(string extensionName)
        {
            // obter o ícone em tamanho grande do ficheiro a associar
            SHFILEINFO shfi = new SHFILEINFO();

            SHGetFileInfo(extensionName, FILE_ATTRIBUTE_NORMAL, ref shfi, System.Convert.ToUInt32(System.Runtime.InteropServices.Marshal.SizeOf(shfi)), Convert.ToUInt32(Convert.ToInt32(SHGFI_USEFILEATTRIBUTES) | Convert.ToInt32(SHGFI_ICON)));

            System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shfi.hIcon);

            return(icon.ToBitmap());
        }
예제 #28
0
 //private Bank myBank;
 public EntryScreenForm()
 {
     InitializeComponent();
     operations = new Operations();
     System.Drawing.Icon bankIco = new System.Drawing.Icon("C:\\Users\\nkalra\\source\\repos\\ApteanEdgeBank\\ApteanEdgeBank\\bank.ico");
     this.Icon = bankIco;
     System.Drawing.Icon ico = new System.Drawing.Icon("C:\\Users\\nkalra\\source\\repos\\ApteanEdgeBank\\ApteanEdgeBank\\addCustomer.ico");
     this.AddCustomerToolStripButton.Image = ico.ToBitmap();
     System.Drawing.Icon deleteIco = new System.Drawing.Icon("C:\\Users\\nkalra\\source\\repos\\ApteanEdgeBank\\ApteanEdgeBank\\deleteCustomer.ico");
     this.DeleteCustomerToolStripButton.Image = deleteIco.ToBitmap();
 }
예제 #29
0
        private void AddFlingrResource(FileInfo fileInfo)
        {
            FlingrResource resource = new FlingrResource(fileInfo);

            using (System.Drawing.Icon sysicon = System.Drawing.Icon.ExtractAssociatedIcon(fileInfo.FullName))
            {
                resource.Icon = sysicon.ToBitmap();
            }

            flingrResources.Add(resource);
        }
        private ImageSource GetImageSourceFromIco(Icon img)
        {
            Bitmap bitmap = img.ToBitmap();
            IntPtr hBitmap = bitmap.GetHbitmap();
            var wpfBitmap =
                 Imaging.CreateBitmapSourceFromHBitmap(
                      hBitmap, IntPtr.Zero, Int32Rect.Empty,
                      BitmapSizeOptions.FromEmptyOptions());

            return wpfBitmap;
        }
예제 #31
0
        protected override void OpenSave(string fileName)
        {
            System.Drawing.Icon   ico = new System.Drawing.Icon(fileName);
            System.Drawing.Bitmap bmp = ico.ToBitmap();
            string bmpFile            = Path.Combine(_outputPath, _fileNameWithoutExtension + ".bmp");

            if (bmp.PixelFormat == System.Drawing.Imaging.PixelFormat.Format32bppArgb && _outputSelected == OutputSelector.Bitmap)
            {
                AlphaBitmap.SetTransparentRGB(bmp, TransparentRGBColor);
            }
            Save(bmp, bmpFile);
        }
예제 #32
0
 private Image GetSystemBitmap(SystemImageList sysImgList, int index)
 {
     System.Drawing.Icon ico = sysImgList.Icon(index);
     if (ico != null)
     {
         return(ico.ToBitmap( ));
     }
     else
     {
         return(null);
     }
 }
예제 #33
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="item"></param>
        /// <param name="applicationIcon"></param>
        public NetSparkleForm(NetSparkleAppCastItem item, Icon applicationIcon)
        {
            InitializeComponent();

            // init ui
            try
            {
                NetSparkleBrowser.AllowWebBrowserDrop = false;
                NetSparkleBrowser.AllowNavigation = false;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error in browser init: " + ex.Message);
            }

            _currentItem = item;

            lblHeader.Text = lblHeader.Text.Replace("APP", item.AppName);
            lblInfoText.Text = lblInfoText.Text.Replace("APP", item.AppName + " " + item.Version);
            lblInfoText.Text = lblInfoText.Text.Replace("OLDVERSION", item.AppVersionInstalled);

            if (!string.IsNullOrEmpty(item.ReleaseNotesLink))
            {

                if (new List<string>(new[]{".md",".mkdn",".mkd",".markdown"}).Contains(Path.GetExtension(item.ReleaseNotesLink).ToLower()))
                {
                    try
                    {
                        ShowMarkdownReleaseNotes(item);
                    }
                    catch (Exception)
                    {
            #if DEBUG
                        throw;
            #else
                        NetSparkleBrowser.Navigate(item.ReleaseNotesLink); //just show it raw
            #endif
                    }

                }
                else
                {
                    NetSparkleBrowser.Navigate(item.ReleaseNotesLink);
                }
            }
            else
                RemoveReleaseNotesControls();

            imgAppIcon.Image = applicationIcon.ToBitmap();
            Icon = applicationIcon;

            TopMost = true;
        }
 /// <summary>
 /// Show 'toast' window to notify new version is available
 /// </summary>
 /// <param name="updates">Appcast updates</param>
 /// <param name="applicationIcon">Icon to use in window</param>
 /// <param name="clickHandler">handler for click</param>
 public virtual void ShowToast(NetSparkleAppCastItem[] updates, Icon applicationIcon, Action<NetSparkleAppCastItem[]> clickHandler)
 {
     var toast = new ToastNotifier
         {
             Image =
                 {
                     Image = applicationIcon != null ? applicationIcon.ToBitmap() : Resources.software_update_available1
                 }
         };
     toast.ToastClicked += (sender, args) => clickHandler(updates); // TODO: this is leak
     toast.Show(Resources.DefaultNetSparkleUIFactory_ToastMessage, Resources.DefaultNetSparkleUIFactory_ToastCallToAction, 5);
 }
        /// <summary> 获取一个文件的图标
        /// </summary>
        /// <param name="Filepath">文件路径</param>
        /// <returns>获取到的图标</returns>
        public Image GetImageByFileName(string Filepath)
        {
            //Bitmap BitmapTemp = Icon.ExtractAssociatedIcon(Filepath).ToBitmap();
            //IntPtr Handle = BitmapTemp.GetHbitmap();
            //Image ReturnImage = Image.FromHbitmap(Handle);
            //return ReturnImage;
            SHFILEINFO SHFILEINFOTemp = new SHFILEINFO();

            SHGetFileInfo(Filepath, 0, ref SHFILEINFOTemp, (uint)System.Runtime.InteropServices.Marshal.SizeOf(SHFILEINFOTemp), (uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_USEFILEATTRIBUTES | (uint)FileInfoFlags.SHGFI_LARGEICON);
            System.Drawing.Icon IconImage = System.Drawing.Icon.FromHandle(SHFILEINFOTemp.hIcon);
            return(Image.FromHbitmap(IconImage.ToBitmap().GetHbitmap()));
        }
예제 #36
0
    public SessionPage()
    {
        InitializeComponent();

        // Create an instance of a ListView column sorter and assign it
        // to the ListView control.
        lvwColumnSorter = new ListViewColumnSorter();
        this.lvSessionPage.ListViewItemSorter = lvwColumnSorter;

        Icon ic = new Icon(Resources.SharedFolder, 48, 48);
        this.picture.Image = ic.ToBitmap();
    }
예제 #37
0
        public Form_SelectLanguage(Icon xProgram_Icon, string xProgram_name, int Language_ID, NavigationButtons.Navigation xnav)
        {
            InitializeComponent();
            Program_Icon = xProgram_Icon;
            Program_name = xProgram_name;
            nav = xnav;
            usrc_NavigationButtons1.Init(nav);
            if (Program_Icon!= null)
            {
                this.Icon = Program_Icon;
            }

            if (Program_name != null)
            {
                lbl_ProgramName.Text = Program_name;
            }
            if (Program_Icon != null)
            {
                this.pic_Program_Icon.Image = Program_Icon.ToBitmap();
            }
            int iCount = DynSettings.s_language.sTextArr.Length;
            int i = 0;
            for ( i = 0;i<iCount;i++)
            {
                string slang = DynSettings.s_language.sTextArr[i];
                if (slang != null)
                {
                    //int iItem = cmb_Language.Items.Add(slang);
                    LanguageList.Add(new Language(slang, i));
                }
            }

            cmb_Language.DataSource = LanguageList;
            cmb_Language.DisplayMember = "Name";
            cmb_Language.ValueMember = "Index";

            if (Language_ID >= 0)
            {
                if (Language_ID < cmb_Language.Items.Count)
                {
                    cmb_Language.SelectedIndex = Language_ID;
                }
                else
                {
                    SelectLanguageOnCultureInfo();
                }
            }
            else
            {
                SelectLanguageOnCultureInfo();
            }
        }
예제 #38
0
 /// <summary>
 /// Opens the specified image or icon file to a local copy.  Icons are converted into bitmaps.
 /// </summary>
 /// <param name="fileName">The string fileName to open.</param>
 public void Open(string fileName)
 {
     if (Path.GetExtension(fileName).ToLower() == ".ico")
     {
         Icon ico = new Icon(fileName);
         _picture = ico.ToBitmap();
     }
     else
     {
         _picture = Image.FromFile(fileName);
     }
     _pictureFilename = fileName;
 }
예제 #39
0
    public SharesPage(FileShareManagerIPlugIn.PluginNodeType nodetype)
    {
        InitializeComponent();

        // Create an instance of a ListView column sorter and assign it
        // to the ListView control.
        lvwColumnSorter = new ListViewColumnSorter();
        this.lvSharePage.ListViewItemSorter = lvwColumnSorter;

        Icon ic = new Icon(Resources.SharedFolder, 48, 48);
        this.picture.Image = ic.ToBitmap();
        this.nodeType = nodetype;
    }
예제 #40
0
    /// <summary>
    /// Returns extracted icon as Texture2D Object
    /// </summary>
    /// <param name="path"></param>
    /// <param name="bSmall"></param>
    /// <returns></returns>
    public static Texture2D GetTextureFromIconatPath(string path, bool bSmall = false)
    {
        System.Drawing.Icon   icon   = GetIcon(path, bSmall);
        System.Drawing.Bitmap bitmap = icon.ToBitmap();
        bitmap.MakeTransparent();

        Texture2D texture = new Texture2D(bitmap.Width, bitmap.Height, TextureFormat.ARGB32, false);

        texture.LoadRawTextureData(Bitmap2RawBytes(bitmap));
        texture.Apply();

        return(texture);
    }
 /// <summary>
 /// Show 'toast' window to notify new version is available
 /// </summary>
 /// <param name="item">Appcast item</param>
 /// <param name="applicationIcon">Icon to use in window</param>
 /// <param name="clickHandler">handler for click</param>
 public virtual void ShowToast(NetSparkleAppCastItem item, Icon applicationIcon, EventHandler clickHandler)
 {
     var toast = new ToastNotifier
         {
             Tag = item,
             Image =
                 {
                     Image = applicationIcon.ToBitmap()
                 }
         };
     toast.ToastClicked += clickHandler;
     toast.Show(Resources.DefaultNetSparkleUIFactory_ToastMessage, Resources.DefaultNetSparkleUIFactory_ToastCallToAction, 5);
 }
		private static ImageSource ToImageSource( Icon icon)
		{
			Bitmap bitmap = icon.ToBitmap();
			IntPtr hBitmap = bitmap.GetHbitmap();
			
			ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(
				hBitmap,
				IntPtr.Zero,
				Int32Rect.Empty,
				BitmapSizeOptions.FromEmptyOptions());
			
			return wpfBitmap;
		}
예제 #43
0
        static ImageSource GetIcon(string file)
        {
            ImageSource retVal = null;

            using (System.Drawing.Icon icn = System.Drawing.Icon.ExtractAssociatedIcon(file))
            {
                using (Bitmap bmp = icn.ToBitmap())
                {
                    retVal = ImageHelper.ConvertBitmapToBitmapSource(bmp);
                }
            }
            return(retVal);
        }
예제 #44
0
		private static BitmapFrame ConvertFromIcon(Icon icon)
		{
			var iconStream = new MemoryStream();

			using (var bmp = icon.ToBitmap())
			{
				bmp.Save(iconStream, ImageFormat.Png);
			}

			iconStream.Position = 0;
			var decoder = new PngBitmapDecoder(iconStream, BitmapCreateOptions.None, BitmapCacheOption.None);
			return decoder.Frames.Last();
		}
예제 #45
0
 private static Image AddOverlay(Icon originalIcon, Image overlay)
 {
     using (Image original = originalIcon.ToBitmap())
     {
         var bitmap = new Bitmap(originalIcon.Width, originalIcon.Height);
         using (var canvas = Graphics.FromImage(bitmap))
         {
             canvas.DrawImage(original, 0, 0);
             canvas.DrawImage(overlay, 0, 0, original.Width, original.Height);
             canvas.Save();
             return bitmap;
         }
     }
 }
예제 #46
0
        private static Bitmap Generate16X16PixelsIcon(Icon anIcon)
        {
            var aBitmap = new Bitmap(anIcon.ToBitmap());
            var an16X16Icon = new Bitmap(16, 16);
            var graphics = Graphics.FromImage(an16X16Icon);

            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphics.DrawImage(aBitmap, new Rectangle(0, 0, 16, 16), new Rectangle(0, 0, aBitmap.Width, aBitmap.Height), GraphicsUnit.Pixel);

            graphics.Dispose();
            aBitmap.Dispose();

            return an16X16Icon;
        }
예제 #47
0
 public DevTextBox()
 {
     try
     {
         InitializeComponent();
         System.Drawing.Icon img = DrectSoft.Common.Ctrs.Properties.Resources.保存;
         this.Image = img.ToBitmap();
         this.Width = 80;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #48
0
        public static ImageSource GetShellIcon(string filePath)
        {
            ImageSource shellIcon = null;

            try
            {
                Shfileinfo shinfo = new Shfileinfo();

                /*
                 * private const uint SHGFI_ICON = 0x100;
                 * private const uint SHGFI_LARGEICON = 0x0;
                 * private const uint SHGFI_SMALLICON = 0x000000001;
                 */
                SHGetFileInfo(
                    filePath,
                    0, ref shinfo, (uint)Marshal.SizeOf(shinfo),
                    0x100 | 0x0);

                using (System.Drawing.Icon i = System.Drawing.Icon.FromHandle(shinfo.hIcon))
                {
                    //Convert icon to a Bitmap source
                    shellIcon = Imaging.CreateBitmapSourceFromHIcon(
                        i.Handle,
                        new Int32Rect(0, 0, i.Width, i.Height),
                        BitmapSizeOptions.FromEmptyOptions());
                }
            }
            catch
            {
                try
                {
                    System.Drawing.Icon fileIcon = System.Drawing.Icon.ExtractAssociatedIcon(filePath);
                    if (fileIcon != null)
                    {
                        using (Bitmap iconBitmap = fileIcon.ToBitmap())
                        {
                            System.IO.MemoryStream ms = new System.IO.MemoryStream();
                            iconBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                            shellIcon = BitmapFrame.Create(ms);
                        }
                    }
                }
                catch (Exception)
                {
                    // ignored
                }
            }
            return(shellIcon);
        }
예제 #49
0
파일: Icons.cs 프로젝트: hamerstandr/Tools
        public static BitmapImage GetImage(string Path = "C:\\Windows", IconSize size = IconSize.Large, FolderType folderType = FolderType.Closed)
        {
            System.Drawing.Icon icon = GetIcon(Path, size, folderType);
            Bitmap       bmp         = icon.ToBitmap();
            MemoryStream strm        = new MemoryStream();

            bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
            BitmapImage bmpImage = new BitmapImage();

            bmpImage.BeginInit();
            strm.Seek(0, SeekOrigin.Begin);
            bmpImage.StreamSource = strm;
            bmpImage.EndInit();
            return(bmpImage);
        }
예제 #50
0
        public static System.Drawing.Icon AddIconOverlay(System.Drawing.Icon originalIcon, System.Drawing.Icon overlay)
        {
            Image    a      = originalIcon.ToBitmap();
            Image    b      = overlay.ToBitmap();
            Bitmap   bitmap = new Bitmap(overlay.Width, overlay.Height);
            Graphics canvas = Graphics.FromImage(bitmap);

            canvas.CompositingMode = CompositingMode.SourceOver;
            canvas.DrawImage(a, new Point(0, 0));
            canvas.DrawImage(b, new Point(0, 0));
            canvas.Save();
            canvas.Dispose();
            a.Dispose();
            b.Dispose();
            return(System.Drawing.Icon.FromHandle(bitmap.GetHicon()));
        }
예제 #51
0
        public void SetIcon()
        {
            System.Drawing.Icon extractedIcon = null;

            try
            {
                extractedIcon = System.Drawing.Icon.ExtractAssociatedIcon(Configuration.Path);
                C_Icon.Source = Convert(extractedIcon.ToBitmap());
            }
            catch (Exception ex)
            {
                string      path = "..\\..\\..\\Images\\File-Explorer-icon.png";
                BitmapImage logo = new BitmapImage(new Uri(path, UriKind.Relative));
                C_Icon.Source = logo;
                return;
            }
        }
예제 #52
0
        private void GetIconPicture(string standardPictureName, string largePictureName)
        {
            oIPictureDispStandard = null;
            oIPictureDispLarge    = null;

            //get the original picture
            System.IO.Stream oStream_s = assembly.GetManifestResourceStream(standardPictureName);
            System.IO.Stream oStream_l = assembly.GetManifestResourceStream(largePictureName);

            //instant icon object,get original source
            System.Drawing.Icon oIcon_s = new System.Drawing.Icon(oStream_s);
            System.Drawing.Icon oIcon_l = new System.Drawing.Icon(oStream_l);

            //call ImageToPictureDisp convertion method
            oIPictureDispStandard = AxHostConverter.ImageToPictureDisp(oIcon_s.ToBitmap());
            oIPictureDispLarge    = AxHostConverter.ImageToPictureDisp(oIcon_l.ToBitmap());
        }
예제 #53
0
        private ImageSource ExtractIcon(FileInfo directory)
        {
            System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(directory.FullName);
            Bitmap       bmp        = ico.ToBitmap();
            MemoryStream strm       = new MemoryStream();

            bmp.Save(strm, System.Drawing.Imaging.ImageFormat.Png);
            BitmapImage bmpImage = new BitmapImage();

            bmpImage.BeginInit();
            strm.Seek(0, SeekOrigin.Begin);
            bmpImage.StreamSource = strm;
            bmpImage.EndInit();
            ImageSource source = bmpImage;

            return(source);
        }
예제 #54
0
        private static BitmapImage IconToBitmapImage(System.Drawing.Icon ico)
        {
            MemoryStream ms = new MemoryStream();

            ico.ToBitmap().Save(ms, System.Drawing.Imaging.ImageFormat.Png);

            BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage();

            bImg.BeginInit();


            bImg.StreamSource = new MemoryStream(ms.ToArray());
            bImg.EndInit();

            ms.Close();

            return(bImg);
        }
예제 #55
0
        private void button1_Click(object sender, EventArgs e)
        {
            string         fName;
            SHFILEINFO     shinfo          = new SHFILEINFO();
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter           = "All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                fName = openFileDialog1.FileName;
                Win32.SHGetFileInfo(fName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON);
                System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
                pictureBox1.Image = (Image)myIcon.ToBitmap();
            }
        }
        public static ImageSource ToImageSource(this Drawing.Icon icon)
        {
            Drawing.Bitmap bitmap  = icon.ToBitmap();
            IntPtr         hBitmap = bitmap.GetHbitmap();

            ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(
                hBitmap,
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            if (!DeleteObject(hBitmap))
            {
                throw new Win32Exception();
            }

            return(wpfBitmap);
        }
예제 #57
0
        private static ImageSource GetProcessIcon(string filePath)
        {
            IconImage icon    = IconImage.ExtractAssociatedIcon(filePath);
            Bitmap    bitmap  = icon.ToBitmap();
            IntPtr    hBitmap = bitmap.GetHbitmap();

            ImageSource wpfBitmap = Imaging.CreateBitmapSourceFromHBitmap(
                hBitmap,
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            if (!DeleteObject(hBitmap))
            {
                throw new Win32Exception();
            }

            return(wpfBitmap);
        }
        public void setSamune(string url)
        {
            if (!util.isShowWindow)
            {
                return;
            }
            if (IsDisposed)
            {
                return;
            }
            WebClient cl = new WebClient();

            cl.Proxy = null;

            System.Drawing.Icon icon = null;
            try {
                byte[] pic = cl.DownloadData(url);

                using (var st = new System.IO.MemoryStream(pic)) {
                    icon = Icon.FromHandle(new System.Drawing.Bitmap(st).GetHicon());
                }
            } catch (Exception e) {
                util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                return;
            }

            formAction(() => {
                try {
                    samuneBox.Image = icon.ToBitmap();
                    //                  samuneBox.ImageLocation = url;
                    if (bool.Parse(config.get("IstitlebarSamune")))
                    {
                        this.Icon = icon;
                    }
                } catch (Exception e) {
                    util.debugWriteLine(e.Message + " " + e.StackTrace + " " + e.Source + " " + e.TargetSite);
                }
            });


//                  Icon = new System.Drawing.Icon(url);
        }
예제 #59
0
        protected override Gdk.Pixbuf OnGetPixbufForFile(string filename, Gtk.IconSize size)
        {
            SHFILEINFO shinfo = new SHFILEINFO();

            Win32.SHGetFileInfo(filename, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_SMALLICON | Win32.SHGFI_ICONLOCATION | Win32.SHGFI_TYPENAME);
            if (shinfo.iIcon == IntPtr.Zero)
            {
                return(null);
            }
            string key = shinfo.iIcon.ToString() + " - " + shinfo.szDisplayName;

            Gdk.Pixbuf pix;
            if (!icons.TryGetValue(key, out pix))
            {
                System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(shinfo.hIcon);
                pix        = CreateFromResource(icon.ToBitmap());
                icons[key] = pix;
            }
            return(pix);
        }
예제 #60
0
        public TreeViewItemExecutable(string name, string path) : base(name, path)
        {
            this.Category = TreeViewCategory.Executable;
            try
            {
                System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(path);
                Bitmap bitmap           = ico.ToBitmap();

                System.Windows.Media.Imaging.BitmapSource bitmapSource =
                    System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                        bitmap.GetHbitmap(),
                        IntPtr.Zero,
                        Int32Rect.Empty,
                        System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()
                        );

                this.Icon = bitmapSource;
            }
            catch (Exception) { }
        }