//根据xml内容填充信息 private void FillInfo(string filePath, string fileNeme) { cmbTileShowMode.SelectedIndex = 0; cmbCommand.SelectedIndex = 0; myExePath = filePath; txtPathView.Text = filePath; btnSaveStyle.Enabled = true; txtNameView.Text = fileNeme; picIconView.Image = Icon.ExtractAssociatedIcon(filePath).ToBitmap(); iconIndex = 0; iconPath = filePath; ShowPic(filePath); if (picEditedView.Image != null || isAlreadyHasPic) { cmbTileShowMode.Enabled = true; } TileXml tileXml = new TileXml(filePath); if (!File.Exists(tileXml.XmlPath)) { chkShowName.Checked = true; cmbFontColor.SelectedIndex = 0; picColorView.BackColor = ThemeColor.GetThemeColor(); btnClearStyle.Enabled = false; } else { chkShowName.Checked = (tileXml.ShowNameOnSquare150x150Logo == "off") ? false : true; cmbFontColor.SelectedIndex = (tileXml.ForegroundText == "dark") ? 1 : 0; picColorView.BackColor = ColorTranslator.FromHtml(tileXml.BackgroundColor); btnClearStyle.Enabled = true; } }
//输入url链接 private void InputUrl() { var action1 = new Action <FormInputBox>(FormLoadForInputUrl); var action2 = new Action <FormInputBox>(BtnOkClickForInputUrl); var frm = new FormInputBox(action1, action2); frm.ShowDialog(); if (urlPath == null) { cmbCommand.SelectedIndex = 0; } else { txtPathView.Text = urlPath; if (File.Exists(myUrlIniPath)) { File.Delete(myUrlIniPath); } File.WriteAllText(myUrlIniPath, urlPath, Encoding.Default); txtNameView.Text = "我的网址"; myExePath = myUrlExePath; btnSaveStyle.Enabled = true; if (picEditedView.Image != null) { cmbTileShowMode.Enabled = true; } picColorView.BackColor = ThemeColor.GetThemeColor(); iconIndex = 0; iconPath = DefaultWebBroeser.DefaultWebBrowserFilePath(); Icon icon = Icon.ExtractAssociatedIcon(iconPath); picIconView.Image = icon.ToBitmap(); ShowPic(myExePath); } }
private int iconIndex; //图标序号 public FormEditConfig() { InitializeComponent(); InitializeControl(); BindEvent(); picColorView.BackColor = ThemeColor.GetThemeColor(); if (!Directory.Exists(urlFolder)) { Directory.CreateDirectory(urlFolder); } if (File.Exists(openURlExePath)) { if (!File.Exists(myUrlExePath)) { File.Copy(openURlExePath, myUrlExePath); } } }
//输入url链接 private void InputUrl() { var action1 = new Action <FormInputBox>(FormLoadForInputUrl); var action2 = new Action <FormInputBox>(BtnOkClickForInputUrl); var frm = new FormInputBox(action1, action2); frm.ShowDialog(); if (urlPath == null) { cmbCommand.SelectedIndex = 0; } else { txtPathView.Text = urlPath; if (File.Exists(myUrlIniPath)) { File.Delete(myUrlIniPath); } File.WriteAllText(myUrlIniPath, urlPath, Encoding.Default); txtNameView.Text = "我的网址"; myExePath = myUrlExePath; btnSaveStyle.Enabled = true; if (picEditedView.Image != null) { cmbTileShowMode.Enabled = true; } picColorView.BackColor = ThemeColor.GetThemeColor(); iconIndex = 0; //创建一个Internet快捷方式文件,获取默认浏览器图标 iconPath = urlFolder + "\\" + MyName + ".url"; StreamWriter sw = File.CreateText(iconPath); sw.WriteLine("[InternetShortcut]"); sw.WriteLine("URL=" + gitHubUrl); sw.Close(); Icon icon = Icon.ExtractAssociatedIcon(iconPath); picIconView.Image = icon.ToBitmap(); ShowPic(myExePath); } }