public MainForm() { InitializeComponent(); //Word wrap on debug listbox debugLogBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; debugLogBox.MeasureItem += lst_MeasureItem; debugLogBox.DrawItem += lst_DrawItem; var bs = new BindingSource(logMsgs, null); debugLogBox.DataSource = bs; logMsgs.Add("Logging initialized!"); if (File.Exists(defConfFileName)) { try { Program.c = JsonConfigLoader.Load(File.ReadAllText(defConfFileName)); currConfSrc.Text = "File: " + Path.GetFullPath(@".\" + defConfFileName); loadFromConfigIntoTextboxes(); } catch (Exception q) { ((ISimpleLogger)this).Log("Error loading config file from default path " + defConfFileName); } } }
private void loadNewConfigButton_Click(object sender, EventArgs e) { Config c = null; try { if (fileRadio.Checked) { var fp = filePathTextBox.Text.Trim(); if (String.IsNullOrWhiteSpace(fp)) { ((ISimpleLogger)this).Log("Can't load from empty file!"); return; } if (!File.Exists(fp)) { ((ISimpleLogger)this).Log("File " + fp + " does not exist!"); return; } c = JsonConfigLoader.Load(File.ReadAllText(fp)); this.currConfSrc.Text = "File: " + fp; try { } catch (Exception errr) { ((ISimpleLogger)this).Log("Failed to get data from file " + fp); ((ISimpleLogger)this).Log(errr.Message + "\r\n" + errr.StackTrace); } } else { var up = urlText.Text.Trim(); if (String.IsNullOrWhiteSpace(up)) { ((ISimpleLogger)this).Log("Can't load from empty URL!"); return; } try { c = WebConfigLoader.Load(up); this.currConfSrc.Text = "URL: " + up; } catch (Exception err) { ((ISimpleLogger)this).Log("Failed to get data from URL " + up); } } Program.c = c; loadFromConfigIntoTextboxes(); ((ISimpleLogger)this).Log("Successfully loaded new configuration from " + currConfSrc.Text); } catch (Exception err) { ((ISimpleLogger)this).Log("Unknown error loading config!"); } }
public MainForm() { InitializeComponent(); Version version = Assembly.GetEntryAssembly().GetName().Version; if (version != null) { this.Text = this.Text + " " + version.ToString(); } //Word wrap on debug listbox debugLogBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; debugLogBox.MeasureItem += lst_MeasureItem; debugLogBox.DrawItem += lst_DrawItem; var bs = new BindingSource(logMsgs, null); debugLogBox.DataSource = bs; logMsgs.Add("Logging initialized!"); if (File.Exists(defConfFileName)) { try { Program.c = JsonConfigLoader.Load(File.ReadAllText(defConfFileName)); currConfSrc.Text = "File: " + Path.GetFullPath(@".\" + defConfFileName); loadFromConfigIntoTextboxes(); } catch (Exception q) { ((ISimpleLogger)this).Log("Error loading config file from default path " + defConfFileName); } } else { try { loadFromConfigIntoTextboxes(); } catch (Exception e) { ((ISimpleLogger)this).Log(e.Message + "\r\n" + e.StackTrace); } } }
public static Config Load(string url) { var req = WebRequest.Create(url); return(JsonConfigLoader.Load(WebHelper.GetDocumentContents(req))); }