Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/whitespaceetc #1583

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="NUnit.Console" version="3.9.0" />
<package id="NUnit.ConsoleRunner" version="3.9.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ namespace ResearchDataManagementPlatform.Menus.MenuItems;

internal class DataExportMenu : RDMPToolStripMenuItem
{
public DataExportMenu(IActivateItems activator):base(activator,"Data Export Options")
public DataExportMenu(IActivateItems activator) : base(activator, "Data Export Options")
{

Enabled = _activator.RepositoryLocator.DataExportRepository != null;

DropDownItems.Add(new ToolStripMenuItem("Configure Disclaimer", null, ConfigureDisclaimer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public class LaunchTutorialMenuItem : ToolStripMenuItem
private readonly Tutorial _tutorial;
private readonly TutorialTracker _tracker;

public LaunchTutorialMenuItem(ToolStripMenuItem parent,IActivateItems activator, Tutorial tutorial, TutorialTracker tracker)
public LaunchTutorialMenuItem(ToolStripMenuItem parent, IActivateItems activator, Tutorial tutorial,
TutorialTracker tracker)
{
parent.DropDownOpening += parent_DropDownOpening;
parent.DropDownOpening += parent_DropDownOpening;
_activator = activator;
_tutorial = tutorial;
_tracker = tracker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@ private void parent_DropDownOpening(object sender, EventArgs e)
{
Enabled = _tracker.IsClearable();
}


}
109 changes: 55 additions & 54 deletions Application/ResearchDataManagementPlatform/Menus/RDMPTopMenuStripUI.cs

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions Application/ResearchDataManagementPlatform/NLog.template.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>

<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
Expand All @@ -9,13 +10,14 @@
<targets>
<target xsi:type="ColoredConsole" name="c"
layout="${longdate} ${uppercase:${level}} ${message} ${all-event-properties}. ${exception:format=toString}" />
<target xsi:type="File" name="log4j" fileName="${basedir}/logs/${shortdate}-log4j.log" layout="${log4jxmlevent}" />
<target xsi:type="File" name="simple" fileName="${basedir}/logs/${shortdate}-simple.log" layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=toString}" />
<target xsi:type="Network" name="u" address="udp4://localhost:878" layout="${log4jxmlevent}" />
<target xsi:type="File" name="log4j" fileName="${basedir}/logs/${shortdate}-log4j.log" layout="${log4jxmlevent}" />
<target xsi:type="File" name="simple" fileName="${basedir}/logs/${shortdate}-simple.log"
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=toString}" />
<target xsi:type="Network" name="u" address="udp4://localhost:878" layout="${log4jxmlevent}" />
</targets>
<rules>
<!--<logger name="*" minlevel="Trace" writeTo="c" />
<!--<logger name="*" minlevel="Trace" writeTo="c" />
<logger name="*" minlevel="Trace" writeTo="log4j" />-->
<logger name="*" minlevel="Trace" writeTo="simple" />
</rules>
</nlog>
</nlog>
44 changes: 22 additions & 22 deletions Application/ResearchDataManagementPlatform/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@ internal static class Program
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool AttachConsole([MarshalAs(UnmanagedType.U4)] int dwProcessId);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
private static void Main(string[] args)
{
// if user has the command line built and runnable from the windows
// client then don't load the dlls (or we end up with 2 copies!).
SafeDirectoryCatalog.IgnoreDll = f => Path.GetFileName(f.DirectoryName)?.Equals("cli")==true;
{
// if user has the command line built and runnable from the windows
// client then don't load the dlls (or we end up with 2 copies!).
SafeDirectoryCatalog.IgnoreDll = f => Path.GetFileName(f.DirectoryName)?.Equals("cli") == true;

try
{
AttachConsole(-1);
}
catch (Exception)
{
Console.WriteLine("Couldn't redirect console. Never mind");
}
try
{
AttachConsole(-1);
}
catch (Exception)
{
Console.WriteLine("Couldn't redirect console. Never mind");
}

Startup.PreStartup();
Startup.PreStartup();

UsefulStuff.GetParser()
.ParseArguments<ResearchDataManagementPlatformOptions>(args)
.MapResult(RunApp, err => -1);
UsefulStuff.GetParser()
.ParseArguments<ResearchDataManagementPlatformOptions>(args)
.MapResult(RunApp, err => -1);
}

private static object RunApp(ResearchDataManagementPlatformOptions arg)
Expand All @@ -56,7 +56,7 @@ private static object RunApp(ResearchDataManagementPlatformOptions arg)
{
arg.PopulateConnectionStringsFromYamlIfMissing(new ThrowImmediatelyCheckNotifier());
}
catch(Exception ex)
catch (Exception ex)
{
ExceptionViewer.Show(ex);
return -500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("cac9817c-fc66-48e8-9333-c740af6ab5b9")]
[assembly: Guid("cac9817c-fc66-48e8-9333-c740af6ab5b9")]
19 changes: 10 additions & 9 deletions Application/ResearchDataManagementPlatform/RDMP.nuspec
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>

<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>ResearchDataManagementPlatform</id>
<version>$version$</version>
<authors>Health Informatics Service, University of Dundee</authors>
<description>Research Data Management Platform</description>
</metadata>
<metadata>
<id>ResearchDataManagementPlatform</id>
<version>$version$</version>
<authors>Health Informatics Service, University of Dundee</authors>
<description>Research Data Management Platform</description>
</metadata>
<files>
<file src="bin\$configuration$\net6.0-windows\win-x64\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\Curation\**\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\Icon\**\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\WindowManagement\**\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\Curation\**\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\Icon\**\*" target="lib\net6.0-windows7.0" />
<file src="bin\$configuration$\net6.0-windows\win-x64\WindowManagement\**\*" target="lib\net6.0-windows7.0" />
</files>
</package>
75 changes: 36 additions & 39 deletions Application/ResearchDataManagementPlatform/RDMPMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public RDMPMainForm()
if (!string.IsNullOrWhiteSpace(t))
{
var type = Type.GetType(t);
_theme = type == null ? new MyVS2015BlueTheme() : (ITheme) System.Activator.CreateInstance(type);
_theme = type == null ? new MyVS2015BlueTheme() : (ITheme)System.Activator.CreateInstance(type);
}
else
{
_theme = new MyVS2015BlueTheme();
}
}
catch (Exception)
{
Expand Down Expand Up @@ -103,52 +105,51 @@ private void RDMPMainForm_Load(object sender, EventArgs e)
_globalErrorCheckNotifier = exceptionCounter;
_rdmpTopMenuStrip1.InjectButton(exceptionCounter);

_windowManager = new WindowManager(_theme,this,_refreshBus, dockPanel1, RepositoryLocator, exceptionCounter);
_windowManager = new WindowManager(_theme, this, _refreshBus, dockPanel1, RepositoryLocator, exceptionCounter);
SetItemActivator(_windowManager.ActivateItems);

_rdmpTopMenuStrip1.SetWindowManager(_windowManager);

//put the version of the software into the window title
_version = StartupUI.GetVersion();

_version = StartupUI.GetVersion();

//put the current platform database into the window title too
if (Activator?.RepositoryLocator?.CatalogueRepository is TableRepository connectedTo)
{
var database = connectedTo.DiscoveredServer?.GetCurrentDatabase();
var instanceDescription = "";

var connectionStringsFileLoaded = RDMPBootStrapper<RDMPMainForm>.ApplicationArguments?.ConnectionStringsFileLoaded;
var connectionStringsFileLoaded =
RDMPBootStrapper<RDMPMainForm>.ApplicationArguments?.ConnectionStringsFileLoaded;
if (connectionStringsFileLoaded != null)
{
instanceDescription =
$" - {connectionStringsFileLoaded.Name ?? connectionStringsFileLoaded.FileLoaded.Name}";
}
if (database != null)
if (database != null)
_connectedTo = $"({database.GetRuntimeName()} on {database.Server.Name}){instanceDescription}";
}

Text = "Research Data Management Platform";

var rdmpDir = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RDMP"));
if(!rdmpDir.Exists)
var rdmpDir =
new DirectoryInfo(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RDMP"));
if (!rdmpDir.Exists)
rdmpDir.Create();

_persistenceFile = new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),"RDMP", "RDMPDockPanelPersist.xml"));
_persistenceFile =
new FileInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RDMP",
"RDMPDockPanelPersist.xml"));

//if there is no persist file or user wants to show the home screen always on startup
if (!_persistenceFile.Exists || UserSettings.ShowHomeOnStartup)
{
_windowManager.PopHome();
}
else
{
try
{
if (_persistenceFile.Exists)
LoadFromXml(new FileStream(_persistenceFile.FullName, FileMode.Open));

//load the state using the method
//load the state using the method
}
catch (Exception ex)
{
Expand All @@ -161,33 +162,29 @@ private void RDMPMainForm_Load(object sender, EventArgs e)
_persistenceFile.Delete();
ApplicationRestarter.Restart();
}
}


FormClosing += CloseForm;
Loading = false;
}

public override string Text {
public override string Text
{
get => base.Text;
set => base.Text = (value + " v" + _version + " " + _connectedTo).Trim();
}

public void LoadFromXml(Stream stream)
{
if (dockPanel1.DocumentStyle == DocumentStyle.SystemMdi)
{
foreach (var form in MdiChildren)
form.Close();
}
else
{
foreach (var document in dockPanel1.DocumentsToArray())
{
// IMPORANT: dispose all panes.
document.DockHandler.DockPanel = null;
document.DockHandler.Close();
}
}

foreach (var pane in dockPanel1.Panes.ToList())
{
Expand All @@ -198,17 +195,18 @@ public void LoadFromXml(Stream stream)
// IMPORTANT: dispose all float windows.
foreach (var window in dockPanel1.FloatWindows.ToList())
window.Dispose();

System.Diagnostics.Debug.Assert(dockPanel1.Panes.Count == 0);
System.Diagnostics.Debug.Assert(dockPanel1.Contents.Count == 0);
System.Diagnostics.Debug.Assert(dockPanel1.FloatWindows.Count == 0);

dockPanel1.LoadFromXml(stream, DeserializeContent);
}

public void LoadFromXml(WindowLayout target)
{
var uniEncoding = new UnicodeEncoding();

// You might not want to use the outer using statement that I have
// I wasn't sure how long you would need the MemoryStream object
using (var ms = new MemoryStream())
Expand All @@ -217,7 +215,7 @@ public void LoadFromXml(WindowLayout target)
try
{
sw.Write(target.LayoutData);
sw.Flush();//otherwise you are risking empty stream
sw.Flush(); //otherwise you are risking empty stream
ms.Seek(0, SeekOrigin.Begin);

LoadFromXml(ms);
Expand Down Expand Up @@ -256,10 +254,7 @@ private void CloseForm(object sender, FormClosingEventArgs e)
// give the window manager a chance to cancel closing
_windowManager.OnFormClosing(e);

if (e.Cancel)
{
return;
}
if (e.Cancel) return;

if (e.CloseReason == CloseReason.UserClosing && UserSettings.ConfirmApplicationExiting)
if (!Activator.YesNo("Are you sure you want to Exit?", "Confirm Exit"))
Expand All @@ -278,9 +273,9 @@ private void CloseForm(object sender, FormClosingEventArgs e)
dockPanel1.SaveAsXml(_persistenceFile.FullName); //save when Form closes
}
}
catch(Exception ex)
catch (Exception ex)
{
ExceptionViewer.Show("Could not write persistence file",ex);
ExceptionViewer.Show("Could not write persistence file", ex);
}
}

Expand All @@ -295,17 +290,19 @@ private IDockContent DeserializeContent(string persiststring)
return toolboxInstance;
}

var instruction = PersistenceDecisionFactory.ShouldCreateBasicControl(persiststring,RepositoryLocator) ??
PersistenceDecisionFactory.ShouldCreateSingleObjectControl(persiststring,RepositoryLocator) ??
var instruction = PersistenceDecisionFactory.ShouldCreateBasicControl(persiststring, RepositoryLocator) ??
PersistenceDecisionFactory.ShouldCreateSingleObjectControl(persiststring,
RepositoryLocator) ??
PersistenceDecisionFactory.ShouldCreateObjectCollection(persiststring, RepositoryLocator);

if (instruction != null)
return _windowManager.ActivateItems.Activate(instruction,_windowManager.ActivateItems);
return _windowManager.ActivateItems.Activate(instruction, _windowManager.ActivateItems);
}
catch (Exception e)
{
_globalErrorCheckNotifier.OnCheckPerformed(new CheckEventArgs(
$"Could not work out what window to show for persistence string '{persiststring}'",CheckResult.Fail, e));
$"Could not work out what window to show for persistence string '{persiststring}'", CheckResult.Fail,
e));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class ThemeExtender
private const string Env = "Environment";

public Color TextBoxBackground { get; set; }

public Color ComboBoxBackground { get; set; }
public Color ComboBoxText { get; set; }

Expand All @@ -27,7 +27,7 @@ public ThemeExtender(byte[] bytes)
{
_xml = XDocument.Load(new StreamReader(new MemoryStream(bytes)));
TextBoxBackground = ColorTranslatorFromHtml("CommonControls", "TextBoxBackground");

ComboBoxBackground = ColorTranslatorFromHtml(Env, "ComboBoxBackground");
ComboBoxText = ColorTranslatorFromHtml(Env, "ComboBoxText");
}
Expand All @@ -36,9 +36,11 @@ private Color ColorTranslatorFromHtml(string category, string name, bool foregro
{
string color = null;

var environmentElement = _xml.Root.Element("Theme").Elements("Category").FirstOrDefault(item => item.Attribute("Name").Value == category);
var environmentElement = _xml.Root.Element("Theme").Elements("Category")
.FirstOrDefault(item => item.Attribute("Name").Value == category);

var colourElement = environmentElement?.Elements("Color").FirstOrDefault(item => item.Attribute("Name").Value == name);
var colourElement = environmentElement?.Elements("Color")
.FirstOrDefault(item => item.Attribute("Name").Value == name);

if (colourElement != null)
color = colourElement.Element(foreground ? "Foreground" : "Background").Attribute("Source").Value;
Expand Down
Loading