diff --git a/EDSTest/Form1.cs b/EDSTest/Form1.cs index 6c2dacca..64cfa2d3 100644 --- a/EDSTest/Form1.cs +++ b/EDSTest/Form1.cs @@ -52,25 +52,48 @@ public ODEditor_MainForm() loadprofiles(); insertToolStripMenuItem.Enabled = false; - - } private void loadprofiles() { - string[] profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)+Path.DirectorySeparatorChar+"Profiles"); - ToolStripMenuItem[] items = new ToolStripMenuItem[profilelist.Length]; + + // load default profiles from the install directory + // load user profiles from the My Documents\.edseditor\profiles\ folder + // Personal is my documents in windows and ~ in mono + + List profilelist = Directory.GetFiles(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Profiles").ToList(); + string homepath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor"); + homepath = Path.Combine(homepath, "profiles"); + + if (Directory.Exists(homepath)) + { + profilelist.AddRange(Directory.GetFiles(homepath).ToList()); + } + + int count = 0; + //some attempt to validate files + + foreach (string file in profilelist) + { + if (Path.GetExtension(file) == ".xml") + count++; + } + + + ToolStripMenuItem[] items = new ToolStripMenuItem[count]; int x = 0; foreach(string file in profilelist) { - - ToolStripMenuItem i = new ToolStripMenuItem(); - i.Name = Path.GetFileName(file); - i.Text = Path.GetFileName(file); - i.Click += ProfileAddClick; - i.Image = Properties.Resources.InsertColumn_5626; - items[x++] = i; + if (Path.GetExtension(file) == ".xml") + { + ToolStripMenuItem i = new ToolStripMenuItem(); + i.Name = Path.GetFileName(file); + i.Text = Path.GetFileName(file); + i.Click += ProfileAddClick; + i.Image = Properties.Resources.InsertColumn_5626; + items[x++] = i; + } } insertToolStripMenuItem.DropDownItems.AddRange(items); diff --git a/EDSTest/ReportView.cs b/EDSTest/ReportView.cs index 94449d52..940be75b 100644 --- a/EDSTest/ReportView.cs +++ b/EDSTest/ReportView.cs @@ -22,7 +22,22 @@ public ReportView(string pathtohtml) private void WebBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e) { - string text = System.IO.File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "style.css")); + + //Try to load a css override from ~/.edseditor/style.css first then fallback to installed default + + string csspath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor"); + csspath = Path.Combine(csspath, "style.css"); + + if(!File.Exists(csspath)) + { + csspath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "style.css"); + } + + if (!File.Exists(csspath)) + return; + + string text = System.IO.File.ReadAllText(csspath); + mshtml.HTMLDocument CurrentDocument = (HTMLDocument)webBrowser1.Document.DomDocument; mshtml.IHTMLStyleSheet styleSheet = CurrentDocument.createStyleSheet("", 0); styleSheet.cssText = text;