private void SaveCustomProfile(CustomProfile cp) { string fqp; string json; fqp = GetCustomProfilePath(); json = JsonConvert.SerializeObject(cp, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); File.WriteAllText(fqp, json); }
private void CreateDefaultCustomProfile(string fqp) { CustomItem item; CustomProfile cp; cp = new CustomProfile(); cp.items = new List <CustomItem>(); foreach (Profile profile in settings.profiles) { item = NewDefaultCustomItem(profile.guid); cp.items.Add(item); } SaveCustomProfile(cp); }
private CustomProfile LoadCustomProfile() { string fqp; CustomProfile cp = null; fqp = GetCustomProfilePath(); if (!File.Exists(fqp)) { CreateDefaultCustomProfile(fqp); } using (StreamReader file = File.OpenText(fqp)) { JsonSerializer serializer = new JsonSerializer(); cp = (CustomProfile)serializer.Deserialize(file, typeof(CustomProfile)); } return(cp); }
private void Setup(Startup startup) { string lastFile; minutesRunning = 0; pauseRotations = false; debug = GetTrueOrFalseAppSetting("Debug", false); controls = ReadControls(); syntax = ReadSyntax(); startup.Next(); LogIt("Application Started"); LogIt(string.Format("Debug set to {0}", debug)); treeView1.Nodes[0].Expand(); userControlHelp1.Dock = DockStyle.Fill; userControlSettings1.Dock = DockStyle.Fill; userControlDefault1.Dock = DockStyle.Fill; userControlProfile1.Dock = DockStyle.Fill; userControlScheme1.Dock = DockStyle.Fill; userControlKeyBinding1.Dock = DockStyle.Fill; lastFile = ConfigurationManager.AppSettings["LastFile"]; LogIt(string.Format(string.Format("Read parameter 'LastFile' = '{0}'", lastFile))); if (!string.IsNullOrEmpty(lastFile) && File.Exists(lastFile)) { fileName = lastFile; OpenFile(); } startup.Next(); schemesFolder = ConfigurationManager.AppSettings["SchemesFolder"]; windowsTerminalFolder = ConfigurationManager.AppSettings["WindowsTerminalFolder"]; windowsTerminalEXE = ConfigurationManager.AppSettings["WindowsTerminalEXE"]; removeUnusedSchemes = GetTrueOrFalseAppSetting("RemoveUnusedSchemes", true); userControlDefault1.Setup(this); startup.Next(); userControlSettings1.Setup(this, schemesFolder, windowsTerminalFolder, windowsTerminalEXE, removeUnusedSchemes); startup.Next(); userControlProfile1.Setup(this, controls, startup); startup.Next(); userControlScheme1.Setup(this, controls, syntax); startup.Next(); myCustomProfile = LoadCustomProfile(); startup.Next(); DoAllReconciliation(); startup.Next(); myTimer = new CustomizerTimer(this, userControlProfile1); writeToFileTimer = new Timer(); writeToFileTimer.Tick += new EventHandler(WriteToFile); writeToFileTimer.Interval = 1000; // in milliseconds writeToFileTimer.Start(); }