Beispiel #1
0
        private void AddToView(string[] files, System.Collections.ArrayList al)
        {
            FileInfo     fi           = null;
            string       ParentPath   = string.Empty;
            string       ExePath      = string.Empty;
            Icon         icon         = null;
            int          index        = imglMenu.Images.Count;
            ListViewItem item         = null;
            int          j            = 0;
            string       groupKeyName = string.Empty;

            foreach (String srcFileName in files)
            {
                fi = new FileInfo(srcFileName);
                if (fi.Extension.ToLower() == ".lnk")
                {
                    ParentPath = ShortCutHelper.GetParentPathOfShortcut(srcFileName);
                    if (PubData.GV_CreateShowcutWithDel == true)
                    {
                        System.IO.File.Delete(srcFileName);
                    }
                }
                else
                {
                    ParentPath = srcFileName;
                }
                //if (ExistExePath(ParentPath) == false)
                //{
                SaveExePathToDB(al, ParentPath);

                ExePath      = ParentPath;
                fi           = new FileInfo(ExePath);
                groupKeyName = fi.Extension;
                if (!htListGroups.Contains(groupKeyName))
                {
                    ListViewGroup group = new ListViewGroup();
                    group.Header = groupKeyName;
                    group.Name   = groupKeyName;
                    lvStartMenu.Groups.Add(group);
                    htListGroups.Add(groupKeyName, group);
                }

                icon = FileIcon.ExtractAssociatedIcon(ExePath);

                imglMenu.Images.Add(icon);
                imglMenu.Images.SetKeyName(index + j, fi.Name);


                item = new ListViewItem();

                item.Text       = fi.Name;
                item.Group      = (ListViewGroup)htListGroups[groupKeyName];
                item.Tag        = fi.FullName;
                item.ImageIndex = index + j;
                lvStartMenu.Items.Add(item);
                j++;
                //}
            }
        }
Beispiel #2
0
        private void LoadUtilSofewares()
        {
            lvUtilSofeware.Items.Clear();
            if (System.IO.Directory.Exists(PubData.GV_IceUtilSofewarePath))
            {
                FileInfo[]   files     = FileDirSearcher.GetAllFilePath(PubData.GV_IceUtilSofewarePath);
                Icon         icon      = null;
                ListViewItem item      = null;
                ImageList    imglUtils = new ImageList();

                int index = imglUtils.Images.Count;
                int i     = imglUtils.Images.Count;
                foreach (FileInfo fi in files)
                {
                    icon = FileIcon.ExtractAssociatedIcon(fi.FullName);
                    imglUtils.Images.Add(icon);
                    imglUtils.Images.SetKeyName(index, fi.Name);
                    item      = new ListViewItem();
                    item.Text = fi.Name;
                    item.Tag  = fi.FullName;
                    lvUtilSofeware.Items.Add(item);
                    index++;
                }

                imglUtils.ColorDepth          = ColorDepth.Depth32Bit;
                imglUtils.ImageSize           = new Size(32, 32);
                lvUtilSofeware.LargeImageList = imglUtils;
                foreach (FileInfo fi in files)
                {
                    lvUtilSofeware.Items[i].ImageIndex = i;
                    i++;
                }
                hasLoadUtils = true;
            }
            else
            {
                System.IO.Directory.CreateDirectory(PubData.GV_IceUtilSofewarePath);
            }
        }
Beispiel #3
0
        private void RefreshUserExeFile()
        {
            const string sql = "SELECT DISTINCT ExePath from t_Ice_ExePath";
            DataSet      ds  = SQLiteHelper.ExecuteDataset(sql, null);

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Image[]        imgls = new Image[ds.Tables[0].Rows.Count];
                    int            j     = 0;
                    Icon           icon;
                    string         ExePath   = string.Empty;
                    ListViewItem[] items     = new ListViewItem[ds.Tables[0].Rows.Count];
                    string[]       imglsKeys = new string[ds.Tables[0].Rows.Count];
                    ListViewItem   item      = null;
                    FileInfo       fi        = null;
                    int            index     = imglMenu.Images.Count;

                    string groupKeyName = string.Empty;
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        ExePath      = row["ExePath"].ToString();
                        fi           = new FileInfo(ExePath);
                        groupKeyName = fi.Extension;
                        if (!htListGroups.Contains(groupKeyName))
                        {
                            ListViewGroup group = new ListViewGroup();
                            group.Header = groupKeyName;
                            group.Name   = groupKeyName;
                            lvStartMenu.Groups.Add(group);
                            htListGroups.Add(groupKeyName, group);
                        }
                        if (fi.Exists == true)
                        {
                            icon = FileIcon.ExtractAssociatedIcon(ExePath);

                            imglMenu.Images.Add(icon);
                            imglMenu.Images.SetKeyName(index + j, fi.Name);
                            //imgls[j] = icon.ToBitmap();
                            //imgls[j].Tag = fi.Name + ".ico";
                            //imglsKeys[j] = fi.Name+".ico";

                            item = new ListViewItem();

                            item.Text     = fi.Name;
                            item.Group    = (ListViewGroup)htListGroups[groupKeyName];
                            item.Tag      = fi.FullName;
                            item.ImageKey = fi.Name;
                            items[j]      = item;
                            lvStartMenu.Items.Add(item);
                            j++;
                        }
                        else
                        {
                            if (PubData.GV_AutoDelWhenFileNotExists == true)
                            {
                                DelExePath(ExePath);
                            }
                            else
                            {
                                if (MessageBox.Show("不存在指定文件路径[" + ExePath + "],是否删除?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                                {
                                    DelExePath(ExePath);
                                }
                            }
                        }
                    }
                }
            }
        }