Ran code maid against this code.

This commit is contained in:
Lars Brubaker 2015-04-08 15:20:10 -07:00
parent 1445945d9c
commit 591528ee91
309 changed files with 139399 additions and 140129 deletions

View file

@ -3,13 +3,13 @@ Copyright (c) 2014, Lars Brubaker
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@ -23,78 +23,79 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
*/
using System;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.VectorMath;
using System;
namespace MatterHackers.MatterControl
{
public class TerminalWindow : SystemWindow
{
static readonly Vector2 minSize = new Vector2(400, 300);
static readonly string TerminalWindowLeftOpen = "TerminalWindowLeftOpen";
static readonly string TerminalWindowSizeKey = "TerminalWindowSize";
static readonly string TerminalWindowPositionKey = "TerminalWindowPosition";
static TerminalWindow connectionWindow = null;
static bool terminalWasOpenOnAppClose = false;
public static void Show()
{
if (connectionWindow == null)
{
terminalWasOpenOnAppClose = false;
string windowSize = UserSettings.Instance.get(TerminalWindowSizeKey);
int width = 400;
int height = 300;
if (windowSize != null && windowSize != "")
{
string[] sizes = windowSize.Split(',');
width = Math.Max(int.Parse(sizes[0]), (int)minSize.x);
height = Math.Max(int.Parse(sizes[1]), (int)minSize.y);
}
{
public class TerminalWindow : SystemWindow
{
private static readonly Vector2 minSize = new Vector2(400, 300);
private static readonly string TerminalWindowLeftOpen = "TerminalWindowLeftOpen";
private static readonly string TerminalWindowSizeKey = "TerminalWindowSize";
private static readonly string TerminalWindowPositionKey = "TerminalWindowPosition";
private static TerminalWindow connectionWindow = null;
private static bool terminalWasOpenOnAppClose = false;
connectionWindow = new TerminalWindow(width, height);
connectionWindow.Closed += (parentSender, e) =>
{
connectionWindow = null;
};
public static void Show()
{
if (connectionWindow == null)
{
terminalWasOpenOnAppClose = false;
string windowSize = UserSettings.Instance.get(TerminalWindowSizeKey);
int width = 400;
int height = 300;
if (windowSize != null && windowSize != "")
{
string[] sizes = windowSize.Split(',');
width = Math.Max(int.Parse(sizes[0]), (int)minSize.x);
height = Math.Max(int.Parse(sizes[1]), (int)minSize.y);
}
// start with the assumption we are open and only change this is we see it close
UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, true);
}
else
{
connectionWindow.BringToFront();
}
}
connectionWindow = new TerminalWindow(width, height);
connectionWindow.Closed += (parentSender, e) =>
{
connectionWindow = null;
};
public static void ShowIfLeftOpen()
{
if (UserSettings.Instance.Fields.GetBool(TerminalWindowLeftOpen, false))
{
Show();
}
}
// start with the assumption we are open and only change this is we see it close
UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, true);
}
else
{
connectionWindow.BringToFront();
}
}
public static void CloseIfOpen()
{
if (connectionWindow != null)
{
terminalWasOpenOnAppClose = true;
connectionWindow.Close();
}
}
public static void ShowIfLeftOpen()
{
if (UserSettings.Instance.Fields.GetBool(TerminalWindowLeftOpen, false))
{
Show();
}
}
public static void CloseIfOpen()
{
if (connectionWindow != null)
{
terminalWasOpenOnAppClose = true;
connectionWindow.Close();
}
}
//private since you can't make one
private TerminalWindow(int width, int height)
: base(width, height)
{
AlwaysOnTopOfMain = true;
AlwaysOnTopOfMain = true;
#if __ANDROID__
TerminalWidget terminalWidget = new TerminalWidget(true);
this.AddChild(new SoftKeyboardContentOffset(terminalWidget, SoftKeyboardContentOffset.AndroidKeyboardOffset));
@ -104,33 +105,33 @@ namespace MatterHackers.MatterControl
#endif
Title = LocalizedString.Get("MatterControl - Terminal");
this.ShowAsSystemWindow();
MinimumSize = minSize;
MinimumSize = minSize;
string desktopPosition = UserSettings.Instance.get(TerminalWindowPositionKey);
if (desktopPosition != null && desktopPosition != "")
{
string[] sizes = desktopPosition.Split(',');
string desktopPosition = UserSettings.Instance.get(TerminalWindowPositionKey);
if (desktopPosition != null && desktopPosition != "")
{
string[] sizes = desktopPosition.Split(',');
//If the desktop position is less than -10,-10, override
int xpos = Math.Max(int.Parse(sizes[0]), -10);
int ypos = Math.Max(int.Parse(sizes[1]), -10);
DesktopPosition = new Point2D(xpos, ypos);
}
}
//If the desktop position is less than -10,-10, override
int xpos = Math.Max(int.Parse(sizes[0]), -10);
int ypos = Math.Max(int.Parse(sizes[1]), -10);
DesktopPosition = new Point2D(xpos, ypos);
}
}
void SaveOnClosing()
{
// save the last size of the window so we can restore it next time.
UserSettings.Instance.set(TerminalWindowSizeKey, string.Format("{0},{1}", Width, Height));
UserSettings.Instance.set(TerminalWindowPositionKey, string.Format("{0},{1}", DesktopPosition.x, DesktopPosition.y));
}
private void SaveOnClosing()
{
// save the last size of the window so we can restore it next time.
UserSettings.Instance.set(TerminalWindowSizeKey, string.Format("{0},{1}", Width, Height));
UserSettings.Instance.set(TerminalWindowPositionKey, string.Format("{0},{1}", DesktopPosition.x, DesktopPosition.y));
}
public override void OnClosed(EventArgs e)
{
SaveOnClosing();
UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, terminalWasOpenOnAppClose);
public override void OnClosed(EventArgs e)
{
SaveOnClosing();
UserSettings.Instance.Fields.SetBool(TerminalWindowLeftOpen, terminalWasOpenOnAppClose);
base.OnClosed(e);
}
}
}
base.OnClosed(e);
}
}
}