mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
fix warnings about null-able
This commit is contained in:
@@ -257,15 +257,9 @@ public class PasswordstateInterface
|
||||
|
||||
return ""+textWriter.ToString();
|
||||
}
|
||||
private class PasswordFinder : IPasswordFinder
|
||||
private class PasswordFinder(string password) : IPasswordFinder
|
||||
{
|
||||
private string password;
|
||||
|
||||
public PasswordFinder(string password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
private string password = password;
|
||||
|
||||
public char[] GetPassword()
|
||||
{
|
||||
|
||||
@@ -58,10 +58,7 @@ namespace SecretServerAuthentication.DSS
|
||||
/// <param name="refresh_token">The refresh token. Required when refreshing a token.</param>
|
||||
/// <returns>Successful retrieval of an access token</returns>
|
||||
/// <exception cref="ApiException">A server side error occurred.</exception>
|
||||
public System.Threading.Tasks.Task<TokenResponse> AuthorizeAsync(Grant_type grant_type, string username, string password, string refresh_token, string OTP)
|
||||
{
|
||||
return AuthorizeAsync(grant_type, username, password, refresh_token, System.Threading.CancellationToken.None, OTP);
|
||||
}
|
||||
public System.Threading.Tasks.Task<TokenResponse> AuthorizeAsync(Grant_type grant_type, string username, string password, string refresh_token, string OTP) => AuthorizeAsync(grant_type, username, password, refresh_token, System.Threading.CancellationToken.None, OTP);
|
||||
|
||||
/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
|
||||
/// <summary>Retrieve or Refresh Access Token</summary>
|
||||
@@ -355,10 +352,7 @@ namespace SecretServerAuthentication.DSS
|
||||
Headers = headers;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString());
|
||||
}
|
||||
public override string ToString() => string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString());
|
||||
}
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.8.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v11.0.0.0))")]
|
||||
|
||||
@@ -223,15 +223,9 @@ public class SecretServerInterface
|
||||
|
||||
return ""+textWriter.ToString();
|
||||
}
|
||||
private class PasswordFinder : IPasswordFinder
|
||||
private class PasswordFinder(string password) : IPasswordFinder
|
||||
{
|
||||
private string password;
|
||||
|
||||
public PasswordFinder(string password)
|
||||
{
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
private string password = password;
|
||||
|
||||
public char[] GetPassword()
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,18 +46,14 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// These items allow combo boxes to remember a value and its description.
|
||||
/// </summary>
|
||||
public class ComboBoxItem
|
||||
/// <remarks>
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="description"></param>
|
||||
public class ComboBoxItem(Object key, String description)
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="description"></param>
|
||||
public ComboBoxItem(Object key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
private readonly String description;
|
||||
private readonly String description = description;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -65,7 +61,7 @@ namespace BrightIdeasSoftware
|
||||
public Object Key {
|
||||
get { return key; }
|
||||
}
|
||||
private readonly Object key;
|
||||
private readonly Object key = key;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the current object.
|
||||
|
||||
@@ -158,15 +158,12 @@ namespace BrightIdeasSoftware
|
||||
/// This class isn't intended to be used directly, but it is left as a public
|
||||
/// class just in case someone wants to subclass it.
|
||||
/// </remarks>
|
||||
public class FastObjectListDataSource : AbstractVirtualListDataSource
|
||||
/// <remarks>
|
||||
/// Create a FastObjectListDataSource
|
||||
/// </remarks>
|
||||
/// <param name="listView"></param>
|
||||
public class FastObjectListDataSource(FastObjectListView listView) : AbstractVirtualListDataSource(listView)
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a FastObjectListDataSource
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
public FastObjectListDataSource(FastObjectListView listView)
|
||||
: base(listView) {
|
||||
}
|
||||
|
||||
#region IVirtualListDataSource Members
|
||||
|
||||
|
||||
@@ -185,15 +185,11 @@ namespace BrightIdeasSoftware
|
||||
/// A model object must satisfy all filters to be included.
|
||||
/// If there are no filters, all model objects are included
|
||||
/// </summary>
|
||||
public class CompositeAllFilter : CompositeFilter {
|
||||
|
||||
/// <summary>
|
||||
/// Create a filter
|
||||
/// </summary>
|
||||
/// <param name="filters"></param>
|
||||
public CompositeAllFilter(List<IModelFilter> filters)
|
||||
: base(filters) {
|
||||
}
|
||||
/// <remarks>
|
||||
/// Create a filter
|
||||
/// </remarks>
|
||||
/// <param name="filters"></param>
|
||||
public class CompositeAllFilter(List<IModelFilter> filters) : CompositeFilter(filters) {
|
||||
|
||||
/// <summary>
|
||||
/// Decide whether or not the given model should be included by the filter
|
||||
@@ -215,15 +211,11 @@ namespace BrightIdeasSoftware
|
||||
/// A model object must only satisfy one of the filters to be included.
|
||||
/// If there are no filters, all model objects are included
|
||||
/// </summary>
|
||||
public class CompositeAnyFilter : CompositeFilter {
|
||||
|
||||
/// <summary>
|
||||
/// Create a filter from the given filters
|
||||
/// </summary>
|
||||
/// <param name="filters"></param>
|
||||
public CompositeAnyFilter(List<IModelFilter> filters)
|
||||
: base(filters) {
|
||||
}
|
||||
/// <remarks>
|
||||
/// Create a filter from the given filters
|
||||
/// </remarks>
|
||||
/// <param name="filters"></param>
|
||||
public class CompositeAnyFilter(List<IModelFilter> filters) : CompositeFilter(filters) {
|
||||
|
||||
/// <summary>
|
||||
/// Decide whether or not the given model should be included by the filter
|
||||
|
||||
@@ -50,7 +50,13 @@ namespace BrightIdeasSoftware
|
||||
/// <para>This is used by normal (non-virtual) ObjectListViews. Virtual lists use
|
||||
/// ModelObjectComparer</para>
|
||||
/// </remarks>
|
||||
public class ColumnComparer : IComparer, IComparer<OLVListItem>
|
||||
/// <remarks>
|
||||
/// Create a ColumnComparer that will order the rows in a list view according
|
||||
/// to the values in a given column
|
||||
/// </remarks>
|
||||
/// <param name="col">The column whose values will be compared</param>
|
||||
/// <param name="order">The ordering for column values</param>
|
||||
public class ColumnComparer(OLVColumn col, SortOrder order) : IComparer, IComparer<OLVListItem>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the method that will be used to compare two strings.
|
||||
@@ -63,18 +69,6 @@ namespace BrightIdeasSoftware
|
||||
}
|
||||
private static StringCompareDelegate stringComparer;
|
||||
|
||||
/// <summary>
|
||||
/// Create a ColumnComparer that will order the rows in a list view according
|
||||
/// to the values in a given column
|
||||
/// </summary>
|
||||
/// <param name="col">The column whose values will be compared</param>
|
||||
/// <param name="order">The ordering for column values</param>
|
||||
public ColumnComparer(OLVColumn col, SortOrder order)
|
||||
{
|
||||
this.column = col;
|
||||
this.sortOrder = order;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a ColumnComparer that will order the rows in a list view according
|
||||
/// to the values in a given column, and by a secondary column if the primary
|
||||
@@ -165,8 +159,8 @@ namespace BrightIdeasSoftware
|
||||
return StringComparer(x, y);
|
||||
}
|
||||
|
||||
private OLVColumn column;
|
||||
private SortOrder sortOrder;
|
||||
private OLVColumn column = col;
|
||||
private SortOrder sortOrder = order;
|
||||
private ColumnComparer secondComparer;
|
||||
}
|
||||
|
||||
@@ -175,15 +169,12 @@ namespace BrightIdeasSoftware
|
||||
/// This comparer sort list view groups. OLVGroups have a "SortValue" property,
|
||||
/// which is used if present. Otherwise, the titles of the groups will be compared.
|
||||
/// </summary>
|
||||
public class OLVGroupComparer : IComparer<OLVGroup>
|
||||
/// <remarks>
|
||||
/// Create a group comparer
|
||||
/// </remarks>
|
||||
/// <param name="order">The ordering for column values</param>
|
||||
public class OLVGroupComparer(SortOrder order) : IComparer<OLVGroup>
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a group comparer
|
||||
/// </summary>
|
||||
/// <param name="order">The ordering for column values</param>
|
||||
public OLVGroupComparer(SortOrder order) {
|
||||
this.sortOrder = order;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compare the two groups. OLVGroups have a "SortValue" property,
|
||||
@@ -207,7 +198,7 @@ namespace BrightIdeasSoftware
|
||||
return result;
|
||||
}
|
||||
|
||||
private SortOrder sortOrder;
|
||||
private SortOrder sortOrder = order;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -217,7 +208,12 @@ namespace BrightIdeasSoftware
|
||||
/// <para>This is used by virtual ObjectListViews. Non-virtual lists use
|
||||
/// ColumnComparer</para>
|
||||
/// </remarks>
|
||||
public class ModelObjectComparer : IComparer, IComparer<object>
|
||||
/// <remarks>
|
||||
/// Create a model object comparer
|
||||
/// </remarks>
|
||||
/// <param name="col"></param>
|
||||
/// <param name="order"></param>
|
||||
public class ModelObjectComparer(OLVColumn col, SortOrder order) : IComparer, IComparer<object>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the method that will be used to compare two strings.
|
||||
@@ -230,17 +226,6 @@ namespace BrightIdeasSoftware
|
||||
}
|
||||
private static StringCompareDelegate stringComparer;
|
||||
|
||||
/// <summary>
|
||||
/// Create a model object comparer
|
||||
/// </summary>
|
||||
/// <param name="col"></param>
|
||||
/// <param name="order"></param>
|
||||
public ModelObjectComparer(OLVColumn col, SortOrder order)
|
||||
{
|
||||
this.column = col;
|
||||
this.sortOrder = order;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a model object comparer with a secondary sorting column
|
||||
/// </summary>
|
||||
@@ -318,8 +303,8 @@ namespace BrightIdeasSoftware
|
||||
return StringComparer(x, y);
|
||||
}
|
||||
|
||||
private OLVColumn column;
|
||||
private SortOrder sortOrder;
|
||||
private OLVColumn column = col;
|
||||
private SortOrder sortOrder = order;
|
||||
private ModelObjectComparer secondComparer;
|
||||
|
||||
#region IComparer<object> Members
|
||||
|
||||
@@ -878,25 +878,16 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// Let the world know that a cell edit operation is beginning or ending
|
||||
/// </summary>
|
||||
public class CellEditEventArgs : EventArgs
|
||||
/// <remarks>
|
||||
/// Create an event args
|
||||
/// </remarks>
|
||||
/// <param name="column"></param>
|
||||
/// <param name="control"></param>
|
||||
/// <param name="cellBounds"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="subItemIndex"></param>
|
||||
public class CellEditEventArgs(OLVColumn column, Control control, Rectangle cellBounds, OLVListItem item, int subItemIndex) : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create an event args
|
||||
/// </summary>
|
||||
/// <param name="column"></param>
|
||||
/// <param name="control"></param>
|
||||
/// <param name="cellBounds"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="subItemIndex"></param>
|
||||
public CellEditEventArgs(OLVColumn column, Control control, Rectangle cellBounds, OLVListItem item, int subItemIndex) {
|
||||
this.Control = control;
|
||||
this.column = column;
|
||||
this.cellBounds = cellBounds;
|
||||
this.listViewItem = item;
|
||||
this.rowObject = item.RowObject;
|
||||
this.subItemIndex = subItemIndex;
|
||||
this.value = column.GetValue(item.RowObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change this to true to cancel the cell editing operation.
|
||||
@@ -917,7 +908,7 @@ namespace BrightIdeasSoftware
|
||||
/// entered and commit that value to the model. Changing the control during the finishing
|
||||
/// event has no effect.
|
||||
/// </summary>
|
||||
public Control Control;
|
||||
public Control Control = control;
|
||||
|
||||
/// <summary>
|
||||
/// The column of the cell that is going to be or has been edited.
|
||||
@@ -925,7 +916,7 @@ namespace BrightIdeasSoftware
|
||||
public OLVColumn Column {
|
||||
get { return this.column; }
|
||||
}
|
||||
private OLVColumn column;
|
||||
private OLVColumn column = column;
|
||||
|
||||
/// <summary>
|
||||
/// The model object of the row of the cell that is going to be or has been edited.
|
||||
@@ -933,7 +924,7 @@ namespace BrightIdeasSoftware
|
||||
public Object RowObject {
|
||||
get { return this.rowObject; }
|
||||
}
|
||||
private Object rowObject;
|
||||
private Object rowObject = item.RowObject;
|
||||
|
||||
/// <summary>
|
||||
/// The listview item of the cell that is going to be or has been edited.
|
||||
@@ -941,7 +932,7 @@ namespace BrightIdeasSoftware
|
||||
public OLVListItem ListViewItem {
|
||||
get { return this.listViewItem; }
|
||||
}
|
||||
private OLVListItem listViewItem;
|
||||
private OLVListItem listViewItem = item;
|
||||
|
||||
/// <summary>
|
||||
/// The data value of the cell as it stands in the control.
|
||||
@@ -959,7 +950,7 @@ namespace BrightIdeasSoftware
|
||||
public int SubItemIndex {
|
||||
get { return this.subItemIndex; }
|
||||
}
|
||||
private int subItemIndex;
|
||||
private int subItemIndex = subItemIndex;
|
||||
|
||||
/// <summary>
|
||||
/// The data value of the cell before the edit operation began.
|
||||
@@ -967,7 +958,7 @@ namespace BrightIdeasSoftware
|
||||
public Object Value {
|
||||
get { return this.value; }
|
||||
}
|
||||
private Object value;
|
||||
private Object value = column.GetValue(item.RowObject);
|
||||
|
||||
/// <summary>
|
||||
/// The bounds of the cell that is going to be or has been edited.
|
||||
@@ -975,7 +966,7 @@ namespace BrightIdeasSoftware
|
||||
public Rectangle CellBounds {
|
||||
get { return this.cellBounds; }
|
||||
}
|
||||
private Rectangle cellBounds;
|
||||
private Rectangle cellBounds = cellBounds;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the control used for editing should be auto matically disposed
|
||||
@@ -1160,25 +1151,22 @@ namespace BrightIdeasSoftware
|
||||
}
|
||||
private SortOrder secondarySortOrder;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This event is triggered when the contents of a list have changed
|
||||
/// and we want the world to have a chance to filter the list.
|
||||
/// </summary>
|
||||
public class FilterEventArgs : EventArgs
|
||||
/// <remarks>
|
||||
/// Create a FilterEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="objects"></param>
|
||||
public class FilterEventArgs(IEnumerable objects) : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a FilterEventArgs
|
||||
/// </summary>
|
||||
/// <param name="objects"></param>
|
||||
public FilterEventArgs(IEnumerable objects) {
|
||||
this.Objects = objects;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets what objects are being filtered
|
||||
/// </summary>
|
||||
public IEnumerable Objects;
|
||||
public IEnumerable Objects = objects;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets what objects survived the filtering
|
||||
@@ -1267,17 +1255,13 @@ namespace BrightIdeasSoftware
|
||||
/// <remarks>
|
||||
/// When used with a virtual list, OldObjects will always be null.
|
||||
/// </remarks>
|
||||
public class ItemsChangingEventArgs : CancellableEventArgs
|
||||
/// <remarks>
|
||||
/// Create ItemsChangingEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="oldObjects"></param>
|
||||
/// <param name="newObjects"></param>
|
||||
public class ItemsChangingEventArgs(IEnumerable oldObjects, IEnumerable newObjects) : CancellableEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create ItemsChangingEventArgs
|
||||
/// </summary>
|
||||
/// <param name="oldObjects"></param>
|
||||
/// <param name="newObjects"></param>
|
||||
public ItemsChangingEventArgs(IEnumerable oldObjects, IEnumerable newObjects) {
|
||||
this.oldObjects = oldObjects;
|
||||
this.NewObjects = newObjects;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the objects that were in the list before it change.
|
||||
@@ -1286,47 +1270,40 @@ namespace BrightIdeasSoftware
|
||||
public IEnumerable OldObjects {
|
||||
get { return oldObjects; }
|
||||
}
|
||||
private IEnumerable oldObjects;
|
||||
private IEnumerable oldObjects = oldObjects;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the objects that will be in the list after it changes.
|
||||
/// </summary>
|
||||
public IEnumerable NewObjects;
|
||||
public IEnumerable NewObjects = newObjects;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event is triggered by RemoveObjects before any change has been made to the list.
|
||||
/// </summary>
|
||||
public class ItemsRemovingEventArgs : CancellableEventArgs
|
||||
/// <remarks>
|
||||
/// Create an ItemsRemovingEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="objectsToRemove"></param>
|
||||
public class ItemsRemovingEventArgs(ICollection objectsToRemove) : CancellableEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create an ItemsRemovingEventArgs
|
||||
/// </summary>
|
||||
/// <param name="objectsToRemove"></param>
|
||||
public ItemsRemovingEventArgs(ICollection objectsToRemove) {
|
||||
this.ObjectsToRemove = objectsToRemove;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the objects that will be removed
|
||||
/// </summary>
|
||||
public ICollection ObjectsToRemove;
|
||||
public ICollection ObjectsToRemove = objectsToRemove;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered after the user types into a list
|
||||
/// </summary>
|
||||
public class AfterSearchingEventArgs : EventArgs
|
||||
/// <remarks>
|
||||
/// Create an AfterSearchingEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="stringToFind"></param>
|
||||
/// <param name="indexSelected"></param>
|
||||
public class AfterSearchingEventArgs(string stringToFind, int indexSelected) : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create an AfterSearchingEventArgs
|
||||
/// </summary>
|
||||
/// <param name="stringToFind"></param>
|
||||
/// <param name="indexSelected"></param>
|
||||
public AfterSearchingEventArgs(string stringToFind, int indexSelected) {
|
||||
this.stringToFind = stringToFind;
|
||||
this.indexSelected = indexSelected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string that was actually searched for
|
||||
@@ -1334,7 +1311,7 @@ namespace BrightIdeasSoftware
|
||||
public string StringToFind {
|
||||
get { return this.stringToFind; }
|
||||
}
|
||||
private string stringToFind;
|
||||
private string stringToFind = stringToFind;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether an the event handler already handled this event
|
||||
@@ -1348,23 +1325,19 @@ namespace BrightIdeasSoftware
|
||||
public int IndexSelected {
|
||||
get { return this.indexSelected; }
|
||||
}
|
||||
private int indexSelected;
|
||||
private int indexSelected = indexSelected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when the user types into a list
|
||||
/// </summary>
|
||||
public class BeforeSearchingEventArgs : CancellableEventArgs
|
||||
/// <remarks>
|
||||
/// Create BeforeSearchingEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="stringToFind"></param>
|
||||
/// <param name="startSearchFrom"></param>
|
||||
public class BeforeSearchingEventArgs(string stringToFind, int startSearchFrom) : CancellableEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create BeforeSearchingEventArgs
|
||||
/// </summary>
|
||||
/// <param name="stringToFind"></param>
|
||||
/// <param name="startSearchFrom"></param>
|
||||
public BeforeSearchingEventArgs(string stringToFind, int startSearchFrom) {
|
||||
this.StringToFind = stringToFind;
|
||||
this.StartSearchFrom = startSearchFrom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the string that will be found by the search routine
|
||||
@@ -1372,12 +1345,12 @@ namespace BrightIdeasSoftware
|
||||
/// <remarks>Modifying this value does not modify the memory of what the user has typed.
|
||||
/// When the user next presses a character, the search string will revert to what
|
||||
/// the user has actually typed.</remarks>
|
||||
public string StringToFind;
|
||||
public string StringToFind = stringToFind;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the first row that will be considered to matching.
|
||||
/// </summary>
|
||||
public int StartSearchFrom;
|
||||
public int StartSearchFrom = startSearchFrom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2035,27 +2008,20 @@ namespace BrightIdeasSoftware
|
||||
return string.Format("NewHotCellHitLocation: {0}, HotCellHitLocationEx: {1}, NewHotColumnIndex: {2}, NewHotRowIndex: {3}, HotGroup: {4}", this.newHotCellHitLocation, this.hotCellHitLocationEx, this.newHotColumnIndex, this.newHotRowIndex, this.hotGroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Let the world know that a checkbox on a subitem is changing
|
||||
/// </summary>
|
||||
public class SubItemCheckingEventArgs : CancellableEventArgs
|
||||
/// <remarks>
|
||||
/// Create a new event block
|
||||
/// </remarks>
|
||||
/// <param name="column"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="subItemIndex"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <param name="newValue"></param>
|
||||
public class SubItemCheckingEventArgs(OLVColumn column, OLVListItem item, int subItemIndex, CheckState currentValue, CheckState newValue) : CancellableEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a new event block
|
||||
/// </summary>
|
||||
/// <param name="column"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="subItemIndex"></param>
|
||||
/// <param name="currentValue"></param>
|
||||
/// <param name="newValue"></param>
|
||||
public SubItemCheckingEventArgs(OLVColumn column, OLVListItem item, int subItemIndex, CheckState currentValue, CheckState newValue) {
|
||||
this.column = column;
|
||||
this.listViewItem = item;
|
||||
this.subItemIndex = subItemIndex;
|
||||
this.currentValue = currentValue;
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The column of the cell that is having its checkbox changed.
|
||||
@@ -2063,7 +2029,7 @@ namespace BrightIdeasSoftware
|
||||
public OLVColumn Column {
|
||||
get { return this.column; }
|
||||
}
|
||||
private OLVColumn column;
|
||||
private OLVColumn column = column;
|
||||
|
||||
/// <summary>
|
||||
/// The model object of the row of the cell that is having its checkbox changed.
|
||||
@@ -2078,7 +2044,7 @@ namespace BrightIdeasSoftware
|
||||
public OLVListItem ListViewItem {
|
||||
get { return this.listViewItem; }
|
||||
}
|
||||
private OLVListItem listViewItem;
|
||||
private OLVListItem listViewItem = item;
|
||||
|
||||
/// <summary>
|
||||
/// The current check state of the cell.
|
||||
@@ -2086,7 +2052,7 @@ namespace BrightIdeasSoftware
|
||||
public CheckState CurrentValue {
|
||||
get { return this.currentValue; }
|
||||
}
|
||||
private CheckState currentValue;
|
||||
private CheckState currentValue = currentValue;
|
||||
|
||||
/// <summary>
|
||||
/// The proposed new check state of the cell.
|
||||
@@ -2095,7 +2061,7 @@ namespace BrightIdeasSoftware
|
||||
get { return this.newValue; }
|
||||
set { this.newValue = value; }
|
||||
}
|
||||
private CheckState newValue;
|
||||
private CheckState newValue = newValue;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the cell that is going to be or has been edited.
|
||||
@@ -2103,21 +2069,18 @@ namespace BrightIdeasSoftware
|
||||
public int SubItemIndex {
|
||||
get { return this.subItemIndex; }
|
||||
}
|
||||
private int subItemIndex;
|
||||
private int subItemIndex = subItemIndex;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This event argument block is used when groups are created for a list.
|
||||
/// </summary>
|
||||
public class CreateGroupsEventArgs : EventArgs
|
||||
/// <remarks>
|
||||
/// Create a CreateGroupsEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="parms"></param>
|
||||
public class CreateGroupsEventArgs(GroupingParameters parms) : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a CreateGroupsEventArgs
|
||||
/// </summary>
|
||||
/// <param name="parms"></param>
|
||||
public CreateGroupsEventArgs(GroupingParameters parms) {
|
||||
this.parameters = parms;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the settings that control the creation of groups
|
||||
@@ -2125,7 +2088,7 @@ namespace BrightIdeasSoftware
|
||||
public GroupingParameters Parameters {
|
||||
get { return this.parameters; }
|
||||
}
|
||||
private GroupingParameters parameters;
|
||||
private GroupingParameters parameters = parms;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the groups that should be used
|
||||
@@ -2151,16 +2114,12 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// This event argument block is used when the text of a group task is clicked
|
||||
/// </summary>
|
||||
public class GroupTaskClickedEventArgs : EventArgs
|
||||
/// <remarks>
|
||||
/// Create a GroupTaskClickedEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="group"></param>
|
||||
public class GroupTaskClickedEventArgs(OLVGroup group) : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a GroupTaskClickedEventArgs
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
public GroupTaskClickedEventArgs(OLVGroup group)
|
||||
{
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets which group was clicked
|
||||
@@ -2169,7 +2128,7 @@ namespace BrightIdeasSoftware
|
||||
{
|
||||
get { return this.group; }
|
||||
}
|
||||
private readonly OLVGroup group;
|
||||
private readonly OLVGroup group = group;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2207,18 +2166,13 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// This event argument block is used when the state of group has changed (collapsed, selected)
|
||||
/// </summary>
|
||||
public class GroupStateChangedEventArgs : EventArgs {
|
||||
/// <summary>
|
||||
/// Create a GroupStateChangedEventArgs
|
||||
/// </summary>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="oldState"> </param>
|
||||
/// <param name="newState"> </param>
|
||||
public GroupStateChangedEventArgs(OLVGroup group, GroupState oldState, GroupState newState) {
|
||||
this.group = group;
|
||||
this.oldState = oldState;
|
||||
this.newState = newState;
|
||||
}
|
||||
/// <remarks>
|
||||
/// Create a GroupStateChangedEventArgs
|
||||
/// </remarks>
|
||||
/// <param name="group"></param>
|
||||
/// <param name="oldState"> </param>
|
||||
/// <param name="newState"> </param>
|
||||
public class GroupStateChangedEventArgs(OLVGroup group, GroupState oldState, GroupState newState) : EventArgs {
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the group was collapsed by this event
|
||||
@@ -2291,7 +2245,7 @@ namespace BrightIdeasSoftware
|
||||
get { return this.group; }
|
||||
}
|
||||
|
||||
private readonly OLVGroup group;
|
||||
private readonly OLVGroup group = group;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the previous state of the group
|
||||
@@ -2300,7 +2254,7 @@ namespace BrightIdeasSoftware
|
||||
get { return this.oldState; }
|
||||
}
|
||||
|
||||
private readonly GroupState oldState;
|
||||
private readonly GroupState oldState = oldState;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -2310,7 +2264,7 @@ namespace BrightIdeasSoftware
|
||||
get { return this.newState; }
|
||||
}
|
||||
|
||||
private readonly GroupState newState;
|
||||
private readonly GroupState newState = newState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -311,18 +311,14 @@ namespace BrightIdeasSoftware
|
||||
/// <remarks>
|
||||
/// Munger uses a chain of these resolve a dotted aspect name.
|
||||
/// </remarks>
|
||||
public class SimpleMunger
|
||||
/// <remarks>
|
||||
/// Create a SimpleMunger
|
||||
/// </remarks>
|
||||
/// <param name="aspectName"></param>
|
||||
public class SimpleMunger(String aspectName)
|
||||
{
|
||||
#region Life and death
|
||||
|
||||
/// <summary>
|
||||
/// Create a SimpleMunger
|
||||
/// </summary>
|
||||
/// <param name="aspectName"></param>
|
||||
public SimpleMunger(String aspectName)
|
||||
{
|
||||
this.aspectName = aspectName;
|
||||
}
|
||||
#region Life and death
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -344,7 +340,7 @@ namespace BrightIdeasSoftware
|
||||
public string AspectName {
|
||||
get { return aspectName; }
|
||||
}
|
||||
private readonly string aspectName;
|
||||
private readonly string aspectName = aspectName;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -494,19 +490,14 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// These exceptions are raised when a munger finds something it cannot process
|
||||
/// </summary>
|
||||
public class MungerException : ApplicationException
|
||||
/// <remarks>
|
||||
/// Create a MungerException
|
||||
/// </remarks>
|
||||
/// <param name="munger"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="ex"></param>
|
||||
public class MungerException(SimpleMunger munger, object target, Exception ex) : ApplicationException("Munger failed", ex)
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a MungerException
|
||||
/// </summary>
|
||||
/// <param name="munger"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="ex"></param>
|
||||
public MungerException(SimpleMunger munger, object target, Exception ex)
|
||||
: base("Munger failed", ex) {
|
||||
this.munger = munger;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the munger that raised the exception
|
||||
@@ -514,7 +505,7 @@ namespace BrightIdeasSoftware
|
||||
public SimpleMunger Munger {
|
||||
get { return munger; }
|
||||
}
|
||||
private readonly SimpleMunger munger;
|
||||
private readonly SimpleMunger munger = munger;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the target that threw the exception
|
||||
@@ -522,7 +513,7 @@ namespace BrightIdeasSoftware
|
||||
public object Target {
|
||||
get { return target; }
|
||||
}
|
||||
private readonly object target;
|
||||
private readonly object target = target;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -309,12 +309,9 @@ namespace BrightIdeasSoftware
|
||||
/// A default implementation of the IOwnerDataCallback interface
|
||||
/// </summary>
|
||||
[Guid("6FC61F50-80E8-49b4-B200-3F38D3865ABD")]
|
||||
internal class OwnerDataCallbackImpl : IOwnerDataCallback
|
||||
internal class OwnerDataCallbackImpl(VirtualObjectListView olv) : IOwnerDataCallback
|
||||
{
|
||||
public OwnerDataCallbackImpl(VirtualObjectListView olv) {
|
||||
this.olv = olv;
|
||||
}
|
||||
VirtualObjectListView olv;
|
||||
VirtualObjectListView olv = olv;
|
||||
|
||||
#region IOwnerDataCallback Members
|
||||
|
||||
|
||||
@@ -145,20 +145,17 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// A do-nothing implementation of the VirtualListDataSource interface.
|
||||
/// </summary>
|
||||
public class AbstractVirtualListDataSource : IVirtualListDataSource, IFilterableDataSource
|
||||
/// <remarks>
|
||||
/// Creates an AbstractVirtualListDataSource
|
||||
/// </remarks>
|
||||
/// <param name="listView"></param>
|
||||
public class AbstractVirtualListDataSource(VirtualObjectListView listView) : IVirtualListDataSource, IFilterableDataSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates an AbstractVirtualListDataSource
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
public AbstractVirtualListDataSource(VirtualObjectListView listView) {
|
||||
this.listView = listView;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The list view that this data source is giving information to.
|
||||
/// </summary>
|
||||
protected VirtualObjectListView listView;
|
||||
protected VirtualObjectListView listView = listView;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -295,15 +292,12 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// This class mimics the behavior of VirtualObjectListView v1.x.
|
||||
/// </summary>
|
||||
public class VirtualListVersion1DataSource : AbstractVirtualListDataSource
|
||||
/// <remarks>
|
||||
/// Creates a VirtualListVersion1DataSource
|
||||
/// </remarks>
|
||||
/// <param name="listView"></param>
|
||||
public class VirtualListVersion1DataSource(VirtualObjectListView listView) : AbstractVirtualListDataSource(listView)
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a VirtualListVersion1DataSource
|
||||
/// </summary>
|
||||
/// <param name="listView"></param>
|
||||
public VirtualListVersion1DataSource(VirtualObjectListView listView)
|
||||
: base(listView) {
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
|
||||
@@ -369,14 +369,8 @@ namespace BrightIdeasSoftware.Design
|
||||
/// only have to modify the returned collection of actions, but we have to implement
|
||||
/// the properties and commands that the returned actions use. </para>
|
||||
/// </remarks>
|
||||
private class ListViewActionListAdapter : DesignerActionList
|
||||
private class ListViewActionListAdapter(ObjectListViewDesigner designer, DesignerActionList wrappedList) : DesignerActionList(wrappedList.Component)
|
||||
{
|
||||
public ListViewActionListAdapter(ObjectListViewDesigner designer, DesignerActionList wrappedList)
|
||||
: base(wrappedList.Component) {
|
||||
this.designer = designer;
|
||||
this.wrappedList = wrappedList;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems() {
|
||||
DesignerActionItemCollection items = wrappedList.GetSortedActionItems();
|
||||
items.RemoveAt(2); // remove Edit Groups
|
||||
@@ -425,21 +419,16 @@ namespace BrightIdeasSoftware.Design
|
||||
set { SetValue(base.Component, "View", value); }
|
||||
}
|
||||
|
||||
ObjectListViewDesigner designer;
|
||||
DesignerActionList wrappedList;
|
||||
ObjectListViewDesigner designer = designer;
|
||||
DesignerActionList wrappedList = wrappedList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DesignerCommandSet
|
||||
|
||||
private class CDDesignerCommandSet : DesignerCommandSet
|
||||
private class CDDesignerCommandSet(ComponentDesigner componentDesigner) : DesignerCommandSet
|
||||
{
|
||||
|
||||
public CDDesignerCommandSet(ComponentDesigner componentDesigner) {
|
||||
this.componentDesigner = componentDesigner;
|
||||
}
|
||||
|
||||
public override ICollection GetCommands(string name) {
|
||||
// Debug.WriteLine("CDDesignerCommandSet.GetCommands:" + name);
|
||||
if (componentDesigner != null) {
|
||||
@@ -453,7 +442,7 @@ namespace BrightIdeasSoftware.Design
|
||||
return base.GetCommands(name);
|
||||
}
|
||||
|
||||
private readonly ComponentDesigner componentDesigner;
|
||||
private readonly ComponentDesigner componentDesigner = componentDesigner;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -463,15 +452,12 @@ namespace BrightIdeasSoftware.Design
|
||||
/// This class works in conjunction with the OLVColumns property to allow OLVColumns
|
||||
/// to be added to the ObjectListView.
|
||||
/// </summary>
|
||||
public class OLVColumnCollectionEditor : System.ComponentModel.Design.CollectionEditor
|
||||
/// <remarks>
|
||||
/// Create a OLVColumnCollectionEditor
|
||||
/// </remarks>
|
||||
/// <param name="t"></param>
|
||||
public class OLVColumnCollectionEditor(Type t) : System.ComponentModel.Design.CollectionEditor(t)
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a OLVColumnCollectionEditor
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
public OLVColumnCollectionEditor(Type t)
|
||||
: base(t) {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What type of object does this editor create?
|
||||
|
||||
@@ -588,6 +588,7 @@ using System.Runtime.Versioning;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Text.Json;
|
||||
|
||||
using MethodInvoker = System.Windows.Forms.MethodInvoker;
|
||||
|
||||
@@ -5869,9 +5870,18 @@ namespace BrightIdeasSoftware
|
||||
// Now that we have stored our state, convert it to a byte array
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
BinaryFormatter serializer = new BinaryFormatter();
|
||||
serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
|
||||
serializer.Serialize(ms, olvState);
|
||||
//BinaryFormatter serializer = new BinaryFormatter();
|
||||
//serializer.AssemblyFormat = FormatterAssemblyStyle.Simple;
|
||||
//serializer.Serialize(ms, olvState);
|
||||
//return ms.ToArray();
|
||||
|
||||
// Use System.Text.Json for serialization instead of BinaryFormatter
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
WriteIndented = false
|
||||
};
|
||||
byte[] serializedData = JsonSerializer.SerializeToUtf8Bytes(olvState, options);
|
||||
ms.Write(serializedData, 0, serializedData.Length);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
@@ -5886,6 +5896,7 @@ namespace BrightIdeasSoftware
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(state))
|
||||
{
|
||||
/*
|
||||
BinaryFormatter deserializer = new BinaryFormatter();
|
||||
ObjectListViewState olvState;
|
||||
try
|
||||
@@ -5925,6 +5936,45 @@ namespace BrightIdeasSoftware
|
||||
this.RebuildColumns();
|
||||
else
|
||||
this.View = olvState.CurrentView;
|
||||
*/
|
||||
ObjectListViewState olvState;
|
||||
try
|
||||
{
|
||||
olvState = JsonSerializer.Deserialize<ObjectListViewState>(ms.ToArray());
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// The number of columns has changed. We have no way to match old
|
||||
// columns to the new ones, so we just give up.
|
||||
if (olvState == null || olvState.NumberOfColumns != this.AllColumns.Count)
|
||||
return false;
|
||||
if (olvState.SortColumn == -1)
|
||||
{
|
||||
this.PrimarySortColumn = null;
|
||||
this.PrimarySortOrder = SortOrder.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.PrimarySortColumn = this.AllColumns[olvState.SortColumn];
|
||||
this.PrimarySortOrder = olvState.LastSortOrder;
|
||||
}
|
||||
for (int i = 0; i < olvState.NumberOfColumns; i++)
|
||||
{
|
||||
OLVColumn column = this.AllColumns[i];
|
||||
column.Width = (int)olvState.ColumnWidths[i];
|
||||
column.IsVisible = (bool)olvState.ColumnIsVisible[i];
|
||||
column.LastDisplayIndex = (int)olvState.ColumnDisplayIndicies[i];
|
||||
}
|
||||
// ReSharper disable RedundantCheckBeforeAssignment
|
||||
if (olvState.IsShowingGroups != this.ShowGroups)
|
||||
// ReSharper restore RedundantCheckBeforeAssignment
|
||||
this.ShowGroups = olvState.IsShowingGroups;
|
||||
if (this.View == olvState.CurrentView)
|
||||
this.RebuildColumns();
|
||||
else
|
||||
this.View = olvState.CurrentView;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -231,15 +231,12 @@ namespace BrightIdeasSoftware {
|
||||
/// This class provides compatibility for v1 RendererDelegates
|
||||
/// </summary>
|
||||
[ToolboxItem(false)]
|
||||
internal class Version1Renderer : AbstractRenderer {
|
||||
public Version1Renderer(RenderDelegate renderDelegate) {
|
||||
this.RenderDelegate = renderDelegate;
|
||||
}
|
||||
internal class Version1Renderer(RenderDelegate renderDelegate) : AbstractRenderer {
|
||||
|
||||
/// <summary>
|
||||
/// The renderer delegate that this renderer wraps
|
||||
/// </summary>
|
||||
public RenderDelegate RenderDelegate;
|
||||
public RenderDelegate RenderDelegate = renderDelegate;
|
||||
|
||||
#region IRenderer Members
|
||||
|
||||
|
||||
@@ -51,17 +51,20 @@
|
||||
* If you wish to use this code in a closed source application, please contact phillip.piper@gmail.com.
|
||||
*/
|
||||
|
||||
using BrightIdeasSoftware.Properties;
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
using System.Drawing.Drawing2D;
|
||||
using BrightIdeasSoftware.Properties;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace BrightIdeasSoftware
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
/// <summary>
|
||||
/// Class used to capture window messages for the header of the list view
|
||||
/// control.
|
||||
|
||||
@@ -40,11 +40,13 @@ using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BrightIdeasSoftware
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
/// <summary>
|
||||
/// A limited wrapper around a Windows tooltip window.
|
||||
/// </summary>
|
||||
|
||||
@@ -2180,15 +2180,12 @@ namespace BrightIdeasSoftware
|
||||
/// <summary>
|
||||
/// This class sorts branches according to how their respective model objects are sorted
|
||||
/// </summary>
|
||||
public class BranchComparer : IComparer<Branch>
|
||||
/// <remarks>
|
||||
/// Create a BranchComparer
|
||||
/// </remarks>
|
||||
/// <param name="actualComparer"></param>
|
||||
public class BranchComparer(IComparer actualComparer) : IComparer<Branch>
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a BranchComparer
|
||||
/// </summary>
|
||||
/// <param name="actualComparer"></param>
|
||||
public BranchComparer(IComparer actualComparer) {
|
||||
this.actualComparer = actualComparer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Order the two branches
|
||||
@@ -2200,7 +2197,7 @@ namespace BrightIdeasSoftware
|
||||
return this.actualComparer.Compare(x.Model, y.Model);
|
||||
}
|
||||
|
||||
private readonly IComparer actualComparer;
|
||||
private readonly IComparer actualComparer = actualComparer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -233,13 +233,9 @@ namespace BrightIdeasSoftware
|
||||
/// A Comparer that will sort a list of columns so that visible ones come before hidden ones,
|
||||
/// and that are ordered by their display order.
|
||||
/// </summary>
|
||||
private class SortByDisplayOrder : IComparer<OLVColumn>
|
||||
private class SortByDisplayOrder(ColumnSelectionForm form) : IComparer<OLVColumn>
|
||||
{
|
||||
public SortByDisplayOrder(ColumnSelectionForm form)
|
||||
{
|
||||
this.Form = form;
|
||||
}
|
||||
private ColumnSelectionForm Form;
|
||||
private ColumnSelectionForm Form = form;
|
||||
|
||||
#region IComparer<OLVColumn> Members
|
||||
|
||||
|
||||
@@ -72,15 +72,12 @@ namespace BrightIdeasSoftware
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public class TypedObjectListView<T> where T : class
|
||||
/// <remarks>
|
||||
/// Create a typed wrapper around the given list.
|
||||
/// </remarks>
|
||||
/// <param name="olv">The listview to be wrapped</param>
|
||||
public class TypedObjectListView<T>(ObjectListView olv) where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a typed wrapper around the given list.
|
||||
/// </summary>
|
||||
/// <param name="olv">The listview to be wrapped</param>
|
||||
public TypedObjectListView(ObjectListView olv) {
|
||||
this.olv = olv;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Properties
|
||||
@@ -115,7 +112,7 @@ namespace BrightIdeasSoftware
|
||||
get { return olv; }
|
||||
set { olv = value; }
|
||||
}
|
||||
private ObjectListView olv;
|
||||
private ObjectListView olv = olv;
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the list of all model objects
|
||||
@@ -325,16 +322,13 @@ namespace BrightIdeasSoftware
|
||||
/// A type-safe wrapper around an OLVColumn
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class TypedColumn<T> where T : class
|
||||
/// <remarks>
|
||||
/// Creates a TypedColumn
|
||||
/// </remarks>
|
||||
/// <param name="column"></param>
|
||||
public class TypedColumn<T>(OLVColumn column) where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a TypedColumn
|
||||
/// </summary>
|
||||
/// <param name="column"></param>
|
||||
public TypedColumn(OLVColumn column) {
|
||||
this.column = column;
|
||||
}
|
||||
private OLVColumn column;
|
||||
private OLVColumn column = column;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
||||
@@ -9,14 +9,9 @@ using mRemoteNG.Resources.Language;
|
||||
namespace mRemoteNG.App.Initialization
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class StartupDataLogger
|
||||
public class StartupDataLogger(MessageCollector messageCollector)
|
||||
{
|
||||
private readonly MessageCollector _messageCollector;
|
||||
|
||||
public StartupDataLogger(MessageCollector messageCollector)
|
||||
{
|
||||
_messageCollector = messageCollector ?? throw new ArgumentNullException(nameof(messageCollector));
|
||||
}
|
||||
private readonly MessageCollector _messageCollector = messageCollector ?? throw new ArgumentNullException(nameof(messageCollector));
|
||||
|
||||
public void LogStartupData()
|
||||
{
|
||||
|
||||
@@ -19,22 +19,16 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlConnectionsLoader : IConnectionsLoader
|
||||
public class SqlConnectionsLoader(
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDataProvider<string> dataProvider) : IConnectionsLoader
|
||||
{
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> _localConnectionPropertiesDeserializer;
|
||||
private readonly IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> _localConnectionPropertiesDeserializer = localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
private readonly IDataProvider<string> _dataProvider = dataProvider.ThrowIfNull(nameof(dataProvider));
|
||||
|
||||
private Func<Optional<SecureString>> AuthenticationRequestor { get; set; } = () => MiscTools.PasswordDialog("", false);
|
||||
|
||||
public SqlConnectionsLoader(
|
||||
IDeserializer<string, IEnumerable<LocalConnectionPropertiesModel>> localConnectionPropertiesDeserializer,
|
||||
IDataProvider<string> dataProvider)
|
||||
{
|
||||
_localConnectionPropertiesDeserializer = localConnectionPropertiesDeserializer.ThrowIfNull(nameof(localConnectionPropertiesDeserializer));
|
||||
_dataProvider = dataProvider.ThrowIfNull(nameof(dataProvider));
|
||||
}
|
||||
|
||||
public ConnectionTreeModel Load()
|
||||
{
|
||||
IDatabaseConnector connector = DatabaseConnectorFactory.DatabaseConnectorFromSettings();
|
||||
|
||||
@@ -23,18 +23,11 @@ using mRemoteNG.Config.Serializers.ConnectionSerializers.Sql;
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlConnectionsSaver : ISaver<ConnectionTreeModel>
|
||||
public class SqlConnectionsSaver(SaveFilter saveFilter, ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> localPropertieSerializer, IDataProvider<string> localPropertiesDataProvider) : ISaver<ConnectionTreeModel>
|
||||
{
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer;
|
||||
private readonly IDataProvider<string> _dataProvider;
|
||||
|
||||
public SqlConnectionsSaver(SaveFilter saveFilter, ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> localPropertieSerializer, IDataProvider<string> localPropertiesDataProvider)
|
||||
{
|
||||
_saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
_localPropertiesSerializer = localPropertieSerializer.ThrowIfNull(nameof(localPropertieSerializer));
|
||||
_dataProvider = localPropertiesDataProvider.ThrowIfNull(nameof(localPropertiesDataProvider));
|
||||
}
|
||||
private readonly SaveFilter _saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
private readonly ISerializer<IEnumerable<LocalConnectionPropertiesModel>, string> _localPropertiesSerializer = localPropertieSerializer.ThrowIfNull(nameof(localPropertieSerializer));
|
||||
private readonly IDataProvider<string> _dataProvider = localPropertiesDataProvider.ThrowIfNull(nameof(localPropertiesDataProvider));
|
||||
|
||||
public void Save(ConnectionTreeModel connectionTreeModel, string propertyNameTrigger = "")
|
||||
{
|
||||
|
||||
@@ -6,15 +6,10 @@ using mRemoteNG.App;
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class FileDataProvider : IDataProvider<string>
|
||||
public class FileDataProvider(string filePath) : IDataProvider<string>
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public string FilePath { get; set; }
|
||||
|
||||
public FileDataProvider(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
}
|
||||
public string FilePath { get; set; } = filePath;
|
||||
|
||||
public virtual string Load()
|
||||
{
|
||||
|
||||
@@ -3,14 +3,9 @@
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class FileDataProviderWithRollingBackup : FileDataProvider
|
||||
public class FileDataProviderWithRollingBackup(string filePath) : FileDataProvider(filePath)
|
||||
{
|
||||
private readonly FileBackupCreator _fileBackupCreator;
|
||||
|
||||
public FileDataProviderWithRollingBackup(string filePath) : base(filePath)
|
||||
{
|
||||
_fileBackupCreator = new FileBackupCreator();
|
||||
}
|
||||
private readonly FileBackupCreator _fileBackupCreator = new FileBackupCreator();
|
||||
|
||||
public override void Save(string content)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
public class InMemoryStringDataProvider : IDataProvider<string>
|
||||
public class InMemoryStringDataProvider(string initialContents = "") : IDataProvider<string>
|
||||
{
|
||||
private string _contents;
|
||||
|
||||
public InMemoryStringDataProvider(string initialContents = "")
|
||||
{
|
||||
_contents = initialContents;
|
||||
}
|
||||
private string _contents = initialContents;
|
||||
|
||||
public string Load()
|
||||
{
|
||||
|
||||
@@ -9,14 +9,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.DataProviders
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlDataProvider : IDataProvider<DataTable>
|
||||
public class SqlDataProvider(IDatabaseConnector databaseConnector) : IDataProvider<DataTable>
|
||||
{
|
||||
public IDatabaseConnector DatabaseConnector { get; }
|
||||
|
||||
public SqlDataProvider(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
DatabaseConnector = databaseConnector;
|
||||
}
|
||||
public IDatabaseConnector DatabaseConnector { get; } = databaseConnector;
|
||||
|
||||
public DataTable Load()
|
||||
{
|
||||
|
||||
@@ -17,21 +17,40 @@ namespace mRemoteNG.Config.DatabaseConnectors
|
||||
|
||||
public class DatabaseConnectionTester
|
||||
{
|
||||
//string connectionString = "Data Source=172.22.155.100,1433;Initial Catalog=Demo;User ID=sa;Password=London123";
|
||||
|
||||
public static void TestConnection(string connectionString)
|
||||
public async Task<ConnectionTestResult> TestConnectivity(string type, string server, string database, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Build the connection string based on the provided parameters
|
||||
string connectionString = $"Data Source={server};Initial Catalog={database};User ID={username};Password={password}";
|
||||
|
||||
// Attempt to open a connection to the database
|
||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
Console.WriteLine("Connection successful!");
|
||||
await connection.OpenAsync();
|
||||
}
|
||||
|
||||
return ConnectionTestResult.ConnectionSucceded;
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
// Handle specific SQL exceptions
|
||||
switch (ex.Number)
|
||||
{
|
||||
case 4060: // Invalid Database
|
||||
return ConnectionTestResult.UnknownDatabase;
|
||||
case 18456: // Login Failed
|
||||
return ConnectionTestResult.CredentialsRejected;
|
||||
case -1: // Server not accessible
|
||||
return ConnectionTestResult.ServerNotAccessible;
|
||||
default:
|
||||
return ConnectionTestResult.UnknownError;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
Console.WriteLine($"Connection failed: {ex.Message}");
|
||||
// Handle any other exceptions
|
||||
return ConnectionTestResult.UnknownError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,9 @@ using mRemoteNG.Tools;
|
||||
namespace mRemoteNG.Config.Import
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class PortScanImporter : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
public class PortScanImporter(ProtocolType targetProtocolType) : IConnectionImporter<IEnumerable<ScanHost>>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
public PortScanImporter(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
private readonly ProtocolType _targetProtocolType = targetProtocolType;
|
||||
|
||||
public void Import(IEnumerable<ScanHost> hosts, ContainerInfo destinationContainer)
|
||||
{
|
||||
|
||||
@@ -4,13 +4,8 @@ using mRemoteNG.Connection;
|
||||
|
||||
namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public class PuttySessionChangedEventArgs : EventArgs
|
||||
public class PuttySessionChangedEventArgs(PuttySessionInfo sessionChanged = null) : EventArgs
|
||||
{
|
||||
public PuttySessionInfo Session { get; set; }
|
||||
|
||||
public PuttySessionChangedEventArgs(PuttySessionInfo sessionChanged = null)
|
||||
{
|
||||
Session = sessionChanged;
|
||||
}
|
||||
public PuttySessionInfo Session { get; set; } = sessionChanged;
|
||||
}
|
||||
}
|
||||
@@ -135,17 +135,17 @@ namespace mRemoteNG.Config.Putty
|
||||
{
|
||||
public static string[] Names => Instance.GetSessionNames();
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(Names);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,16 +21,10 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class DataTableDeserializer : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
public class DataTableDeserializer(ICryptographyProvider cryptographyProvider, SecureString decryptionKey) : IDeserializer<DataTable, ConnectionTreeModel>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _decryptionKey;
|
||||
|
||||
public DataTableDeserializer(ICryptographyProvider cryptographyProvider, SecureString decryptionKey)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_decryptionKey = decryptionKey.ThrowIfNull(nameof(decryptionKey));
|
||||
}
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
private readonly SecureString _decryptionKey = decryptionKey.ThrowIfNull(nameof(decryptionKey));
|
||||
|
||||
public ConnectionTreeModel Deserialize(DataTable table)
|
||||
{
|
||||
|
||||
@@ -14,27 +14,20 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Sql
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class DataTableSerializer : ISerializer<ConnectionInfo, DataTable>
|
||||
public class DataTableSerializer(SaveFilter saveFilter, ICryptographyProvider cryptographyProvider, SecureString encryptionKey) : ISerializer<ConnectionInfo, DataTable>
|
||||
{
|
||||
private const int DELETE = 0;
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
private readonly SecureString _encryptionKey = encryptionKey.ThrowIfNull(nameof(encryptionKey));
|
||||
private DataTable _dataTable;
|
||||
private DataTable _sourceDataTable;
|
||||
private readonly Dictionary<string, int> _sourcePrimaryKeyDict = [];
|
||||
private const string TABLE_NAME = "tblCons";
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly SaveFilter _saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
private int _currentNodeIndex;
|
||||
|
||||
public Version Version { get; } = new Version(3, 0);
|
||||
|
||||
public DataTableSerializer(SaveFilter saveFilter, ICryptographyProvider cryptographyProvider, SecureString encryptionKey)
|
||||
{
|
||||
_saveFilter = saveFilter.ThrowIfNull(nameof(saveFilter));
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_encryptionKey = encryptionKey.ThrowIfNull(nameof(encryptionKey));
|
||||
}
|
||||
|
||||
public void SetSourceDataTable(DataTable sourceDataTable)
|
||||
{
|
||||
_sourceDataTable = sourceDataTable;
|
||||
|
||||
@@ -11,23 +11,16 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class XmlConnectionNodeSerializer27 : ISerializer<ConnectionInfo, XElement>
|
||||
public class XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter) : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
private readonly SecureString _encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
|
||||
private readonly SaveFilter _saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
|
||||
public Version Version { get; } = new Version(2, 7);
|
||||
|
||||
public XmlConnectionNodeSerializer27(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
_encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
|
||||
_saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
}
|
||||
|
||||
public XElement Serialize(ConnectionInfo connectionInfo)
|
||||
{
|
||||
XElement element = new(XName.Get("Node", ""));
|
||||
|
||||
@@ -11,23 +11,16 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class XmlConnectionNodeSerializer28 : ISerializer<ConnectionInfo, XElement>
|
||||
public class XmlConnectionNodeSerializer28(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter) : ISerializer<ConnectionInfo, XElement>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly SecureString _encryptionKey;
|
||||
private readonly SaveFilter _saveFilter;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
private readonly SecureString _encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
|
||||
private readonly SaveFilter _saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
|
||||
public Version Version { get; } = new Version(2, 8);
|
||||
|
||||
public XmlConnectionNodeSerializer28(ICryptographyProvider cryptographyProvider,
|
||||
SecureString encryptionKey,
|
||||
SaveFilter saveFilter)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
_encryptionKey = encryptionKey ?? throw new ArgumentNullException(nameof(encryptionKey));
|
||||
_saveFilter = saveFilter ?? throw new ArgumentNullException(nameof(saveFilter));
|
||||
}
|
||||
|
||||
public XElement Serialize(ConnectionInfo connectionInfo)
|
||||
{
|
||||
XElement element = new(XName.Get("Node", ""));
|
||||
|
||||
@@ -12,17 +12,11 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class XmlConnectionsDocumentCompiler
|
||||
public class XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
private SecureString _encryptionKey;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer;
|
||||
|
||||
public XmlConnectionsDocumentCompiler(ICryptographyProvider cryptographyProvider, ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider ?? throw new ArgumentNullException(nameof(cryptographyProvider));
|
||||
_connectionNodeSerializer = connectionNodeSerializer ?? throw new ArgumentNullException(nameof(connectionNodeSerializer));
|
||||
}
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer = connectionNodeSerializer ?? throw new ArgumentNullException(nameof(connectionNodeSerializer));
|
||||
|
||||
public XDocument CompileDocument(ConnectionTreeModel connectionTreeModel, bool fullFileEncryption)
|
||||
{
|
||||
|
||||
@@ -4,14 +4,9 @@ using mRemoteNG.Security;
|
||||
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
public class XmlConnectionsDocumentEncryptor
|
||||
public class XmlConnectionsDocumentEncryptor(ICryptographyProvider cryptographyProvider)
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
|
||||
public XmlConnectionsDocumentEncryptor(ICryptographyProvider cryptographyProvider)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider;
|
||||
}
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider;
|
||||
|
||||
public XDocument EncryptDocument(XDocument documentToEncrypt, SecureString encryptionKey)
|
||||
{
|
||||
|
||||
@@ -14,22 +14,16 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class XmlConnectionsSerializer : ISerializer<ConnectionTreeModel, string>,
|
||||
public class XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer) : ISerializer<ConnectionTreeModel, string>,
|
||||
ISerializer<ConnectionInfo, string>
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider;
|
||||
private readonly ISerializer<ConnectionInfo, XElement> _connectionNodeSerializer = connectionNodeSerializer;
|
||||
|
||||
public Version Version => _connectionNodeSerializer.Version;
|
||||
public bool UseFullEncryption { get; set; }
|
||||
|
||||
public XmlConnectionsSerializer(ICryptographyProvider cryptographyProvider,
|
||||
ISerializer<ConnectionInfo, XElement> connectionNodeSerializer)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider;
|
||||
_connectionNodeSerializer = connectionNodeSerializer;
|
||||
}
|
||||
|
||||
public string Serialize(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
RootNodeInfo rootNode = (RootNodeInfo)connectionTreeModel.RootNodes.First(node => node is RootNodeInfo);
|
||||
|
||||
@@ -15,16 +15,10 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.MiscSerializers
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ActiveDirectoryDeserializer
|
||||
public class ActiveDirectoryDeserializer(string ldapPath, bool importSubOu)
|
||||
{
|
||||
private readonly string _ldapPath;
|
||||
private readonly bool _importSubOu;
|
||||
|
||||
public ActiveDirectoryDeserializer(string ldapPath, bool importSubOu)
|
||||
{
|
||||
_ldapPath = ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
_importSubOu = importSubOu;
|
||||
}
|
||||
private readonly string _ldapPath = ldapPath.ThrowIfNullOrEmpty(nameof(ldapPath));
|
||||
private readonly bool _importSubOu = importSubOu;
|
||||
|
||||
public ConnectionTreeModel Deserialize()
|
||||
{
|
||||
|
||||
@@ -10,14 +10,9 @@ using mRemoteNG.Tree.Root;
|
||||
namespace mRemoteNG.Config.Serializers.MiscSerializers
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class PortScanDeserializer : IDeserializer<IEnumerable<ScanHost>, ConnectionTreeModel>
|
||||
public class PortScanDeserializer(ProtocolType targetProtocolType) : IDeserializer<IEnumerable<ScanHost>, ConnectionTreeModel>
|
||||
{
|
||||
private readonly ProtocolType _targetProtocolType;
|
||||
|
||||
public PortScanDeserializer(ProtocolType targetProtocolType)
|
||||
{
|
||||
_targetProtocolType = targetProtocolType;
|
||||
}
|
||||
private readonly ProtocolType _targetProtocolType = targetProtocolType;
|
||||
|
||||
public ConnectionTreeModel Deserialize(IEnumerable<ScanHost> scannedHosts)
|
||||
{
|
||||
|
||||
@@ -9,16 +9,11 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlDatabaseVersionVerifier
|
||||
public class SqlDatabaseVersionVerifier(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
private readonly Version _currentSupportedVersion = new(3, 0);
|
||||
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlDatabaseVersionVerifier(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool VerifyDatabaseVersion(Version dbVersion)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion22To23Upgrader : IVersionUpgrader
|
||||
public class SqlVersion22To23Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion22To23Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion23To24Upgrader : IVersionUpgrader
|
||||
public class SqlVersion23To24Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion23To24Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion24To25Upgrader : IVersionUpgrader
|
||||
public class SqlVersion24To25Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion24To25Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion25To26Upgrader : IVersionUpgrader
|
||||
public class SqlVersion25To26Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion25To26Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -8,14 +8,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion26To27Upgrader : IVersionUpgrader
|
||||
public class SqlVersion26To27Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion26To27Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -9,14 +9,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion27To28Upgrader : IVersionUpgrader
|
||||
public class SqlVersion27To28Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion27To28Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -8,15 +8,10 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion28To29Upgrader : IVersionUpgrader
|
||||
public class SqlVersion28To29Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly Version _version = new(2, 9);
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion28To29Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -8,15 +8,10 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Config.Serializers.Versioning
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SqlVersion29To30Upgrader : IVersionUpgrader
|
||||
public class SqlVersion29To30Upgrader(IDatabaseConnector databaseConnector) : IVersionUpgrader
|
||||
{
|
||||
private readonly Version _version = new(3, 0);
|
||||
private readonly IDatabaseConnector _databaseConnector;
|
||||
|
||||
public SqlVersion29To30Upgrader(IDatabaseConnector databaseConnector)
|
||||
{
|
||||
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
}
|
||||
private readonly IDatabaseConnector _databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
|
||||
|
||||
public bool CanUpgrade(Version currentVersion)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// The MIT License (MIT)
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright(c) crdx
|
||||
//
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Security;
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public abstract class AbstractConnectionRecord : INotifyPropertyChanged
|
||||
public abstract class AbstractConnectionRecord(string uniqueId) : INotifyPropertyChanged
|
||||
{
|
||||
#region Fields
|
||||
|
||||
@@ -829,7 +829,7 @@ namespace mRemoteNG.Connection
|
||||
|
||||
#region Misc
|
||||
|
||||
[Browsable(false)] public string ConstantID { get; }
|
||||
[Browsable(false)] public string ConstantID { get; } = uniqueId.ThrowIfNullOrEmpty(nameof(uniqueId));
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory(nameof(Language.Miscellaneous), 7),
|
||||
LocalizedAttributes.LocalizedDisplayName(nameof(Language.ExternalToolBefore)),
|
||||
@@ -1032,20 +1032,14 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
protected AbstractConnectionRecord(string uniqueId)
|
||||
{
|
||||
ConstantID = uniqueId.ThrowIfNullOrEmpty(nameof(uniqueId));
|
||||
}
|
||||
|
||||
protected virtual TPropertyType GetPropertyValue<TPropertyType>(string propertyName, TPropertyType value)
|
||||
{
|
||||
return (TPropertyType)GetType().GetProperty(propertyName)?.GetValue(this, null);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
|
||||
@@ -12,22 +12,22 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
public static string[] Icons = { };
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
return new StandardValuesCollection(Icons);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static System.Drawing.Icon FromString(string iconName)
|
||||
public static System.Drawing.Icon? FromString(string iconName)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,7 +41,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, $"Couldn\'t get Icon from String" + Environment.NewLine + ex.Message);
|
||||
Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, $"Couldn't get Icon from String" + Environment.NewLine + ex.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -6,18 +6,17 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ConnectionInfoComparer<TProperty> : IComparer<ConnectionInfo> where TProperty : IComparable<TProperty>
|
||||
public class ConnectionInfoComparer<TProperty>(Func<ConnectionInfo, TProperty> sortExpression) : IComparer<ConnectionInfo> where TProperty : IComparable<TProperty>
|
||||
{
|
||||
private readonly Func<ConnectionInfo, TProperty> _sortExpression;
|
||||
private readonly Func<ConnectionInfo, TProperty> _sortExpression = sortExpression;
|
||||
public ListSortDirection SortDirection { get; set; } = ListSortDirection.Ascending;
|
||||
|
||||
public ConnectionInfoComparer(Func<ConnectionInfo, TProperty> sortExpression)
|
||||
public int Compare(ConnectionInfo? x, ConnectionInfo? y)
|
||||
{
|
||||
_sortExpression = sortExpression;
|
||||
}
|
||||
if (x == null && y == null) return 0;
|
||||
if (x == null) return SortDirection == ListSortDirection.Ascending ? -1 : 1;
|
||||
if (y == null) return SortDirection == ListSortDirection.Ascending ? 1 : -1;
|
||||
|
||||
public int Compare(ConnectionInfo x, ConnectionInfo y)
|
||||
{
|
||||
return SortDirection == ListSortDirection.Ascending ? CompareAscending(x, y) : CompareDescending(x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ using mRemoteNG.Config.Serializers.ConnectionSerializers.Sql;
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ConnectionsService
|
||||
public class ConnectionsService(PuttySessionsManager puttySessionsManager)
|
||||
{
|
||||
private static readonly object SaveLock = new();
|
||||
private readonly PuttySessionsManager _puttySessionsManager;
|
||||
private readonly IDataProvider<string> _localConnectionPropertiesDataProvider;
|
||||
private readonly LocalConnectionPropertiesXmlSerializer _localConnectionPropertiesSerializer;
|
||||
private readonly PuttySessionsManager _puttySessionsManager = puttySessionsManager ?? throw new ArgumentNullException(nameof(puttySessionsManager));
|
||||
private readonly IDataProvider<string> _localConnectionPropertiesDataProvider = new FileDataProvider(Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.LocalConnectionProperties));
|
||||
private readonly LocalConnectionPropertiesXmlSerializer _localConnectionPropertiesSerializer = new LocalConnectionPropertiesXmlSerializer();
|
||||
private bool _batchingSaves = false;
|
||||
private bool _saveRequested = false;
|
||||
private bool _saveAsyncRequested = false;
|
||||
@@ -42,13 +42,6 @@ namespace mRemoteNG.Connection
|
||||
|
||||
public ConnectionTreeModel ConnectionTreeModel { get; private set; }
|
||||
|
||||
public ConnectionsService(PuttySessionsManager puttySessionsManager)
|
||||
{
|
||||
_puttySessionsManager = puttySessionsManager ?? throw new ArgumentNullException(nameof(puttySessionsManager));
|
||||
_localConnectionPropertiesDataProvider = new FileDataProvider(Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.LocalConnectionProperties));
|
||||
_localConnectionPropertiesSerializer = new LocalConnectionPropertiesXmlSerializer();
|
||||
}
|
||||
|
||||
public void NewConnectionsFile(string filename)
|
||||
{
|
||||
try
|
||||
|
||||
19
mRemoteNG/Connection/InterfaceControl.Designer.cs
generated
19
mRemoteNG/Connection/InterfaceControl.Designer.cs
generated
@@ -1,4 +1,4 @@
|
||||
namespace mRemoteNG.Connection
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public sealed partial class InterfaceControl : System.Windows.Forms.Panel
|
||||
{
|
||||
@@ -21,14 +21,11 @@ namespace mRemoteNG.Connection
|
||||
|
||||
//Required by the Windows Form Designer
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
//NOTE: The following procedure is required by the Windows Form Designer
|
||||
//It can be modified using the Windows Form Designer.
|
||||
//Do not modify it using the code editor.
|
||||
[System.Diagnostics.DebuggerStepThrough()]
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
}
|
||||
|
||||
//NOTE: The following procedure is required by the Windows Form Designer
|
||||
//It can be modified using the Windows Form Designer.
|
||||
//Do not modify it using the code editor.
|
||||
[System.Diagnostics.DebuggerStepThrough()]
|
||||
private void InitializeComponent() => components = new System.ComponentModel.Container();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.Connection.Protocol
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ProtocolList : CollectionBase, INotifyCollectionChanged
|
||||
{
|
||||
public ProtocolBase this[object index]
|
||||
@@ -23,7 +25,6 @@ namespace mRemoteNG.Connection.Protocol
|
||||
|
||||
public new int Count => List.Count;
|
||||
|
||||
|
||||
public void Add(ProtocolBase cProt)
|
||||
{
|
||||
List.Add(cProt);
|
||||
@@ -64,7 +65,7 @@ namespace mRemoteNG.Connection.Protocol
|
||||
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
public event NotifyCollectionChangedEventHandler? CollectionChanged; // Fix for CS8612: Declare the event as nullable to match the interface.
|
||||
|
||||
private void RaiseCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace mRemoteNG.Connection
|
||||
|
||||
[Browsable(false)] public RootPuttySessionsNodeInfo RootRootPuttySessionsInfo { get; set; }
|
||||
|
||||
[ReadOnly(true)] public override string PuttySession { get; set; }
|
||||
[ReadOnly(true)] public override string PuttySession { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true)] public override string Name { get; set; }
|
||||
[ReadOnly(true)] public override string Name { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true), Browsable(false)] public override string Description { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string Description { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true), Browsable(false)]
|
||||
public override string Icon
|
||||
@@ -39,24 +39,24 @@ namespace mRemoteNG.Connection
|
||||
set { }
|
||||
}
|
||||
|
||||
[ReadOnly(true)] public override string Hostname { get; set; }
|
||||
[ReadOnly(true)] public override string Hostname { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true)] public override string Username { get; set; }
|
||||
[ReadOnly(true)] public override string Username { get; set; } = string.Empty;
|
||||
|
||||
//[ReadOnly(true), Browsable(false)] public override SecureString Password { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string Password { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string Password { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true)] public override ProtocolType Protocol { get; set; }
|
||||
|
||||
[ReadOnly(true)] public override int Port { get; set; }
|
||||
|
||||
[ReadOnly(true), Browsable(false)] public override string PreExtApp { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string PreExtApp { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true), Browsable(false)] public override string PostExtApp { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string PostExtApp { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true), Browsable(false)] public override string MacAddress { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string MacAddress { get; set; } = string.Empty;
|
||||
|
||||
[ReadOnly(true), Browsable(false)] public override string UserField { get; set; }
|
||||
[ReadOnly(true), Browsable(false)] public override string UserField { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace mRemoteNG.Container
|
||||
childAsContainer.CollectionChanged -= RaiseCollectionChangedEvent;
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
||||
|
||||
private void RaiseCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
|
||||
namespace mRemoteNG.Credential
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class CredentialDomainUserComparer : IComparer<ICredentialRecord>, IEqualityComparer<ICredentialRecord>
|
||||
{
|
||||
public int Compare(ICredentialRecord x, ICredentialRecord y)
|
||||
public int Compare(ICredentialRecord? x, ICredentialRecord? y)
|
||||
{
|
||||
if (x == null && y == null) return 0;
|
||||
if (x == null) return -1;
|
||||
if (y == null) return 1;
|
||||
|
||||
CaseInsensitiveComparer comparer = new();
|
||||
return comparer.Compare($"{x.Domain}\\{x.Username}", $"{y.Domain}\\{y.Username}");
|
||||
}
|
||||
|
||||
public bool Equals(ICredentialRecord x, ICredentialRecord y)
|
||||
public bool Equals(ICredentialRecord? x, ICredentialRecord? y)
|
||||
{
|
||||
return Compare(x, y) == 0;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace mRemoteNG.Credential
|
||||
return Title;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void RaisePropertyChangedEvent(string propertyName)
|
||||
{
|
||||
|
||||
@@ -11,17 +11,12 @@ namespace mRemoteNG.Credential
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class CredentialRecordTypeConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(Guid) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return destinationType == typeof(Guid) || destinationType == typeof(ICredentialRecord) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (value is ICredentialRecord && destinationType == typeof(Guid))
|
||||
return ((ICredentialRecord)value).Id;
|
||||
@@ -30,7 +25,7 @@ namespace mRemoteNG.Credential
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
|
||||
{
|
||||
if (!(value is Guid)) return base.ConvertFrom(context, culture, value);
|
||||
ICredentialRecord[] matchedCredentials = Runtime.CredentialProviderCatalog.GetCredentialRecords()
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace mRemoteNG.Credential
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class PlaceholderCredentialRecord(IEnumerable<Guid> id) : ICredentialRecord
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public Guid Id { get; } = id.FirstOrDefault();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Security;
|
||||
|
||||
namespace mRemoteNG.Credential.Repositories
|
||||
{
|
||||
public class CredentialRepositoryConfig : ICredentialRepositoryConfig
|
||||
public class CredentialRepositoryConfig(Guid id) : ICredentialRepositoryConfig
|
||||
{
|
||||
private string _title = "New Credential Repository";
|
||||
private string _source = "";
|
||||
@@ -12,7 +12,7 @@ namespace mRemoteNG.Credential.Repositories
|
||||
private string _typeName = "";
|
||||
private bool _loaded;
|
||||
|
||||
public Guid Id { get; }
|
||||
public Guid Id { get; } = id;
|
||||
|
||||
public string Title
|
||||
{
|
||||
@@ -68,12 +68,7 @@ namespace mRemoteNG.Credential.Repositories
|
||||
{
|
||||
}
|
||||
|
||||
public CredentialRepositoryConfig(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void RaisePropertyChangedEvent(string propertyName)
|
||||
{
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace mRemoteNG.Messages
|
||||
{
|
||||
public class Message : IMessage
|
||||
public class Message(MessageClass messageClass, string messageText, bool onlyLog = false) : IMessage
|
||||
{
|
||||
public MessageClass Class { get; set; }
|
||||
public string Text { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public bool OnlyLog { get; set; }
|
||||
|
||||
public Message(MessageClass messageClass, string messageText, bool onlyLog = false)
|
||||
{
|
||||
Class = messageClass;
|
||||
Text = messageText;
|
||||
Date = DateTime.Now;
|
||||
OnlyLog = onlyLog;
|
||||
}
|
||||
public MessageClass Class { get; set; } = messageClass;
|
||||
public string Text { get; set; } = messageText;
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public bool OnlyLog { get; set; } = onlyLog;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace mRemoteNG.Messages
|
||||
_messageList.Clear();
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
||||
|
||||
private void RaiseCollectionChangedEvent(NotifyCollectionChangedAction action, IList items)
|
||||
{
|
||||
|
||||
@@ -7,14 +7,9 @@ using mRemoteNG.UI.Window;
|
||||
namespace mRemoteNG.Messages.MessageWriters
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class NotificationPanelMessageWriter : IMessageWriter
|
||||
public class NotificationPanelMessageWriter(ErrorAndInfoWindow messageWindow) : IMessageWriter
|
||||
{
|
||||
private readonly ErrorAndInfoWindow _messageWindow;
|
||||
|
||||
public NotificationPanelMessageWriter(ErrorAndInfoWindow messageWindow)
|
||||
{
|
||||
_messageWindow = messageWindow ?? throw new ArgumentNullException(nameof(messageWindow));
|
||||
}
|
||||
private readonly ErrorAndInfoWindow _messageWindow = messageWindow ?? throw new ArgumentNullException(nameof(messageWindow));
|
||||
|
||||
public void Write(IMessage message)
|
||||
{
|
||||
|
||||
@@ -5,14 +5,9 @@ using mRemoteNG.App;
|
||||
namespace mRemoteNG.Messages.MessageWriters
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class TextLogMessageWriter : IMessageWriter
|
||||
public class TextLogMessageWriter(Logger logger) : IMessageWriter
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public TextLogMessageWriter(Logger logger)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
private readonly Logger _logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
|
||||
public void Write(IMessage message)
|
||||
{
|
||||
|
||||
@@ -11,20 +11,13 @@ using WeifenLuo.WinFormsUI.Docking;
|
||||
namespace mRemoteNG.Messages.WriterDecorators
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class MessageFocusDecorator : IMessageWriter
|
||||
public class MessageFocusDecorator(ErrorAndInfoWindow messageWindow, IMessageTypeFilteringOptions filter, IMessageWriter decoratedWriter) : IMessageWriter
|
||||
{
|
||||
private readonly IMessageTypeFilteringOptions _filter;
|
||||
private readonly IMessageWriter _decoratedWriter;
|
||||
private readonly ErrorAndInfoWindow _messageWindow;
|
||||
private readonly IMessageTypeFilteringOptions _filter = filter ?? throw new ArgumentNullException(nameof(filter));
|
||||
private readonly IMessageWriter _decoratedWriter = decoratedWriter ?? throw new ArgumentNullException(nameof(decoratedWriter));
|
||||
private readonly ErrorAndInfoWindow _messageWindow = messageWindow ?? throw new ArgumentNullException(nameof(messageWindow));
|
||||
private readonly FrmMain _frmMain = FrmMain.Default;
|
||||
|
||||
public MessageFocusDecorator(ErrorAndInfoWindow messageWindow, IMessageTypeFilteringOptions filter, IMessageWriter decoratedWriter)
|
||||
{
|
||||
_filter = filter ?? throw new ArgumentNullException(nameof(filter));
|
||||
_messageWindow = messageWindow ?? throw new ArgumentNullException(nameof(messageWindow));
|
||||
_decoratedWriter = decoratedWriter ?? throw new ArgumentNullException(nameof(decoratedWriter));
|
||||
}
|
||||
|
||||
public async void Write(IMessage message)
|
||||
{
|
||||
_decoratedWriter.Write(message);
|
||||
|
||||
@@ -18,10 +18,10 @@ using System.Resources;
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information
|
||||
[assembly: AssemblyVersion("1.78.2.3028")]
|
||||
[assembly: AssemblyFileVersion("1.78.2.3028")]
|
||||
[assembly: AssemblyVersion("1.78.2.3038")]
|
||||
[assembly: AssemblyFileVersion("1.78.2.3038")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
||||
[assembly: AssemblyInformationalVersion("1.78.2 (Nightly Build 3028)")]
|
||||
[assembly: AssemblyInformationalVersion("1.78.2 (Nightly Build 3038)")]
|
||||
|
||||
// Logging
|
||||
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config")]
|
||||
|
||||
@@ -5,24 +5,17 @@ using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.Security.Authentication
|
||||
{
|
||||
public class PasswordAuthenticator : IAuthenticator
|
||||
public class PasswordAuthenticator(ICryptographyProvider cryptographyProvider,
|
||||
string cipherText,
|
||||
Func<Optional<SecureString>> authenticationRequestor) : IAuthenticator
|
||||
{
|
||||
private readonly ICryptographyProvider _cryptographyProvider;
|
||||
private readonly string _cipherText;
|
||||
private readonly Func<Optional<SecureString>> _authenticationRequestor;
|
||||
private readonly ICryptographyProvider _cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
private readonly string _cipherText = cipherText.ThrowIfNullOrEmpty(nameof(cipherText));
|
||||
private readonly Func<Optional<SecureString>> _authenticationRequestor = authenticationRequestor.ThrowIfNull(nameof(authenticationRequestor));
|
||||
|
||||
public int MaxAttempts { get; set; } = 3;
|
||||
public SecureString LastAuthenticatedPassword { get; private set; }
|
||||
|
||||
public PasswordAuthenticator(ICryptographyProvider cryptographyProvider,
|
||||
string cipherText,
|
||||
Func<Optional<SecureString>> authenticationRequestor)
|
||||
{
|
||||
_cryptographyProvider = cryptographyProvider.ThrowIfNull(nameof(cryptographyProvider));
|
||||
_cipherText = cipherText.ThrowIfNullOrEmpty(nameof(cipherText));
|
||||
_authenticationRequestor = authenticationRequestor.ThrowIfNull(nameof(authenticationRequestor));
|
||||
}
|
||||
|
||||
public bool Authenticate(SecureString password)
|
||||
{
|
||||
bool authenticated = false;
|
||||
|
||||
@@ -6,17 +6,11 @@ namespace mRemoteNG.Themes
|
||||
/// <summary>
|
||||
/// Class used for the UI to display the color tables,as the Dictionary value keys cannot be directly replaced
|
||||
/// </summary>
|
||||
public class PseudoKeyColor
|
||||
public class PseudoKeyColor(string _key, Color _value)
|
||||
{
|
||||
public PseudoKeyColor(string _key, Color _value)
|
||||
{
|
||||
Key = _key;
|
||||
Value = _value;
|
||||
}
|
||||
public string Key { get; set; } = _key;
|
||||
|
||||
public string Key { get; set; }
|
||||
|
||||
public Color Value { get; set; }
|
||||
public Color Value { get; set; } = _value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,19 +7,13 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class AdHelper
|
||||
public class AdHelper(string domain)
|
||||
{
|
||||
private DirectoryEntry _dEntry;
|
||||
|
||||
public AdHelper(string domain)
|
||||
{
|
||||
Children = [];
|
||||
Domain = domain;
|
||||
}
|
||||
public Hashtable Children { get; } = [];
|
||||
|
||||
public Hashtable Children { get; }
|
||||
|
||||
private string Domain { get; }
|
||||
private string Domain { get; } = domain;
|
||||
|
||||
public void GetChildEntries(string adPath = "")
|
||||
{
|
||||
|
||||
@@ -4,15 +4,11 @@ using mRemoteNG.Connection.Protocol;
|
||||
|
||||
namespace mRemoteNG.Tools.Attributes
|
||||
{
|
||||
public class AttributeUsedInAllProtocolsExcept : AttributeUsedInProtocol
|
||||
{
|
||||
public AttributeUsedInAllProtocolsExcept(params ProtocolType[] exceptions)
|
||||
: base(Enum
|
||||
public class AttributeUsedInAllProtocolsExcept(params ProtocolType[] exceptions) : AttributeUsedInProtocol(Enum
|
||||
.GetValues(typeof(ProtocolType))
|
||||
.Cast<ProtocolType>()
|
||||
.Except(exceptions)
|
||||
.ToArray())
|
||||
{
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,8 @@ using mRemoteNG.Connection.Protocol;
|
||||
namespace mRemoteNG.Tools.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class AttributeUsedInProtocol : Attribute
|
||||
public class AttributeUsedInProtocol(params ProtocolType[] supportedProtocolTypes) : Attribute
|
||||
{
|
||||
public ProtocolType[] SupportedProtocolTypes { get; }
|
||||
|
||||
public AttributeUsedInProtocol(params ProtocolType[] supportedProtocolTypes)
|
||||
{
|
||||
SupportedProtocolTypes = supportedProtocolTypes;
|
||||
}
|
||||
public ProtocolType[] SupportedProtocolTypes { get; } = supportedProtocolTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#if !PORTABLE
|
||||
#if !PORTABLE
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Windows.Forms;
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable NotAccessedField.Local
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Local
|
||||
@@ -16,15 +17,10 @@ using System.ComponentModel;
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
public class Authenticode
|
||||
{
|
||||
#region Public Methods
|
||||
public Authenticode(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
}
|
||||
|
||||
public StatusValue Verify()
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class Authenticode(string filePath)
|
||||
{
|
||||
public StatusValue Verify()
|
||||
{
|
||||
IntPtr trustFileInfoPointer = default(IntPtr);
|
||||
IntPtr trustDataPointer = default(IntPtr);
|
||||
@@ -50,14 +46,17 @@ namespace mRemoteNG.Tools
|
||||
return Status;
|
||||
}
|
||||
|
||||
//X509Certificate2 certificate2 = new(X509Certificate.CreateFromSignedFile(FilePath));
|
||||
|
||||
X509Certificate2 certificate2 = new(X509Certificate.CreateFromSignedFile(FilePath));
|
||||
_thumbprint = certificate2.Thumbprint;
|
||||
if (_thumbprint != ThumbprintToMatch)
|
||||
{
|
||||
Status = StatusValue.ThumbprintNotMatch;
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
_thumbprint = certificate2.Thumbprint;
|
||||
|
||||
if (_thumbprint != ThumbprintToMatch)
|
||||
{
|
||||
Status = StatusValue.ThumbprintNotMatch;
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
NativeMethods.WINTRUST_FILE_INFO trustFileInfo = new() { pcwszFilePath = FilePath};
|
||||
trustFileInfoPointer = Marshal.AllocCoTaskMem(Marshal.SizeOf(trustFileInfo));
|
||||
@@ -78,8 +77,7 @@ namespace mRemoteNG.Tools
|
||||
|
||||
IntPtr windowHandle = DisplayParentForm?.Handle ?? IntPtr.Zero;
|
||||
|
||||
_trustProviderErrorCode =
|
||||
NativeMethods.WinVerifyTrust(windowHandle, NativeMethods.WINTRUST_ACTION_GENERIC_VERIFY_V2, trustDataPointer);
|
||||
_trustProviderErrorCode = NativeMethods.WinVerifyTrust(windowHandle, NativeMethods.WINTRUST_ACTION_GENERIC_VERIFY_V2, trustDataPointer);
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (_trustProviderErrorCode)
|
||||
{
|
||||
@@ -104,8 +102,7 @@ namespace mRemoteNG.Tools
|
||||
|
||||
if (ex is CryptographicException)
|
||||
{
|
||||
PropertyInfo hResultProperty =
|
||||
ex.GetType().GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
PropertyInfo? hResultProperty = ex.GetType().GetProperty("HResult", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
if (hResultProperty != null)
|
||||
{
|
||||
int hResult = Convert.ToInt32(hResultProperty.GetValue(ex, null));
|
||||
@@ -134,61 +131,54 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
private DisplayValue Display { get; set; } = DisplayValue.None;
|
||||
|
||||
private DisplayContextValue DisplayContext {get; set;}
|
||||
private Form DisplayParentForm {get; set;}
|
||||
internal Exception Exception {get; private set;}
|
||||
private string FilePath {get; set;}
|
||||
private Form? DisplayParentForm { get; set; } = null; // Use nullable reference type
|
||||
internal Exception? Exception { get; private set; } = null; // Set to null to satisfy non-nullable property
|
||||
private string FilePath { get; set; } = filePath;
|
||||
internal bool RequireThumbprintMatch { get; set;}
|
||||
|
||||
internal StatusValue Status { get; private set; }
|
||||
|
||||
public string GetStatusMessage()
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (Status)
|
||||
{
|
||||
case StatusValue.Verified:
|
||||
return "The file was verified successfully.";
|
||||
case StatusValue.FileNotExist:
|
||||
return "The specified file does not exist.";
|
||||
case StatusValue.FileEmpty:
|
||||
return "The specified file is empty.";
|
||||
case StatusValue.NoSignature:
|
||||
return "The specified file is not digitally signed.";
|
||||
case StatusValue.NoThumbprintToMatch:
|
||||
return "A thumbprint match is required but no thumbprint to match against was specified.";
|
||||
case StatusValue.ThumbprintNotMatch:
|
||||
/* (char)0x2260 == the "not equal to" symbol (which I cannot print in here without changing the encoding of the file)
|
||||
* Fancy...
|
||||
*
|
||||
* "<>" is fiarly cryptic for non-programers
|
||||
* So is "!="
|
||||
* "=/=" gets the job done, no?
|
||||
* What about plain old English (or localized value): X is not equal to Y?
|
||||
* :P
|
||||
*/
|
||||
return $"The thumbprint does not match. {_thumbprint} {(char) 0x2260} {ThumbprintToMatch}.";
|
||||
case StatusValue.TrustProviderError:
|
||||
public string GetStatusMessage()
|
||||
{
|
||||
// ReSharper disable once SwitchStatementMissingSomeCases
|
||||
switch (Status)
|
||||
{
|
||||
case StatusValue.Verified:
|
||||
return "The file was verified successfully.";
|
||||
case StatusValue.FileNotExist:
|
||||
return "The specified file does not exist.";
|
||||
case StatusValue.FileEmpty:
|
||||
return "The specified file is empty.";
|
||||
case StatusValue.NoSignature:
|
||||
return "The specified file is not digitally signed.";
|
||||
case StatusValue.NoThumbprintToMatch:
|
||||
return "A thumbprint match is required but no thumbprint to match against was specified.";
|
||||
case StatusValue.ThumbprintNotMatch:
|
||||
return $"The thumbprint does not match. {_thumbprint} {(char)0x2260} {ThumbprintToMatch}.";
|
||||
case StatusValue.TrustProviderError:
|
||||
Win32Exception ex = new(_trustProviderErrorCode);
|
||||
return $"The trust provider returned an error. {ex.Message}";
|
||||
case StatusValue.UnhandledException:
|
||||
return $"An unhandled exception occurred. {Exception.Message}";
|
||||
default:
|
||||
return "The status is unknown.";
|
||||
}
|
||||
}
|
||||
return $"The trust provider returned an error. {ex.Message}";
|
||||
case StatusValue.UnhandledException:
|
||||
return Exception != null
|
||||
? $"An unhandled exception occurred. {Exception.Message}"
|
||||
: "An unhandled exception occurred, but no exception details are available.";
|
||||
default:
|
||||
return "The status is unknown.";
|
||||
}
|
||||
}
|
||||
|
||||
private string _thumbprint;
|
||||
private string _thumbprint = string.Empty;
|
||||
|
||||
internal string ThumbprintToMatch { get; set;}
|
||||
|
||||
private int _trustProviderErrorCode;
|
||||
internal string ThumbprintToMatch { get; set; } = string.Empty; // Initialize to an empty string to satisfy non-nullable property
|
||||
|
||||
private int _trustProviderErrorCode;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -115,18 +115,11 @@ namespace mRemoteNG.Tools.Cmdline
|
||||
|
||||
#region Protected Classes
|
||||
|
||||
protected class Argument
|
||||
protected class Argument(string text, bool isFileName = false, bool forceQuotes = false)
|
||||
{
|
||||
public Argument(string text, bool isFileName = false, bool forceQuotes = false)
|
||||
{
|
||||
Text = text;
|
||||
IsFileName = isFileName;
|
||||
ForceQuotes = forceQuotes;
|
||||
}
|
||||
|
||||
public string Text { get; set; }
|
||||
public bool IsFileName { get; set; }
|
||||
public bool ForceQuotes { get; set; }
|
||||
public string Text { get; set; } = text;
|
||||
public bool IsFileName { get; set; } = isFileName;
|
||||
public bool ForceQuotes { get; set; } = forceQuotes;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -3,14 +3,9 @@ using System.Linq;
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
public class DisposableOptional<T> : Optional<T>, IDisposable
|
||||
public class DisposableOptional<T>(T value) : Optional<T>(value), IDisposable
|
||||
where T : IDisposable
|
||||
{
|
||||
public DisposableOptional(T value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
@@ -19,11 +19,11 @@ namespace mRemoteNG.Tools
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ExternalTool : INotifyPropertyChanged
|
||||
{
|
||||
private string _displayName;
|
||||
private string _fileName;
|
||||
private string _displayName = string.Empty; // Initialize to avoid CS8618
|
||||
private string _fileName = string.Empty; // Initialize to avoid CS8618
|
||||
private bool _waitForExit;
|
||||
private string _arguments;
|
||||
private string _workingDir;
|
||||
private string _arguments = string.Empty; // Initialize to avoid CS8618
|
||||
private string _workingDir = string.Empty; // Initialize to avoid CS8618
|
||||
private bool _tryIntegrate;
|
||||
private bool _showOnToolbar = true;
|
||||
private bool _runElevated;
|
||||
@@ -90,9 +90,9 @@ namespace mRemoteNG.Tools
|
||||
set => SetField(ref _runElevated, value, nameof(RunElevated));
|
||||
}
|
||||
|
||||
public ConnectionInfo ConnectionInfo { get; set; }
|
||||
public ConnectionInfo ConnectionInfo { get; set; } = new ConnectionInfo(); // Initialize to avoid CS8618
|
||||
|
||||
public Icon Icon => File.Exists(FileName) ? MiscTools.GetIconFromFile(FileName) : Properties.Resources.mRemoteNG_Icon;
|
||||
public Icon Icon => File.Exists(FileName) ? MiscTools.GetIconFromFile(FileName) ?? Properties.Resources.mRemoteNG_Icon : Properties.Resources.mRemoteNG_Icon;
|
||||
|
||||
public Image Image => Icon?.ToBitmap() ?? Properties.Resources.mRemoteNG_Icon.ToBitmap();
|
||||
|
||||
@@ -111,18 +111,17 @@ namespace mRemoteNG.Tools
|
||||
RunElevated = runElevated;
|
||||
}
|
||||
|
||||
public void Start(ConnectionInfo startConnectionInfo = null)
|
||||
public void Start(ConnectionInfo startConnectionInfo = null!)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(FileName))
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
|
||||
"ExternalApp.Start() failed: FileName cannot be blank.");
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "ExternalApp.Start() failed: FileName cannot be blank.");
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectionInfo = startConnectionInfo;
|
||||
ConnectionInfo = startConnectionInfo ?? new ConnectionInfo(); // Ensure ConnectionInfo is not null
|
||||
if (startConnectionInfo is ContainerInfo container)
|
||||
{
|
||||
container.Children.ForEach(Start);
|
||||
@@ -196,7 +195,7 @@ namespace mRemoteNG.Tools
|
||||
newConnectionInfo.Panel = Language._Tools;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public event PropertyChangedEventHandler? PropertyChanged = delegate { }; // Updated to match nullability
|
||||
|
||||
protected virtual void RaisePropertyChangedEvent(object sender, string propertyName)
|
||||
{
|
||||
|
||||
@@ -11,14 +11,9 @@ using mRemoteNG.Tools.Cmdline;
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ExternalToolArgumentParser
|
||||
public class ExternalToolArgumentParser(ConnectionInfo connectionInfo)
|
||||
{
|
||||
private readonly ConnectionInfo _connectionInfo;
|
||||
|
||||
public ExternalToolArgumentParser(ConnectionInfo connectionInfo)
|
||||
{
|
||||
_connectionInfo = connectionInfo;
|
||||
}
|
||||
private readonly ConnectionInfo _connectionInfo = connectionInfo;
|
||||
|
||||
public string ParseArguments(string input)
|
||||
{
|
||||
@@ -246,20 +241,13 @@ namespace mRemoteNG.Tools
|
||||
None
|
||||
}
|
||||
|
||||
private struct Replacement
|
||||
private struct Replacement(int start, int length, string value)
|
||||
{
|
||||
public int Start { get; }
|
||||
public int Start { get; } = start;
|
||||
|
||||
public int Length { get; }
|
||||
public int Length { get; } = length;
|
||||
|
||||
public string Value { get; }
|
||||
|
||||
public Replacement(int start, int length, string value)
|
||||
{
|
||||
Start = start;
|
||||
Length = length;
|
||||
Value = value;
|
||||
}
|
||||
public string Value { get; } = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
@@ -26,18 +27,33 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
public override StandardValuesCollection GetStandardValues([NotNull] ITypeDescriptorContext? context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
return new StandardValuesCollection(ExternalTools);
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesExclusive([NotNull] ITypeDescriptorContext? context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesSupported([NotNull] ITypeDescriptorContext? context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,36 +18,32 @@ namespace mRemoteNG.Tools
|
||||
[SupportedOSPlatform("windows")]
|
||||
public static class MiscTools
|
||||
{
|
||||
public static Icon GetIconFromFile(string FileName)
|
||||
public static Icon? GetIconFromFile(string FileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return File.Exists(FileName) == false ? null : Icon.ExtractAssociatedIcon(FileName);
|
||||
return File.Exists(FileName) ? Icon.ExtractAssociatedIcon(FileName) : null;
|
||||
}
|
||||
catch (ArgumentException AEx)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"GetIconFromFile failed (Tools.Misc) - using default icon" +
|
||||
Environment.NewLine + AEx.Message,
|
||||
true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "GetIconFromFile failed (Tools.Misc) - using default icon" + Environment.NewLine + AEx.Message, true);
|
||||
return Properties.Resources.mRemoteNG_Icon;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
|
||||
"GetIconFromFile failed (Tools.Misc)" + Environment.NewLine +
|
||||
ex.Message, true);
|
||||
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "GetIconFromFile failed (Tools.Misc)" + Environment.NewLine + ex.Message, true);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<SecureString> PasswordDialog(string passwordName = null, bool verify = true)
|
||||
public static Optional<SecureString> PasswordDialog(string? passwordName = null, bool verify = true)
|
||||
{
|
||||
//var splash = FrmSplashScreenNew.GetInstance();
|
||||
//TODO: something not right there
|
||||
//if (PresentationSource.FromVisual(splash))
|
||||
// splash.Close();
|
||||
|
||||
passwordName ??= string.Empty; // Ensure passwordName is not null
|
||||
FrmPassword passwordForm = new(passwordName, verify);
|
||||
return passwordForm.GetKey();
|
||||
}
|
||||
@@ -139,7 +135,7 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
|
||||
public static Image TakeScreenshot(UI.Tabs.ConnectionTab sender)
|
||||
public static Image? TakeScreenshot(UI.Tabs.ConnectionTab sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -159,74 +155,88 @@ namespace mRemoteNG.Tools
|
||||
return null;
|
||||
}
|
||||
|
||||
public class EnumTypeConverter : EnumConverter
|
||||
public class EnumTypeConverter(Type type) : EnumConverter(type)
|
||||
{
|
||||
private readonly Type _enumType;
|
||||
private readonly Type _enumType = type;
|
||||
|
||||
public EnumTypeConverter(Type type) : base(type)
|
||||
{
|
||||
_enumType = type;
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destType)
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destType)
|
||||
{
|
||||
return destType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context,
|
||||
CultureInfo culture,
|
||||
object value,
|
||||
Type destType)
|
||||
public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type? destType)
|
||||
{
|
||||
if (value == null) return null;
|
||||
System.Reflection.FieldInfo fi = _enumType.GetField(Enum.GetName(_enumType, value));
|
||||
DescriptionAttribute dna = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
|
||||
if (value == null) return string.Empty;
|
||||
|
||||
return dna != null ? dna.Description : value.ToString();
|
||||
string? enumName = Enum.GetName(_enumType, value);
|
||||
if (enumName == null)
|
||||
{
|
||||
throw new ArgumentException("Invalid enum value provided.");
|
||||
}
|
||||
|
||||
System.Reflection.FieldInfo? fi = _enumType.GetField(enumName);
|
||||
if (fi == null)
|
||||
{
|
||||
throw new ArgumentException("FieldInfo could not be retrieved for the provided enum value.");
|
||||
}
|
||||
|
||||
DescriptionAttribute? dna = (DescriptionAttribute?)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
|
||||
return dna?.Description ?? value.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type srcType)
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type? srcType)
|
||||
{
|
||||
return srcType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value)
|
||||
{
|
||||
foreach (System.Reflection.FieldInfo fi in _enumType.GetFields())
|
||||
if (value is string stringValue)
|
||||
{
|
||||
DescriptionAttribute dna = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
|
||||
|
||||
if (dna != null && (string)value == dna.Description)
|
||||
foreach (System.Reflection.FieldInfo fi in _enumType.GetFields())
|
||||
{
|
||||
return Enum.Parse(_enumType, fi.Name);
|
||||
DescriptionAttribute? dna = (DescriptionAttribute?)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
|
||||
|
||||
if (dna != null && string.Equals(stringValue, dna.Description, StringComparison.Ordinal))
|
||||
{
|
||||
return Enum.Parse(_enumType, fi.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return Enum.Parse(_enumType, stringValue);
|
||||
}
|
||||
|
||||
return value != null ? Enum.Parse(_enumType, (string)value) : null;
|
||||
throw new ArgumentNullException(nameof(value), "Value cannot be null.");
|
||||
}
|
||||
}
|
||||
|
||||
public class YesNoTypeConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
}
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
|
||||
{
|
||||
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object? value)
|
||||
{
|
||||
if (!(value is string)) return base.ConvertFrom(context, culture, value);
|
||||
if (string.Equals(value.ToString(), Language.Yes, StringComparison.CurrentCultureIgnoreCase))
|
||||
if (value is not string stringValue)
|
||||
{
|
||||
// Ensure 'value' is not null before passing it to the base method
|
||||
return value != null
|
||||
? base.ConvertFrom(context, culture, value)
|
||||
: throw new ArgumentNullException(nameof(value), "Value cannot be null.");
|
||||
}
|
||||
|
||||
if (string.Equals(stringValue, Language.Yes, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.Equals(value.ToString(), Language.No, StringComparison.CurrentCultureIgnoreCase))
|
||||
if (string.Equals(stringValue, Language.No, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -234,27 +244,24 @@ namespace mRemoteNG.Tools
|
||||
throw new Exception("Values must be \"Yes\" or \"No\"");
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context,
|
||||
CultureInfo culture,
|
||||
object value,
|
||||
Type destinationType)
|
||||
public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
return Convert.ToBoolean(value) ? Language.Yes : Language.No;
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
return base.ConvertTo(context, culture, value, destinationType) ?? throw new InvalidOperationException("Base conversion returned null.");
|
||||
}
|
||||
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
|
||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
|
||||
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
|
||||
{
|
||||
bool[] bools = {true, false};
|
||||
bool[] bools = { true, false };
|
||||
|
||||
StandardValuesCollection svc = new(bools);
|
||||
|
||||
|
||||
@@ -35,7 +35,13 @@ namespace mRemoteNG.Tools
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return _optional.Any() ? _optional.First().ToString() : "";
|
||||
// Fixes CS8602 and CS8603 by ensuring null checks and returning a non-null value
|
||||
if (_optional.Length > 0 && _optional[0] != null)
|
||||
{
|
||||
return _optional[0]?.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static implicit operator Optional<T>(T value)
|
||||
@@ -79,8 +85,11 @@ namespace mRemoteNG.Tools
|
||||
/// values, the values are compared directly.
|
||||
/// </summary>
|
||||
/// <param name="other"></param>
|
||||
public int CompareTo(Optional<T> other)
|
||||
public int CompareTo(Optional<T>? other)
|
||||
{
|
||||
if (other is null)
|
||||
return 1; // Treat null as less than any non-null Optional
|
||||
|
||||
bool otherHasAnything = other.Any();
|
||||
bool thisHasAnything = _optional.Length > 0;
|
||||
|
||||
@@ -100,21 +109,16 @@ namespace mRemoteNG.Tools
|
||||
throw new ArgumentException($"Cannot compare objects. Optional type {typeof(T).FullName} is not comparable to itself");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Override Equals and GetHashCode
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(this, obj))
|
||||
return true;
|
||||
|
||||
Optional<T> objAsOptional = obj as Optional<T>;
|
||||
if (objAsOptional != null)
|
||||
if (obj is Optional<T> objAsOptional)
|
||||
return Equals(objAsOptional);
|
||||
|
||||
if (obj is T)
|
||||
Equals((T)obj);
|
||||
if (obj is T objAsT)
|
||||
return Equals(objAsT);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Reflection;
|
||||
@@ -7,14 +7,9 @@ using System.Reflection;
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
public class PropertyGridCommandSite : IMenuCommandService, ISite
|
||||
public class PropertyGridCommandSite(object @object) : IMenuCommandService, ISite
|
||||
{
|
||||
private readonly object TheObject;
|
||||
|
||||
public PropertyGridCommandSite(object @object)
|
||||
{
|
||||
TheObject = @object;
|
||||
}
|
||||
private readonly object TheObject = @object;
|
||||
|
||||
public DesignerVerbCollection Verbs
|
||||
{
|
||||
@@ -56,10 +51,9 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
}
|
||||
|
||||
private void VerbEventHandler(object sender, EventArgs e)
|
||||
private void VerbEventHandler(object? sender, EventArgs e)
|
||||
{
|
||||
DesignerVerb verb = sender as DesignerVerb;
|
||||
if (verb == null)
|
||||
if (sender is not DesignerVerb verb)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -100,16 +94,16 @@ namespace mRemoteNG.Tools
|
||||
|
||||
public object GetService(Type serviceType)
|
||||
{
|
||||
return serviceType == typeof(IMenuCommandService) ? this : null;
|
||||
return serviceType == typeof(IMenuCommandService) ? this : null!;
|
||||
}
|
||||
|
||||
public IComponent Component => throw new NotSupportedException();
|
||||
|
||||
public IContainer Container => null;
|
||||
public IContainer Container => null!;
|
||||
|
||||
public bool DesignMode => true;
|
||||
|
||||
public string Name
|
||||
public string? Name
|
||||
{
|
||||
get => throw new NotSupportedException();
|
||||
set => throw new NotSupportedException();
|
||||
@@ -151,13 +145,8 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandAttribute : Attribute
|
||||
public class CommandAttribute(bool isCommand = true) : Attribute
|
||||
{
|
||||
public bool Command { get; set; }
|
||||
|
||||
public CommandAttribute(bool isCommand = true)
|
||||
{
|
||||
Command = isCommand;
|
||||
}
|
||||
public bool Command { get; set; } = isCommand;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ using mRemoteNG.Resources.Language;
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class ScanHost
|
||||
public class ScanHost(string host)
|
||||
{
|
||||
#region Properties
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace mRemoteNG.Tools
|
||||
public static int RloginPort { get; set; } = (int)ProtocolRlogin.Defaults.Port;
|
||||
public static int RdpPort { get; set; } = (int)RdpProtocol.Defaults.Port;
|
||||
public static int VncPort { get; set; } = (int)ProtocolVNC.Defaults.Port;
|
||||
public ArrayList OpenPorts { get; set; }
|
||||
public ArrayList ClosedPorts { get; set; }
|
||||
public ArrayList OpenPorts { get; set; } = [];
|
||||
public ArrayList ClosedPorts { get; set; } = [];
|
||||
public bool Rdp { get; set; }
|
||||
public bool Vnc { get; set; }
|
||||
public bool Ssh { get; set; }
|
||||
@@ -35,7 +35,7 @@ namespace mRemoteNG.Tools
|
||||
public bool Rlogin { get; set; }
|
||||
public bool Http { get; set; }
|
||||
public bool Https { get; set; }
|
||||
public string HostIp { get; set; }
|
||||
public string HostIp { get; set; } = host;
|
||||
public string HostName { get; set; } = "";
|
||||
|
||||
public string HostNameWithoutDomain
|
||||
@@ -52,16 +52,8 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public ScanHost(string host)
|
||||
{
|
||||
HostIp = host;
|
||||
OpenPorts = [];
|
||||
ClosedPorts = [];
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -9,15 +9,10 @@ namespace mRemoteNG.Tools
|
||||
public class LocalizedAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedCategoryAttribute : CategoryAttribute
|
||||
public class LocalizedCategoryAttribute(string value, int Order = 1) : CategoryAttribute(value)
|
||||
{
|
||||
private const int MaxOrder = 10;
|
||||
private int Order;
|
||||
|
||||
public LocalizedCategoryAttribute(string value, int Order = 1) : base(value)
|
||||
{
|
||||
this.Order = Order > MaxOrder ? MaxOrder : Order;
|
||||
}
|
||||
private int Order = Order > MaxOrder ? MaxOrder : Order;
|
||||
|
||||
protected override string GetLocalizedString(string value)
|
||||
{
|
||||
@@ -32,14 +27,9 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedDisplayNameAttribute : DisplayNameAttribute
|
||||
public class LocalizedDisplayNameAttribute(string value) : DisplayNameAttribute(value)
|
||||
{
|
||||
private bool Localized;
|
||||
|
||||
public LocalizedDisplayNameAttribute(string value) : base(value)
|
||||
{
|
||||
Localized = false;
|
||||
}
|
||||
private bool Localized = false;
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
@@ -57,14 +47,9 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedDescriptionAttribute : DescriptionAttribute
|
||||
public class LocalizedDescriptionAttribute(string value) : DescriptionAttribute(value)
|
||||
{
|
||||
private bool Localized;
|
||||
|
||||
public LocalizedDescriptionAttribute(string value) : base(value)
|
||||
{
|
||||
Localized = false;
|
||||
}
|
||||
private bool Localized = false;
|
||||
|
||||
public override string Description
|
||||
{
|
||||
@@ -82,11 +67,8 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedDefaultValueAttribute : DefaultValueAttribute
|
||||
public class LocalizedDefaultValueAttribute(string name) : DefaultValueAttribute(Language.ResourceManager.GetString(name))
|
||||
{
|
||||
public LocalizedDefaultValueAttribute(string name) : base(Language.ResourceManager.GetString(name))
|
||||
{
|
||||
}
|
||||
|
||||
// This allows localized attributes in a derived class to override a matching
|
||||
// non-localized attribute inherited from its base class
|
||||
@@ -96,14 +78,9 @@ namespace mRemoteNG.Tools
|
||||
#region Special localization - with String.Format
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedDisplayNameInheritAttribute : DisplayNameAttribute
|
||||
public class LocalizedDisplayNameInheritAttribute(string value) : DisplayNameAttribute(value)
|
||||
{
|
||||
private bool Localized;
|
||||
|
||||
public LocalizedDisplayNameInheritAttribute(string value) : base(value)
|
||||
{
|
||||
Localized = false;
|
||||
}
|
||||
private bool Localized = false;
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
@@ -122,14 +99,9 @@ namespace mRemoteNG.Tools
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public class LocalizedDescriptionInheritAttribute : DescriptionAttribute
|
||||
public class LocalizedDescriptionInheritAttribute(string value) : DescriptionAttribute(value)
|
||||
{
|
||||
private bool Localized;
|
||||
|
||||
public LocalizedDescriptionInheritAttribute(string value) : base(value)
|
||||
{
|
||||
Localized = false;
|
||||
}
|
||||
private bool Localized = false;
|
||||
|
||||
public override string Description
|
||||
{
|
||||
|
||||
@@ -7,15 +7,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class WindowPlacement
|
||||
public class WindowPlacement(Form form)
|
||||
{
|
||||
private Form _form;
|
||||
|
||||
|
||||
public WindowPlacement(Form form)
|
||||
{
|
||||
_form = form;
|
||||
}
|
||||
private Form _form = form;
|
||||
|
||||
|
||||
#region Public Properties
|
||||
|
||||
@@ -19,22 +19,18 @@ namespace mRemoteNG.Tree
|
||||
{
|
||||
if (RootNodes.Contains(rootNode)) return;
|
||||
RootNodes.Add(rootNode);
|
||||
rootNode.CollectionChanged += RaiseCollectionChangedEvent;
|
||||
rootNode.PropertyChanged += RaisePropertyChangedEvent;
|
||||
RaiseCollectionChangedEvent(this,
|
||||
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||
rootNode));
|
||||
rootNode.CollectionChanged += RaiseCollectionChangedEvent!;
|
||||
rootNode.PropertyChanged += RaisePropertyChangedEvent!;
|
||||
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, rootNode));
|
||||
}
|
||||
|
||||
public void RemoveRootNode(ContainerInfo rootNode)
|
||||
{
|
||||
if (!RootNodes.Contains(rootNode)) return;
|
||||
rootNode.CollectionChanged -= RaiseCollectionChangedEvent;
|
||||
rootNode.PropertyChanged -= RaisePropertyChangedEvent;
|
||||
rootNode.CollectionChanged -= RaiseCollectionChangedEvent!;
|
||||
rootNode.PropertyChanged -= RaisePropertyChangedEvent!;
|
||||
RootNodes.Remove(rootNode);
|
||||
RaiseCollectionChangedEvent(this,
|
||||
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove,
|
||||
rootNode));
|
||||
RaiseCollectionChangedEvent(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, rootNode));
|
||||
}
|
||||
|
||||
public IReadOnlyList<ConnectionInfo> GetRecursiveChildList()
|
||||
@@ -76,16 +72,16 @@ namespace mRemoteNG.Tree
|
||||
connectionInfo?.RemoveParent();
|
||||
}
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
public event NotifyCollectionChangedEventHandler? CollectionChanged;
|
||||
|
||||
private void RaiseCollectionChangedEvent(object sender, NotifyCollectionChangedEventArgs args)
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private void RaiseCollectionChangedEvent(object? sender, NotifyCollectionChangedEventArgs args)
|
||||
{
|
||||
CollectionChanged?.Invoke(sender, args);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void RaisePropertyChangedEvent(object sender, PropertyChangedEventArgs args)
|
||||
private void RaisePropertyChangedEvent(object? sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
PropertyChanged?.Invoke(sender, args);
|
||||
}
|
||||
|
||||
@@ -7,19 +7,13 @@ using mRemoteNG.Connection;
|
||||
namespace mRemoteNG.Tree
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class NodeSearcher
|
||||
public class NodeSearcher(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
private readonly ConnectionTreeModel _connectionTreeModel;
|
||||
private readonly ConnectionTreeModel _connectionTreeModel = connectionTreeModel;
|
||||
|
||||
private List<ConnectionInfo> Matches { get; set; }
|
||||
public ConnectionInfo CurrentMatch { get; private set; }
|
||||
|
||||
|
||||
public NodeSearcher(ConnectionTreeModel connectionTreeModel)
|
||||
{
|
||||
_connectionTreeModel = connectionTreeModel;
|
||||
}
|
||||
|
||||
public IEnumerable<ConnectionInfo> SearchByName(string searchText)
|
||||
{
|
||||
ResetMatches();
|
||||
|
||||
@@ -10,18 +10,11 @@ namespace mRemoteNG.Tree.Root
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
[DefaultProperty("Name")]
|
||||
public class RootNodeInfo : ContainerInfo
|
||||
public class RootNodeInfo(RootNodeType rootType, string uniqueId) : ContainerInfo(uniqueId)
|
||||
{
|
||||
private string _name;
|
||||
private string _name = Language.Connections;
|
||||
private string _customPassword = "";
|
||||
|
||||
public RootNodeInfo(RootNodeType rootType, string uniqueId)
|
||||
: base(uniqueId)
|
||||
{
|
||||
_name = Language.Connections;
|
||||
Type = rootType;
|
||||
}
|
||||
|
||||
public RootNodeInfo(RootNodeType rootType)
|
||||
: this(rootType, Guid.NewGuid().ToString())
|
||||
{
|
||||
@@ -60,7 +53,7 @@ namespace mRemoteNG.Tree.Root
|
||||
|
||||
[Browsable(false)] public string DefaultPassword { get; } = "mR3m"; //TODO move password away from code to settings
|
||||
|
||||
[Browsable(false)] public RootNodeType Type { get; set; }
|
||||
[Browsable(false)] public RootNodeType Type { get; set; } = rootType;
|
||||
|
||||
public override TreeNodeType GetTreeNodeType()
|
||||
{
|
||||
|
||||
@@ -8,14 +8,9 @@ using System.Runtime.Versioning;
|
||||
namespace mRemoteNG.Tree
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class SelectedConnectionDeletionConfirmer : IConfirm<ConnectionInfo>
|
||||
public class SelectedConnectionDeletionConfirmer(Func<string, DialogResult> confirmationFunc) : IConfirm<ConnectionInfo>
|
||||
{
|
||||
private readonly Func<string, DialogResult> _confirmationFunc;
|
||||
|
||||
public SelectedConnectionDeletionConfirmer(Func<string, DialogResult> confirmationFunc)
|
||||
{
|
||||
_confirmationFunc = confirmationFunc;
|
||||
}
|
||||
private readonly Func<string, DialogResult> _confirmationFunc = confirmationFunc;
|
||||
|
||||
public bool Confirm(ConnectionInfo deletionTarget)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing.Design;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Windows.Forms.Design;
|
||||
@@ -12,12 +13,12 @@ namespace mRemoteNG.UI.Controls.Adapters
|
||||
{
|
||||
private IWindowsFormsEditorService _editorService;
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext? context)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
public override object? EditValue(ITypeDescriptorContext? context, IServiceProvider provider, object? value)
|
||||
{
|
||||
if (provider == null) return value;
|
||||
_editorService = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
@@ -30,7 +31,7 @@ namespace mRemoteNG.UI.Controls.Adapters
|
||||
|
||||
_editorService.DropDownControl(listBox);
|
||||
if (listBox.SelectedItem == listBox.NoneSelection)
|
||||
return null;
|
||||
return null!;
|
||||
if (listBox.SelectedItem == listBox.AddNewSelection)
|
||||
{
|
||||
//var newCred = new CredentialRecord();
|
||||
@@ -41,7 +42,7 @@ namespace mRemoteNG.UI.Controls.Adapters
|
||||
return listBox.SelectedItem ?? value;
|
||||
}
|
||||
|
||||
private void ListBoxOnSelectedValueChanged(object sender, EventArgs eventArgs)
|
||||
private void ListBoxOnSelectedValueChanged([NotNull] object? sender, EventArgs eventArgs)
|
||||
{
|
||||
_editorService.CloseDropDown();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// <param name="obj">A reference to the selected object that will linked to the parent PropertyGrid.</param>
|
||||
internal ObjectWrapper(object obj)
|
||||
{
|
||||
SelectedObject = obj;
|
||||
SelectedObject = obj ?? throw new ArgumentNullException(nameof(obj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -26,11 +26,11 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// <summary>
|
||||
/// Get or set a reference to the collection of properties to show in the parent PropertyGrid
|
||||
/// </summary>
|
||||
public List<PropertyDescriptor> PropertyDescriptors { get; set; } = [];
|
||||
public List<PropertyDescriptor> PropertyDescriptors { get; set; } = new List<PropertyDescriptor>();
|
||||
|
||||
#region ICustomTypeDescriptor Members
|
||||
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[]? attributes)
|
||||
{
|
||||
return GetProperties();
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// <returns>String</returns>
|
||||
public string GetClassName()
|
||||
{
|
||||
return TypeDescriptor.GetClassName(SelectedObject, true);
|
||||
return TypeDescriptor.GetClassName(SelectedObject, true) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -64,7 +64,7 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// <returns>String</returns>
|
||||
public string GetComponentName()
|
||||
{
|
||||
return TypeDescriptor.GetComponentName(SelectedObject, true);
|
||||
return TypeDescriptor.GetComponentName(SelectedObject, true) ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -80,8 +80,9 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// GetDefaultEvent
|
||||
/// </summary>
|
||||
/// <returns>EventDescriptor</returns>
|
||||
public EventDescriptor GetDefaultEvent()
|
||||
public EventDescriptor? GetDefaultEvent()
|
||||
{
|
||||
// Explicitly mark the return type as nullable to handle the possibility of null.
|
||||
return TypeDescriptor.GetDefaultEvent(SelectedObject, true);
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// GetDefaultProperty
|
||||
/// </summary>
|
||||
/// <returns>PropertyDescriptor</returns>
|
||||
public PropertyDescriptor GetDefaultProperty()
|
||||
public PropertyDescriptor? GetDefaultProperty()
|
||||
{
|
||||
return TypeDescriptor.GetDefaultProperty(SelectedObject, true);
|
||||
}
|
||||
@@ -99,12 +100,12 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
/// </summary>
|
||||
/// <param name="editorBaseType">editorBaseType</param>
|
||||
/// <returns>object</returns>
|
||||
public object GetEditor(Type editorBaseType)
|
||||
public object? GetEditor(Type editorBaseType)
|
||||
{
|
||||
return TypeDescriptor.GetEditor(this, editorBaseType, true);
|
||||
}
|
||||
|
||||
public EventDescriptorCollection GetEvents(Attribute[] attributes)
|
||||
public EventDescriptorCollection GetEvents(Attribute[]? attributes)
|
||||
{
|
||||
return TypeDescriptor.GetEvents(SelectedObject, attributes, true);
|
||||
}
|
||||
@@ -114,7 +115,7 @@ namespace mRemoteNG.UI.Controls.FilteredPropertyGrid
|
||||
return TypeDescriptor.GetEvents(SelectedObject, true);
|
||||
}
|
||||
|
||||
public object GetPropertyOwner(PropertyDescriptor pd)
|
||||
public object? GetPropertyOwner(PropertyDescriptor? pd)
|
||||
{
|
||||
return SelectedObject;
|
||||
}
|
||||
|
||||
@@ -11,15 +11,9 @@ namespace mRemoteNG.UI.Controls.PageSequence
|
||||
NextPage
|
||||
}
|
||||
|
||||
public class SequencedPageReplcementRequestArgs
|
||||
public class SequencedPageReplcementRequestArgs(SequencedControl newControl, RelativePagePosition pageToReplace)
|
||||
{
|
||||
public SequencedControl NewControl { get; }
|
||||
public RelativePagePosition PagePosition { get; }
|
||||
|
||||
public SequencedPageReplcementRequestArgs(SequencedControl newControl, RelativePagePosition pageToReplace)
|
||||
{
|
||||
NewControl = newControl ?? throw new ArgumentNullException(nameof(newControl));
|
||||
PagePosition = pageToReplace;
|
||||
}
|
||||
public SequencedControl NewControl { get; } = newControl ?? throw new ArgumentNullException(nameof(newControl));
|
||||
public RelativePagePosition PagePosition { get; } = pageToReplace;
|
||||
}
|
||||
}
|
||||
@@ -185,14 +185,9 @@ namespace mRemoteNG.UI.Controls
|
||||
|
||||
#region Events
|
||||
|
||||
public class ConnectRequestedEventArgs : EventArgs
|
||||
public class ConnectRequestedEventArgs(string connectionString) : EventArgs
|
||||
{
|
||||
public ConnectRequestedEventArgs(string connectionString)
|
||||
{
|
||||
ConnectionString = connectionString;
|
||||
}
|
||||
|
||||
public string ConnectionString { get; }
|
||||
public string ConnectionString { get; } = connectionString;
|
||||
}
|
||||
|
||||
public delegate void ConnectRequestedEventHandler(object sender, ConnectRequestedEventArgs e);
|
||||
@@ -212,14 +207,9 @@ namespace mRemoteNG.UI.Controls
|
||||
ConnectRequestedEvent?.Invoke(this, new ConnectRequestedEventArgs(e.ConnectionString));
|
||||
}
|
||||
|
||||
public class ProtocolChangedEventArgs : EventArgs
|
||||
public class ProtocolChangedEventArgs(ProtocolType protocol) : EventArgs
|
||||
{
|
||||
public ProtocolChangedEventArgs(ProtocolType protocol)
|
||||
{
|
||||
Protocol = protocol;
|
||||
}
|
||||
|
||||
public ProtocolType Protocol { get; }
|
||||
public ProtocolType Protocol { get; } = protocol;
|
||||
}
|
||||
|
||||
public delegate void ProtocolChangedEventHandler(object sender, ProtocolChangedEventArgs e);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace mRemoteNG.UI.Controls
|
||||
/* Sets and Gets the tooltiptext on toolTip1 */
|
||||
public string ToolTipText
|
||||
{
|
||||
get => toolTip1.GetToolTip(Octet1);
|
||||
get => toolTip1.GetToolTip(Octet1) ?? string.Empty;
|
||||
set
|
||||
{
|
||||
toolTip1.SetToolTip(Octet1, value);
|
||||
@@ -46,34 +46,48 @@ namespace mRemoteNG.UI.Controls
|
||||
}
|
||||
|
||||
/* Set or Get the string that represents the value in the box */
|
||||
public override string Text
|
||||
public override string? Text
|
||||
{
|
||||
get => Octet1.Text + @"." + Octet2.Text + @"." + Octet3.Text + @"." + Octet4.Text;
|
||||
get => (Octet1.Text ?? string.Empty) + @"." + (Octet2.Text ?? string.Empty) + @"." + (Octet3.Text ?? string.Empty) + @"." + (Octet4.Text ?? string.Empty);
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
string[] pieces = value.Split(@".".ToCharArray(), 4);
|
||||
Octet1.Text = pieces[0];
|
||||
Octet2.Text = pieces[1];
|
||||
Octet3.Text = pieces[2];
|
||||
Octet4.Text = pieces[3];
|
||||
Octet1.Text = pieces.Length > 0 ? pieces[0] : string.Empty;
|
||||
Octet2.Text = pieces.Length > 1 ? pieces[1] : string.Empty;
|
||||
Octet3.Text = pieces.Length > 2 ? pieces[2] : string.Empty;
|
||||
Octet4.Text = pieces.Length > 3 ? pieces[3] : string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
Octet1.Text = "";
|
||||
Octet2.Text = "";
|
||||
Octet3.Text = "";
|
||||
Octet4.Text = "";
|
||||
Octet1.Text = string.Empty;
|
||||
Octet2.Text = string.Empty;
|
||||
Octet3.Text = string.Empty;
|
||||
Octet4.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fix for CS8618: Initialize all non-nullable fields in the constructor to ensure they are not null. */
|
||||
|
||||
public MrngIpTextBox()
|
||||
{
|
||||
// This call is required by the Windows.Forms Form Designer.
|
||||
InitializeComponent();
|
||||
SetTabSTopProperties();
|
||||
|
||||
// Initialize non-nullable fields to avoid CS8618 warnings
|
||||
panel1 = new Panel();
|
||||
Octet1 = new MrngTextBox();
|
||||
Octet2 = new MrngTextBox();
|
||||
Octet3 = new MrngTextBox();
|
||||
Octet4 = new MrngTextBox();
|
||||
label1 = new MrngLabel();
|
||||
label2 = new MrngLabel();
|
||||
label3 = new MrngLabel();
|
||||
toolTip1 = new ToolTip();
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
private void SetTabSTopProperties()
|
||||
@@ -269,10 +283,11 @@ namespace mRemoteNG.UI.Controls
|
||||
}
|
||||
}
|
||||
|
||||
/* Performs KeyPress analysis and handling to ensure a valid ip octet is
|
||||
* being entered in Box1.
|
||||
/* Update the method signatures to include nullable reference type annotations
|
||||
* to match the nullability of the target delegate 'KeyPressEventHandler'.
|
||||
*/
|
||||
private void Box1_KeyPress(object sender, KeyPressEventArgs e)
|
||||
|
||||
private void Box1_KeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Only Accept a '.', a numeral, or backspace
|
||||
if (e.KeyChar.ToString() == "." || char.IsDigit(e.KeyChar) || e.KeyChar == 8)
|
||||
@@ -317,7 +332,7 @@ namespace mRemoteNG.UI.Controls
|
||||
/* Performs KeyPress analysis and handling to ensure a valid ip octet is
|
||||
* being entered in Box2.
|
||||
*/
|
||||
private void Box2_KeyPress(object sender, KeyPressEventArgs e)
|
||||
private void Box2_KeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Similar to Box1_KeyPress but in special case for backspace moves cursor
|
||||
//to the previous box (Box1)
|
||||
@@ -361,7 +376,7 @@ namespace mRemoteNG.UI.Controls
|
||||
/* Performs KeyPress analysis and handling to ensure a valid ip octet is
|
||||
* being entered in Box3.
|
||||
*/
|
||||
private void Box3_KeyPress(object sender, KeyPressEventArgs e)
|
||||
private void Box3_KeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Identical to Box2_KeyPress except that previous box is Box2 and
|
||||
//next box is Box3
|
||||
@@ -405,7 +420,7 @@ namespace mRemoteNG.UI.Controls
|
||||
/* Performs KeyPress analysis and handling to ensure a valid ip octet is
|
||||
* being entered in Box4.
|
||||
*/
|
||||
private void Box4_KeyPress(object sender, KeyPressEventArgs e)
|
||||
private void Box4_KeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Similar to Box3 but ignores the '.' character and does not advance
|
||||
//to the next box. Also Box3 is previous box for backspace case.
|
||||
@@ -428,11 +443,11 @@ namespace mRemoteNG.UI.Controls
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
// Selects All text in a box for overwriting upon entering the box
|
||||
private void Box_Enter(object sender, EventArgs e)
|
||||
// Update the method signature to include nullable reference type annotations
|
||||
private void Box_Enter(object? sender, EventArgs e)
|
||||
{
|
||||
TextBox tb = (TextBox)sender;
|
||||
tb.SelectAll();
|
||||
TextBox? tb = sender as TextBox;
|
||||
tb?.SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
5
mRemoteNG/UI/Controls/mrngPictureBox.Designer.cs
generated
5
mRemoteNG/UI/Controls/mrngPictureBox.Designer.cs
generated
@@ -26,10 +26,7 @@
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
private void InitializeComponent() => components = new System.ComponentModel.Container();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -8,10 +8,15 @@ using mRemoteNG.UI.GraphicsUtilities;
|
||||
|
||||
namespace mRemoteNG.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DisplayProperties"/> instance with the given
|
||||
/// <see cref="IGraphicsProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="graphicsProvider"></param>
|
||||
[SupportedOSPlatform("windows")]
|
||||
public class DisplayProperties
|
||||
public class DisplayProperties(IGraphicsProvider graphicsProvider)
|
||||
{
|
||||
private readonly IGraphicsProvider _graphicsProvider;
|
||||
private readonly IGraphicsProvider _graphicsProvider = graphicsProvider.ThrowIfNull(nameof(graphicsProvider));
|
||||
|
||||
public SizeF ResolutionScalingFactor => _graphicsProvider.GetResolutionScalingFactor();
|
||||
|
||||
@@ -24,16 +29,6 @@ namespace mRemoteNG.UI
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DisplayProperties"/> instance with the given
|
||||
/// <see cref="IGraphicsProvider"/>.
|
||||
/// </summary>
|
||||
/// <param name="graphicsProvider"></param>
|
||||
public DisplayProperties(IGraphicsProvider graphicsProvider)
|
||||
{
|
||||
_graphicsProvider = graphicsProvider.ThrowIfNull(nameof(graphicsProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scale the given nominal width value by the <see cref="ResolutionScalingFactor"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -272,21 +272,15 @@ namespace mRemoteNG.UI.Forms
|
||||
#region Private Classes
|
||||
|
||||
[ImmutableObject(true)]
|
||||
private class ExportFormat
|
||||
private class ExportFormat(SaveFormat format)
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public SaveFormat Format { get; }
|
||||
public SaveFormat Format { get; } = format;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ExportFormat(SaveFormat format)
|
||||
{
|
||||
Format = format;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -94,15 +94,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
}
|
||||
}
|
||||
}
|
||||
internal class DropdownList
|
||||
internal class DropdownList(int argIndex, string argDisplay)
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public string DisplayString { get; set; }
|
||||
|
||||
public DropdownList(int argIndex, string argDisplay)
|
||||
{
|
||||
Index = argIndex;
|
||||
DisplayString = argDisplay;
|
||||
}
|
||||
public int Index { get; set; } = argIndex;
|
||||
public string DisplayString { get; set; } = argDisplay;
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
|
||||
//UserControl overrides dispose to clean up the component list.
|
||||
[System.Diagnostics.DebuggerNonUserCode()]
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
protected override void Dispose(bool disposing) => base.Dispose(disposing);
|
||||
|
||||
//NOTE: The following procedure is required by the Windows Form Designer
|
||||
//It can be modified using the Windows Form Designer.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user