Example #1
0
        public void SetFullPath(string path)
        {
            if (this.FullPath != null)
            {
                FileData outs;
                Factory.Resolve <FolderService>().Files.TryRemove(this.FullPath, out outs);
            }

            this.FullPath = path;

            Factory.Resolve <FolderService>().Files.TryAdd(this.FullPath, this);

            this.IsDirectory = Directory.Exists(path);
            if (this.IsDirectory)
            {
                this.Name = new DirectoryInfo(path).Name;
            }
            else
            {
                FileInfo info = new FileInfo(path);
                this.Name     = info.Name;
                this.IsHidden = info.Attributes.HasFlag(FileAttributes.Hidden);
            }

            this.Icon = new Lazy <BitmapSource>(() => IconUtil.GetIcon(this.FullPath));
        }
        //Quando o foco da linha do GridPerfil é trocado
        private void gcPerfil_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            BO_PerfilFuncionalidade boPerfilFuncionalidade = (BO_PerfilFuncionalidade)FactoryBO <PerfilFuncionalidade> .GetBO();

            int linhaFocada = tvPerfil.FocusedRowHandle;

            if (tvPerfil.AllowEditing && ultimaLinhaFocada != linhaFocada)
            {
                MessageBox.Show("Finalize a operação antes de mudar de linha!", "Operação inválida");
                tvPerfil.FocusedRowHandle = ultimaLinhaFocada;
            }

            var per = gcPerfil.GetFocusedRow() as Perfil;

            if (per != null && perfis.Count != 0)
            {
                perfilFuncionalidades = new ObservableCollection <PerfilFuncionalidade>();
                perfilFuncionalidades = IconUtil.ConverterL2OC(boPerfilFuncionalidade.ObterListaFuncinalidadedoPerfilSelecionado(per));
                btnAddFuncionalidadePerfil.IsEnabled = true;
            }
            else
            {
                perfilFuncionalidades = null;
                btnAddFuncionalidadePerfil.IsEnabled = false;
            }
        }
        private void gcUsuario_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            var usuFocado = gcUsuario.GetFocusedRow() as Usuario;

            BO_Perfil boPerfil = (BO_Perfil)FactoryBO <Perfil> .GetBO();

            BO_Empresa boEmpresa = (BO_Empresa)FactoryBO <Empresa> .GetBO();

            boEmpresa.Attach(emp); //  Antes a empresas estava utiliazando para um endereço "new" automatico///////////////////////////////////////////////////////////////////////////////////////

            //Preenche o Grid control Usuario perfil de acordo com o usuario linha focada
            usuarioPerfis = new ObservableCollection <UsuarioPerfil>();
            usuarioPerfis = IconUtil.ConverterL2OC(boUsuarioPerfil.ObterListaObjetoUsuario(usuFocado));

            ObservableCollection <Perfil> listaPerfil = new ObservableCollection <Perfil>();

            if (usuarioPerfis != null)
            {
                foreach (var item in usuarioPerfis)
                {
                    listaPerfil.Add(boPerfil.ObterPerfil(item));
                }

                //gcPerfilEmpresa.ItemsSource = listaPerfil;
                perfis = listaPerfil;
            }

            int linhaFocada = tvUsuario.FocusedRowHandle;

            if (tvUsuario.AllowEditing && ultimaLinhaFocada != linhaFocada)
            {
                MessageBox.Show("Finalize a operação antes de mudar de linha!", "Operação inválida");
                tvUsuario.FocusedRowHandle = ultimaLinhaFocada;
            }
        }
Example #4
0
        /// <summary>
        /// Extract the information from an executable file
        /// </summary>
        /// <param name="filePath"> Fully qualified name of the file</param>
        /// <param name="entry"> </param>
        private void LoadAnExe(string filePath, TextBox entry)
        {
            // we have an internet shortcut
            FileInfo  lnk       = new FileInfo(filePath);
            MenuEntry thisEntry = new MenuEntry();

            thisEntry.TargetOriginal = filePath;
            thisEntry.Target         = filePath;
            thisEntry.Arguments      = "";
            thisEntry.IconPath       = "";
            thisEntry.IconIndex      = 0;
            thisEntry.PanelName      = entry.Name;
            thisEntry.StartIn        = lnk.DirectoryName;

            string        iconfilename = IconFolder + @"\" + lnk.Name.Substring(0, lnk.Name.Length - lnk.Extension.Length) + ".ico";
            IconExtractor extractor    = new IconExtractor(filePath);
            Icon          icon         = extractor.GetIcon(thisEntry.IconIndex);

            splitIcons = IconUtil.Split(icon);
            iconCount  = splitIcons.GetUpperBound(0);

            Image1.Image    = splitIcons[0].ToBitmap();
            IconNumber.Text = "0";

            thisEntry.IconPath = iconfilename;

            SetItem(thisEntry);
        }
        public static Icon GetHighResIcon(string incPath)
        {
            Icon icon = null;

            try
            {
                try
                {
                    IconExtractor ie = new IconExtractor(incPath);
                    icon = ie.GetIcon(0);
                }
                catch (Exception ex)
                {
                    icon = IconFromFilePath(incPath);
                    ex.Log();
                }
                Icon[] splitIcons  = IconUtil.Split(icon); //icon0
                Icon   biggestIcon = splitIcons[0];
                foreach (var item in splitIcons)
                {
                    biggestIcon = item.Width > biggestIcon.Width ? item : biggestIcon;
                }

                return(biggestIcon);
            }
            catch (Exception ex)
            {
                ex.Log($"Error at 'GetHighResIcon(string incPath={incPath})'\n\n{ex.Message}");
                return(IconFromFilePath(incPath));
            }
        }
Example #6
0
        private void btnPickFile_Click(object sender, EventArgs e)
        {
            var result = iconPickerDialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var fileName = iconPickerDialog.FileName;
                m_iconIndex = iconPickerDialog.IconIndex;

                Icon   icon       = null;
                Icon[] splitIcons = null;
                try
                {
                    if (Path.GetExtension(iconPickerDialog.FileName).ToLower() == ".ico")
                    {
                        m_iconExtractor = null;
                        icon            = new Icon(iconPickerDialog.FileName);
                    }
                    else
                    {
                        m_iconExtractor = new IconExtractor(fileName);
                        icon            = m_iconExtractor.GetIcon(m_iconIndex);
                    }

                    splitIcons = IconUtil.Split(icon);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                txtFileName.Text = String.Format(
                    "{0}, #{1}, {2} variations", fileName, m_iconIndex, splitIcons.Length);

                // Update icons.

                Icon = icon;
                icon.Dispose();

                lvwIcons.BeginUpdate();
                ClearAllIcons();

                foreach (var i in splitIcons)
                {
                    var item = new IconListViewItem();
                    var size = i.Size;
                    item.BitCount    = IconUtil.GetBitCount(i);
                    item.Bitmap      = IconUtil.ToBitmap(i);
                    item.ToolTipText = String.Format("{0}x{1}, {2} bits", size.Width, size.Height, item.BitCount);
                    i.Dispose();

                    lvwIcons.Items.Add(item);
                }

                lvwIcons.EndUpdate();

                btnSaveAsIco.Enabled = (m_iconExtractor != null);
            }
        }
 public PopupInserirProduto(TelaPrincipal telaPrincipalInfo)
 {
     InitializeComponent();
     frmTelaPrincipal = telaPrincipalInfo;
     categorias       = new ObservableCollection <Categoria>();
     categorias       = IconUtil.ConverterL2OC(boCategoria.ObterListaCategoriadaEmpresa(frmTelaPrincipal.empLogada));
 }
Example #8
0
        // https://stackoverflow.com/questions/22499407/how-to-display-a-bitmap-in-a-wpf-image
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is WindowsPEResourceIcon resIcon)
            {
                var exePath = resIcon.FilePath;

                // check if lnk, if so resolve the executable location first
                if (resIcon.FilePath.EndsWith(".lnk", StringComparison.OrdinalIgnoreCase))
                {
                    var shell    = new WshShell();
                    var shortcut = (IWshShortcut)shell.CreateShortcut(resIcon.FilePath);
                    exePath = shortcut.TargetPath;
                }

                // extract icon from exe
                try
                {
                    var extractor      = new IconExtractor(exePath);
                    var iconCollection = extractor.GetIcon(resIcon.Index);
                    var biggestIcon    = IconUtil.Split(iconCollection).OrderByDescending(x => x.Width * x.Height).FirstOrDefault();
                    if (biggestIcon != null)
                    {
                        return(CreateBitmapImageFromBitmap(biggestIcon.ToBitmap()));
                    }
                }
                catch (Exception)
                {
                    // no icon, file not found or whatever
                }
            }

            return(null);
        }
        public Icon GetBestIcon(String path)
        {
            if (!path.EndsWith(".exe") && !path.EndsWith(".dll"))
            {
                return(null);
            }
            IconExtractor ie        = new IconExtractor(path);
            string        fileName  = ie.FileName;
            int           iconCount = ie.Count;

            if (iconCount > 0)
            {
                Icon[] allIcons = ie.GetAllIcons();
                Icon   ret      = null;
                foreach (var icon in allIcons)
                {
                    Icon[] splitIcons  = IconUtil.Split(icon);
                    Icon   biggestIcon = splitIcons.OrderBy(x => x.Size.Height).Last();
                    if (ret == null || biggestIcon.Height > ret.Height)
                    {
                        ret = biggestIcon;
                    }
                }

                return(ret);
            }

            return(null);
        }
Example #10
0
 public void LoadListViewByMyPcPath(ListView listView, ImageList imageList, string myPcPath)
 {
     Cursor.Current = Cursors.WaitCursor;
     ListView.ListViewItemCollection listViewItems  = listView.Items;
     ImageList.ImageCollection       imageListItems = imageList.Images;
     listViewItems.Clear(); imageListItems.Clear();
     string[] dirsArray; int imageIndex = 0;
     try
     {
         dirsArray = Directory.GetLogicalDrives();
         for (int i = 0; i < dirsArray.Length; i++)
         {
             DriveInfo driInfo      = new DriveInfo(dirsArray[i]);
             string[]  driInfoArray = new string[4];
             driInfoArray[0] = string.Format("{0}({1})", driInfo.VolumeLabel, driInfo.Name);
             driInfoArray[1] = SFUCommon.GetCommonSize(driInfo.TotalSize);
             driInfoArray[2] = SFUCommon.GetCommonSize(driInfo.TotalFreeSpace);
             driInfoArray[3] = driInfo.Name;
             ListViewItem listViewItem = new ListViewItem(driInfoArray, imageIndex);
             listViewItems.Add(listViewItem);
             imageListItems.Add(IconUtil.GetDirectoryIcon(driInfo.Name));
             imageIndex++;
         }
     }
     catch (Exception)
     {
         //如果不使用try catch抓取错误并以此跳过错误,在添加没有放入光盘的光驱Items时会提示错误
     }
     Cursor.Current = Cursors.Default;
 }
Example #11
0
        public void LoadListView(ListView listView, ImageList imageList, string remotePath)
        {
            if (upYun == null)
            {
                return;
            }
            Cursor.Current = Cursors.WaitCursor;
            List <FolderItem> itemsArray = new List <FolderItem>();

            try { itemsArray = upYun.readDir(remotePath).Cast <FolderItem>().ToList(); }
            catch { } // UpYun SDK BUG: 调用readDir方法时,如果该目录下没有任何文件或目录,会有数组越界的问题
            try
            {
                ListView.ListViewItemCollection listViewItems = listView.Items;
                int    imageIndex  = 0;
                string programPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                ImageList.ImageCollection imageItems = imageList.Images;
                listViewItems.Clear(); imageItems.Clear();
                if (!remotePath.Equals("/"))
                {
                    string[] itemInfo = new string[4];
                    itemInfo[0] = "上级目录";
                    itemInfo[3] = "ParentDir";
                    ListViewItem parentDirItem = new ListViewItem(itemInfo, 0);
                    listViewItems.Add(parentDirItem);
                    imageItems.Add(StaticFileUpload.Business.Properties.Resources.up_16x16);
                    imageIndex++;
                }
                imageItems.Add(IconUtil.GetDirectoryIcon(programPath));
                imageIndex++;
                foreach (FolderItem item in itemsArray)
                {
                    ListViewItem listViewItem = null;
                    string[]     itemInfo     = new string[4];
                    itemInfo[0] = item.filename;
                    itemInfo[1] = SFUCommon.GetCommonSize(item.size);
                    itemInfo[2] = SFUCommon.GetCommonTime(item.number).ToString();
                    if (item.filetype.Equals("N"))
                    {
                        itemInfo[3]  = "N";
                        listViewItem = new ListViewItem(itemInfo, imageIndex);
                        imageItems.Add(IconUtil.GetFileIcon(item.filename, false));
                        imageIndex++;
                    }
                    else
                    {
                        itemInfo[3]  = "F";
                        listViewItem = new ListViewItem(itemInfo, remotePath.Equals("/") ? 0 : 1);
                    }
                    listViewItems.Add(listViewItem);
                }
            }
            catch (Exception ex)
            {
                SFULogger.DEFAULT.Error(ex);
                throw;
            }
            Cursor.Current = Cursors.Default;
        }
Example #12
0
        private void doConsultar()
        {
            tvFuncionalidade.AllowEditing = false;
            funcionalidades = IconUtil.ConverterL2OC(boFuncionalidade.ObterListaObjeto());

            habilitarBotoes(true);
            frmTelaPrincipal.tabControlMenu.IsEnabled = true;
        }
Example #13
0
        public virtual void Initialize()
		{
			AssemblyName = BaseConstants.AssemblyName;

			if (!string.IsNullOrEmpty(IconName))
			{
				ButtonImage = IconUtil.GetMenuIconResource(IconName);
			}
		}
Example #14
0
        public void LoadListView(ListView listView, ImageList imageList, string localPath)
        {
            Cursor.Current = Cursors.WaitCursor;
            string[] filesArray, diresArray; int imageIndex = 1;
            ListView.ListViewItemCollection listViewItems  = listView.Items;
            ImageList.ImageCollection       imageListItems = imageList.Images;
            try
            {
                diresArray = Directory.GetDirectories(localPath);
                filesArray = Directory.GetFiles(localPath);
            }
            catch (Exception ex)
            {
                SFULogger.DEFAULT.Error("该目录不存在!", ex);
                MessageBox.Show("该目录不存在!");
                return;
            }
            // 清空 ListView & ImageList 控件条目集合
            listViewItems.Clear(); imageListItems.Clear();
            listViewItems.Add("上级目录", 0);
            imageListItems.Add(StaticFileUpload.Business.Properties.Resources.up_16x16);

            // 遍历 localPath 目录下的子文件夹
            for (int i = 0; i < diresArray.Length; i++)
            {
                string[]      dirInfoArray  = new string[3];
                DirectoryInfo directoryInfo = new DirectoryInfo(diresArray[i]);
                if ((directoryInfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    dirInfoArray[0] = directoryInfo.Name;
                    dirInfoArray[1] = "      ";
                    dirInfoArray[2] = directoryInfo.LastWriteTime.ToString();
                    ListViewItem listViewItem = new ListViewItem(dirInfoArray, imageIndex);
                    listViewItems.Add(listViewItem);
                    imageListItems.Add(dirInfoArray[0], IconUtil.GetDirectoryIcon(directoryInfo.FullName));
                    imageIndex++;
                }
            }
            // 遍历 localPath 目录下的子文件
            for (int i = 0; i < filesArray.Length; i++)
            {
                string[] fileInfoArray = new string[3];
                FileInfo fileInfo      = new FileInfo(filesArray[i]);
                if ((fileInfo.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
                {
                    fileInfoArray[0] = fileInfo.Name;
                    fileInfoArray[1] = SFUCommon.GetCommonSize(fileInfo.Length);
                    fileInfoArray[2] = fileInfo.LastWriteTime.ToString();
                    ListViewItem listViewItem = new ListViewItem(fileInfoArray, imageIndex);
                    listViewItems.Add(listViewItem);
                    imageListItems.Add(fileInfo.Name, IconUtil.GetFileIcon(fileInfo.FullName, false));
                    imageIndex++;
                }
            }
            Cursor.Current = Cursors.Default;
        }
Example #15
0
        private void SetIcons()
        {
            wizardTitleControl1.TitleText    = PluginResources.GoogleDialog_Title;
            wizardTitleControl1.SubTitleText = PluginResources.GoogleDialog_Description;
            const int iconSize  = 48;
            var       imageSize = DpiAwareUtil.AdjustWidthForCurrentDpi(iconSize);

            wizardTitleControl1.TitleBitmap = IconUtil.IconToBitmap(PluginResources.Google_Cloud_Platform, imageSize,
                                                                    imageSize);
        }
Example #16
0
        ///<exception cref="Exception"></exception>
        public static BitmapSource ExtractIconFromEXEDLL(string exeordllPath, int iconIndex, int width, int height)
        {
            System.Drawing.Icon   fullIcon  = new IconExtractor(exeordllPath).GetIcon(iconIndex);          //Throws if invalid path or index
            System.Drawing.Icon[] splitIcon = IconUtil.Split(fullIcon);
            System.Drawing.Icon   selectedIcon;
            if (splitIcon.Count() == 0)
            {
                throw new InvalidOperationException("The icon contains no sizes");
            }
            try {
                selectedIcon = (
                    splitIcon
                    .Last((icon) => {
                    return(icon.Width == width && icon.Height == height);
                })                         //Throws if no icons match
                    );
            } catch (InvalidOperationException) {
                IEnumerable <System.Drawing.Icon> largerIcons = (
                    splitIcon
                    .Where((icon) => {
                    return(icon.Width >= width && icon.Height >= height);
                })
                    );
                IEnumerable <System.Drawing.Icon> selectedIcons1;
                if (largerIcons.Count() == 0)
                {
                    selectedIcons1 = splitIcon;
                }
                else
                {
                    selectedIcons1 = largerIcons;
                }

                IEnumerable <System.Drawing.Icon> inProportionIcons = (
                    selectedIcons1.Where((icon) => {
                    return(icon.Width / icon.Height == width / height);
                })
                    );

                if (inProportionIcons.Count() == 0)
                {
                    selectedIcon = inProportionIcons.Best((icon) => {
                        return(Math.Abs((icon.Width - width)) * -1);
                    }, true);
                }
                else
                {
                    selectedIcon = selectedIcons1.Best((icon) => {
                        return(Math.Abs(((icon.Width * icon.Height) - (width * height))) * -1);
                    }, true);
                }
            }
            return(BitmapToBitmapSource(IconUtil.ToBitmap(selectedIcon)));            //Might throw exceptions
        }
Example #17
0
        private static Icon[] GetIcons(string filename)
        {
            Icon[]        splitIcons = new Icon[0];
            IconExtractor ie         = new IconExtractor(filename);

            if (ie.Count > 0)
            {
                splitIcons = IconUtil.Split(ie.GetIcon(0));
            }
            return(splitIcons);
        }
        private void BuildListView()
        {
            //reset the list view items
            lvwIcons.Items.Clear();

            //validate the path exists
            var targetPath = txtPathToExtractFrom.Text;

            if (!File.Exists(targetPath))
            {
                return;
            }

            lvwIcons.BeginUpdate();
            try
            {
                //icon files don't need extraction
                if (string.Equals(Path.GetExtension(targetPath), ".ico", StringComparison.InvariantCultureIgnoreCase))
                {
                    _icons = new[] { new Icon(targetPath) };
                }
                else
                {
                    var iconExtraction = new IconExtractor(targetPath);
                    _icons = iconExtraction.GetAllIcons();
                }

                foreach (var i in _icons)
                {
                    var splitIcons = IconUtil.Split(i);

                    var largestIcon = splitIcons.OrderByDescending(k => k.Width)
                                      .ThenByDescending(k => Math.Max(k.Height, k.Width))
                                      .First();

                    var item = new IconListViewItem {
                        Bitmap = IconUtil.ToBitmap(largestIcon)
                    };
                    i.Dispose();
                    largestIcon.Dispose();

                    lvwIcons.Items.Add(item);
                }
            }
            catch
            {
                // ignored
            }
            finally
            {
                lvwIcons.EndUpdate();
            }
        }
        private void doConsultar()
        {
            tvCategoria.AllowEditing = false;

            categorias = IconUtil.ConverterL2OC(boCategoria.ObterListaCategoriadaEmpresa(frmTelaPrincipal.empLogada));
            empresas   = IconUtil.ConverterL2OC(boEmpresa.ObterListaObjeto());

            //util.BestFitColumn(gcCategoria);

            habilitarBotoes(true);

            frmTelaPrincipal.tabControlMenu.IsEnabled = true;
        }
Example #20
0
        private void SetIcons()
        {
            _icons.ColorDepth = ColorDepth.Depth32Bit;
            _icons.ImageSize  = new Size(12, 12);
            var color = SystemColors.ControlText;

            _icons.Images.Add(IconUtil.CreateColoredIcon(Poderosa.TerminalSession.Properties.Resources.TerminalSmall, color));
            _icons.Images.Add(IconUtil.CreateColoredIcon(Poderosa.TerminalSession.Properties.Resources.MacroSmall, color));

            _optionsTab.ImageList = _icons;

            _terminalTabPage.ImageIndex = 0;
            _macroTabPage.ImageIndex    = 1;
        }
Example #21
0
 private static ImageSource GetApplicationIcon(string path)
 {
     if (!string.IsNullOrWhiteSpace(path))
     {
         IconExtractor iconExtractor = new IconExtractor(path);
         // If any icon is found
         if (iconExtractor.Count > 0)
         {
             // Gets the largest icon from the exe
             return(iconExtractor.GetIcon(0).ToImageSource());
         }
     }
     return(IconUtil.ToImageSource(SystemIcons.Application));
 }
Example #22
0
 private void exctractIcon(string path)
 {
     try
     {
         IconExtractor ie         = new IconExtractor(path);
         Icon          icon       = ie.GetIcon(0);
         MultiIcon     mIcon      = new MultiIcon();
         SingleIcon    sIcon      = mIcon.Add("oink");
         Icon[]        splitIcons = IconUtil.Split(icon);
         sIcon.CreateFrom(IconUtil.ToBitmap(splitIcons[splitIcons.Length - 1]), IconOutputFormat.Vista);
         sIcon.Save(applicationPath + iconName);
     }
     catch { }
 }
        //Quando o foco da linha do GridEmpresa é trocado
        private void gcEmpresa_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            var emp = gcEmpresa.GetFocusedRow() as Empresa;

            perfis = new ObservableCollection <Perfil>();
            perfis = IconUtil.ConverterL2OC(boPerfil.ObterListaPerfilporEmpresa(emp));

            int linhaFocada = tvEmpresa.FocusedRowHandle;

            if (tvEmpresa.AllowEditing && ultimaLinhaFocada != linhaFocada)
            {
                MessageBox.Show("Finalize a operação antes de mudar de linha!", "Operação inválida");
                tvEmpresa.FocusedRowHandle = ultimaLinhaFocada;
            }
        }
Example #24
0
        private void LoadAURL(string filePath, TextBox entry)
        {
            string LinkTarget           = "";
            string LinkArguments        = "";
            string LinkIconLocation     = "";
            string LinkWorkingDirectory = "";
            int    LinkIconIndex        = 0;
            string LinkDescription      = "";


            StringBuilder temp = new StringBuilder(255);
            int           i    = GetPrivateProfileString("InternetShortcut", "URL", "", temp, 255, filePath);

            LinkTarget       = temp.ToString();
            i                = GetPrivateProfileString("InternetShortcut", "IconFile", "", temp, 255, filePath);
            LinkIconLocation = temp.ToString();
            i                = GetPrivateProfileString("InternetShortcut", "IconIndex", "", temp, 255, filePath);
            LinkIconIndex    = Convert.ToInt32(temp.ToString());

            MenuEntry thisEntry = new MenuEntry();

            thisEntry.TargetOriginal   = LinkTarget;
            thisEntry.Target           = LinkTarget;
            thisEntry.Arguments        = LinkArguments;
            thisEntry.IconPathOriginal = LinkIconLocation;
            thisEntry.IconIndex        = LinkIconIndex;
            thisEntry.StartIn          = LinkWorkingDirectory;
            thisEntry.Description      = LinkDescription;

            FileInfo lnk = new FileInfo(filePath);
            //            string iconfilename = IconFolder + @"\" + LinkIconLocation.Substring(LinkIconLocation.LastIndexOf("/") + 1);

            string iconfilename = IconFolder + @"\" + lnk.Name.Substring(0, lnk.Name.Length - lnk.Extension.Length) + ".ico";

            var client = new System.Net.WebClient();

            client.DownloadFile(LinkIconLocation, iconfilename);

            Icon icon = new Icon(iconfilename);

            splitIcons = IconUtil.Split(icon);
            iconCount  = splitIcons.GetUpperBound(0);

            Image1.Image    = splitIcons[0].ToBitmap();
            IconNumber.Text = "0";
            IconSize.Text   = splitIcons[0].Width.ToString() + "x" + splitIcons[0].Height.ToString();
            SetItem(thisEntry);
        }
        private void gcPerfilEmpresa_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
        {
            BO_PerfilFuncionalidade boPerfilFuncionalidade = (BO_PerfilFuncionalidade)FactoryBO <PerfilFuncionalidade> .GetBO();

            var per = gcPerfilEmpresa.GetFocusedRow() as Perfil;

            if (per != null && perfis.Count != 0)
            {
                perfilFuncionalidades = new ObservableCollection <PerfilFuncionalidade>();
                perfilFuncionalidades = IconUtil.ConverterL2OC(boPerfilFuncionalidade.ObterListaFuncinalidadedoPerfilSelecionado(per));
            }
            else
            {
                perfilFuncionalidades = null;
            }
        }
Example #26
0
        public static BitmapImage BitmapToBitmapImage(Icon icon)
        {
            BitmapImage image  = new BitmapImage();
            Bitmap      bitmap = IconUtil.ToBitmap(icon);

            using (MemoryStream memory = new MemoryStream())
            {
                bitmap.Save(memory, ImageFormat.Png);
                memory.Position = 0;
                image.BeginInit();
                image.StreamSource = memory;
                image.CacheOption  = BitmapCacheOption.OnLoad;
                image.EndInit();
            }
            return(image);
        }
Example #27
0
        private void btnLoadIcon_Click(object sender, EventArgs e)
        {
            using (var ofd = new OpenFileDialog())
            {
                ofd.FileName = string.Empty;
                ofd.Filter   = Resources.IconFilter;
                if (ofd.ShowDialog() != DialogResult.OK || Path.GetExtension(ofd.FileName) != ".ico")
                {
                    return;
                }

                _icon = new Icon(ofd.FileName);
                var icons       = IconUtil.Split(_icon);
                var biggesticon = icons.Aggregate((icon1, icon2) => icon1.Width * icon1.Height > icon2.Width * icon2.Height ? icon1 : icon2);
                pictureBox1.Image = IconUtil.ToBitmap(biggesticon);
            }
        }
        public ApplicationPicker_Control(GameApplication app) : base()
        {
            Orientation = Orientation.Horizontal;

            _iconExtractor = new IconExtractor(app.ExecutablePath);
            int iconCount = _iconExtractor.Count;

            System.Drawing.Icon[] splitIcons = IconUtil.Split(_iconExtractor.GetIcon(0));
            ImageSource           imageSource;

            System.Drawing.Bitmap bitmap;
            try
            {
                int c = 0;
                do
                {
                    bitmap = IconUtil.ToBitmap(splitIcons[c]);
                    c++;
                }while (bitmap.Size.Width < 256 && c >= 0 && c < splitIcons.Length);
            }
            catch (Exception)
            {
                throw;
            }
            var stream = new MemoryStream();

            bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
            imageSource = BitmapFrame.Create(stream);

            Children.Add(new Image()
            {
                Source            = imageSource,
                VerticalAlignment = VerticalAlignment.Center,
                MaxHeight         = 75,
                MaxWidth          = 75,
                Margin            = new Thickness(0, 0, 20, 0)
            });

            Children.Add(new TextBlock()
            {
                Text = app.Name,
                VerticalAlignment = VerticalAlignment.Center,
                FontSize          = 25
            });
            App = app;
        }
Example #29
0
        private void doConsultar()
        {
            tvProduto.AllowEditing = false;

            categorias = IconUtil.ConverterL2OC(boCategoria.ObterListaCategoriadaEmpresa(frmTelaPrincipal.empLogada));
            if (categorias == null)
            {
                MessageBox.Show("Não há regitros de categoria(s) no banco de dados!");
                //_this = null;
                btnNovo.IsEnabled = btnEditar.IsEnabled = false;
            }
            else
            {
                produtos = IconUtil.ConverterL2OC(boProduto.ObterListaProdutosdaEmpresa(frmTelaPrincipal.empLogada));
                frmTelaPrincipal.tabControlMenu.IsEnabled = true;
            }
        }
Example #30
0
        private byte[] GetLogoBytes()
        {
            var splitIcons = IconUtil.Split(_icons[lvwIcons.SelectedItems[0].Index]);

            byte[] byteArray;
            using (var stream = new MemoryStream())
            {
                using (var bitmapLoad = Bitmap.FromHicon(splitIcons.OrderByDescending(k => k.Width)
                                                         .ThenByDescending(k => k.Height)
                                                         .First().Handle))
                {
                    bitmapLoad.Save(stream, ImageFormat.Png);

                    byteArray = stream.ToArray();
                }
            }
            return(byteArray);
        }