コード例 #1
0
ファイル: Utils.cs プロジェクト: Giksai/Explorer
        /// <summary>
        /// Returns an ImageSource with the given file's icon
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        public static ImageSource GetFileIcon(FileSystemInfo file)
        {
            // If it's already in the cache, just return it from there
            string ext = file.Extension.ToLower();

            if (fileIconCache.ContainsKey(ext))
            {
                return(fileIconCache[ext]);
            }

            // It's not in the cache, so load it.
            ImageSource imageSource;

            System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName);

            using (System.Drawing.Bitmap bmp = icon.ToBitmap())
            {
                MemoryStream stream = new MemoryStream();
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                imageSource = BitmapFrame.Create(stream);
            }

            // Add it to the cache and return it
            fileIconCache.Add(ext, imageSource);
            return(imageSource);
        }
コード例 #2
0
        /// <summary>
        /// This event gets called when an item is dropped on the dock
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DisplayGrid_Drop(object sender, System.Windows.DragEventArgs e)
        {
            //TODO : We could make it so you are able to add multiple icons at the same time
            var      files    = (string[])e.Data.GetData(DataFormats.FileDrop);
            FileInfo fileInfo = new FileInfo(files[0]);

            //Create the image of the Icon
            System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(files[0]);
            //Create the name that this icon image is going to be stored under
            var    newIconImageName = fileInfo.Name.Replace(fileInfo.Extension.ToString(), "") + ".png";
            string startupPath      = Environment.CurrentDirectory;

            if (!File.Exists(startupPath + "\\icons\\" + newIconImageName))
            {
                icon.ToBitmap().Save(startupPath + "\\icons\\" + newIconImageName);
            }

            // instantiate a new shortcut object temporarily with enough information to generate an XML fragment
            var button = new Bauble.Buttons.Shortcut("icons/" + newIconImageName, fileInfo.Name, files[0]) as IBaubleButton;

            // have the settings object create a fully instantiated button object
            button = _settings.AddShortcut(button);
            // load the button onto the current dock
            DisplayButton(DisplayGrid.ColumnDefinitions.Count + 1, button);
            // Allow the IconFlow to initialize the button for any animations it uses
            _settings.IconFlow.Initialize(button);
            // save the new button list out to the file system
            _settings.SaveButtonList();
        }
コード例 #3
0
        public static Image LoadImageFromIcon(this ResourceManager resourceManager, string cacheKey, System.Drawing.Icon icon)
        {
            return(resourceManager.LoadImage(cacheKey, textureLoader => new LazyImage(resourceManager.DefaultImage, () =>
            {
                var _log = Log.Get <ResourceManager>();

                try
                {
                    _log.Info($"Loading image from icon...");

                    using (var bmpStream = new MemoryStream())
                    {
                        // Convert to bitmap
                        icon.ToBitmap().Save(bmpStream, System.Drawing.Imaging.ImageFormat.Bmp);

                        // Convert to texture
                        return textureLoader.Load(bmpStream.ToArray());
                    }
                }
                catch (Exception ex)
                {
                    _log.Error($"Could not load image from icon: '{ex.Message}'.", ex);
                    return ResourceManager.Instance.DefaultImage;
                }
            })));
        }
コード例 #4
0
        /*
         * static System.Drawing.Bitmap CaptureCursor() //ref int x, ref int y)
         * {
         *  System.Drawing.Bitmap bmp;
         *  IntPtr hicon;
         *  CURSORINFO ci = new CURSORINFO();
         *  aICONINFO icInfo;
         *  ci.cbSize = Marshal.SizeOf(ci);
         *  if (GetCursorInfo(out ci))
         *  {
         *      if (ci.flags == CURSOR_SHOWING)
         *      {
         *          hicon = CopyIcon(ci.hCursor);
         *          if (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();
         *              DestroyIcon(hicon);
         *              return bmp;
         *          }
         *      }
         *  }
         *  return null;
         * }*/

        static BitmapSource CaptureCursor() //ref int x, ref int y)
        {
            IntPtr     hicon;
            CURSORINFO ci = new CURSORINFO();
            aICONINFO  icInfo;

            ci.cbSize = Marshal.SizeOf(ci);
            if (GetCursorInfo(out ci))
            {
                if (ci.flags == CURSOR_SHOWING)
                {
                    hicon = CopyIcon(ci.hCursor);
                    if (GetIconInfo(hicon, out icInfo))
                    {
                        System.Drawing.Icon   ic  = System.Drawing.Icon.FromHandle(hicon);
                        System.Drawing.Bitmap bmp = ic.ToBitmap();

                        BitmapSource retVal = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                        DestroyIcon(hicon);
                        return(retVal);
                    }
                }
            }
            return(null);
        }
コード例 #5
0
        private void AsIsInfoShown(object sender, EventArgs e)
        {
            SystemSounds.Asterisk.Play();
            var myIcon = new System.Drawing.Icon(System.Drawing.SystemIcons.Information, 32, 32);

            lblIcon.Image = myIcon.ToBitmap();
        }
コード例 #6
0
ファイル: AWindow.cs プロジェクト: nrjohnstone/MASGAU
        public AWindow(IWindow owner)
            : base(owner, Core.settings)
        {
            TabItem from_me = new TabItem();

            from_me.BeginInit();
            from_me.EndInit();
            this.Background = from_me.Background;
            ProgressBar from_color = new ProgressBar();

            default_progress_color = from_color.Foreground;

            // Taskbar progress setup
            TaskbarItemInfo = new TaskbarItemInfo();
            //            var uriSource = new Uri(System.IO.Path.Combine(Core.ExecutablePath, "masgau.ico"), UriKind.Relative);


            System.Drawing.Icon ico = Properties.Resources.MASGAUIcon;

            this.Icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                ico.ToBitmap().GetHbitmap(),
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            if (owner != null)
            {
                this.Owner = owner as System.Windows.Window;
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }
            else
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            }
        }
コード例 #7
0
        protected static void ImgToShowSourcePropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d.GetType() == typeof(AGImage))
            {
                try
                {
                    AGImage ag = d as AGImage;

                    System.Drawing.Icon   ic   = (System.Drawing.Icon)LaserControl.Properties.Resources.ResourceManager.GetObject(e.NewValue.ToString());
                    System.Drawing.Bitmap bmp  = ic.ToBitmap();
                    System.Drawing.Bitmap bmpD = MakeGrayscale3(bmp);

                    ag.ImgEnabled  = BitmapToImageSource(bmp);
                    ag.ImgDisabled = BitmapToImageSource(bmpD);

                    ag.Source = ag.IsEnabled ? ag.ImgEnabled : ag.ImgDisabled;

                    ic.Dispose();
                }
                catch
                {
                    //Mache nichts
                }
            }
        }
コード例 #8
0
ファイル: MainWindow.xaml.cs プロジェクト: wasuken/FileCipher
        //itemで指定したフルパスの先にあるファイルorフォルダのフルパスと名前と対応するアイコンを追加する。
        private ImageList returnImageList(string item)
        {
            Image     img = new Image();
            ITEM_TYPE type;

            if (!Directory.Exists(item))
            {
                System.Drawing.Icon appIcon = System.Drawing.Icon.ExtractAssociatedIcon(item);

                img.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    appIcon.ToBitmap().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());
                type = ITEM_TYPE.file;
            }
            else
            {
                BitmapImage     folIcon = new BitmapImage();
                MemoryStream    data    = new MemoryStream(File.ReadAllBytes(@"../../img/folder.png"));
                WriteableBitmap wbmp    = new WriteableBitmap(BitmapFrame.Create(data));
                data.Close();
                img.Source = wbmp;
                type       = ITEM_TYPE.folder;
            }
            return(new ImageList(item, img.Source, type));
        }
コード例 #9
0
        protected static void ImgToShowSourcePropertyChange(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d.GetType() == typeof(ImgButton))
            {
                try
                {
                    ImgButton ib = d as ImgButton;

//                    Console.WriteLine("Tada: {0} -> {1} ", e.NewValue, ib.IsEnabled);

                    System.Drawing.Icon   ic   = (System.Drawing.Icon)LaserControl.Properties.Resources.ResourceManager.GetObject(e.NewValue.ToString());
                    System.Drawing.Bitmap bmp  = ic.ToBitmap();
                    System.Drawing.Bitmap bmpD = MakeGrayscale3(bmp);

                    ib.ImgEnabled  = BitmapToImageSource(bmp);
                    ib.ImgDisabled = BitmapToImageSource(bmpD);

                    if (ib.IsEnabled)
                    {
                        ib.Data.ImageToDisplay = ib.ImgEnabled;
                    }
                    else
                    {
                        ib.Data.ImageToDisplay = ib.ImgDisabled;
                    }

                    ic.Dispose();
                }
                catch
                {
                    //Mache nichts
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VerInfoForm));
     this.pictureBox1 = new System.Windows.Forms.PictureBox();
     this.label1      = new System.Windows.Forms.Label();
     this.button1     = new System.Windows.Forms.Button();
     ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
     this.SuspendLayout();
     //
     // pictureBox1
     //
     System.Drawing.Icon   ico = new System.Drawing.Icon(Properties.Resources.Icon, 64, 64);
     System.Drawing.Bitmap bmp = ico.ToBitmap();
     this.pictureBox1.Image    = bmp;
     this.pictureBox1.Location = new System.Drawing.Point(12, 12);
     this.pictureBox1.Name     = "pictureBox1";
     this.pictureBox1.Size     = new System.Drawing.Size(64, 64);
     this.pictureBox1.TabIndex = 0;
     this.pictureBox1.TabStop  = false;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Location = new System.Drawing.Point(82, 12);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(0, 12);
     this.label1.TabIndex = 1;
     //
     // button1
     //
     this.button1.DialogResult            = System.Windows.Forms.DialogResult.OK;
     this.button1.Location                = new System.Drawing.Point(247, 53);
     this.button1.Name                    = "button1";
     this.button1.Size                    = new System.Drawing.Size(75, 23);
     this.button1.TabIndex                = 2;
     this.button1.Text                    = "OK";
     this.button1.UseVisualStyleBackColor = true;
     //
     // VerInfoForm
     //
     this.AcceptButton        = this.button1;
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(334, 92);
     this.Controls.Add(this.button1);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.pictureBox1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "VerInfoForm";
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text            = "バージョン情報";
     this.Load           += new System.EventHandler(this.VerInfoForm_Load);
     ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #11
0
 public DrawingTree()
 {
     InitializeComponent();
     System.Drawing.Icon   icon   = Properties.Resources.dollar;
     System.Drawing.Bitmap bitmap = icon.ToBitmap();
     this.Icon       = bitmap.ToImageSource();
     this.ResizeMode = ResizeMode.NoResize;
     FontSize        = 12.5;
 }
コード例 #12
0
        public MainWindow()
        {
            InitializeComponent();

            string filename = "C:/Program Files/Internet Explorer/iexplore.exe";

            System.Drawing.Icon   icon       = System.Drawing.Icon.ExtractAssociatedIcon(filename);
            System.Drawing.Bitmap iconBitmap = icon.ToBitmap();
        }
コード例 #13
0
ファイル: CmdCommit.cs プロジェクト: EAWCS1/SUITT
 public CmdCommit()
     : base(null, CAPTION, 0, null, MESSAGE, NAME, TOOLTIP)
 {
     System.Drawing.Icon icon = new System.Drawing.Icon(GetType().Assembly.
         GetManifestResourceStream("ISDUTLib.tm.ui.images.commitTrans.ico"));
     if(icon!=null)
     {
         base.m_bitmap = icon.ToBitmap();
     }
 }
コード例 #14
0
        public static string Icon2Base64String(System.Drawing.Icon I)
        {
            MemoryStream ms = new MemoryStream();

            if (I != null)
            {
                I.ToBitmap().Save(ms, ImageFormat.Png);
            }
            byte[] arr = ms.GetBuffer();
            return(Convert.ToBase64String(arr));
        }
コード例 #15
0
ファイル: Utilities.cs プロジェクト: kekekeks/fcmd
        /// <summary>Save a Windows icon to cache</summary>
        /// <param name="sdi">The System.Drawing.Icon, which needs to be saved</param>
        /// <param name="name">The icon name</param>
        /// <param name="size">The icon size</param>
        public static void SaveIconToCache(System.Drawing.Icon sdi, string name, int size = 16)
        {
            if (!Directory.Exists(PathToIcons + Path.DirectorySeparatorChar + size))
            {
                Directory.CreateDirectory(PathToIcons + Path.DirectorySeparatorChar + size);
            }

            string IconPath = PathToIcons + Path.DirectorySeparatorChar + size + Path.DirectorySeparatorChar + name + ".png";

            sdi.ToBitmap().Save(IconPath);
        }
コード例 #16
0
        public ImageSource ImageSourceFromIcon(System.Drawing.Icon ico)
        {
            ImageSource imageSource;

            using (System.Drawing.Bitmap bmp = ico.ToBitmap())
            {
                var stream = new MemoryStream();
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                imageSource = BitmapFrame.Create(stream);
                return(imageSource);
            }
        }
コード例 #17
0
 private void buttonSavePng_Click(object sender, EventArgs e)
 {
     using (var saveFileDialog = new SaveFileDialog {
         Filter = "PNG image files|*.png|All files|*.*"
     })
     {
         if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             _icon.ToBitmap().Save(saveFileDialog.FileName, ImageFormat.Png);
         }
     }
 }
コード例 #18
0
        private void ShowFtpClientDirectories(string cmd, string currentDirectory)
        {
            System.Drawing.Icon icon = FileHelp.GetDirectoryIcon();

            //清空区域
            localDirectoryList.Items.Clear();


            var directories = Directory.GetDirectories(currentDirectory);

            foreach (var directory in directories)
            {
                DirectoryInfo di = new DirectoryInfo(directory);

                StackPanel sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Tag         = di.Name;

                Image img = new Image();
                img.Source = BitmapToBitmapSource(icon.ToBitmap());

                Label lb = new Label();
                lb.FontSize = 16;
                lb.Content  = di.Name;

                sp.Children.Add(img);
                sp.Children.Add(lb);
                localDirectoryList.Items.Add(sp);
            }
            var files = Directory.GetFiles(currentDirectory);

            foreach (var file in files)
            {
                System.Drawing.Icon fileIcon = FileHelp.GetFileIcon(file);
                FileInfo            fi       = new FileInfo(file);
                StackPanel          sp       = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                sp.Tag         = fi.Name;

                Image img = new Image();
                img.Source = BitmapToBitmapSource(fileIcon.ToBitmap());

                Label lb = new Label();
                lb.FontSize = 16;
                lb.Content  = fi.Name;

                sp.Children.Add(img);
                sp.Children.Add(lb);

                localDirectoryList.Items.Add(sp);
            }
        }
コード例 #19
0
        public static System.Windows.Media.ImageBrush createImageBrushFromIcon(System.Drawing.Icon i_theIcon)
        {
            ImageSource imageSource;

            using (System.Drawing.Bitmap bmp = i_theIcon.ToBitmap())
            {
                var stream = new MemoryStream();
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                imageSource = System.Windows.Media.Imaging.BitmapFrame.Create(stream);
            }

            return(new ImageBrush(imageSource));
        }
コード例 #20
0
ファイル: Form1.cs プロジェクト: winterheart/game-utilities
        private void button4_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog od = new OpenFileDialog();

            od.Filter = "Icon files (*.ico)|*.ico";
            if (od.ShowDialog() == DialogResult.OK)
            {
                System.Drawing.Icon ic = new System.Drawing.Icon(od.FileName);
                pictureBox1.Image = ic.ToBitmap();
                icon = od.FileName;
                makeChanges();
            }
        }
コード例 #21
0
ファイル: Utilities.cs プロジェクト: 15831944/CAS2018
        public static System.Windows.Media.ImageSource ToImageSource(this System.Drawing.Icon icon)
        {
            System.Drawing.Bitmap bitmap = icon.ToBitmap();
            IntPtr      hBitmap          = bitmap.GetHbitmap();
            ImageSource wpfBitmap        = Imaging.CreateBitmapSourceFromHBitmap(hBitmap,
                                                                                 IntPtr.Zero, System.Windows.Int32Rect.Empty,
                                                                                 BitmapSizeOptions.FromEmptyOptions());

            if (!DeleteObject(hBitmap))
            {
                throw new System.ComponentModel.Win32Exception();
            }
            return(wpfBitmap);
        }
コード例 #22
0
        public static ImageSource ToImageSource(System.Drawing.Icon toConvert)
        {
            if (toConvert == null)
            {
                return(null);
            }
            ImageSource imageSource = null;

            using (System.Drawing.Bitmap bitmap = toConvert.ToBitmap())
            {
                imageSource = ToImageSource(bitmap);
            }
            return(imageSource);
        }
コード例 #23
0
        public static BitmapImage ToBitmapImage(System.Drawing.Icon toConvert)
        {
            if (toConvert == null)
            {
                return(null);
            }
            BitmapImage bitmapImage = new BitmapImage();

            using (System.Drawing.Bitmap bitmap = toConvert.ToBitmap())
            {
                bitmapImage = ToBitmapImage(bitmap);
            }
            return(bitmapImage);
        }
コード例 #24
0
ファイル: Graphics.cs プロジェクト: zhenkaining/vimage
        public static Sprite GetSpriteFromIcon(string fileName)
        {
            int index = TextureFileNames.IndexOf(fileName);

            if (index >= 0)
            {
                // Texture Already Exists
                // move it to the end of the array and return it
                Texture texture = Textures[index];
                string  name    = TextureFileNames[index];

                Textures.RemoveAt(index);
                TextureFileNames.RemoveAt(index);
                Textures.Add(texture);
                TextureFileNames.Add(name);

                return(new Sprite(Textures[Textures.Count - 1]));
            }
            else
            {
                // New Texture (from .ico)
                try
                {
                    System.Drawing.Icon   icon      = new System.Drawing.Icon(fileName, 256, 256);
                    System.Drawing.Bitmap iconImage = ExtractVistaIcon(icon);
                    if (iconImage == null)
                    {
                        iconImage = icon.ToBitmap();
                    }

                    Sprite iconSprite;

                    using (MemoryStream iconStream = new MemoryStream())
                    {
                        iconImage.Save(iconStream, System.Drawing.Imaging.ImageFormat.Png);
                        Texture iconTexture = new Texture(iconStream);
                        Textures.Add(iconTexture);
                        TextureFileNames.Add(fileName);

                        iconSprite = new Sprite(new Texture(iconTexture));
                    }

                    return(iconSprite);
                }
                catch (Exception) { }
            }

            return(null);
        }
コード例 #25
0
        private ImageSource getIconSource(string iconPath)
        {
            ImageSource imageSource;

            System.Drawing.Icon testIcon = System.Drawing.Icon.ExtractAssociatedIcon(iconPath);

            using (System.Drawing.Bitmap bmp = testIcon.ToBitmap())
            {
                var stream = new MemoryStream();
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                imageSource = BitmapFrame.Create(stream);
            }

            return(imageSource);
        }
コード例 #26
0
        public NewWindow(AViewWindow owner)
            : base(owner, Core.settings)
        {
            this.Owner = owner;
            //            var uriSource = new Uri(System.IO.Path.Combine(Core.ExecutablePath, "masgau.ico"), UriKind.Relative);
            //          this.Icon = new BitmapImage(uriSource);

            System.Drawing.Icon ico = Properties.Resources.MASGAUIcon;

            this.Icon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                ico.ToBitmap().GetHbitmap(),
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());
        }
コード例 #27
0
 /// <summary>
 /// MIcon: Display MyIcon on the message box.
 /// </summary>
 static public System.Windows.Forms.DialogResult Show(string Message, string Title, MyButtons MButtons, MyIcon MIcon, bool isChsLanguage)
 {
     lock (olock)
     {
         BuildMessageBox(Title);
         frmTitle.Text   = Title;
         frmMessage.Text = Message;
         ButtonStatements(MButtons, isChsLanguage);
         IconStatements(MIcon);
         System.Drawing.Image imageIcon = new System.Drawing.Bitmap(frmIcon.ToBitmap(), 38, 38);
         pIcon.Image = imageIcon;
         newMessageBox.ShowDialog();
         return(CYReturnButton);
     }
 }
コード例 #28
0
        private void iconPage_Initialize(object sender, WizardPageInitEventArgs e)
        {
            var windowsExe = _feedBuilder.MainCandidate as WindowsExe;

            if (windowsExe == null)
            {
                pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = false;
            }
            else
            {
                _icon = windowsExe.ExtractIcon();
                pictureBoxIcon.Image   = _icon.ToBitmap();
                pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = true;
            }
        }
コード例 #29
0
        private void AddProfile_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog exe_filedlg = new Microsoft.Win32.OpenFileDialog();

            exe_filedlg.DefaultExt = ".exe";
            exe_filedlg.Filter     = "Executable Files (*.exe)|*.exe;";

            Nullable <bool> result = exe_filedlg.ShowDialog();

            if (result.HasValue && result == true)
            {
                string filename = System.IO.Path.GetFileName(exe_filedlg.FileName.ToLowerInvariant());

                if (Global.LightingStateManager.Events.ContainsKey(filename))
                {
                    if (Global.LightingStateManager.Events[filename] is GameEvent_Aurora_Wrapper)
                    {
                        Global.LightingStateManager.Events.Remove(filename);
                    }
                    else
                    {
                        MessageBox.Show("Profile for this application already exists.");
                        return;
                    }
                }

                GenericApplication gen_app_pm = new GenericApplication(filename);
                gen_app_pm.Initialize();
                ((GenericApplicationSettings)gen_app_pm.Settings).ApplicationName = Path.GetFileNameWithoutExtension(filename);

                System.Drawing.Icon ico = System.Drawing.Icon.ExtractAssociatedIcon(exe_filedlg.FileName.ToLowerInvariant());

                if (!System.IO.Directory.Exists(gen_app_pm.GetProfileFolderPath()))
                {
                    System.IO.Directory.CreateDirectory(gen_app_pm.GetProfileFolderPath());
                }

                using (var icon_asbitmap = ico.ToBitmap())
                {
                    icon_asbitmap.Save(Path.Combine(gen_app_pm.GetProfileFolderPath(), "icon.png"), System.Drawing.Imaging.ImageFormat.Png);
                }
                ico.Dispose();

                Global.LightingStateManager.RegisterEvent(gen_app_pm);
                ConfigManager.Save(Global.Configuration);
                GenerateProfileStack(filename);
            }
        }
コード例 #30
0
ファイル: FileIcon.cs プロジェクト: ljm3994/CloudManager
        public static System.Drawing.Bitmap GetIcon(CloudFiles item)
        {
            SHFILEINFO sfi = new SHFILEINFO();

            if (item.Item.Extention != null)
            {
                IntPtr img1 = img1 = SHGetFileInfo("." + item.Item.Extention.ToUpper(), FILE_ATTRIBUTE_NORMAL, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_TYPENAME | SHGFI_SYSICONINDEX);
            }
            else
            {
                IntPtr img1 = img1 = SHGetFileInfo("Doesn't matter", FILE_ATTRIBUTE_DIRECTORY, ref sfi, (uint)Marshal.SizeOf(sfi), SHGFI_ICON | SHGFI_LARGEICON | SHGFI_USEFILEATTRIBUTES | SHGFI_OPENICON | SHGFI_TYPENAME);
            }
            System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(sfi.hIcon).Clone();
            DestroyIcon(sfi.hIcon);
            return(icon.ToBitmap());
        }
コード例 #31
0
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Получение иконки файла связанного с типом файла
            /// </summary>
            /// <param name="file_name">Имя файла</param>
            /// <returns>Изображение</returns>
            //---------------------------------------------------------------------------------------------------------
            public static BitmapSource GetIconFromFileTypeFromShell(String file_name)
            {
                IntPtr icon_small = XNative.SHGetFileInfo(file_name, 0, ref XNative.ShellFileInfoDefault,
                                                          (UInt32)Marshal.SizeOf(XNative.ShellFileInfoDefault), XNative.SHGFI_ICON | XNative.SHGFI_LARGEICON);

                //The icon is returned in the hIcon member of the shinfo struct
                System.Drawing.Icon icon = System.Drawing.Icon.FromHandle(XNative.ShellFileInfoDefault.IconHandle);

                var h_bitmap = icon.ToBitmap().GetHbitmap();
                var result   = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(h_bitmap, IntPtr.Zero,
                                                                                            Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());

                XNative.DeleteObject(h_bitmap);

                return(result);
            }
コード例 #32
0
ファイル: CmdActivate.cs プロジェクト: EAWCS1/SUITT
 public CmdActivate()
     : base(null, CAPTION, 0, null, MESSAGE, NAME, TOOLTIP)
 {
     try
     {
         base.m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream("ISDUTLib.tm.ui.images.redlight.png"));
     }
     catch (Exception e)
     {
         System.Drawing.Icon icon = new System.Drawing.Icon(GetType().Assembly.
         GetManifestResourceStream("ISDUTLib.tm.ui.images.database.ico"));
         if (icon != null)
         {
             base.m_bitmap = icon.ToBitmap();
         }
     }
 }
コード例 #33
0
ファイル: ComplexMap.cs プロジェクト: diegowald/intellitrack
 private SharpMap.Styles.VectorStyle LoadStyle(string filename)
 {
   SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
   if (System.IO.File.Exists(filename))
   {
     string fileExtension = System.IO.Path.GetExtension(filename).ToLower();
     switch (fileExtension)
     {
       case ".png":
       case ".jpg":
       case ".gif":
       case ".bmp":
         style.Symbol = new System.Drawing.Bitmap(filename, true);
         break;
       case ".ico":
         System.Drawing.Icon icon = new System.Drawing.Icon(filename);
         style.Symbol = icon.ToBitmap();
         break;
       default:
         style.Line.Color = System.Drawing.Color.Black;
         break;
     }
   }
   else
   {
     style.Line.Color = System.Drawing.Color.Black;
   }
   return style;
 }
コード例 #34
0
 private void iconPage_Initialize(object sender, WizardPageInitEventArgs e)
 {
     var windowsExe = _feedBuilder.MainCandidate as WindowsExe;
     if (windowsExe == null)
         pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = false;
     else
     {
         _icon = windowsExe.ExtractIcon();
         pictureBoxIcon.Image = _icon.ToBitmap();
         pictureBoxIcon.Visible = buttonSaveIco.Enabled = buttonSavePng.Enabled = true;
     }
 }
コード例 #35
0
        public static bool ConvertGifIcoToPng(byte[] aInput, int nImageFormat, out byte[] aOutput)
        {
            aOutput = null;
            bool bRes = false;
            if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_GIF == nImageFormat)
            {
                using (MemoryStream ms = new MemoryStream(aInput))
                {
                    System.Drawing.Image oImage = System.Drawing.Image.FromStream(ms);
                    using (MemoryStream ms2 = new MemoryStream())
                    {
                        oImage.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
                        aOutput = ms2.ToArray();
                        bRes = true;
                    }
                }
            }
            else if (FileFormats.AVS_OFFICESTUDIO_FILE_IMAGE_ICO == nImageFormat)
            {
                using (MemoryStream ms = new MemoryStream(aInput))
                {

                    System.Drawing.Icon oIcon = new System.Drawing.Icon(ms, new System.Drawing.Size(256, 256));
                    using (MemoryStream ms2 = new MemoryStream())
                    {
                        oIcon.ToBitmap().Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
                        aOutput = ms2.ToArray();
                        bRes = true;
                    }
                }
            }
            return bRes;
        }
コード例 #36
0
ファイル: ImageViewer.cs プロジェクト: Torrunt/vimage
 public void CopyAsImage()
 {
     Thread thread = new Thread(() =>
     {
         try
         {
             System.Drawing.Bitmap bitmap;
             if (File.IndexOf(".ico") == File.Length - 4)
             {
                 // If .ico - copy largest version
                 System.Drawing.Icon icon = new System.Drawing.Icon(File, 256, 256);
                 bitmap = Graphics.ExtractVistaIcon(icon);
                 if (bitmap == null)
                     bitmap = icon.ToBitmap();
             }
             else
                 bitmap = new System.Drawing.Bitmap(File);
             Clipboard.SetImage(bitmap);
         }
         catch (Exception) { }
     });
     thread.SetApartmentState(ApartmentState.STA);
     thread.Start();
 }
コード例 #37
0
ファイル: Form1.cs プロジェクト: winterheart/game-utilities
 private void button4_Click(object sender, System.EventArgs e)
 {
     OpenFileDialog od = new OpenFileDialog();
     od.Filter = "Icon files (*.ico)|*.ico";
     if (od.ShowDialog() == DialogResult.OK)
     {
         System.Drawing.Icon ic=new System.Drawing.Icon(od.FileName);
         pictureBox1.Image = ic.ToBitmap();
         icon = od.FileName;
         makeChanges();
     }
 }
コード例 #38
0
 private static byte[] IconAsSizedPng(byte[] iconBytes, int iSize)
 {
     System.Drawing.Icon icon;
     using (System.IO.MemoryStream ms = new System.IO.MemoryStream(iconBytes))
         icon = new System.Drawing.Icon(ms, iSize, iSize);
     using (icon)
     {
         using (System.Drawing.Bitmap bmp = icon.ToBitmap())
         {
             //bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
             using (var ms = new System.IO.MemoryStream())
             {
                 bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                 return ms.ToArray();
             }
         }
     }
 }
コード例 #39
0
ファイル: Graphics.cs プロジェクト: Torrunt/vimage
        public static Sprite GetSpriteFromIcon(string fileName)
        {
            try
            {
                System.Drawing.Icon icon = new System.Drawing.Icon(fileName, 256, 256);
                System.Drawing.Bitmap iconImage = ExtractVistaIcon(icon);
                if (iconImage == null)
                    iconImage = icon.ToBitmap();

                Sprite iconSprite;

                using (MemoryStream iconStream = new MemoryStream())
                {
                    iconImage.Save(iconStream, System.Drawing.Imaging.ImageFormat.Png);
                    iconSprite = new Sprite(new Texture(iconStream));
                }

                return iconSprite;
            }
            catch (Exception) { }
            return null;
        }
コード例 #40
-1
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VerInfoForm));
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.label1 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
            this.SuspendLayout();
            // 
            // pictureBox1
            // 
            System.Drawing.Icon ico = new System.Drawing.Icon(Properties.Resources.Icon, 64, 64);
            System.Drawing.Bitmap bmp = ico.ToBitmap();
            this.pictureBox1.Image = bmp;
            this.pictureBox1.Location = new System.Drawing.Point(12, 12);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(64, 64);
            this.pictureBox1.TabIndex = 0;
            this.pictureBox1.TabStop = false;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(82, 12);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(0, 12);
            this.label1.TabIndex = 1;
            // 
            // button1
            // 
            this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.button1.Location = new System.Drawing.Point(247, 53);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 2;
            this.button1.Text = "OK";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // VerInfoForm
            // 
            this.AcceptButton = this.button1;
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(334, 92);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.pictureBox1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "VerInfoForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "バージョン情報";
            this.Load += new System.EventHandler(this.VerInfoForm_Load);
            ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }