コード例 #1
0
        public static List <TabPages> GetJsonList(JEnumerable <JToken> jToken, string key)
        {
            JObject jsonObj = JsonHelper.readJson();
            //foreach the JObject add the value
            List <TabPages> tabpageindexlist = new List <TabPages>()
            {
            };

            //List<string> tabpageindexlist = new List<string>();
            foreach (JToken child in jToken)
            {
                if (child.Count() != 0)
                {
                    string tabpageid    = JsonHelper.GetJsonValue(child.Children(), "tabpageid");
                    string tabpagename  = JsonHelper.GetJsonValue(child.Children(), "tabpagename");
                    int    tabpageindex = int.Parse(JsonHelper.GetJsonValue(child.Children(), "tabpageindex"));
                    tabpageindexlist.Add(new TabPages()
                    {
                        tabpageid = tabpageid, tabpagename = tabpagename, tabpageindex = tabpageindex
                    });
                    //tabpageindexlist.Add(JsonHelper.GetJsonValue(child.Children(), "tabpageindex"));
                }
            }
            return(tabpageindexlist);
        }
コード例 #2
0
 /// <summary>
 /// TabPages右键点击弹出菜单
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void listView1MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         //绑定前先清空菜单
         strip.Items.Clear();
         //绑定tabPage右键菜单
         strip.Items.Add("移动到");
         strip.Items.Add("删除此快捷方式");
         //绑定"移动到"的子级菜单,即从json获取所有tabPage名称
         JObject jobject = JsonHelper.readJson();
         foreach (JToken child in jobject["Settings"]["tabControl_Main"].Children())
         {
             if (child.Count() != 0)
             {
                 string tabpagename = JsonHelper.GetJsonValue(child.Children(), "tabpagename");
                 if (tabpagename != tabControl_Main.SelectedTab.Text)
                 {
                     ToolStripItem stripitem = new ToolStripMenuItem();
                     stripitem.Name   = tabpagename;
                     stripitem.Text   = tabpagename;
                     stripitem.Click += new EventHandler(itemClicked);
                     /*只能通过ContextMenuStrip的Item的索引为其添加子菜单,通过Item的Text属性会报错*/
                     ((ToolStripDropDownItem)(strip.Items[0])).DropDownItems.Add(stripitem);
                 }
             }
         }
         strip.Show(listView1, e.Location);//鼠标右键按下弹出菜单
     }
 }
コード例 #3
0
        private void LoadTabControl_Main()
        {
            tabControl_Main.TabPages.Clear();
            //foreach the JObject add the value
            JObject jobject = JsonHelper.readJson();

            foreach (JToken child in jobject["Settings"]["tabControl_Main"].Children())
            {
                if (child.Count() != 0)
                {
                    string tabpageid    = JsonHelper.GetJsonValue(child.Children(), "tabpageid");
                    string tabpagename  = JsonHelper.GetJsonValue(child.Children(), "tabpagename");
                    string tabpageindex = JsonHelper.GetJsonValue(child.Children(), "tabpageindex");
                    //if(tabpageid != "tabPage_default")
                    //{
                    //tabControl_Main.TabPages.Insert(int.Parse(tabpageindex), tabpagename);
                    TabPage Page = new TabPage();
                    Page.Name     = tabpageid;
                    Page.Text     = tabpagename;
                    Page.TabIndex = int.Parse(tabpageindex);
                    Page.Tag      = "386;620;0;0;9";
                    this.tabControl_Main.Controls.Add(Page);
                    //}
                }
            }
            MatchTabPage(tabControl_Main.SelectedTab.Text);
            listView1.MouseClick += new MouseEventHandler(listView1MouseClick);
            strip.ItemClicked    += new ToolStripItemClickedEventHandler(stripItemClicked);
        }
コード例 #4
0
        //private void LoadImageList(string filePath)
        //{
        //    ////for test
        //    //var path = Environment.CurrentDirectory + "\\Images\\";
        //    //var list = new List<string>();
        //    //list.Add("close.ico");
        //    //list.Add("logo2.ico");
        //    //list.Add("settings2.ico");

        //    //ImageList imageList1 = new ImageList();
        //    //imageList1.ImageSize = new Size(48, 48);
        //    //imageList1.ColorDepth = ColorDepth.Depth32Bit;
        //    //foreach (var fileName in list)
        //    //{
        //    //    imageList1.Images.Add(Image.FromFile(path + fileName));
        //    //}

        //    //filePath = GetFilePath(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Notepad++\Notepad++.lnk");

        //    filePath = GetFilePath(filePath);
        //    if (filePath != "")
        //    {
        //        ImageList imageList1 = new ImageList();
        //        imageList1.ImageSize = new Size(48, 48);
        //        imageList1.ColorDepth = ColorDepth.Depth32Bit;
        //        imageList1.Images.Add(Icon.ExtractAssociatedIcon(filePath));
        //        listView1.LargeImageList = imageList1;

        //        for (int i = 0; i < imageList1.Images.Count; i++)
        //        {
        //            var lvi = new ListViewItem();
        //            lvi.ImageIndex = i;
        //            lvi.Text = Path.GetFileNameWithoutExtension(filePath);//"P" + i;
        //            lvi.ToolTipText = Path.GetFileNameWithoutExtension(filePath);//"P" + i;
        //            listView1.Items.Add(lvi);
        //        }
        //    }
        //    else
        //    {
        //        MessageBox.Show("该目录不存在!");
        //    }
        //}
        private void LoadImageList()
        {
            imageList1.Images.Clear();
            listView1.Clear();
            MatchTabPage(tabControl_Main.SelectedTab.Text);
            //foreach the JObject add the value
            JObject       jobject      = JsonHelper.readJson();
            int           count        = 0;
            List <string> apptitlelist = new List <string>();
            List <string> apppathlist  = new List <string>();

            foreach (JToken child in jobject["AppListModel"].Children())
            {
                if (child.Count() != 0)
                {
                    if (tabControl_Main.SelectedTab.Text.Equals(JsonHelper.GetJsonValue(child.Children(), "apptag")))
                    {
                        count++;
                        string apptitle = JsonHelper.GetJsonValue(child.Children(), "apptitle");
                        apptitlelist.Add(JsonHelper.GetJsonValue(child.Children(), "apptitle"));
                        string apppath = JsonHelper.GetJsonValue(child.Children(), "appiconpath").Replace("/", "\\");
                        apppathlist.Add(apppath);
                        string appiconpath = apppath;
                        if (JsonHelper.GetJsonValue(child.Children(), "apptype").Equals(".lnk"))
                        {
                            appiconpath = GetFilePath(apppath);
                        }
                        if (appiconpath != "")
                        {
                            //ImageList imageList1 = new ImageList();
                            imageList1.ImageSize  = new Size(48, 48);
                            imageList1.ColorDepth = ColorDepth.Depth32Bit;
                            //imageList1.Images.Add(Icon.ExtractAssociatedIcon(appiconpath));
                            imageList1.Images.Add(GetIcon(appiconpath));
                        }
                        else
                        {
                            MessageBox.Show("该目录不存在!");
                        }
                    }
                }
            }
            listView1.LargeImageList = imageList1;

            for (int i = 0; i < imageList1.Images.Count; i++)
            {
                var lvi = new ListViewItem();
                lvi.ImageIndex  = i;
                lvi.Text        = apptitlelist[i]; //Path.GetFileNameWithoutExtension(filePath);//"P" + i;
                lvi.ToolTipText = apppathlist[i];  //Path.GetFileNameWithoutExtension(filePath);//"P" + i;
                listView1.Items.Add(lvi);
            }
        }
コード例 #5
0
ファイル: Form_Settings.cs プロジェクト: barryying/FlashStart
        private void LoadIsAutoBackup()
        {
            JObject jobject = JsonHelper.readJson();

            isautobackup = JsonHelper.GetJsonValue(jobject["Settings"].Children(), "isautobackup");
            if (isautobackup == "false")
            {
                checkBox_isautobackup.Checked = false;
            }
            else
            {
                checkBox_isautobackup.Checked = true;
            }
        }
コード例 #6
0
ファイル: Form_Settings.cs プロジェクト: barryying/FlashStart
        private void LoadTabPages()
        {
            listView1.Clear();
            DisableEdit();

            //ColumnHeader ch = new ColumnHeader();
            //ch.Text = "选项卡ID";   //设置列标题
            //ch.Width = 120;    //设置列宽度
            //ch.TextAlign = HorizontalAlignment.Left;   //设置列的对齐方式
            //this.listView1.Columns.Add(ch);    //将列头添加到ListView控件。
            this.listView1.Columns.Add("选项卡ID", 140, HorizontalAlignment.Left); //一步添加
            this.listView1.Columns.Add("选项卡名称", 100, HorizontalAlignment.Left); //一步添加
            this.listView1.Columns.Add("选项卡排序", 100, HorizontalAlignment.Left); //一步添加
            this.listView1.View = View.Details;

            this.listView1.BeginUpdate();   //数据更新,UI暂时挂起,直到EndUpdate绘制控件,可以有效避免闪烁并大大提高加载速度
            //从json文件读取数据
            JObject       jsonObj      = JsonHelper.readJson();
            int           count        = 0;
            List <string> apptitlelist = new List <string>();
            List <string> apppathlist  = new List <string>();

            foreach (JToken child in jsonObj["Settings"]["tabControl_Main"].Children())
            {
                if (child.Count() != 0)
                {
                    count++;
                    string       tabpageid    = JsonHelper.GetJsonValue(child.Children(), "tabpageid");
                    string       tabpagename  = JsonHelper.GetJsonValue(child.Children(), "tabpagename");
                    string       tabpageindex = JsonHelper.GetJsonValue(child.Children(), "tabpageindex");
                    ListViewItem lvi          = new ListViewItem();
                    lvi.ImageIndex = count;     //通过与imageList绑定,显示imageList中第i项图标
                    lvi.Text       = tabpageid;
                    lvi.SubItems.Add(tabpagename);
                    lvi.SubItems.Add(tabpageindex);
                    this.listView1.Items.Add(lvi);
                }
            }
            ////测试数据foreach the JObject add the value
            //for (int i = 0; i < 10; i++)   //添加10行数据
            //{
            //    ListViewItem lvi = new ListViewItem();
            //    lvi.ImageIndex = i;     //通过与imageList绑定,显示imageList中第i项图标
            //    lvi.Text = "subitem" + i;
            //    lvi.SubItems.Add("第2列,第" + i + "行");
            //    lvi.SubItems.Add("第3列,第" + i + "行");
            //    this.listView1.Items.Add(lvi);
            //}
            this.listView1.EndUpdate();  //结束数据处理,UI界面一次性绘制。
        }
コード例 #7
0
ファイル: Form_Settings.cs プロジェクト: barryying/FlashStart
        private void LoadShortcutKey()
        {
            JObject jobject     = JsonHelper.readJson();
            string  shortcutkey = JsonHelper.GetJsonValue(jobject["Settings"].Children(), "shortcutkey");

            txt_shortcutkey.Text = shortcutkey;
            lbl_shortcutkey.Text = shortcutkey;

            isdoubleclick          = JsonHelper.GetJsonValue(jobject["Settings"].Children(), "isdoubleclick");
            lbl_isdoubleclick.Text = isdoubleclick;
            if (isdoubleclick == "false")
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }
        }
コード例 #8
0
 private void AutoBackup(object sender, System.Timers.ElapsedEventArgs elap)
 {
     try
     {
         JObject jobject      = JsonHelper.readJson();
         string  isautobackup = JsonHelper.GetJsonValue(jobject["Settings"].Children(), "isautobackup");
         if (isautobackup == "true")
         {
             string jsonPath      = Environment.CurrentDirectory + "\\resourse.json";
             string directionPath = Environment.CurrentDirectory + "\\Backup\\resourse.json";
             FileHelper.CopyFile(jsonPath, directionPath, true);
             Console.WriteLine("备份成功!");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("e.Message: " + e.Message + ";e.StackTrace: " + e.StackTrace);
     }
 }
コード例 #9
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            JObject jobject = JsonHelper.readJson();

            if (JsonHelper.GetJsonValue(jobject["Settings"].Children(), "isdoubleclick") == "true")
            {
                if (this.listView1.SelectedItems.Count == 0)
                {
                    return;
                }

                //前提,listview禁止多选
                ListViewItem currentRow = listView1.SelectedItems[0];
                if (currentRow.ToolTipText.LastIndexOf(".lnk") > 0)
                {
                    System.Diagnostics.Process.Start(GetFilePath(currentRow.ToolTipText));
                }
                else
                {
                    System.Diagnostics.Process.Start(currentRow.ToolTipText);
                }
            }
        }
コード例 #10
0
        private void SetShortcutKey()
        {
            JObject jobject = JsonHelper.readJson();

            shortcutkey = JsonHelper.GetJsonValue(jobject["Settings"].Children(), "shortcutkey");
        }