2017-02-20 16:42:48 +00:00
|
|
|
|
using System;
|
2014-12-31 23:28:50 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-02-20 16:42:48 +00:00
|
|
|
|
using System.Drawing;
|
2014-12-31 23:28:50 +00:00
|
|
|
|
using System.Linq;
|
2017-02-20 16:42:48 +00:00
|
|
|
|
|
2014-05-18 02:03:38 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2014-01-30 15:28:05 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.Common
|
2014-01-30 00:55:31 +00:00
|
|
|
|
{
|
|
|
|
|
public class ToolDialogSettings
|
|
|
|
|
{
|
2017-05-17 18:18:26 +00:00
|
|
|
|
private int? _wndx;
|
|
|
|
|
private int? _wndy;
|
2014-06-29 15:04:20 +00:00
|
|
|
|
|
2014-01-30 00:55:31 +00:00
|
|
|
|
public ToolDialogSettings()
|
|
|
|
|
{
|
|
|
|
|
SaveWindowPosition = true;
|
2014-02-15 20:19:36 +00:00
|
|
|
|
FloatingWindow = true;
|
2014-01-30 00:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-23 01:01:37 +00:00
|
|
|
|
public void RestoreDefaults()
|
|
|
|
|
{
|
|
|
|
|
_wndx = null;
|
|
|
|
|
_wndy = null;
|
|
|
|
|
SaveWindowPosition = true;
|
|
|
|
|
FloatingWindow = true;
|
|
|
|
|
TopMost = false;
|
|
|
|
|
AutoLoad = false;
|
|
|
|
|
Width = null;
|
|
|
|
|
Height = null;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 15:04:20 +00:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public int? Wndx
|
|
|
|
|
{
|
2017-04-14 19:59:01 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _wndx;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 15:04:20 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2014-06-29 15:09:21 +00:00
|
|
|
|
if (value != -32000)
|
2014-06-29 15:04:20 +00:00
|
|
|
|
{
|
|
|
|
|
_wndx = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public int? Wndy
|
|
|
|
|
{
|
2017-04-14 19:59:01 +00:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _wndy;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-29 15:04:20 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2014-06-29 15:09:21 +00:00
|
|
|
|
if (value != -32000)
|
2014-06-29 15:04:20 +00:00
|
|
|
|
{
|
|
|
|
|
_wndy = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-20 16:42:48 +00:00
|
|
|
|
/// <summary>
|
2017-05-17 18:18:26 +00:00
|
|
|
|
/// Gets a value that represents the top left corner coordinate, if <see cref="Wndx"/> and <see cref="Wndy"/> form a valid point
|
|
|
|
|
/// Throws an InvalidOperationException if <see cref="Wndx"/> or <see cref="Wndy"/> is null
|
2017-02-20 16:42:48 +00:00
|
|
|
|
/// It is expected to check for this before using this property
|
|
|
|
|
/// </summary>
|
|
|
|
|
[JsonIgnore]
|
|
|
|
|
public Point TopLeft
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_wndx.HasValue && _wndy.HasValue)
|
|
|
|
|
{
|
|
|
|
|
return new Point(_wndx.Value, _wndy.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new InvalidOperationException("TopLeft can not be used when one of the coordinates is null");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 00:55:31 +00:00
|
|
|
|
public int? Width { get; set; }
|
|
|
|
|
public int? Height { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool SaveWindowPosition { get; set; }
|
2014-01-30 03:34:58 +00:00
|
|
|
|
public bool TopMost { get; set; }
|
2014-01-30 00:55:31 +00:00
|
|
|
|
public bool FloatingWindow { get; set; }
|
2014-12-19 23:33:05 +00:00
|
|
|
|
public bool AutoLoad { get; set; }
|
2014-01-30 00:55:31 +00:00
|
|
|
|
|
2014-05-18 02:03:38 +00:00
|
|
|
|
[JsonIgnore]
|
2017-05-17 18:18:26 +00:00
|
|
|
|
public bool UseWindowPosition => SaveWindowPosition && Wndx.HasValue
|
|
|
|
|
&& Wndy.HasValue
|
|
|
|
|
&& Wndx != -32000 && Wndy != -32000;
|
2014-01-30 00:55:31 +00:00
|
|
|
|
|
2014-05-18 02:03:38 +00:00
|
|
|
|
[JsonIgnore]
|
2017-05-17 18:18:26 +00:00
|
|
|
|
public bool UseWindowSize => SaveWindowPosition && Width.HasValue && Height.HasValue;
|
2014-01-30 15:28:05 +00:00
|
|
|
|
|
2014-05-18 02:03:38 +00:00
|
|
|
|
[JsonIgnore]
|
2017-05-17 18:18:26 +00:00
|
|
|
|
public Point WindowPosition => new Point(Wndx ?? 0, Wndy ?? 0);
|
2014-01-30 15:28:05 +00:00
|
|
|
|
|
2014-05-18 02:03:38 +00:00
|
|
|
|
[JsonIgnore]
|
2017-05-17 18:18:26 +00:00
|
|
|
|
public Size WindowSize => new Size(Width ?? 0, Height ?? 0);
|
2014-12-31 23:28:50 +00:00
|
|
|
|
|
|
|
|
|
public class ColumnList : List<Column>
|
|
|
|
|
{
|
|
|
|
|
public Column this[string name]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.FirstOrDefault(c => c.Name == name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Column
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public int Width { get; set; }
|
|
|
|
|
public bool Visible { get; set; }
|
|
|
|
|
public int Index { get; set; }
|
|
|
|
|
}
|
2014-01-30 00:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|