Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added support for VS 22 #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public enum ActivePanel
{
[Description("Left Panel")]
Left,
[Description("Right Panel")]
Right
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public enum ActivePanel
{
[Description("Left Panel")]
Left,

[Description("Right Panel")]
Right
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public class ActivePanelConverter : EnumConverter<ActivePanel>
{ }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public class ActivePanelConverter : EnumConverter<ActivePanel>
{ }
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class CommandIds
{
internal const uint TotalCommander = 0x201;
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class CommandIds
{
internal const uint TotalCommander = 0x201;
}
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public class EnumConverter<TEnum> : EnumConverter where TEnum : struct
{
public EnumConverter()
: base(typeof(TEnum))
{ }
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;
return base.CanConvertFrom(context, sourceType);
}
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var val = value as string;
if (val != null)
{
foreach (TEnum item in Enum.GetValues(typeof(TEnum)))
{
if (item.GetDescription() == val)
return item;
}
}
return default(TEnum);
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
return true;
return base.CanConvertTo(context, destinationType);
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is TEnum && destinationType == typeof(string))
return ((TEnum)value).GetDescription();
return default(TEnum).GetDescription();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
public class EnumConverter<TEnum> : EnumConverter where TEnum : struct
{
public EnumConverter()
: base(typeof(TEnum))
{ }

public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
return true;

return base.CanConvertFrom(context, sourceType);
}

public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var val = value as string;

if (val != null)
{
foreach (TEnum item in Enum.GetValues(typeof(TEnum)))
{
if (item.GetDescription() == val)
return item;
}
}

return default(TEnum);
}

public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(string))
return true;

return base.CanConvertTo(context, destinationType);
}

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (value is TEnum && destinationType == typeof(string))
return ((TEnum)value).GetDescription();

return default(TEnum).GetDescription();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class EnumExtensions
{
internal static TAttribute GetFirstAttribute<TEnum, TAttribute>(this TEnum enumValue) where TEnum : struct
{
var enumType = enumValue.GetType();
if (!enumType.IsEnum)
throw new ArgumentException();
var field = enumType.GetField(enumValue.ToString());
var attributes = field.GetCustomAttributes(typeof(TAttribute), false) as TAttribute[];
return attributes != null ? attributes.FirstOrDefault() : default(TAttribute);
}
internal static string GetDescription<TEnum>(this TEnum enumValue) where TEnum : struct
{
var attribute = enumValue.GetFirstAttribute<TEnum, DescriptionAttribute>();
return attribute != null ? attribute.Description : enumValue.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class EnumExtensions
{
internal static TAttribute GetFirstAttribute<TEnum, TAttribute>(this TEnum enumValue) where TEnum : struct
{
var enumType = enumValue.GetType();

if (!enumType.IsEnum)
throw new ArgumentException();

var field = enumType.GetField(enumValue.ToString());
var attributes = field.GetCustomAttributes(typeof(TAttribute), false) as TAttribute[];

return attributes != null ? attributes.FirstOrDefault() : default(TAttribute);
}

internal static string GetDescription<TEnum>(this TEnum enumValue) where TEnum : struct
{
var attribute = enumValue.GetFirstAttribute<TEnum, DescriptionAttribute>();
return attribute != null ? attribute.Description : enumValue.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1017:MarkAssembliesWithComVisible")]
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class Guids
{
internal const string Package = "504f9f56-9629-48c7-adb9-cbcce53bf9b7";
internal const string Options = "10a4a8b0-08aa-4b25-a95e-b95a03448a1c";
internal static readonly Guid MenuGroup = new Guid("40cf569c-214e-41db-b92d-b8066cf86495");
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GrzegorzKozub.VisualStudioExtensions.TotalCommanderLauncher
{
internal static class Guids
{
internal const string Package = "504f9f56-9629-48c7-adb9-cbcce53bf9b7";
internal const string Options = "10a4a8b0-08aa-4b25-a95e-b95a03448a1c";
internal static readonly Guid MenuGroup = new Guid("40cf569c-214e-41db-b92d-b8066cf86495");
}
}
File renamed without changes.
Loading