You've already forked linux-packaging-mono
Imported Upstream version 5.8.0.22
Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
parent
5f4a27cc8a
commit
7d05485754
@ -47,7 +47,6 @@ using System.Windows.Markup;
|
||||
[assembly: NeutralResourcesLanguage ("en")]
|
||||
[assembly: CLSCompliant (true)]
|
||||
[assembly: AssemblyDelaySign (true)]
|
||||
[assembly: AssemblyKeyFile ("../winfx3.pub")]
|
||||
|
||||
[assembly: ComVisible (false)]
|
||||
[assembly: AllowPartiallyTrustedCallers]
|
||||
|
@ -4,13 +4,11 @@ include ../../build/rules.make
|
||||
LIBRARY = WindowsBase.dll
|
||||
|
||||
LIB_REFS = System System.Xml
|
||||
KEYFILE = ../winfx3.pub
|
||||
LIB_MCS_FLAGS = -unsafe -nowarn:67,618
|
||||
TEST_MCS_FLAGS = -unsafe
|
||||
TEST_LIB_REFS = WindowsBase System System.Xml System.Core System.IO.Compression
|
||||
|
||||
ifeq (2.0, $(FRAMEWORK_VERSION))
|
||||
LIB_MCS_FLAGS += -d:NET_3_0
|
||||
endif
|
||||
ifeq (4, $(FRAMEWORK_VERSION_MAJOR))
|
||||
LIB_REFS += System.Xaml
|
||||
TEST_LIB_REFS += System.Xaml
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Converters {
|
||||
@ -32,22 +32,26 @@ namespace System.Windows.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Int32Rect;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Int32Rect.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Int32Rect int32Rect)
|
||||
return int32Rect.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Converters {
|
||||
@ -32,22 +32,26 @@ namespace System.Windows.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Point;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Point.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Point point)
|
||||
return point.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,7 @@
|
||||
// Authors:
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Converters {
|
||||
@ -32,22 +31,26 @@ namespace System.Windows.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Rect;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Rect.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Rect rect)
|
||||
return rect.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Converters {
|
||||
@ -32,22 +34,26 @@ namespace System.Windows.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Size;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Size.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Size size)
|
||||
return size.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
// Chris Toshok (toshok@ximian.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Converters {
|
||||
@ -32,22 +32,26 @@ namespace System.Windows.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Vector;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Vector.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Vector vector)
|
||||
return vector.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace System.Windows.Media.Converters {
|
||||
@ -32,22 +33,26 @@ namespace System.Windows.Media.Converters {
|
||||
{
|
||||
public override bool CanConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool CanConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return value is Matrix;
|
||||
}
|
||||
|
||||
public override object ConvertFromString (string value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value == null)
|
||||
throw new NotSupportedException ("value != null");
|
||||
return Matrix.Parse (value);
|
||||
}
|
||||
|
||||
public override string ConvertToString (object value, IValueSerializerContext context)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (value is Matrix matrix)
|
||||
return matrix.ToString (CultureInfo.InvariantCulture);
|
||||
return base.ConvertToString (value, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media.Converters;
|
||||
using System.Windows.Threading;
|
||||
@ -109,7 +110,16 @@ namespace System.Windows.Media {
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = _m11.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _m12.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _m21.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _m22.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _offsetX.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _offsetY.GetHashCode ();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public void Invert ()
|
||||
@ -167,7 +177,41 @@ namespace System.Windows.Media {
|
||||
|
||||
public static Matrix Parse (string source)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
Matrix value;
|
||||
if (source.Trim () == "Identity")
|
||||
{
|
||||
value = Identity;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
double m11;
|
||||
double m12;
|
||||
double m21;
|
||||
double m22;
|
||||
double offsetX;
|
||||
double offsetY;
|
||||
if (double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m11)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m12)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m21)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out m22)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out offsetX)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out offsetY))
|
||||
{
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException ("Invalid Matrix format: " + source);
|
||||
}
|
||||
value = new Matrix (m11, m12, m21, m22, offsetX, offsetY);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Matrix format: {0}", source));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void Prepend (Matrix matrix)
|
||||
@ -294,24 +338,40 @@ namespace System.Windows.Media {
|
||||
Prepend (m);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format,
|
||||
IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (IsIdentity)
|
||||
return "Identity";
|
||||
else
|
||||
return string.Format ("{0},{1},{2},{3},{4},{5}",
|
||||
_m11, _m12, _m21, _m22, _offsetX, _offsetY);
|
||||
return ToString (null);
|
||||
}
|
||||
|
||||
public string ToString (IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ToString (null, provider);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format,
|
||||
IFormatProvider provider)
|
||||
{
|
||||
return ToString (provider);
|
||||
}
|
||||
|
||||
private string ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
if (IsIdentity)
|
||||
return "Identity";
|
||||
|
||||
if (provider == null)
|
||||
provider = CultureInfo.CurrentCulture;
|
||||
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
|
||||
var separator = NumericListTokenizer.GetSeparator (provider);
|
||||
|
||||
var matrixFormat = string.Format (
|
||||
"{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}{1}{{4:{0}}}{1}{{5:{0}}}",
|
||||
format, separator);
|
||||
return string.Format (provider, matrixFormat,
|
||||
_m11, _m12, _m21, _m22, _offsetX, _offsetY);
|
||||
}
|
||||
|
||||
public Point Transform (Point point)
|
||||
|
@ -33,22 +33,24 @@ namespace System.Windows.Media {
|
||||
{
|
||||
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return sourceType == typeof (string);
|
||||
}
|
||||
|
||||
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return destinationType == typeof (string);
|
||||
}
|
||||
|
||||
public override object ConvertFrom (ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (!(value is string))
|
||||
throw new NotSupportedException ("MatrixConverter only supports converting from strings");
|
||||
return Matrix.Parse ((string)value);
|
||||
}
|
||||
|
||||
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ((Matrix)value).ToString (culture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Converters;
|
||||
using System.Windows.Markup;
|
||||
|
||||
@ -109,29 +109,84 @@ namespace System.Windows {
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = _x;
|
||||
hashCode = (hashCode * 397) ^ _y;
|
||||
hashCode = (hashCode * 397) ^ _width;
|
||||
hashCode = (hashCode * 397) ^ _height;
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public static Int32Rect Parse (string source)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
Int32Rect value;
|
||||
if (source.Trim () == "Empty")
|
||||
{
|
||||
value = Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
if (int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out x)
|
||||
&& int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out y)
|
||||
&& int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out width)
|
||||
&& int.TryParse (tokenizer.GetNextToken (), NumberStyles.Integer, CultureInfo.InvariantCulture, out height))
|
||||
{
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException ("Invalid Int32Rect format: " + source);
|
||||
}
|
||||
value = new Int32Rect (x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Int32Rect format: {0}", source));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (IsEmpty)
|
||||
return "Empty";
|
||||
return String.Format ("{0},{1},{2},{3}", _x, _y, _width, _height);
|
||||
return ToString (null);
|
||||
}
|
||||
|
||||
public string ToString (IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ToString (null, provider);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ToString (provider);
|
||||
}
|
||||
|
||||
private string ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
if (IsEmpty)
|
||||
return "Empty";
|
||||
|
||||
if (provider == null)
|
||||
provider = CultureInfo.CurrentCulture;
|
||||
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
|
||||
var separator = NumericListTokenizer.GetSeparator (provider);
|
||||
|
||||
var rectFormat = string.Format (
|
||||
"{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}",
|
||||
format, separator);
|
||||
return string.Format (provider, rectFormat,
|
||||
_x, _y, _width, _height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
102
mcs/class/WindowsBase/System.Windows/NumericListTokenizer.cs
Normal file
102
mcs/class/WindowsBase/System.Windows/NumericListTokenizer.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace System.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper class for parsing serialized data structures from the System.Windows namespace.
|
||||
/// </summary>
|
||||
internal class NumericListTokenizer
|
||||
{
|
||||
private readonly string _str;
|
||||
private readonly char _separator;
|
||||
private int _position;
|
||||
|
||||
private enum Symbol
|
||||
{
|
||||
Token,
|
||||
Separator,
|
||||
Whitspace,
|
||||
EndOfLine
|
||||
}
|
||||
|
||||
public NumericListTokenizer (string str, IFormatProvider formatProvider)
|
||||
{
|
||||
_str = str ?? throw new ArgumentNullException (nameof(str));
|
||||
_separator = GetSeparator (formatProvider ?? throw new ArgumentNullException (nameof(formatProvider)));
|
||||
}
|
||||
|
||||
public static char GetSeparator (IFormatProvider formatProvider)
|
||||
{
|
||||
// By convention, string representations of target classes always use ';' as a separator
|
||||
// if the decimal number separator is ','. Otherwise, the separator is ','.
|
||||
return NumberFormatInfo.GetInstance (formatProvider).NumberDecimalSeparator != "," ? ',' : ';';
|
||||
}
|
||||
|
||||
private Symbol GetCurrentSymbol ()
|
||||
{
|
||||
if (_position >= _str.Length)
|
||||
return Symbol.EndOfLine;
|
||||
if (_str[_position] == _separator)
|
||||
return Symbol.Separator;
|
||||
if (char.IsWhiteSpace (_str, _position))
|
||||
return Symbol.Whitspace;
|
||||
return Symbol.Token;
|
||||
}
|
||||
|
||||
private void SkipAllWhitespaces ()
|
||||
{
|
||||
while (GetCurrentSymbol () == Symbol.Whitspace)
|
||||
{
|
||||
_position++;
|
||||
}
|
||||
}
|
||||
|
||||
private void SkipNextDelimeter ()
|
||||
{
|
||||
SkipAllWhitespaces ();
|
||||
switch (GetCurrentSymbol ())
|
||||
{
|
||||
case Symbol.Token:
|
||||
return;
|
||||
case Symbol.Separator:
|
||||
_position++;
|
||||
SkipAllWhitespaces ();
|
||||
return;
|
||||
default:
|
||||
throw new InvalidOperationException ("Separator not found");
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasNoMoreTokens ()
|
||||
{
|
||||
SkipAllWhitespaces ();
|
||||
return GetCurrentSymbol () == Symbol.EndOfLine;
|
||||
}
|
||||
|
||||
public string GetNextToken ()
|
||||
{
|
||||
var length = 0;
|
||||
if (_position == 0)
|
||||
{
|
||||
SkipAllWhitespaces ();
|
||||
}
|
||||
else
|
||||
{
|
||||
SkipNextDelimeter ();
|
||||
}
|
||||
|
||||
while (GetCurrentSymbol () == Symbol.Token)
|
||||
{
|
||||
_position++;
|
||||
length++;
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
{
|
||||
throw new InvalidOperationException ("Next token not found");
|
||||
}
|
||||
|
||||
return _str.Substring (_position - length, length);
|
||||
}
|
||||
}
|
||||
}
|
@ -147,15 +147,21 @@ namespace System.Windows {
|
||||
|
||||
public static Point Parse (string source)
|
||||
{
|
||||
string[] points = source.Split(',');
|
||||
|
||||
if (points.Length<2)
|
||||
throw new InvalidOperationException ("source does not contain two numbers");
|
||||
if (points.Length > 2)
|
||||
throw new InvalidOperationException ("source contains too many delimiters");
|
||||
|
||||
CultureInfo ci = CultureInfo.InvariantCulture;
|
||||
return new Point (Convert.ToDouble(points[0],ci), Convert.ToDouble(points[1],ci));
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
double x;
|
||||
double y;
|
||||
if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x) ||
|
||||
!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y))
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Point format: {0}", source));
|
||||
}
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException ("Invalid Point format: " + source);
|
||||
}
|
||||
return new Point(x, y);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
@ -170,18 +176,13 @@ namespace System.Windows {
|
||||
|
||||
private string ToString(string format,IFormatProvider formatProvider)
|
||||
{
|
||||
CultureInfo ci = (CultureInfo)formatProvider;
|
||||
|
||||
if (ci == null)
|
||||
ci = CultureInfo.CurrentCulture;
|
||||
string seperator = ci.NumberFormat.NumberDecimalSeparator;
|
||||
if (seperator.Equals(","))
|
||||
seperator = ";";
|
||||
else
|
||||
seperator = ",";
|
||||
object[] ob = { this._x, seperator, this._y };
|
||||
|
||||
return string.Format(formatProvider, "{0:" + format + "}{1}{2:" + format + "}", ob);
|
||||
if (formatProvider == null)
|
||||
formatProvider = CultureInfo.CurrentCulture;
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
var separator = NumericListTokenizer.GetSeparator (formatProvider);
|
||||
var pointFormat = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
|
||||
return string.Format (formatProvider, pointFormat, _x, _y);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format, IFormatProvider formatProvider)
|
||||
|
@ -24,10 +24,8 @@
|
||||
// Sebastien Pouliot <sebastien@ximian.com>
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Converters;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
@ -121,7 +119,14 @@ namespace System.Windows {
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
unchecked
|
||||
{
|
||||
var hashCode = _x.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _y.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _width.GetHashCode ();
|
||||
hashCode = (hashCode * 397) ^ _height.GetHashCode ();
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Contains (Rect rect)
|
||||
@ -296,7 +301,37 @@ namespace System.Windows {
|
||||
|
||||
public static Rect Parse (string source)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
Rect value;
|
||||
if (source.Trim () == "Empty")
|
||||
{
|
||||
value = Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
double x;
|
||||
double y;
|
||||
double width;
|
||||
double height;
|
||||
if (double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out width)
|
||||
&& double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out height))
|
||||
{
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException ("Invalid Rect format: " + source);
|
||||
}
|
||||
value = new Rect (x, y, width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Rect format: {0}", source));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
@ -325,17 +360,12 @@ namespace System.Windows {
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
|
||||
string separator = ",";
|
||||
NumberFormatInfo numberFormat =
|
||||
provider.GetFormat (typeof (NumberFormatInfo)) as NumberFormatInfo;
|
||||
if (numberFormat != null &&
|
||||
numberFormat.NumberDecimalSeparator == separator)
|
||||
separator = ";";
|
||||
var separator = NumericListTokenizer.GetSeparator (provider);
|
||||
|
||||
string rectFormat = String.Format (
|
||||
var rectFormat = string.Format (
|
||||
"{{0:{0}}}{1}{{1:{0}}}{1}{{2:{0}}}{1}{{3:{0}}}",
|
||||
format, separator);
|
||||
return String.Format (provider, rectFormat,
|
||||
return string.Format (provider, rectFormat,
|
||||
_x, _y, _width, _height);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Converters;
|
||||
using System.Windows.Markup;
|
||||
|
||||
@ -64,29 +65,63 @@ namespace System.Windows {
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
unchecked
|
||||
{
|
||||
return (_width.GetHashCode () * 397) ^ _height.GetHashCode ();
|
||||
}
|
||||
}
|
||||
|
||||
public static Size Parse (string source)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
Size value;
|
||||
if (source.Trim () == "Empty")
|
||||
{
|
||||
return Empty;
|
||||
}
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
double width;
|
||||
double height;
|
||||
if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out width) ||
|
||||
!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out height))
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Size format: {0}", source));
|
||||
}
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException ("Invalid Size format: " + source);
|
||||
}
|
||||
return new Size(width, height);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
if (IsEmpty)
|
||||
return "Empty";
|
||||
return String.Format ("{0},{1}", _width, _height);
|
||||
return ConvertToString (null, null);
|
||||
}
|
||||
|
||||
public string ToString (IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ConvertToString (null, provider);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ConvertToString (format, provider);
|
||||
}
|
||||
|
||||
private string ConvertToString (string format, IFormatProvider provider)
|
||||
{
|
||||
if (IsEmpty)
|
||||
return "Empty";
|
||||
|
||||
if (provider == null)
|
||||
provider = CultureInfo.CurrentCulture;
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
var separator = NumericListTokenizer.GetSeparator (provider);
|
||||
var vectorFormat = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
|
||||
return string.Format (provider, vectorFormat, _width, _height);
|
||||
}
|
||||
|
||||
public bool IsEmpty {
|
||||
|
@ -23,8 +23,8 @@
|
||||
// Chris Toshok (toshok@novell.com)
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Converters;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
@ -57,12 +57,10 @@ namespace System.Windows {
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
return string.Format (provider, "{0:" + format + "},{1:" + format + "}", _x, _y);
|
||||
unchecked
|
||||
{
|
||||
return (_x.GetHashCode () * 397) ^ _y.GetHashCode ();
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Equals (Vector vector1, Vector vector2)
|
||||
@ -150,17 +148,47 @@ namespace System.Windows {
|
||||
|
||||
public static Vector Parse (string source)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
if (source == null)
|
||||
throw new ArgumentNullException ("source");
|
||||
var tokenizer = new NumericListTokenizer (source, CultureInfo.InvariantCulture);
|
||||
double x;
|
||||
double y;
|
||||
if (!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out x) ||
|
||||
!double.TryParse (tokenizer.GetNextToken (), NumberStyles.Float, CultureInfo.InvariantCulture, out y))
|
||||
{
|
||||
throw new FormatException (string.Format ("Invalid Vector format: {0}", source));
|
||||
}
|
||||
if (!tokenizer.HasNoMoreTokens ())
|
||||
{
|
||||
throw new InvalidOperationException("Invalid Vector format: " + source);
|
||||
}
|
||||
return new Vector(x, y);
|
||||
}
|
||||
|
||||
public override string ToString ()
|
||||
{
|
||||
return String.Format ("{0},{1}", _x, _y);
|
||||
return ToString(null);
|
||||
}
|
||||
|
||||
public string ToString (IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
return ToString (null, provider);
|
||||
}
|
||||
|
||||
string IFormattable.ToString (string format, IFormatProvider provider)
|
||||
{
|
||||
return ToString (format, provider);
|
||||
}
|
||||
|
||||
private string ToString(string format,IFormatProvider formatProvider)
|
||||
{
|
||||
if (formatProvider == null)
|
||||
formatProvider = CultureInfo.CurrentCulture;
|
||||
if (format == null)
|
||||
format = string.Empty;
|
||||
var separator = NumericListTokenizer.GetSeparator (formatProvider);
|
||||
var vectorFormat = string.Format ("{{0:{0}}}{1}{{1:{0}}}", format, separator);
|
||||
return string.Format (formatProvider, vectorFormat, _x, _y);
|
||||
}
|
||||
|
||||
public double Length {
|
||||
|
@ -0,0 +1,65 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MonoTests.System.Windows.Media {
|
||||
|
||||
[TestFixture]
|
||||
public class MatrixConverterTest {
|
||||
const double DELTA = 0.000000001d;
|
||||
|
||||
void CheckMatrix (Matrix expected, Matrix actual)
|
||||
{
|
||||
Assert.AreEqual (expected.M11, actual.M11, DELTA);
|
||||
Assert.AreEqual (expected.M12, actual.M12, DELTA);
|
||||
Assert.AreEqual (expected.M21, actual.M21, DELTA);
|
||||
Assert.AreEqual (expected.M22, actual.M22, DELTA);
|
||||
Assert.AreEqual (expected.OffsetX, actual.OffsetX, DELTA);
|
||||
Assert.AreEqual (expected.OffsetY, actual.OffsetY, DELTA);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanConvertFrom ()
|
||||
{
|
||||
var conv = new MatrixConverter ();
|
||||
Assert.IsTrue (conv.CanConvertFrom (typeof (string)));
|
||||
Assert.IsFalse (conv.CanConvertFrom (typeof (Matrix)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanConvertTo ()
|
||||
{
|
||||
var conv = new MatrixConverter ();
|
||||
Assert.IsTrue (conv.CanConvertTo (typeof (string)));
|
||||
Assert.IsFalse (conv.CanConvertTo (typeof (Matrix)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertFrom ()
|
||||
{
|
||||
var conv = new MatrixConverter ();
|
||||
object obj = conv.ConvertFrom ("1, 2, 3, 4, 5, 6");
|
||||
Assert.AreEqual (typeof (Matrix), obj.GetType ());
|
||||
CheckMatrix (new Matrix (1, 2, 3, 4, 5, 6), (Matrix)obj);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (NotSupportedException))]
|
||||
public void ConvertFromInvalidType ()
|
||||
{
|
||||
var conv = new MatrixConverter ();
|
||||
conv.ConvertFrom (new Matrix (10, 20, 30, 40, 50, 60));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertTo ()
|
||||
{
|
||||
var conv = new MatrixConverter ();
|
||||
var matrix = new Matrix (1, 2, 3, 4, 5, 6);
|
||||
object obj = conv.ConvertTo (null, CultureInfo.InvariantCulture, matrix, typeof (string));
|
||||
Assert.AreEqual (typeof (string), obj.GetType ());
|
||||
Assert.AreEqual ("1,2,3,4,5,6", (string)obj);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using NUnit.Framework;
|
||||
@ -158,7 +159,6 @@ namespace MonoTests.System.Windows.Media {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void Parse ()
|
||||
{
|
||||
CheckMatrix (Matrix.Identity, Matrix.Parse ("Identity"));
|
||||
@ -348,7 +348,7 @@ namespace MonoTests.System.Windows.Media {
|
||||
public void ToStringTest ()
|
||||
{
|
||||
Matrix m = new Matrix (1, 2, 3, 4, 5, 6);
|
||||
Assert.AreEqual ("1,2,3,4,5,6", m.ToString());
|
||||
Assert.AreEqual ("1,2,3,4,5,6", m.ToString(CultureInfo.InvariantCulture));
|
||||
m = Matrix.Identity;
|
||||
Assert.AreEqual ("Identity", m.ToString());
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Windows.Media.Converters;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MonoTests.System.Windows.Media {
|
||||
|
||||
[TestFixture]
|
||||
public class MatrixValueSerializerTest {
|
||||
const double DELTA = 0.000000001d;
|
||||
|
||||
void CheckMatrix (Matrix expected, Matrix actual)
|
||||
{
|
||||
Assert.AreEqual (expected.M11, actual.M11, DELTA);
|
||||
Assert.AreEqual (expected.M12, actual.M12, DELTA);
|
||||
Assert.AreEqual (expected.M21, actual.M21, DELTA);
|
||||
Assert.AreEqual (expected.M22, actual.M22, DELTA);
|
||||
Assert.AreEqual (expected.OffsetX, actual.OffsetX, DELTA);
|
||||
Assert.AreEqual (expected.OffsetY, actual.OffsetY, DELTA);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanConvertFromString ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
Assert.IsTrue (serializer.CanConvertFromString ("", null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanConvertToString ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
Assert.IsTrue (serializer.CanConvertToString (new Matrix (1, 2, 3, 4, 5 ,6), null));
|
||||
Assert.IsFalse (serializer.CanConvertToString ("", null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvertFromString ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
object obj = serializer.ConvertFromString ("1, 2, 3, 4, 5 ,6", null);
|
||||
Assert.AreEqual (typeof (Matrix), obj.GetType ());
|
||||
CheckMatrix (new Matrix (1, 2, 3, 4, 5, 6), (Matrix)obj);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RoundTripConvert()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
var matrix = new Matrix (1.1, 2.2, 3.3, 4.4, 5.5, 6.6);
|
||||
var obj = serializer.ConvertFromString (serializer.ConvertToString (matrix, null), null);
|
||||
CheckMatrix (matrix, (Matrix)obj);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (FormatException))]
|
||||
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
serializer.ConvertFromString ("a,b,c,d,e,f", null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (NotSupportedException))]
|
||||
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
serializer.ConvertFromString (null, null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (NotSupportedException))]
|
||||
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
|
||||
{
|
||||
var serializer = new MatrixValueSerializer ();
|
||||
serializer.ConvertToString (10, null);
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using NUnit.Framework;
|
||||
@ -54,7 +55,6 @@ namespace MonoTests.System.Windows {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ConvertFrom ()
|
||||
{
|
||||
Int32RectConverter r = new Int32RectConverter ();
|
||||
@ -79,7 +79,6 @@ namespace MonoTests.System.Windows {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ConvertFrom_negative ()
|
||||
{
|
||||
Int32RectConverter r = new Int32RectConverter ();
|
||||
@ -90,14 +89,13 @@ namespace MonoTests.System.Windows {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category ("NotWorking")]
|
||||
public void ConvertTo ()
|
||||
{
|
||||
Int32RectConverter r = new Int32RectConverter ();
|
||||
|
||||
Int32Rect rect = new Int32Rect (0, 0, 1, 2);
|
||||
|
||||
object o = r.ConvertTo (rect, typeof (string));
|
||||
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
|
||||
|
||||
Assert.AreEqual (typeof (string), o.GetType());
|
||||
Assert.AreEqual ("0,0,1,2", (string)o);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user