public static void AddAdditionQuickMethodTo(Dictionary <String, QuickModel> models) { // 从配置文件中读取出加载项,放入model中 var plugins = QuickConfig.ThisConfig.Plugins; if (!plugins.Contains(s_defaultPlugin)) { plugins.Insert(0, s_defaultPlugin); } List <string> addedList = new List <string>(); foreach (var pluginPath in plugins) { if (addedList.Contains(pluginPath)) { continue; } addedList.Add(pluginPath); string additionDir = QuickUtilities.DirectoryFromDomain(PLUGINS_PATH); string addFullPath = Path.Combine(additionDir, pluginPath); try { var methods = GetMethodsFromAssembly(addFullPath); if (methods == null) { continue; } foreach (var method in methods) { AddToCorrectModel(models, method); } } catch { } } }
private static void Save(QuickModel instance, String filename) { XmlSerializer xmlsSave = new XmlSerializer(typeof(QuickModel)); using (FileStream fs = new FileStream(Path.Combine(QuickUtilities.DirectoryFromDomain(@"config\"), filename), FileMode.Create, FileAccess.Write)) { xmlsSave.Serialize(fs, instance); } }
private static bool NeedLocalUpdate() { if (File.Exists(NotifyFilePath)) { using (var reader = File.OpenText(NotifyFilePath)) { return(!QuickUtilities.IsLatestVersion(Application.ProductVersion, reader.ReadToEnd().Trim())); } } return(false); }
public void RunFile(String cmd, String arg) { try { Process.Start(cmd, arg); } catch (Win32Exception) { Process.Start(Path.Combine(QuickUtilities.DirectoryFromDomain(""), cmd), arg); } }
public static QuickModel GetModel(String filename) { XmlSerializer ser = new XmlSerializer(typeof(QuickModel)); QuickModel ret = null; using (FileStream fs = new FileStream(Path.Combine(QuickUtilities.DirectoryFromDomain(@"config\"), filename), FileMode.Open, FileAccess.Read)) { ret = (QuickModel)ser.Deserialize(fs); return(ret); } }
public static void CreateTemplate() { var template = new QuickModel(); template.ProgramName = "kwps.application"; template.MethodList.Add(new QuickMethod()); template.BorderColorR = 77; template.BorderColorG = 130; template.BorderColorB = 228; using (var fs = File.Create(QuickUtilities.DirectoryFromDomain(@"config\template.xml"))) { new XmlSerializer(template.GetType()).Serialize(fs, template); } }
private static bool HasUpdate(out XDocument resp, out string latestVersion) { try { resp = XDocument.Load(@"http://10.20.133.13/Download/Version.xml"); String version = Application.ProductVersion; latestVersion = resp.Element("info").Element("version").Attribute("value").Value; return(!QuickUtilities.IsLatestVersion(version, latestVersion)); } catch { //先吞掉更新失败的问题 resp = null; latestVersion = null; return(false); } }