code clean up & fix complier warnings

This commit is contained in:
Sean Kaim
2016-08-09 16:58:44 -04:00
parent 369a6c2f04
commit 6da05af387
2 changed files with 29 additions and 53 deletions

View File

@@ -1,4 +1,3 @@
using mRemoteNG.My;
using mRemoteNG.Tools;
using System;
using System.ComponentModel;
@@ -79,12 +78,10 @@ namespace mRemoteNG.Themes
}
Type themeInfoType = (new ThemeInfo()).GetType();
object myProperty = null;
object otherProperty = null;
foreach (System.Reflection.PropertyInfo propertyInfo in themeInfoType.GetProperties())
foreach (System.Reflection.PropertyInfo propertyInfo in themeInfoType.GetProperties())
{
myProperty = propertyInfo.GetValue(this, null);
otherProperty = propertyInfo.GetValue(otherTheme, null);
var myProperty = propertyInfo.GetValue(this, null);
var otherProperty = propertyInfo.GetValue(otherTheme, null);
if (!myProperty.Equals(otherProperty))
{
return false;
@@ -93,17 +90,23 @@ namespace mRemoteNG.Themes
return true;
}
// just fixing a complier warning. We don't use us so returning this value shouldn't be an issue at all.
public override int GetHashCode()
{
return Name.GetHashCode();
}
#endregion
#region Events
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged(string propertyName)
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if
(PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
#endregion
#region Properties
[Browsable(false)]
@@ -122,7 +125,7 @@ namespace mRemoteNG.Themes
}
#region General
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral", 1),
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral"),
LocalizedAttributes.LocalizedDisplayName("strThemeNameWindowBackgroundColor"),
LocalizedAttributes.LocalizedDescription("strThemeDescriptionWindowBackgroundColor")]
public Color WindowBackgroundColor
@@ -139,7 +142,7 @@ namespace mRemoteNG.Themes
}
}
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral", 1), Browsable(false),
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral"), Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strThemeNameMenuBackgroundColor"),
LocalizedAttributes.LocalizedDescription("strThemeDescriptionMenuBackgroundColor")]
public Color MenuBackgroundColor
@@ -156,7 +159,7 @@ namespace mRemoteNG.Themes
}
}
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral", 1), Browsable(false),
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral"), Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strThemeNameMenuTextColor"),
LocalizedAttributes.LocalizedDescription("strThemeDescriptionMenuTextColor")]
public Color MenuTextColor
@@ -173,7 +176,7 @@ namespace mRemoteNG.Themes
}
}
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral", 1),
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral"),
Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strThemeNameToolbarBackgroundColor"),
LocalizedAttributes.LocalizedDescription("strThemeDescriptionToolbarBackgroundColor")]
@@ -191,7 +194,7 @@ namespace mRemoteNG.Themes
}
}
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral", 1), Browsable(false),
[LocalizedAttributes.LocalizedCategory("strThemeCategoryGeneral"), Browsable(false),
LocalizedAttributes.LocalizedDisplayName("strThemeNameToolbarTextColor"),
LocalizedAttributes.LocalizedDescription("strThemeDescriptionToolbarTextColor")]
public Color ToolbarTextColor

View File

@@ -4,7 +4,6 @@ using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Windows.Forms;
using mRemoteNG.App;
@@ -18,24 +17,6 @@ namespace mRemoteNG.Tools
{
public class MiscTools
{
private struct SHFILEINFO
{
public IntPtr hIcon; // : icon
//public int iIcon; // : icondex
//public int dwAttributes; // : SFGAO_ flags
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
}
[DllImport("shell32.dll")]
private static extern IntPtr SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, int uFlags);
private const int SHGFI_ICON = 0x100;
private const int SHGFI_SMALLICON = 0x1;
//Private Const SHGFI_LARGEICON = &H0 ' Large icon
public static Icon GetIconFromFile(string FileName)
{
try
@@ -56,10 +37,6 @@ namespace mRemoteNG.Tools
}
}
public static SecureString PasswordDialog(string passwordName = null, bool verify = true)
{
PasswordForm passwordForm = new PasswordForm(passwordName, verify);
@@ -177,15 +154,11 @@ namespace mRemoteNG.Tools
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destType)
{
if (value != null)
{
FieldInfo fi = _enumType.GetField(Enum.GetName(_enumType, value: value));
DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute)));
if (value == null) return null;
FieldInfo fi = _enumType.GetField(Enum.GetName(_enumType, value: value));
DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute)));
return dna != null ? dna.Description : value.ToString();
}
return null;
return dna != null ? dna.Description : value.ToString();
}
public override bool CanConvertFrom(ITypeDescriptorContext context, Type srcType)
@@ -195,7 +168,7 @@ namespace mRemoteNG.Tools
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
foreach (FieldInfo fi in _enumType.GetFields())
foreach (FieldInfo fi in _enumType.GetFields())
{
DescriptionAttribute dna = (DescriptionAttribute) (Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute)));
@@ -204,8 +177,8 @@ namespace mRemoteNG.Tools
return Enum.Parse(_enumType, fi.Name);
}
}
return Enum.Parse(_enumType, (string) value);
return value != null ? Enum.Parse(_enumType, (string) value) : null;
}
}
@@ -256,7 +229,7 @@ namespace mRemoteNG.Tools
{
if (destinationType == typeof(string))
{
return ((Convert.ToBoolean(value)) ? Language.strYes : Language.strNo);
return Convert.ToBoolean(value) ? Language.strYes : Language.strNo;
}
return base.ConvertTo(context, culture, value, destinationType);