コード例 #1
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 执行删除组
        /// </summary>
        private void btnDoDeleteGroupName_Click(object sender, EventArgs e)
        {
            string oldGroupName = this.lbGroupNames.SelectedItem.ToString();

            if (string.IsNullOrEmpty(oldGroupName))
            {
                MessageUtil.ShowWarning("删除失败,请选择要删除的分组名称");
                return;
            }

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            if (null == groups.FirstOrDefault(o => o.Name == oldGroupName))
            {
                MessageUtil.ShowWarning("删除失败,旧的分组名称不存在");
                return;
            }

            if (!MessageUtil.ConfirmYesNo("是否删除该选择的分组?"))
            {
                return;
            }

            BoxFileData.deleteBoxGroup(oldGroupName);

            MessageUtil.ShowTips("删除成功");

            //刷新列表
            this.refreshShortcutGroup();

            this.showOperateGroupPanel();
        }
コード例 #2
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 执行添加组
        /// </summary>
        private void btnDoAddGroup_Click(object sender, EventArgs e)
        {
            string groupName = this.txtGroupName.Text.Trim();

            if (string.IsNullOrEmpty(groupName))
            {
                MessageUtil.ShowWarning("添加失败,新分组名称为空");
                return;
            }

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            if (null != groups.FirstOrDefault(o => o.Name == groupName))
            {
                MessageUtil.ShowWarning("添加失败,分组名称已存在");
                return;
            }

            BoxFileData.addBoxGroup(groupName);

            MessageUtil.ShowTips("添加成功");

            this.refreshShortcutGroup();

            this.showOperateGroupPanel();
        }
コード例 #3
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 执行修改组名称
        /// </summary>
        private void btnDoModifyGroup_Click(object sender, EventArgs e)
        {
            string oldGroupName = this.lbGroupNames.SelectedItem.ToString();
            string newGroupName = this.txtGroupName.Text.Trim();

            if (string.IsNullOrEmpty(newGroupName))
            {
                MessageUtil.ShowWarning("保存失败,新的分组名称为空");
                return;
            }

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            if (null == groups.FirstOrDefault(o => o.Name == oldGroupName))
            {
                MessageUtil.ShowWarning("保存失败,旧的分组名称不存在");
                return;
            }

            if (newGroupName == oldGroupName)
            {
                MessageUtil.ShowWarning("保存失败,新的分组名称跟旧的分组名称一致");
                return;
            }

            BoxFileData.updateBoxGroup(oldGroupName, newGroupName);

            MessageUtil.ShowTips("保存成功");

            //刷新列表
            this.refreshShortcutGroup();

            this.showOperateGroupPanel();
        }
コード例 #4
0
ファイル: FrmTray.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 将快捷的文件添加到托盘右键菜单中
        /// </summary>
        private void FlushTrayChildMenuInLove()
        {
            this.smallIconImageList = new ImageList()
            {
                ImageSize = new Size(16, 16), ColorDepth = ColorDepth.Depth32Bit
            };

            IList <BoxFile> boxFiles = new List <BoxFile>();

            boxFiles = BoxFileData.getLikeShortcuts();

            if (boxFiles != null && boxFiles.Count > 0)
            {
                ToolStripMenuItem toolStripMenuItem;
                BoxFile           boxFileItem;
                for (int i = 0; i < boxFiles.Count; i++)
                {
                    boxFileItem = boxFiles[i];

                    this.smallIconImageList.Images.Add(boxFileItem.SmallIcon);

                    toolStripMenuItem             = new ToolStripMenuItem();
                    toolStripMenuItem.Text        = boxFileItem.Name;
                    toolStripMenuItem.ToolTipText = boxFileItem.Name;
                    toolStripMenuItem.Tag         = boxFileItem;
                    toolStripMenuItem.Image       = this.smallIconImageList.Images[i];
                    toolStripMenuItem.Click      += new EventHandler(toolStripSubMenu_Click);

                    this.notifyContextMenuStrip.Items.Add(toolStripMenuItem);
                }
                boxFileItem       = null;
                boxFiles          = null;
                toolStripMenuItem = null;
            }
        }
コード例 #5
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 创建组与文件
        /// </summary>
        private void initShortcutStyle()
        {
            ListView          listView;
            TabPage           tabPage;
            ToolStripMenuItem toolStripSubMenu;

            this.tabFileGroup.TabPages.Clear();

            this.lbGroupNames.Items.Clear();

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            foreach (BoxGroup group in groups)
            {
                //将图标填充到ListView
                listView                      = new ListView();
                listView.BorderStyle          = BorderStyle.Fixed3D;
                listView.MultiSelect          = true;
                listView.View                 = View.List;
                listView.LabelEdit            = false;
                listView.Scrollable           = true;
                listView.Dock                 = DockStyle.Fill;
                listView.AllowDrop            = true;
                listView.BackgroundImage      = global::QuickBox.Properties.Resources.bg2;
                listView.BackgroundImageTiled = true;

                //ListView事件
                listView.MouseClick       += new MouseEventHandler(listViewFiles_MouseClick);
                listView.MouseDoubleClick += new MouseEventHandler(listViewFiles_MouseDoubleClick);
                listView.DragDrop         += new DragEventHandler(listViewFiles_DragDrop);
                listView.DragEnter        += new DragEventHandler(listViewFiles_DragEnter);

                //创建新的TabPage
                tabPage      = new TabPage();
                tabPage.Text = group.Name;
                tabPage.Tag  = tabPage;
                tabPage.Controls.Add(listView);

                //添加到选项卡
                this.tabFileGroup.TabPages.Add(tabPage);

                //动态创建菜单
                toolStripSubMenu      = new ToolStripMenuItem();
                toolStripSubMenu.Text = group.Name;

                //刷新该分组下的图标
                this.refreshShortcut(group.Name, listView);
            }

            //初始化分组列表
            this.refreshShortcutGroup();
        }
コード例 #6
0
ファイル: FrmTray.cs プロジェクト: andylaufzf/QuickBox
        private void InitTrayMenu()
        {
            this.notifyContextMenuStrip.Items.Clear();

            //将快捷的文件添加到托盘右键菜单中
            this.FlushTrayChildMenuInLove();

            //添加分隔符
            toolStripSeparator = new ToolStripSeparator();
            this.notifyContextMenuStrip.Items.Add(toolStripSeparator);

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            if (groups != null && groups.Count > 0)
            {
                foreach (BoxGroup group in groups)
                {
                    //创建菜单
                    toolStripSubMenu       = new ToolStripMenuItem();
                    toolStripSubMenu.Text  = group.Name;
                    toolStripSubMenu.Image = QuickBox.Properties.Resources.Group;

                    //添加到托盘菜单
                    this.notifyContextMenuStrip.Items.Add(toolStripSubMenu);

                    //刷新该分组下的图标
                    this.FlushTrayChildMenuInGroup(toolStripSubMenu, group.Name);
                }
                groups = null;
            }

            //添加分隔符
            toolStripSeparator = new ToolStripSeparator();
            this.notifyContextMenuStrip.Items.Add(toolStripSeparator);

            //添加“退出”
            toolStripSubMenu        = new ToolStripMenuItem();
            toolStripSubMenu.Text   = "退出(&E)";
            toolStripSubMenu.Name   = MenuName_Exit;
            toolStripSubMenu.Image  = QuickBox.Properties.Resources.Exit;
            toolStripSubMenu.Click += new EventHandler(toolStripSubMenu_Click);
            this.notifyContextMenuStrip.Items.Add(toolStripSubMenu);

            toolStripSubMenu = null;
        }
コード例 #7
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 刷新组
        /// </summary>
        private void refreshShortcutGroup()
        {
            this.lbGroupNames.Items.Clear();

            IList <BoxGroup> groups = BoxFileData.getBoxGroups();

            foreach (BoxGroup group in groups)
            {
                //添加到分组列表
                this.lbGroupNames.Items.Add(group.Name);
            }

            if (groups.Count > 0)
            {
                //分组列表默认选择第一项
                this.lbGroupNames.SelectedIndex = 0;
            }
        }
コード例 #8
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 刷新快捷位置的图标
        /// </summary>
        private void refreshLikeShortcut()
        {
            this.largeIconImageList = new ImageList()
            {
                ImageSize = new Size(32, 32), ColorDepth = ColorDepth.Depth32Bit
            };
            this.smallIconImageList = new ImageList()
            {
                ImageSize = new Size(16, 16), ColorDepth = ColorDepth.Depth32Bit
            };

            listViewLove.LargeImageList = largeIconImageList;
            listViewLove.SmallImageList = smallIconImageList;

            IList <BoxFile> boxFiles = BoxFileData.getLikeShortcuts();

            ListViewItem listViewItem;
            BoxFile      boxFileItem;

            listViewLove.Items.Clear();

            if (boxFiles != null && boxFiles.Count > 0)
            {
                for (int i = 0; i < boxFiles.Count; i++)
                {
                    boxFileItem = boxFiles[i];

                    this.largeIconImageList.Images.Add(boxFileItem.LargeIcon);
                    this.smallIconImageList.Images.Add(boxFileItem.SmallIcon);

                    listViewItem            = new ListViewItem();
                    listViewItem.Text       = boxFileItem.Name;
                    listViewItem.Tag        = boxFileItem;
                    listViewItem.ImageIndex = i;

                    listViewItem.SubItems.AddRange(new string[] { boxFileItem.Path });

                    listViewLove.Items.Add(listViewItem);
                }
            }
        }
コード例 #9
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 快捷ListView的右键菜单事件
        /// </summary>
        private void loveToolStripItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            BoxFile selectBoxFileItem;

            if (menuItem.Name == MenuName_RemoveFileItemInLove)      //移除选定项
            {
                if (listViewLove.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < listViewLove.SelectedItems.Count; i++)
                    {
                        selectBoxFileItem = listViewLove.SelectedItems[i].Tag as BoxFile;
                        BoxFileData.deleteLikeShortcut(selectBoxFileItem);
                    }

                    //刷新该分组下的图标
                    this.refreshLikeShortcut();

                    //刷新托盘菜单
                    FrmTray.DoInitMenu();
                }
            }
        }
コード例 #10
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// ListView的右键菜单事件
        /// </summary>
        private void toolStripItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (menuItem.Name == MenuName_MoveToNewGroup)
            {
                return;
            }

            TabPage  selectTabPage  = this.tabFileGroup.SelectedTab;
            ListView selectListView = selectTabPage.Controls[0] as ListView;
            BoxFile  selectBoxFileItem;

            string groupName = selectTabPage.Text;

            if (menuItem.Name == MenuName_LoveFileItem)             //标记此项
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < selectListView.SelectedItems.Count; i++)
                    {
                        selectBoxFileItem = selectListView.SelectedItems[i].Tag as BoxFile;

                        BoxFileData.addLikeShortcut(selectBoxFileItem);
                    }

                    // 刷新快捷位置的图标
                    this.refreshLikeShortcut();

                    //刷新托盘菜单
                    FrmTray.DoInitMenu();
                }
            }
            else if (menuItem.Name == MenuName_RemoveFileItem)      //移除选定项
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < selectListView.SelectedItems.Count; i++)
                    {
                        selectBoxFileItem = selectListView.SelectedItems[i].Tag as BoxFile;

                        //删除文件
                        BoxFileData.deleteShortcut(selectBoxFileItem, groupName);
                    }

                    //刷新该分组下的图标
                    this.refreshShortcut(groupName, selectListView);

                    //更新托盘窗体对应分组下面的图标
                    FrmTray.DoUpdateMenuByGroupName(groupName);
                }
            }
            else if (menuItem.Name == MenuName_ModifyFileItemName)  //重命名
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    selectBoxFileItem = selectListView.SelectedItems[0].Tag as BoxFile;

                    string value = selectBoxFileItem.Name;
                    if (MessageUtil.ShowPrompt("重命名", "请输入文件名称:", ref value) == DialogResult.OK)
                    {
                        //修改文件名称
                        BoxFileData.updateShortcut(selectBoxFileItem.Key, value, groupName);

                        //刷新该分组下的图标
                        this.refreshShortcut(groupName, selectListView);

                        //更新托盘窗体对应分组下面的图标
                        FrmTray.DoUpdateMenuByGroupName(groupName);
                    }
                }
            }
            else if (menuItem.Name == MenuName_ModifyFileItemIcon)  //修改文件图标
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < selectListView.SelectedItems.Count; i++)
                    {
                        selectBoxFileItem = selectListView.SelectedItems[i].Tag as BoxFile;
                        Bitmap fileLargeIcon = Utils.GetFileIcon(selectBoxFileItem.Path, false).ToBitmap();
                        Bitmap fileSmallIcon = Utils.GetFileIcon(selectBoxFileItem.Path, true).ToBitmap();

                        BoxFileData.updateShortcut(selectBoxFileItem.Key, fileLargeIcon, fileSmallIcon, selectTabPage.Text);
                    }

                    //刷新该分组下的图标
                    this.refreshShortcut(groupName, selectListView);

                    //更新托盘窗体对应分组下面的图标
                    FrmTray.DoUpdateMenuByGroupName(groupName);
                }
            }
            else if (menuItem.Name == MenuName_OpenWorkingDirectory)  //打开文件位置
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    selectBoxFileItem = selectListView.SelectedItems[0].Tag as BoxFile;

                    //打开文件位置
                    Utils.OpenFolder(selectBoxFileItem.Path);
                }
            }
            else if (menuItem.Name == MenuName_SetGroup)            //设置分组
            {
                //设置分组

                //前置配置分组
                this.tabFileGroup.SendToBack();
                //后置列表
                this.gbConfigGroupName.BringToFront();
            }
            else if (menuItem.Name.StartsWith("MoveToGroup_"))       //移动分组
            {
                if (selectListView.SelectedItems.Count > 0)
                {
                    string newGroupName = menuItem.Name.Split('_')[1];

                    for (int i = 0; i < selectListView.SelectedItems.Count; i++)
                    {
                        selectBoxFileItem = selectListView.SelectedItems[i].Tag as BoxFile;

                        BoxFileData.moveShortcut(selectBoxFileItem, groupName, newGroupName);
                    }

                    //刷新该分组下的图标
                    this.refreshShortcut(groupName, selectListView);

                    //更新托盘窗体对应分组下面的图标
                    FrmTray.DoUpdateMenuByGroupName(groupName);

                    //刷新新分组下的图标
                    this.refreshShortcut(newGroupName);

                    //更新托盘窗体对应新分组下面的图标
                    FrmTray.DoUpdateMenuByGroupName(newGroupName);
                }
            }
        }
コード例 #11
0
ファイル: FrmFiles.cs プロジェクト: andylaufzf/QuickBox
        /// <summary>
        /// 拖拽文件到当前选中的TabPage中
        /// </summary>
        private void listViewFiles_DragDrop(object sender, DragEventArgs e)
        {
            TabPage  selectTabPage  = this.tabFileGroup.SelectedTab;
            ListView selectListView = selectTabPage.Controls[0] as ListView;
            string   groupName      = selectTabPage.Text;

            //获取拖拽进来的文件数组
            string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];

            if (files.Length > 0)
            {
                string fileName;
                string fileExtension;
                string filePath;

                Bitmap fileLargeIcon;
                Bitmap fileSmallIcon;

                BoxFile boxFileItem;

                foreach (string file in files)
                {
                    if (File.Exists(file))
                    {
                        //文件名称
                        fileName = Path.GetFileNameWithoutExtension(file);
                        //文件格式
                        fileExtension = Path.GetExtension(file).ToLower();
                        //文件路径
                        if (fileExtension == ".lnk")
                        {
                            //如果是快捷方式,就取出真实路径
                            filePath = Utils.GetFileTargetPath(file);//根据快捷方式获取真实路径
                        }
                        else
                        {
                            filePath = Path.GetFullPath(file);
                        }
                        //文件大图标
                        fileLargeIcon = Utils.GetFileLargeIcon(filePath).ToBitmap();
                        //文件小图标
                        fileSmallIcon = Utils.GetFileSmallIcon(filePath).ToBitmap();

                        //添加新文件
                        boxFileItem = new BoxFile()
                        {
                            Name      = fileName,
                            LargeIcon = fileLargeIcon,
                            SmallIcon = fileSmallIcon,
                            Path      = filePath
                        };

                        //添加新文件到组中
                        BoxFileData.addShortcut(boxFileItem, groupName);
                    }
                }

                //刷新该分组下的图标
                this.refreshShortcut(groupName, selectListView);

                //更新托盘窗体对应分组下面的图标
                FrmTray.DoUpdateMenuByGroupName(groupName);
            }
        }