コード例 #1
0
ファイル: MainWindow.cs プロジェクト: Snsaiu/-
        /// <summary>
        /// 删除app6快捷应用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetQuickApp deleteapp = SetQuickApp.GetInstace();

            deleteapp.DeleteAPP(btnApp6);
            labInfo.Text = "App6 delete OK";
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: Snsaiu/-
        /// <summary>
        /// 新建一个快捷应用app6
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newToolStripMenuItem5_Click(object sender, EventArgs e)
        {
            timerWindowHidder.Enabled = false;
            SetQuickApp newapp = SetQuickApp.GetInstace();

            //SetQuickApp newapp = new SetQuickApp();
            newapp.NewApp(btnApp6);
            timerWindowHidder.Enabled = true;
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: Snsaiu/-
        static string fullpath = Application.StartupPath + "\\" + "apppath";//全局路径
        /// <summary>
        /// 创建一个新的快捷应用app1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            timerWindowHidder.Enabled = false;
            SetQuickApp newapp = SetQuickApp.GetInstace();

            //SetQuickApp newapp = new SetQuickApp();
            newapp.NewApp(btnApp1);
            this.btnApp1.Image        = (GetExeIcon.GetIcon(newapp.AppPath, true)).ToBitmap();
            timerWindowHidder.Enabled = true;
        }
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: Snsaiu/-
        /// <summary>
        /// 打开app6应用程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnApp6_Click(object sender, EventArgs e)
        {
            SetQuickApp openApp = SetQuickApp.GetInstace();

            if (openApp.OpenApp(btnApp6))
            {
                labInfo.Text = "应用正在打开";
            }
            else
            {
                labInfo.Text = "应用无法打开";
            }
        }
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: Snsaiu/-
        private void MainWindow_Load(object sender, EventArgs e)
        {
            //创建xml文档
            XmlDocument xmldoc = new XmlDocument();


            if (!File.Exists("data.xml"))
            {
                XmlDeclaration dec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
                xmldoc.AppendChild(dec);
                XmlElement root1 = xmldoc.CreateElement("dataCol");
                xmldoc.AppendChild(root1);
                xmldoc.Save("data.xml");
                labInfo.Text = "xml created successful!";
            }



            xmldoc.Load("data.xml");
            //应用帮助提示
            if (xmldoc.SelectSingleNode("dataCol/MainWindow").Attributes["help"].Value == "true")
            {
                this.cbHelp.Checked      = true;
                this.ttMainWindow.Active = true;
            }
            else
            {
                this.cbHelp.Checked      = false;
                this.ttMainWindow.Active = false;
            }

            GetTomWeather = xmldoc.SelectSingleNode("dataCol/TomCityWeather").Attributes["weather"].Value;
            //
            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T1"].Value == "true")
            {
                this.cbT1.Checked = true;
            }
            else
            {
                this.cbT1.Checked = false;
            }

            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T2"].Value == "true")
            {
                this.cbT2.Checked = true;
            }
            else
            {
                this.cbT2.Checked = false;
            }

            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T3"].Value == "true")
            {
                this.cbT3.Checked = true;
            }
            else
            {
                this.cbT3.Checked = false;
            }

            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T4"].Value == "true")
            {
                this.cbT4.Checked = true;
            }
            else
            {
                this.cbT4.Checked = false;
            }

            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T5"].Value == "true")
            {
                this.cbT5.Checked = true;
            }
            else
            {
                this.cbT5.Checked = false;
            }

            if (xmldoc.SelectSingleNode("dataCol/IsAppRemind").Attributes["T6"].Value == "true")
            {
                this.cbT6.Checked = true;
            }
            else
            {
                this.cbT6.Checked = false;
            }


            XmlElement  root = xmldoc.DocumentElement;
            XmlNodeList list = root.ChildNodes;

            foreach (XmlNode node in list)
            {
                if (node.Name == "CityWeather")
                {
                    XmlNode repleaseWeather = xmldoc.SelectSingleNode("dataCol/CityWeather");
                    //获得cityweather节点下的所有属性
                    //判断是否需要更新天气
                    //1个小时更新一次,判断方法当前时间减去上次更新时间,如果时间差大于1个小时进行更新
                    int latestTime  = int.Parse(repleaseWeather.Attributes["latestTime"].Value);//获得后更新时间
                    int currentHour = DateTime.UtcNow.Hour;
                    //如果当前时间-最后更新时间大于等于1,那么进行天气更新
                    if (Math.Abs(currentHour - latestTime) >= 1)
                    {
                        GetWeather getweather = new GetWeather();
                        getweather.getWeather(repleaseWeather.Attributes["cityname"].Value);
                        repleaseWeather.Attributes["weather"].Value    = getweather.Getclound;
                        repleaseWeather.Attributes["temp"].Value       = getweather.Gettemperature;
                        repleaseWeather.Attributes["latestTime"].Value = DateTime.Now.Hour.ToString();

                        xmldoc.Save("data.xml");

                        lbWeather.Text = repleaseWeather.Attributes["cityname"].Value + repleaseWeather.Attributes["weather"].Value + repleaseWeather.Attributes["temp"].Value;
                    }
                    else
                    {
                        lbWeather.Text = repleaseWeather.Attributes["cityname"].Value + repleaseWeather.Attributes["weather"].Value + repleaseWeather.Attributes["temp"].Value;
                    }
                    break;
                }
                else
                {
                    XmlElement CityInfo = xmldoc.CreateElement("CityWeather");
                    CityInfo.SetAttribute("cityname", "南京");
                    CityInfo.SetAttribute("weather", "good");
                    CityInfo.SetAttribute("temp", "20");
                    CityInfo.SetAttribute("latestTime", "1");
                    root.AppendChild(CityInfo);
                    xmldoc.Save("data.xml");
                    break;
                    // labInfo.Text = "create CityInfo!";
                    //  xmldoc.Load("data.xml");
                    //  lbWeather.Text = xmldoc.SelectSingleNode("dataCol/CityWeather").Attributes["weather"].Value.ToString();
                }
            }

            //判断下滑
            isdroped = false;
            string sourcePath = Application.StartupPath;
            string shortcut   = Path.GetFileName(Application.ExecutablePath) + " - Shortcut.lnk";
            string targetPath = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" + "\\" + shortcut;

            if (File.Exists(targetPath))
            {
                cbAutoSetup.Checked = true;
            }
            else
            {
                cbAutoSetup.Checked = false;
            }



            //读取时间提醒
            RemindList remindlist = new RemindList();

            for (int i = 0; i < remindlist.Filename.Length; i++)
            {
                string[]     NameAndContent = FileNameToText.NameToText(remindlist.Filename[i]);
                ListViewItem lv             = new ListViewItem(new string[] { NameAndContent[0], NameAndContent[1] });
                lvRemind.Items.Add(lv);
            }



            //string SaveWeatherCity = Application.StartupPath + "\\" + "cityOfWeather";
            //if (!Directory.Exists(SaveWeatherCity))
            //{
            //    Directory.CreateDirectory(SaveWeatherCity);
            //}
            //string saceWeatherCityFile = SaveWeatherCity + "\\" + "City.txt";
            //if (!File.Exists(saceWeatherCityFile))
            //{
            //    lbWeather.Text = "双击添加天气";
            //}
            //else
            //{
            //    string cityName;
            //    using (StreamReader sr = new StreamReader(saceWeatherCityFile))
            //    {
            //        cityName = sr.ReadToEnd();
            //    }
            //    programmingQuickSetup.GetWeather getweather = new programmingQuickSetup.GetWeather();
            //    getweather.getWeather(cityName);
            //    lbWeather.Text = cityName + ":" + getweather.Getclound + ";温度:" + getweather.Gettemperature;
            //}



            #region windowLocation
            RemindInfo.IsHidder = true;
            //Screen x = Screen.PrimaryScreen;
            //Rectangle r = x.Bounds;

            //Point p = new Point(r.Width-300, r.Y);
            this.Location = new Point(Control.MousePosition.X - 100, Control.MousePosition.Y - 20);



            #endregion



            //废弃初始化应用方法
            #region

            /*
             *
             #region app1 init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp1.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp1.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp1.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp1.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *
             *          }
             #endregion
             #region  app2 init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp2.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp2.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp2.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp2.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *              else
             *              {
             *                  this.btnApp2.Text = "右击添加快捷应用";
             *              }
             *          }
             #endregion
             #region app3init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp3.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp3.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp3.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp3.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *
             *          }
             #endregion
             #region app4init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp4.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp4.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp4.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp4.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *
             *          }
             *
             #endregion
             #region app5init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp5.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp5.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp5.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp5.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *
             *          }
             #endregion
             *
             #region app6init
             *          {
             *              if (File.Exists(fullpath + "\\" + "btnApp6.txt") == false)
             *              {
             *
             *                  return;
             *              }
             *              string appfilename;
             *              using (StreamReader sr = new StreamReader(fullpath + "\\" + "btnApp6.txt"))
             *              {
             *
             *                  appfilename = sr.ReadToEnd();
             *
             *              }
             *
             *              if (appfilename != "")
             *              {
             *                 // btnApp6.Text = Path.GetFileNameWithoutExtension(appfilename);
             *                  btnApp6.Image = (GetExeIcon.GetIcon(appfilename, true)).ToBitmap();
             *              }
             *
             *          }
             #endregion
             *
             */

            #endregion
            Button[]    btnlists = new Button[] { btnApp1, btnApp2, btnApp3, btnApp4, btnApp5, btnApp6 };
            SetQuickApp initApp  = SetQuickApp.GetInstace();
            initApp.SetIcomn(btnlists);


            //天气显示



            if (GetTomWeather.Contains("雨") || GetTomWeather.Contains("雪"))
            {
                Timer timerWeatherWarn = new Timer();
                timerWeatherWarn.Interval = 1500;
                timerWeatherWarn.Enabled  = true;
                timerWeatherWarn.Tick    += TimerWeatherWarn_Tick;
            }
        }
コード例 #6
0
 public static SetQuickApp GetInstace()
 {
     getinstance = new SetQuickApp();
     return(getinstance);
 }