27 changed files with 45 additions and 1593 deletions
@ -1,967 +0,0 @@
@@ -1,967 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
using Debugger; |
||||
using Debugger.MetaData; |
||||
using ICSharpCode.NRefactory.Ast; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace ICSharpCode.NRefactory.Visitors |
||||
{ |
||||
public class EvaluateException: GetValueException |
||||
{ |
||||
public EvaluateException(INode code, string msg):base(msg) {} |
||||
public EvaluateException(INode code, string msgFmt, params string[] msgArgs):base(string.Format(msgFmt, msgArgs)) {} |
||||
} |
||||
|
||||
class TypedValue |
||||
{ |
||||
Value value; |
||||
DebugType type; |
||||
|
||||
public Value Value { |
||||
get { return value; } |
||||
} |
||||
|
||||
public DebugType Type { |
||||
get { return type; } |
||||
} |
||||
|
||||
public object PrimitiveValue { |
||||
get { return value.PrimitiveValue; } |
||||
} |
||||
|
||||
public TypedValue(Value value, DebugType type) |
||||
{ |
||||
this.value = value; |
||||
this.type = type; |
||||
} |
||||
} |
||||
|
||||
public class ExpressionEvaluator: NotImplementedAstVisitor |
||||
{ |
||||
StackFrame context; |
||||
|
||||
public StackFrame Context { |
||||
get { return context; } |
||||
} |
||||
|
||||
public Thread EvalThread { |
||||
get { return this.Context.Thread; } |
||||
} |
||||
|
||||
ExpressionEvaluator(StackFrame context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
|
||||
public static INode Parse(string code, SupportedLanguage language) |
||||
{ |
||||
SnippetParser parser = new SnippetParser(language); |
||||
INode astRoot = parser.Parse(code); |
||||
if (parser.Errors.Count > 0) { |
||||
throw new GetValueException(parser.Errors.ErrorOutput); |
||||
} |
||||
if (parser.SnippetType != SnippetType.Expression && parser.SnippetType != SnippetType.Statements) { |
||||
throw new GetValueException("Code must be expression or statement"); |
||||
} |
||||
return astRoot; |
||||
} |
||||
|
||||
/// <summary> Evaluate given expression. If you have expression tree already, use overloads of this method.</summary>
|
||||
/// <returns> Returned value or null for statements </returns>
|
||||
public static Value Evaluate(string code, SupportedLanguage language, StackFrame context, object data = null) |
||||
{ |
||||
return Evaluate(Parse(code, language), context, data); |
||||
} |
||||
|
||||
public static Value Evaluate(INode code, StackFrame context, object data = null) |
||||
{ |
||||
if (context == null) |
||||
throw new GetValueException("Invalid stackframe"); |
||||
if (context.IsInvalid) |
||||
throw new DebuggerException("The context is no longer valid"); |
||||
|
||||
TypedValue val = new ExpressionEvaluator(context).Evaluate(code, false, data); |
||||
if (val == null) |
||||
return null; |
||||
return val.Value; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Parses string representation of an expression (eg. "a.b[10] + 2") into NRefactory Expression tree.
|
||||
/// </summary>
|
||||
public static Expression ParseExpression(string code, SupportedLanguage language) |
||||
{ |
||||
SnippetParser parser = new SnippetParser(language); |
||||
INode astRoot = parser.Parse(code); |
||||
if (parser.Errors.Count > 0) { |
||||
throw new GetValueException(parser.Errors.ErrorOutput); |
||||
} |
||||
Expression astExpression = astRoot as Expression; |
||||
if (astExpression == null) { |
||||
throw new GetValueException("Code must be expression"); |
||||
} |
||||
return astExpression; |
||||
} |
||||
|
||||
|
||||
|
||||
TypedValue Evaluate(INode expression) |
||||
{ |
||||
return Evaluate(expression, true); |
||||
} |
||||
|
||||
TypedValue Evaluate(INode expression, bool permRef, object data = null) |
||||
{ |
||||
TypedValue val; |
||||
|
||||
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); |
||||
watch.Start(); |
||||
try { |
||||
val = (TypedValue)expression.AcceptVisitor(this, data); |
||||
if (val != null && permRef) |
||||
val = new TypedValue(val.Value.GetPermanentReference(this.EvalThread), val.Type); |
||||
} catch (NotImplementedException e) { |
||||
throw new EvaluateException(expression, "Language feature not implemented: " + e.Message); |
||||
} finally { |
||||
watch.Stop(); |
||||
context.Process.TraceMessage("Evaluated: {0} in {1} ms total", expression.PrettyPrint(), watch.ElapsedMilliseconds); |
||||
} |
||||
|
||||
if (val != null && val.Value.IsInvalid) |
||||
throw new DebuggerException("Expression \"" + expression.PrettyPrint() + "\" is invalid right after evaluation"); |
||||
|
||||
return val; |
||||
} |
||||
|
||||
List<TypedValue> EvaluateAll(List<Expression> exprs) |
||||
{ |
||||
List<TypedValue> vals = new List<TypedValue>(exprs.Count); |
||||
foreach(Expression expr in exprs) { |
||||
vals.Add(Evaluate(expr)); |
||||
} |
||||
return vals; |
||||
} |
||||
|
||||
int EvaluateAsInt(INode expression) |
||||
{ |
||||
if (expression is PrimitiveExpression) { |
||||
int? i = ((PrimitiveExpression)expression).Value as int?; |
||||
if (i == null) |
||||
throw new EvaluateException(expression, "Integer expected"); |
||||
return i.Value; |
||||
} else { |
||||
TypedValue typedVal = Evaluate(expression); |
||||
if (typedVal.Type.CanImplicitelyConvertTo(typeof(int))) { |
||||
int i = (int)Convert.ChangeType(typedVal.PrimitiveValue, typeof(int)); |
||||
return i; |
||||
} else { |
||||
throw new EvaluateException(expression, "Integer expected"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
TypedValue EvaluateAs(INode expression, DebugType type) |
||||
{ |
||||
TypedValue val = Evaluate(expression); |
||||
if (val.Type == type) |
||||
return val; |
||||
if (!val.Type.CanImplicitelyConvertTo(type)) |
||||
throw new EvaluateException(expression, "Can not implicitely cast {0} to {1}", val.Type.FullName, type.FullName); |
||||
if (type.IsPrimitive) { |
||||
object oldVal = val.PrimitiveValue; |
||||
object newVal; |
||||
try { |
||||
newVal = Convert.ChangeType(oldVal, type.PrimitiveType); |
||||
} catch (InvalidCastException) { |
||||
throw new EvaluateException(expression, "Can not cast {0} to {1}", val.GetType().FullName, type.FullName); |
||||
} catch (OverflowException) { |
||||
throw new EvaluateException(expression, "Overflow"); |
||||
} |
||||
return CreateValue(newVal); |
||||
} else { |
||||
return new TypedValue(val.Value, type); |
||||
} |
||||
} |
||||
|
||||
Value[] GetValues(List<TypedValue> typedVals) |
||||
{ |
||||
List<Value> vals = new List<Value>(typedVals.Count); |
||||
foreach(TypedValue typedVal in typedVals) { |
||||
vals.Add(typedVal.Value); |
||||
} |
||||
return vals.ToArray(); |
||||
} |
||||
|
||||
DebugType[] GetTypes(List<TypedValue> typedVals) |
||||
{ |
||||
List<DebugType> types = new List<DebugType>(typedVals.Count); |
||||
foreach(TypedValue typedVal in typedVals) { |
||||
types.Add(typedVal.Type); |
||||
} |
||||
return types.ToArray(); |
||||
} |
||||
|
||||
TypedValue CreateValue(object primitiveValue) |
||||
{ |
||||
Value val = Eval.CreateValue(this.EvalThread, primitiveValue); |
||||
return new TypedValue(val, val.Type); |
||||
} |
||||
|
||||
public override object VisitAssignmentExpression(AssignmentExpression assignmentExpression, object data) |
||||
{ |
||||
BinaryOperatorType op; |
||||
switch (assignmentExpression.Op) { |
||||
case AssignmentOperatorType.Assign: op = BinaryOperatorType.None; break; |
||||
case AssignmentOperatorType.Add: op = BinaryOperatorType.Add; break; |
||||
case AssignmentOperatorType.ConcatString: op = BinaryOperatorType.Concat; break; |
||||
case AssignmentOperatorType.Subtract: op = BinaryOperatorType.Subtract; break; |
||||
case AssignmentOperatorType.Multiply: op = BinaryOperatorType.Multiply; break; |
||||
case AssignmentOperatorType.Divide: op = BinaryOperatorType.Divide; break; |
||||
case AssignmentOperatorType.DivideInteger: op = BinaryOperatorType.DivideInteger; break; |
||||
case AssignmentOperatorType.ShiftLeft: op = BinaryOperatorType.ShiftLeft; break; |
||||
case AssignmentOperatorType.ShiftRight: op = BinaryOperatorType.ShiftRight; break; |
||||
case AssignmentOperatorType.ExclusiveOr: op = BinaryOperatorType.ExclusiveOr; break; |
||||
case AssignmentOperatorType.Modulus: op = BinaryOperatorType.Modulus; break; |
||||
case AssignmentOperatorType.BitwiseAnd: op = BinaryOperatorType.BitwiseAnd; break; |
||||
case AssignmentOperatorType.BitwiseOr: op = BinaryOperatorType.BitwiseOr; break; |
||||
case AssignmentOperatorType.Power: op = BinaryOperatorType.Power; break; |
||||
default: throw new GetValueException("Unknown operator " + assignmentExpression.Op); |
||||
} |
||||
|
||||
TypedValue right; |
||||
if (op == BinaryOperatorType.None) { |
||||
right = Evaluate(assignmentExpression.Right); |
||||
} else { |
||||
BinaryOperatorExpression binOpExpr = new BinaryOperatorExpression(); |
||||
binOpExpr.Left = assignmentExpression.Left; |
||||
binOpExpr.Op = op; |
||||
binOpExpr.Right = assignmentExpression.Right; |
||||
right = Evaluate(binOpExpr); |
||||
} |
||||
|
||||
// We can not have perfRef because we need to be able to set the value
|
||||
TypedValue left = (TypedValue)assignmentExpression.Left.AcceptVisitor(this, null); |
||||
|
||||
if (left == null) { |
||||
// Can this happen?
|
||||
throw new GetValueException(string.Format("\"{0}\" can not be set", assignmentExpression.Left.PrettyPrint())); |
||||
} |
||||
if (!left.Value.IsReference && left.Type.FullName != right.Type.FullName) { |
||||
throw new GetValueException(string.Format("Type {0} expected, {1} seen", left.Type.FullName, right.Type.FullName)); |
||||
} |
||||
left.Value.SetValue(this.EvalThread, right.Value); |
||||
return right; |
||||
} |
||||
|
||||
public override object VisitBlockStatement(BlockStatement blockStatement, object data) |
||||
{ |
||||
foreach(INode statement in blockStatement.Children) { |
||||
Evaluate(statement); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public override object VisitEmptyStatement(EmptyStatement emptyStatement, object data) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public override object VisitExpressionStatement(ExpressionStatement expressionStatement, object data) |
||||
{ |
||||
Evaluate(expressionStatement.Expression); |
||||
return null; |
||||
} |
||||
|
||||
public override object VisitCastExpression(CastExpression castExpression, object data) |
||||
{ |
||||
TypedValue val = Evaluate(castExpression.Expression); |
||||
DebugType castTo = null; |
||||
try { |
||||
castTo = castExpression.CastTo.ResolveType(context.AppDomain); |
||||
} catch (GetValueException) { |
||||
var typeRef = castExpression.CastTo.Clone(); |
||||
typeRef.Type = typeRef.Type.Insert(0, context.MethodInfo.DeclaringType.Namespace + "."); |
||||
castTo = typeRef.ResolveType(context.AppDomain); |
||||
} |
||||
if (castTo.IsPrimitive && val.Type.IsPrimitive && castTo != val.Type) { |
||||
object oldVal = val.PrimitiveValue; |
||||
object newVal; |
||||
try { |
||||
newVal = Convert.ChangeType(oldVal, castTo.PrimitiveType); |
||||
} catch (InvalidCastException) { |
||||
throw new EvaluateException(castExpression, "Can not cast {0} to {1}", val.Type.FullName, castTo.FullName); |
||||
} catch (OverflowException) { |
||||
throw new EvaluateException(castExpression, "Overflow"); |
||||
} |
||||
val = CreateValue(newVal); |
||||
} |
||||
if (!castTo.IsAssignableFrom(val.Value.Type) && !val.Value.IsNull) |
||||
throw new GetValueException("Can not cast {0} to {1}", val.Value.Type.FullName, castTo.FullName); |
||||
return new TypedValue(val.Value, castTo); |
||||
} |
||||
|
||||
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data) |
||||
{ |
||||
string identifier = identifierExpression.Identifier; |
||||
|
||||
DebugParameterInfo par = context.MethodInfo.GetParameter(identifier); |
||||
if (par != null) |
||||
return new TypedValue(par.GetValue(context), (DebugType)par.ParameterType); |
||||
|
||||
DebugLocalVariableInfo loc = context.MethodInfo.GetLocalVariable(context.IP, identifier); |
||||
if (loc != null) |
||||
return new TypedValue(loc.GetValue(context), (DebugType)loc.LocalType); |
||||
|
||||
// try get local var from external information - data or UserData
|
||||
int[] localIndex = (data ?? identifierExpression.UserData) as int[]; |
||||
|
||||
if (localIndex != null) { |
||||
Value localValue = DebugMethodInfo.GetLocalVariableValue(context, localIndex[0]); |
||||
return new TypedValue(localValue, localValue.Type); |
||||
} |
||||
|
||||
// Instance class members
|
||||
// Note that the method might be generated instance method that represents anonymous method
|
||||
TypedValue thisValue = GetThisValue(); |
||||
if (thisValue != null) { |
||||
IDebugMemberInfo instMember = (IDebugMemberInfo)thisValue.Type.GetMember<MemberInfo>(identifier, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, DebugType.IsFieldOrNonIndexedProperty); |
||||
if (instMember != null) |
||||
return new TypedValue(Value.GetMemberValue(this.EvalThread, thisValue.Value, (MemberInfo)instMember), instMember.MemberType); |
||||
} |
||||
|
||||
// Static class members
|
||||
foreach(DebugType declaringType in ((DebugType)context.MethodInfo.DeclaringType).GetSelfAndDeclaringTypes()) { |
||||
IDebugMemberInfo statMember = (IDebugMemberInfo)declaringType.GetMember<MemberInfo>(identifier, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static, DebugType.IsFieldOrNonIndexedProperty); |
||||
if (statMember != null) |
||||
return new TypedValue(Value.GetMemberValue(this.EvalThread, null, (MemberInfo)statMember), statMember.MemberType); |
||||
} |
||||
|
||||
throw new GetValueException("Identifier \"" + identifier + "\" not found in this context"); |
||||
} |
||||
|
||||
public override object VisitIndexerExpression(IndexerExpression indexerExpression, object data) |
||||
{ |
||||
TypedValue target = Evaluate(indexerExpression.TargetObject); |
||||
|
||||
if (target.Type.IsArray) { |
||||
List<int> intIndexes = new List<int>(); |
||||
foreach(Expression indexExpr in indexerExpression.Indexes) { |
||||
intIndexes.Add(EvaluateAsInt(indexExpr)); |
||||
} |
||||
return new TypedValue( |
||||
target.Value.GetArrayElement(intIndexes.ToArray()), |
||||
(DebugType)target.Type.GetElementType() |
||||
); |
||||
} else if (target.Type.FullName == typeof(string).FullName) { |
||||
if (indexerExpression.Indexes.Count != 1) |
||||
throw new GetValueException("Single index expected"); |
||||
|
||||
int index = EvaluateAsInt(indexerExpression.Indexes[0]); |
||||
string str = (string)target.PrimitiveValue; |
||||
if (index < 0 || index >= str.Length) |
||||
throw new GetValueException("Index was outside the bounds of the array."); |
||||
return CreateValue(str[index]); |
||||
} else { |
||||
List<TypedValue> indexes = EvaluateAll(indexerExpression.Indexes); |
||||
DebugPropertyInfo pi = (DebugPropertyInfo)target.Type.GetProperty("Item", GetTypes(indexes)); |
||||
if (pi == null) |
||||
throw new GetValueException("The object does not have an indexer property"); |
||||
return new TypedValue( |
||||
target.Value.GetPropertyValue(this.EvalThread, pi, GetValues(indexes)), |
||||
(DebugType)pi.PropertyType |
||||
); |
||||
} |
||||
} |
||||
|
||||
public override object VisitInvocationExpression(InvocationExpression invocationExpression, object data) |
||||
{ |
||||
TypedValue target; |
||||
DebugType targetType; |
||||
string methodName; |
||||
MemberReferenceExpression memberRef = invocationExpression.TargetObject as MemberReferenceExpression; |
||||
if (memberRef != null) { |
||||
// TODO: Optimize
|
||||
try { |
||||
// Instance
|
||||
target = Evaluate(memberRef.TargetObject); |
||||
targetType = target.Type; |
||||
} catch (GetValueException) { |
||||
// Static
|
||||
target = null; |
||||
targetType = memberRef.TargetObject.ResolveType(context.AppDomain); |
||||
} |
||||
methodName = memberRef.MemberName; |
||||
} else { |
||||
IdentifierExpression ident = invocationExpression.TargetObject as IdentifierExpression; |
||||
if (ident != null) { |
||||
target = Evaluate(new ThisReferenceExpression()); |
||||
targetType = target.Type; |
||||
methodName = ident.Identifier; |
||||
} else { |
||||
throw new GetValueException("Member reference expected for method invocation"); |
||||
} |
||||
} |
||||
List<TypedValue> args = EvaluateAll(invocationExpression.Arguments); |
||||
MethodInfo method = targetType.GetMethod(methodName, DebugType.BindingFlagsAllInScope, null, GetTypes(args), null); |
||||
if (method == null) |
||||
throw new GetValueException("Method " + methodName + " not found"); |
||||
Value retVal = Value.InvokeMethod(this.EvalThread, target != null ? target.Value : null, method, GetValues(args)); |
||||
if (retVal == null) |
||||
return null; |
||||
return new TypedValue(retVal, (DebugType)method.ReturnType); |
||||
} |
||||
|
||||
public override object VisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data) |
||||
{ |
||||
if (!objectCreateExpression.ObjectInitializer.IsNull) |
||||
throw new EvaluateException(objectCreateExpression.ObjectInitializer, "Object initializers not supported"); |
||||
|
||||
DebugType type = objectCreateExpression.CreateType.ResolveType(context.AppDomain); |
||||
List<TypedValue> ctorArgs = EvaluateAll(objectCreateExpression.Parameters); |
||||
DebugConstructorInfo ctor = (DebugConstructorInfo)type.GetConstructor(BindingFlags.Default, null, CallingConventions.Any, GetTypes(ctorArgs), null); |
||||
if (ctor == null) |
||||
throw new EvaluateException(objectCreateExpression, "Constructor not found"); |
||||
Value val = Value.InvokeMethod(this.EvalThread, null, ctor.MethodInfo, GetValues(ctorArgs)); |
||||
return new TypedValue(val, type); |
||||
} |
||||
|
||||
public override object VisitArrayCreateExpression(ArrayCreateExpression arrayCreateExpression, object data) |
||||
{ |
||||
if (arrayCreateExpression.CreateType.RankSpecifier[0] != 0) |
||||
throw new EvaluateException(arrayCreateExpression, "Multi-dimensional arrays are not suppored"); |
||||
|
||||
DebugType type = arrayCreateExpression.CreateType.ResolveType(context.AppDomain); |
||||
int length = 0; |
||||
if (arrayCreateExpression.Arguments.Count == 1) { |
||||
length = EvaluateAsInt(arrayCreateExpression.Arguments[0]); |
||||
} else if (!arrayCreateExpression.ArrayInitializer.IsNull) { |
||||
length = arrayCreateExpression.ArrayInitializer.CreateExpressions.Count; |
||||
} |
||||
Value array = Eval.NewArray(this.EvalThread, (DebugType)type.GetElementType(), (uint)length, null); |
||||
if (!arrayCreateExpression.ArrayInitializer.IsNull) { |
||||
List<Expression> inits = arrayCreateExpression.ArrayInitializer.CreateExpressions; |
||||
if (inits.Count != length) |
||||
throw new EvaluateException(arrayCreateExpression, "Incorrect initializer length"); |
||||
for(int i = 0; i < length; i++) { |
||||
TypedValue init = EvaluateAs(inits[i], (DebugType)type.GetElementType()); |
||||
array.SetArrayElement(this.EvalThread, new int[] { i }, init.Value); |
||||
} |
||||
} |
||||
return new TypedValue(array, type); |
||||
} |
||||
|
||||
public override object VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression, object data) |
||||
{ |
||||
TypedValue target; |
||||
DebugType targetType; |
||||
try { |
||||
// Instance
|
||||
target = Evaluate(memberReferenceExpression.TargetObject); |
||||
targetType = target.Type; |
||||
} catch (GetValueException e) { |
||||
// Static
|
||||
target = null; |
||||
try { |
||||
targetType = memberReferenceExpression.TargetObject.ResolveType(context.AppDomain); |
||||
} catch (GetValueException) { |
||||
throw e; // Use the other, nicer message
|
||||
} |
||||
} |
||||
MemberInfo[] memberInfos = targetType.GetMember(memberReferenceExpression.MemberName, DebugType.BindingFlagsAllInScope); |
||||
if (memberInfos.Length == 0) |
||||
throw new GetValueException("Member \"" + memberReferenceExpression.MemberName + "\" not found"); |
||||
return new TypedValue( |
||||
Value.GetMemberValue(this.EvalThread, target != null ? target.Value : null, memberInfos[0]), |
||||
((IDebugMemberInfo)memberInfos[0]).MemberType |
||||
); |
||||
} |
||||
|
||||
public override object VisitParenthesizedExpression(ParenthesizedExpression parenthesizedExpression, object data) |
||||
{ |
||||
return Evaluate(parenthesizedExpression.Expression); |
||||
} |
||||
|
||||
public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data) |
||||
{ |
||||
return CreateValue(primitiveExpression.Value); |
||||
} |
||||
|
||||
TypedValue GetThisValue() |
||||
{ |
||||
// This is needed so that captured 'this' is supported
|
||||
DebugLocalVariableInfo thisVar = context.MethodInfo.GetLocalVariableThis(); |
||||
if (thisVar != null) |
||||
return new TypedValue(thisVar.GetValue(context), (DebugType)thisVar.LocalType); |
||||
|
||||
// when symbols are not present
|
||||
try { |
||||
return new TypedValue(context.GetThisValue(), (DebugType)context.MethodInfo.DeclaringType); |
||||
} catch (GetValueException) { |
||||
// static method
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) |
||||
{ |
||||
TypedValue thisValue = GetThisValue(); |
||||
if (thisValue == null) |
||||
throw new GetValueException(context.MethodInfo.FullName + " is static method and does not have \"this\""); |
||||
return thisValue; |
||||
} |
||||
|
||||
#region Binary and unary expressions
|
||||
|
||||
public override object VisitUnaryOperatorExpression(UnaryOperatorExpression unaryOperatorExpression, object data) |
||||
{ |
||||
TypedValue value = Evaluate(unaryOperatorExpression.Expression); |
||||
UnaryOperatorType op = unaryOperatorExpression.Op; |
||||
|
||||
if (op == UnaryOperatorType.Dereference) { |
||||
if (!value.Type.IsPointer) |
||||
throw new GetValueException("Target object is not a pointer"); |
||||
return new TypedValue(value.Value.Dereference(), (DebugType)value.Type.GetElementType()); |
||||
} |
||||
|
||||
if (!value.Type.IsPrimitive) |
||||
throw new GetValueException("Primitive value expected"); |
||||
|
||||
if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement || |
||||
op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement) |
||||
{ |
||||
TypedValue oldValue = value; |
||||
TypedValue newValue = null; |
||||
try { |
||||
if (op == UnaryOperatorType.Decrement || op == UnaryOperatorType.PostDecrement) |
||||
newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Subtract, new PrimitiveExpression(1)), null); |
||||
if (op == UnaryOperatorType.Increment || op == UnaryOperatorType.PostIncrement) |
||||
newValue = (TypedValue)VisitAssignmentExpression(new AssignmentExpression(unaryOperatorExpression.Expression, AssignmentOperatorType.Add, new PrimitiveExpression(1)), null); |
||||
} catch (EvaluateException e) { |
||||
throw new EvaluateException(unaryOperatorExpression, e.Message); |
||||
} |
||||
if (op == UnaryOperatorType.PostDecrement || op == UnaryOperatorType.PostIncrement) { |
||||
return oldValue; |
||||
} else { |
||||
// Note: the old unaryOparatorExpression is still cached and still has the old value
|
||||
return newValue; |
||||
} |
||||
} |
||||
|
||||
if (op == UnaryOperatorType.Minus) { |
||||
object val = value.PrimitiveValue; |
||||
// Special case - it would promote the value to long otherwise
|
||||
if (val is uint && (uint)val == (uint)1 << 31) |
||||
return CreateValue(int.MinValue); |
||||
|
||||
// Special case - it would overflow otherwise
|
||||
if (val is ulong && (ulong)val == (ulong)1 << 63) |
||||
return CreateValue(long.MinValue); |
||||
} |
||||
|
||||
if (op == UnaryOperatorType.Plus || op == UnaryOperatorType.Minus || |
||||
op == UnaryOperatorType.BitNot || op == UnaryOperatorType.Not) |
||||
{ |
||||
Type[] overloads; |
||||
if (op == UnaryOperatorType.Not) { |
||||
overloads = new Type[] { typeof(bool) }; |
||||
} else if (op == UnaryOperatorType.Minus) { |
||||
overloads = new Type[] { typeof(int), typeof(long), typeof(ulong), typeof(float), typeof(double) }; |
||||
} else { |
||||
overloads = new Type[] { typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double) }; |
||||
} |
||||
foreach(Type argType in overloads) { |
||||
if (value.Type.CanPromoteTo(argType)) { |
||||
object a = Convert.ChangeType(value.PrimitiveValue, argType); |
||||
object res; |
||||
try { |
||||
res = PerformUnaryOperation(a, op, argType); |
||||
} catch (ArithmeticException e) { |
||||
// Can happen for smaller int or long
|
||||
throw new EvaluateException(unaryOperatorExpression, e.Message); |
||||
} |
||||
if (res != null) |
||||
return CreateValue(res); |
||||
break; // Match only one overload
|
||||
} |
||||
} |
||||
} |
||||
|
||||
throw new EvaluateException(unaryOperatorExpression, "Can not use the unary operator {0} on type {1}", op.ToString(), value.Type.FullName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Perform given arithmetic operation.
|
||||
/// The arguments must be already converted to the correct types.
|
||||
/// </summary>
|
||||
object PerformUnaryOperation(object val, UnaryOperatorType op, Type argType) |
||||
{ |
||||
checked { |
||||
if (argType == typeof(bool)) { |
||||
bool a = (bool)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Not: return !a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(float)) { |
||||
float a = (float)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Minus: return -a; |
||||
case UnaryOperatorType.Plus: return +a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(double)) { |
||||
double a = (double)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Minus: return -a; |
||||
case UnaryOperatorType.Plus: return +a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(int)) { |
||||
int a = (int)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Minus: return -a; |
||||
case UnaryOperatorType.Plus: return +a; |
||||
case UnaryOperatorType.BitNot: return ~a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(uint)) { |
||||
uint a = (uint)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Plus: return +a; |
||||
case UnaryOperatorType.BitNot: return ~a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(long)) { |
||||
long a = (long)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Minus: return -a; |
||||
case UnaryOperatorType.Plus: return +a; |
||||
case UnaryOperatorType.BitNot: return ~a; |
||||
} |
||||
} |
||||
|
||||
if (argType == typeof(ulong)) { |
||||
ulong a = (ulong)val; |
||||
switch (op) { |
||||
case UnaryOperatorType.Plus: return +a; |
||||
case UnaryOperatorType.BitNot: return ~a; |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
public override object VisitBinaryOperatorExpression(BinaryOperatorExpression binaryOperatorExpression, object data) |
||||
{ |
||||
BinaryOperatorType op = binaryOperatorExpression.Op; |
||||
|
||||
TypedValue left = Evaluate(binaryOperatorExpression.Left); |
||||
TypedValue right = Evaluate(binaryOperatorExpression.Right); |
||||
|
||||
// Try to apply any implicit binary operation
|
||||
// Be careful to do these in correct order
|
||||
|
||||
// ==, !=
|
||||
// bool operator ==(string x, string y);
|
||||
//
|
||||
// ==, != C is not Value type; other rules apply (must be after string)
|
||||
// bool operator ==(C x, C y);
|
||||
|
||||
if (op == BinaryOperatorType.Equality || op == BinaryOperatorType.InEquality) { |
||||
if (left.Type.Is<string>() && right.Type.Is<string>()) { |
||||
if (left.Value.IsNull || right.Value.IsNull) { |
||||
return CreateValue(left.Value.IsNull && right.Value.IsNull); |
||||
} else { |
||||
return CreateValue((string)left.PrimitiveValue == (string)right.PrimitiveValue); |
||||
} |
||||
} |
||||
if (!left.Type.IsValueType && !right.Type.IsValueType) { |
||||
// Reference comparison
|
||||
if (left.Value.IsNull || right.Value.IsNull) { |
||||
return CreateValue(left.Value.IsNull && right.Value.IsNull); |
||||
} else { |
||||
return CreateValue(left.Value.Address == right.Value.Address); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// +
|
||||
// string operator +(string x, string y);
|
||||
// string operator +(string x, object y);
|
||||
// string operator +(object x, string y);
|
||||
|
||||
if (op == BinaryOperatorType.Add) { |
||||
if (left.Type.Is<string>() || right.Type.Is<string>()) { |
||||
string a = left.Value.IsNull ? string.Empty : left.Value.InvokeToString(this.EvalThread); |
||||
string b = right.Value.IsNull ? string.Empty : right.Value.InvokeToString(this.EvalThread); |
||||
return CreateValue(a + b); |
||||
} |
||||
} |
||||
|
||||
// <<, >>
|
||||
// int operator <<(int x, int count);
|
||||
// uint operator <<(uint x, int count);
|
||||
// long operator <<(long x, int count);
|
||||
// ulong operator <<(ulong x, int count);
|
||||
|
||||
if (op == BinaryOperatorType.ShiftLeft || op == BinaryOperatorType.ShiftRight) { |
||||
Type[] overloads = { typeof(int), typeof(uint), typeof(long), typeof(ulong)}; |
||||
foreach(Type argType in overloads) { |
||||
if (left.Type.CanPromoteTo(argType) && right.Type.CanPromoteTo(typeof(int))) { |
||||
object a = Convert.ChangeType(left.PrimitiveValue, argType); |
||||
object b = Convert.ChangeType(right.PrimitiveValue, typeof(int)); |
||||
// Shift operations never cause overflows
|
||||
object res = PerformBinaryOperation(a, b, op, argType); |
||||
return CreateValue(res); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// *, /, %, +, and –
|
||||
// ==, !=, <, >, <=, >=,
|
||||
// &, ^, and | (except float and double)
|
||||
// int operator +(int x, int y);
|
||||
// uint operator +(uint x, uint y);
|
||||
// long operator +(long x, long y);
|
||||
// ulong operator +(ulong x, ulong y);
|
||||
// void operator +(long x, ulong y);
|
||||
// void operator +(ulong x, long y);
|
||||
// float operator +(float x, float y);
|
||||
// double operator +(double x, double y);
|
||||
//
|
||||
// &, |, ^, &&, ||
|
||||
// ==, !=
|
||||
// bool operator &(bool x, bool y);
|
||||
|
||||
if (op != BinaryOperatorType.ShiftLeft && op != BinaryOperatorType.ShiftRight) { |
||||
Type[] overloads = { typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(bool) }; |
||||
foreach(Type argType in overloads) { |
||||
if (left.Type.CanPromoteTo(argType) && right.Type.CanPromoteTo(argType)) { |
||||
if (argType == typeof(float) || argType == typeof(double)) { |
||||
// Invalid overloads
|
||||
if (left.Type.CanPromoteTo(typeof(long)) && right.Type.CanPromoteTo(typeof(ulong))) |
||||
break; |
||||
if (left.Type.CanPromoteTo(typeof(ulong)) && right.Type.CanPromoteTo(typeof(long))) |
||||
break; |
||||
} |
||||
object a = Convert.ChangeType(left.PrimitiveValue, argType); |
||||
object b = Convert.ChangeType(right.PrimitiveValue, argType); |
||||
object res; |
||||
try { |
||||
res = PerformBinaryOperation(a, b, op, argType); |
||||
} catch (ArithmeticException e) { |
||||
throw new EvaluateException(binaryOperatorExpression, e.Message); |
||||
} |
||||
if (res != null) |
||||
return CreateValue(res); |
||||
break; // Match only one overload
|
||||
} |
||||
} |
||||
} |
||||
|
||||
throw new EvaluateException(binaryOperatorExpression, "Can not use the binary operator {0} on types {1} and {2}", op.ToString(), left.Type.FullName, right.Type.FullName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Perform given arithmetic operation.
|
||||
/// The arguments must be already converted to the correct types.
|
||||
/// </summary>
|
||||
object PerformBinaryOperation(object left, object right, BinaryOperatorType op, Type argTypes) |
||||
{ |
||||
checked { |
||||
if (argTypes == typeof(string)) { |
||||
string a = (string)left; |
||||
string b = (string)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.Add: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(bool)) { |
||||
bool a = (bool)left; |
||||
bool b = (bool)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.ExclusiveOr: return a ^ b; |
||||
case BinaryOperatorType.BitwiseAnd: return a & b; |
||||
case BinaryOperatorType.BitwiseOr: return a | b; |
||||
case BinaryOperatorType.LogicalAnd: return a && b; |
||||
case BinaryOperatorType.LogicalOr: return a || b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(float)) { |
||||
float a = (float)left; |
||||
float b = (float)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(double)) { |
||||
double a = (double)left; |
||||
double b = (double)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(int)) { |
||||
switch (op) { |
||||
case BinaryOperatorType.ShiftLeft: return (int)left << (int)right; |
||||
case BinaryOperatorType.ShiftRight: return (int)left >> (int)right; |
||||
} |
||||
int a = (int)left; |
||||
int b = (int)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.BitwiseAnd: return a & b; |
||||
case BinaryOperatorType.BitwiseOr: return a | b; |
||||
case BinaryOperatorType.ExclusiveOr: return a ^ b; |
||||
|
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(uint)) { |
||||
switch (op) { |
||||
case BinaryOperatorType.ShiftLeft: return (uint)left << (int)right; |
||||
case BinaryOperatorType.ShiftRight: return (uint)left >> (int)right; |
||||
} |
||||
uint a = (uint)left; |
||||
uint b = (uint)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.BitwiseAnd: return a & b; |
||||
case BinaryOperatorType.BitwiseOr: return a | b; |
||||
case BinaryOperatorType.ExclusiveOr: return a ^ b; |
||||
|
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(long)) { |
||||
switch (op) { |
||||
case BinaryOperatorType.ShiftLeft: return (long)left << (int)right; |
||||
case BinaryOperatorType.ShiftRight: return (long)left >> (int)right; |
||||
} |
||||
long a = (long)left; |
||||
long b = (long)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.BitwiseAnd: return a & b; |
||||
case BinaryOperatorType.BitwiseOr: return a | b; |
||||
case BinaryOperatorType.ExclusiveOr: return a ^ b; |
||||
|
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
if (argTypes == typeof(ulong)) { |
||||
switch (op) { |
||||
case BinaryOperatorType.ShiftLeft: return (ulong)left << (int)right; |
||||
case BinaryOperatorType.ShiftRight: return (ulong)left >> (int)right; |
||||
} |
||||
ulong a = (ulong)left; |
||||
ulong b = (ulong)right; |
||||
switch (op) { |
||||
case BinaryOperatorType.BitwiseAnd: return a & b; |
||||
case BinaryOperatorType.BitwiseOr: return a | b; |
||||
case BinaryOperatorType.ExclusiveOr: return a ^ b; |
||||
|
||||
case BinaryOperatorType.GreaterThan: return a > b; |
||||
case BinaryOperatorType.GreaterThanOrEqual: return a >= b; |
||||
case BinaryOperatorType.Equality: return a == b; |
||||
case BinaryOperatorType.InEquality: return a != b; |
||||
case BinaryOperatorType.LessThan: return a < b; |
||||
case BinaryOperatorType.LessThanOrEqual: return a <= b; |
||||
|
||||
case BinaryOperatorType.Add: return a + b; |
||||
case BinaryOperatorType.Subtract: return a - b; |
||||
case BinaryOperatorType.Multiply: return a * b; |
||||
case BinaryOperatorType.Divide: return a / b; |
||||
case BinaryOperatorType.Modulus: return a % b; |
||||
case BinaryOperatorType.Concat: return a + b; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System.Reflection; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("IconEditor")] |
||||
[assembly: AssemblyDescription("IconEditor with support for Windows Vista icons")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
@ -1,78 +0,0 @@
@@ -1,78 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>IconEditor</RootNamespace> |
||||
<AssemblyName>IconEditor</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}</ProjectGuid> |
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>134742016</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<RunPostBuildEvent>Always</RunPostBuildEvent> |
||||
<OutputPath>..\..\..\..\..\AddIns\DisplayBindings\IconEditor\</OutputPath> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<IntermediateOutputPath>obj\Debug\</IntermediateOutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> |
||||
<IntermediateOutputPath>obj\Release\</IntermediateOutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="MainForm.cs" /> |
||||
<Compile Include="MainForm.Designer.cs"> |
||||
<DependentUpon>MainForm.cs</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="AssemblyInfo.cs" /> |
||||
<Compile Include="IconFile.cs" /> |
||||
<Compile Include="IconEntry.cs" /> |
||||
<Compile Include="InvalidIconException.cs" /> |
||||
<EmbeddedResource Include="MainForm.resx"> |
||||
<DependentUpon>MainForm.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
<Compile Include="IconPanel.Designer.cs"> |
||||
<DependentUpon>IconPanel.cs</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="IconPanel.cs" /> |
||||
<EmbeddedResource Include="IconPanel.resx"> |
||||
<DependentUpon>IconPanel.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
<Compile Include="AlphaTransparentBitmap.cs" /> |
||||
<Compile Include="EditorPanel.Designer.cs"> |
||||
<DependentUpon>EditorPanel.cs</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="EditorPanel.cs" /> |
||||
<EmbeddedResource Include="EditorPanel.resx"> |
||||
<DependentUpon>EditorPanel.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
||||
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.1.0.1626 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditor", "IconEditor.csproj", "{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}" |
||||
EndProject |
||||
Global |
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
||||
Debug|Any CPU = Debug|Any CPU |
||||
Release|Any CPU = Release|Any CPU |
||||
EndGlobalSection |
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
||||
{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
EndGlobalSection |
||||
EndGlobal |
||||
@ -1,130 +0,0 @@
@@ -1,130 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
namespace IconEditor |
||||
{ |
||||
partial class MainForm : System.Windows.Forms.Form |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); |
||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip(); |
||||
this.newToolStripButton = new System.Windows.Forms.ToolStripButton(); |
||||
this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); |
||||
this.saveToolStripButton = new System.Windows.Forms.ToolStripButton(); |
||||
this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); |
||||
this.helpToolStripButton = new System.Windows.Forms.ToolStripButton(); |
||||
this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); |
||||
this.toolStrip1.SuspendLayout(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { |
||||
this.newToolStripButton, |
||||
this.openToolStripButton, |
||||
this.saveToolStripButton, |
||||
this.toolStripSeparator, |
||||
this.helpToolStripButton}); |
||||
this.toolStrip1.Location = new System.Drawing.Point(0, 0); |
||||
this.toolStrip1.Name = "toolStrip1"; |
||||
this.toolStrip1.Size = new System.Drawing.Size(331, 25); |
||||
this.toolStrip1.TabIndex = 1; |
||||
this.toolStrip1.Text = "toolStrip1"; |
||||
//
|
||||
// newToolStripButton
|
||||
//
|
||||
this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; |
||||
this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image"))); |
||||
this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; |
||||
this.newToolStripButton.Name = "newToolStripButton"; |
||||
this.newToolStripButton.Size = new System.Drawing.Size(23, 22); |
||||
this.newToolStripButton.Text = "&New"; |
||||
this.newToolStripButton.Click += new System.EventHandler(this.NewToolStripButtonClick); |
||||
//
|
||||
// openToolStripButton
|
||||
//
|
||||
this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; |
||||
this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image"))); |
||||
this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; |
||||
this.openToolStripButton.Name = "openToolStripButton"; |
||||
this.openToolStripButton.Size = new System.Drawing.Size(23, 22); |
||||
this.openToolStripButton.Text = "&Open"; |
||||
this.openToolStripButton.Click += new System.EventHandler(this.OpenToolStripButtonClick); |
||||
//
|
||||
// saveToolStripButton
|
||||
//
|
||||
this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; |
||||
this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image"))); |
||||
this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; |
||||
this.saveToolStripButton.Name = "saveToolStripButton"; |
||||
this.saveToolStripButton.Size = new System.Drawing.Size(23, 22); |
||||
this.saveToolStripButton.Text = "&Save"; |
||||
this.saveToolStripButton.Click += new System.EventHandler(this.SaveToolStripButtonClick); |
||||
//
|
||||
// toolStripSeparator
|
||||
//
|
||||
this.toolStripSeparator.Name = "toolStripSeparator"; |
||||
this.toolStripSeparator.Size = new System.Drawing.Size(6, 25); |
||||
//
|
||||
// helpToolStripButton
|
||||
//
|
||||
this.helpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; |
||||
this.helpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("helpToolStripButton.Image"))); |
||||
this.helpToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; |
||||
this.helpToolStripButton.Name = "helpToolStripButton"; |
||||
this.helpToolStripButton.Size = new System.Drawing.Size(23, 22); |
||||
this.helpToolStripButton.Text = "He&lp"; |
||||
this.helpToolStripButton.Click += new System.EventHandler(this.HelpToolStripButtonClick); |
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
this.openFileDialog.FileName = "openFileDialog1"; |
||||
this.openFileDialog.Filter = "Icon files|*.ico|Cursor files|*.cur|All files|*.*"; |
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.ClientSize = new System.Drawing.Size(331, 305); |
||||
this.Controls.Add(this.toolStrip1); |
||||
this.Name = "MainForm"; |
||||
this.Text = "IconEditor"; |
||||
this.toolStrip1.ResumeLayout(false); |
||||
this.toolStrip1.PerformLayout(); |
||||
this.ResumeLayout(false); |
||||
this.PerformLayout(); |
||||
} |
||||
private System.Windows.Forms.OpenFileDialog openFileDialog; |
||||
private System.Windows.Forms.ToolStripButton helpToolStripButton; |
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator; |
||||
private System.Windows.Forms.ToolStripButton saveToolStripButton; |
||||
private System.Windows.Forms.ToolStripButton openToolStripButton; |
||||
private System.Windows.Forms.ToolStripButton newToolStripButton; |
||||
private System.Windows.Forms.ToolStrip toolStrip1; |
||||
} |
||||
} |
||||
@ -1,108 +0,0 @@
@@ -1,108 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace IconEditor |
||||
{ |
||||
public partial class MainForm |
||||
{ |
||||
[STAThread] |
||||
public static void Main(string[] args) |
||||
{ |
||||
Application.EnableVisualStyles(); |
||||
Application.SetCompatibleTextRenderingDefault(false); |
||||
//ScanIcons(new DirectoryInfo(@"d:\net\icons"));
|
||||
Application.Run(new MainForm()); |
||||
} |
||||
|
||||
// scan for invalid or special icons
|
||||
static void ScanIcons(DirectoryInfo dir) |
||||
{ |
||||
foreach (DirectoryInfo subdir in dir.GetDirectories()) { |
||||
ScanIcons(subdir); |
||||
} |
||||
foreach (FileInfo file in dir.GetFiles("*.ico")) { |
||||
try { |
||||
IconFile f = new IconFile(file.OpenRead()); |
||||
if (f.AvailableColorDepths.Contains(24)) { |
||||
Debug.WriteLine(file.FullName + " - 24"); |
||||
} |
||||
} catch (InvalidIconException ex) { |
||||
Debug.WriteLine(file.FullName + " - " + ex.Message); |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void Save(string fileName, Stream data) |
||||
{ |
||||
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { |
||||
byte[] buffer = new byte[4096]; |
||||
int c; |
||||
do { |
||||
c = data.Read(buffer, 0, buffer.Length); |
||||
if (c != 0) |
||||
fs.Write(buffer, 0, c); |
||||
} while (c != 0); |
||||
} |
||||
} |
||||
|
||||
EditorPanel pnl = new EditorPanel(); |
||||
|
||||
public MainForm() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
|
||||
pnl.Dock = DockStyle.Fill; |
||||
Controls.Add(pnl); |
||||
Controls.SetChildIndex(pnl, 0); |
||||
|
||||
//IconFile f = new IconFile(@"D:\net\icons\WinXP\Internet.ico");
|
||||
//IconFile f = new IconFile(@"c:\temp\example-vista-icon-2.ico");
|
||||
//IconFile f = new IconFile(@"D:\NET\Icons\exit.ico");
|
||||
//pnl.ShowFile(f);
|
||||
} |
||||
|
||||
void HelpToolStripButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
MessageBox.Show(@"SharpDevelop IconEditor:
|
||||
(C) Daniel Grunwald, 2006 |
||||
|
||||
Contact me: daniel@danielgrunwald.de", "IconEditor");
|
||||
} |
||||
|
||||
string fileName; |
||||
|
||||
void NewToolStripButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
fileName = null; |
||||
pnl.ShowFile(new IconFile()); |
||||
} |
||||
|
||||
void OpenToolStripButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) { |
||||
try { |
||||
pnl.ShowFile(new IconFile(openFileDialog.FileName)); |
||||
fileName = openFileDialog.FileName; |
||||
} catch (InvalidIconException ex) { |
||||
MessageBox.Show("Invalid icon file: " + ex.Message); |
||||
} catch (IOException ex) { |
||||
MessageBox.Show("Error opening icon file: " + ex.Message); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void SaveToolStripButtonClick(object sender, EventArgs e) |
||||
{ |
||||
MessageBox.Show("not implemented"); |
||||
//pnl.SaveIcon(@"c:\temp\save.ico");
|
||||
} |
||||
} |
||||
} |
||||
@ -1,187 +0,0 @@
@@ -1,187 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>17, 17</value> |
||||
</metadata> |
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> |
||||
<data name="newToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value> |
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 |
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAQ9JREFUOE+t09lq |
||||
wkAUBmBfyr5DfY32jaReSOmFCyKCgkKLFrVUBZeKiEbshqRuaNw1xiXmLxMJBJ0Zc+GBw9zMfDPnHMZm |
||||
u1ZE35s4zXCqjmC8Al+sgHLjD9y7yGFWPIbecOO45yORtMAEHnxxJHL1IyKI9JeEXqtMwOl50Q8bSS0l |
||||
8PzBBPbqAQQxICrgjeapgKZpkJUdBmNZB+y3d/QSnsIZKrDdqZjMFYj9OR9wB1NngHrQsJC36EkrfIkT |
||||
PuDyJ84AZbOHNF2j1Z2h9i3xAVKfOUjjZssN2oMFmq0xSkLfOmBu3E97iurnENlKxzpgbpzwO0Kh1kOy |
||||
KFoDjHmzVuYYjRmTDZfyWh9Yd/4B2Mz2w1z7EGUAAAAASUVORK5CYII= |
||||
</value> |
||||
</data> |
||||
<data name="openToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value> |
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 |
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAlpJREFUOE+tk21I |
||||
k1EYhif0oyA0sqIQCix/+GcQFFH9CCmiUBTLLEjShJofVBgL2fxoU9Pp5ubUlS5rU9f8rCyjsA+pUCRC |
||||
TR1ppmVFUSlmhq78unrnQF1KGHTg/nEOz30993PO+7qJFrmUeiv2n+Mij+XLRLLYULdF2pxlEVIDcw0p |
||||
AsyxD5fmI/rQ94pqi26eOlsfuZj+7BgSm01QdA4ih7m73Yx9qGpavwatjPebqCzOprPt8YKQgzFagqL0 |
||||
BEjyEFWVaBkdLHMxT34uYNwWR9nVTEoL0zHlp2DMSeaSRk6eKt4VWm5WM/rVPNN5SjDTLQebZEHNA1wr |
||||
UvHjk3E6tsNcV62e1r3KLGqtKm6WplNpSsVqVFJsOM8VfSKFWjkGtcyZptSYzvC7XByx3zQoqCnTMvlG |
||||
CX1prnornPUmQJcUXsbSVhGK5bIOkcmQyveeTHiv4VZ5Nk33Nc6iuSO8CIfmECYa/bE/8ON1iRipJNh5 |
||||
F0V6Bd86lfQ1JlFj1TDVq4COKCegLVIwHmGiKRB7/V6G7+5koHozymgfYRy5E1CgTWKgXcZ1i5qWp0KS |
||||
rjgBcAJawph6FszYk/2M1O1isGYLX8p9ab6wgqP+3rMvYciS01GfzA1LFvQkQ6sQ9/khxhoCGHnox1Dt |
||||
NvorxXw0b8Km8UQh2cip6GOzgNyMeKqKM7HdjqFZJ5pRk2YJ9aql3EnxoCJxNaZ4Ly6e3UDY3O6OEXRp |
||||
59ApTpIhiyDh9GHORAZyPHQPB/ZtZ/cOMVvFPvh6e7F+3SrWrHRnraf7Xz/xf/rJ/kvxb84I3U1y+9/W |
||||
AAAAAElFTkSuQmCC |
||||
</value> |
||||
</data> |
||||
<data name="saveToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value> |
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 |
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAixJREFUOE+tk91L |
||||
k3EUx/cvdN9N0EW3NTWGa7EaPOUcyqphWBG9PZEv5dJlmqhYmUYtXyBb4dJJy+kknFT4BqZIjaFMJUsz |
||||
V7TEoabYRDD49ju/6Pm1Mi+iH5zLz+c855zvo1L9j/fsaRRUvvZltHmX8Ni9gMaGCO47ZlBb8wn22yHc |
||||
KJ9CackECgteIy93FBfOB6H0JrC3B6ipXsVGb2V1Dca0XhxOe8JLEXhbF7mgsuLLX3mCIwsr2G1+DrVa |
||||
huWQRwjcj+a5oLTk87qCn/D78CLiTD4UXJ7GAXOTEDjrZ7ngku3dH4Jf4ZHJCLZJXlhzxpGa4hSCurth |
||||
LsjOGo0R/A4PBsPYrHdDlgMwmRxCUF31kQvkMwFFsB7c4/+ATYkNOHL0BZKSaoXgZuU0urvATgkcP/kK |
||||
lmMDfNu0MJqZPps6/4D7cNDSCUmyC8HVskl0+MAyADS5vrG7f0X59Tm+VFoYzZyZEVTg5NR2GAwVQnCl |
||||
cByeZuChc40FJwpjek5MmU/YkH6uiHdOTmHwfg/0+jIhsOWNMRiouhPlnUnAQoI4rYSht7MYm5qDnHsN |
||||
e41tHNbucUGnKxICiqXjHpTPJgHBZ/Nv4U1oHqGZJVwstiNe72JwI+J3PYA2MV8IMjOG2dzLfOatBg+2 |
||||
7JDQ0tEPX9cguvv8GHg5hH0mC9S6eiQweLumDhqNVQgo06dP9fN4UsIoJHRnOhVtmxZGM1NXKoJ3JmTH |
||||
Cv71r/4OTrQ4xWMwWlcAAAAASUVORK5CYII= |
||||
</value> |
||||
</data> |
||||
<data name="helpToolStripButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value> |
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 |
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAhhJREFUOE+1U09r |
||||
E0EU70fIR9iPUBQ8eMrR46IN5JhCDz2oBA8SBHEpCMFgG5GiwdJdq2Ijqe6ldo3Wrmhri0gXazW2YbMt |
||||
UdNmm45ulf7R/HwzU1hLIzn54LFvhvn9eW9nOjr+R0wvBLhTXEf6bgV9w0sYLJQx/uoz2mq9c7eRn2pA |
||||
L67Bq+/i29YeWLBL9Q6u5ktI6w6Kr1dbE3HwA3sT/o8mbAfQRgE1LZPXtsPgbjZxaXAG4y/Kh0m48sbP |
||||
JgwbiKYAwwLYNkR4DEje5HsMFSI5l3l2kGD6/RYezzeEMgfzwzzMWSCRlV9OFk0xqhl06wNy+Tchyb2n |
||||
dXxhv4TVaFLazppAJ9VKL0MySxYoVI0hkXaw5AbovjAWEmTur4qBqZoEdfbKVCgTBObqdolBUW0ocRs1 |
||||
P8Cx2PWQ4PJtl6a9J+xLIB1OMHIilU2b1gSMqCZ9TdTq33FEHQgJcg8rWPF3qHcJVOKeyOyoJIioDqUk |
||||
UFM2SuUqus4YIcHEzFdYji8GxIGROAc41JJHc6E1B58wRRqWhzFrEVduTR78E5mRBSz7v0l1H0AgXgsH |
||||
+2DNcPBp3cep0/rhezA5V0Vfbg5ug+4CqaiaI/rmyWu+t1zdQIysDxdmW9/GiZcVnO+fgvHkI+YXV7BG |
||||
067VA9Ezt91Fyvq/wH8/lKHCW/RcfITj8Rs4evIaYmdHkBl63v4xtX1tLQ78AZ3a8qxOv4hDAAAAAElF |
||||
TkSuQmCC |
||||
</value> |
||||
</data> |
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>116, 17</value> |
||||
</metadata> |
||||
</root> |
||||
@ -1,64 +0,0 @@
@@ -1,64 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
/* |
||||
using Microsoft.Win32; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.FiletypeRegisterer.Unregister |
||||
{ |
||||
|
||||
public class MainClass |
||||
{ |
||||
const int SHCNE_ASSOCCHANGED = 0x08000000; |
||||
const int SHCNF_IDLIST = 0x0; |
||||
|
||||
public static void UnRegisterFiletype(string extension) { |
||||
try { |
||||
Registry.ClassesRoot.DeleteSubKeyTree("SD." + extension + "file"); |
||||
|
||||
RegistryKey extKey; |
||||
extKey = Registry.ClassesRoot.OpenSubKey("." + extension, true); |
||||
|
||||
// if no association return
|
||||
if (extKey == null) return; |
||||
// if other association return too
|
||||
if ((string)extKey.GetValue("", "") != ("SD." + extension + "file")) return; |
||||
|
||||
// restore previous association
|
||||
string prev = (string)extKey.GetValue("PreSD", ""); |
||||
if(prev != "") { |
||||
extKey.SetValue("", prev); |
||||
} |
||||
extKey.Close(); |
||||
|
||||
|
||||
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, IntPtr.Zero, IntPtr.Zero); |
||||
} catch {} |
||||
|
||||
} |
||||
|
||||
[System.Runtime.InteropServices.DllImport("shell32.dll")] |
||||
static extern void SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2); |
||||
|
||||
public static void Main() { |
||||
Console.WriteLine("--------------------------------"); |
||||
Console.WriteLine(" Filetype Unregister"); |
||||
Console.WriteLine("--------------------------------"); |
||||
|
||||
string[] args = Environment.GetCommandLineArgs(); |
||||
if (args.Length != 2) { |
||||
Console.WriteLine("\nUsage: Unregister.exe ext"); |
||||
Console.WriteLine(" where ext is the extension, e.g. cs"); |
||||
return; |
||||
} |
||||
|
||||
System.Console.WriteLine("Unregistering " + args[1] + "..."); |
||||
UnRegisterFiletype(args[1]); |
||||
Console.WriteLine("\nSuccessful."); |
||||
return; |
||||
} |
||||
|
||||
} |
||||
} |
||||
*/ |
||||
Loading…
Reference in new issue