Esempio n. 1
0
        private void VerifyCloneForFreezable(Freezable frozenObject)
        {
            if (frozenObject == null)
            {
                return;
            }

            TrustedType       type   = PT.Trust(frozenObject.GetType());
            TrustedMethodInfo method = type.GetMethod("Clone", BindingFlags.Public | BindingFlags.Instance);

            if (method == null)
            {
                throw new ApplicationException("Could not find Clone method on " + type.Name);
            }

            Freezable copy = (Freezable)method.Invoke(frozenObject, null);

            if (!ObjectUtils.DeepEqualsToAnimatable(frozenObject, copy))
            {
                AddFailure("{0}.Copy failed to produce an exact copy", type.Name);
            }

            method = type.GetMethod("CloneCurrentValue", BindingFlags.Public | BindingFlags.Instance);
            if (method == null)
            {
                throw new ApplicationException("Could not find CloneCurrentValue method on " + type.Name);
            }

            copy = (Freezable)method.Invoke(frozenObject, null);

            if (!ObjectUtils.DeepEqualsToAnimatable(frozenObject, copy))
            {
                AddFailure("{0}.CloneCurrentValue failed to produce an exact copy", type.Name);
            }
        }
Esempio n. 2
0
        /// <summary/>
        protected override object CreateWindow(object o)
        {
            window = new TrustedWindow();

            if (IsWindowPositionValid)
            {
                window.Left = WindowPosition.X;
                window.Top  = WindowPosition.Y;
            }

            // Always on top so that we don't get bad screen captures
            window.Topmost     = true;
            window.WindowStyle = WindowStyle.None;

            // This control is set on the window only to set
            //  the window client area to the correct desired size.
            Canvas dummyContent = new Canvas();

            dummyContent.Height  = WindowHeight;
            dummyContent.Width   = WindowWidth;
            window.SizeToContent = SizeToContent.WidthAndHeight;
            window.Content       = dummyContent;

            window.Background = new SolidColorBrush(DefaultBackgroundColor);
            window.Show();

            TrustedWindowInteropHelper helper = new TrustedWindowInteropHelper(PT.Untrust(window));

            windowHandle = helper.Handle;

            return(null);
        }
Esempio n. 3
0
        /// <summary/>
        public static object ParseXaml(string filename)
        {
            object root = null;

            using (TrustedFileStream stream = new TrustedFileStream(filename, FileMode.Open))
            {
                root = XamlReader.Load(PT.Untrust(stream));
            }
            return(root);
        }
Esempio n. 4
0
        private void CompareProperties(Type type, object obj1, object obj2, string space)
        {
            space += "    ";

            // We don't want static properties.  They're problematic.
            TrustedPropertyInfo[] properties = PT.Trust(type).GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (TrustedPropertyInfo property in properties)
            {
                string      propertyName = property.Name;
                TrustedType propertyType = property.PropertyType;

                if (!property.DeclaringType.IsPublic)
                {
                    continue;
                }

                Log(space + "{0} : {1}", propertyName, propertyType.Name);

                if (IsPropertyProblematic(propertyName))
                {
                    Log(space + "- Skipping problematic property");
                    continue;
                }

                // "Item" is the indexer property's name.
                // This property requires parameters to be evaluated and is therefore a problem.
                // -  For IEnumerables, we can iterate through its items and compare them.
                // -  We don't know how to dynamically deal with other types of indexers so we skip them.
                if (propertyName == "Item")
                {
                    if (obj1 is IEnumerable)
                    {
                        CompareItems(type, (IEnumerable)obj1, (IEnumerable)obj2, space);
                    }
                    else
                    {
                        Log(space + "- Skipping indexer");
                    }
                    continue;
                }

                object value1 = property.GetValue(obj1, null);
                object value2 = property.GetValue(obj2, null);

                if (propertyType.IsValueType)
                {
                    CompareValueTypes(value1, value2, space);
                }
                else
                {
                    CompareRefTypes(value1, value2, space);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Saves the Color array to a .PNG file.
        /// </summary>
        /// <param name="bitmap">Bit matrix to save</param>
        /// <param name="filename">.PNG file name to save it as.</param>
        public static void SaveImageAs(BitmapSource bitmap, string filename)
        {
            PngBitmapEncoder encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(bitmap));

            using (TrustedFileStream fs = new TrustedFileStream(filename, FileMode.Create))
            {
                encoder.Save(PT.Untrust(fs));
            }
            GlobalLog.LogFile(filename);
        }
Esempio n. 6
0
 private Type GetAnimationType(Type baseType)
 {
     if (baseType.IsValueType)
     {
         if (baseType.Name == "Matrix3D")
         {
             // Matrix3DAnimation does not exist in Avalon, so use the one that we created
             return(typeof(Matrix3DAnimation));
         }
         else
         {
             TrustedAssembly presentationCore = TrustedAssembly.GetAssembly(typeof(Animatable));
             return(PT.Untrust(presentationCore.GetType("System.Windows.Media.Animation." + baseType.Name + "Animation")));
         }
     }
     else
     {
         // Reference-type animations do not exist in Avalon, so use the one that we created
         return(typeof(DiscreteAnimation));
     }
 }
Esempio n. 7
0
        private void CreateVariationsFromScript(string scriptFile, TokenList commandLineTokens)
        {
            TrustedFileStream stream = new TrustedFileStream(scriptFile, FileMode.Open);
            XmlDocument       doc    = new XmlDocument();

            doc.Load(PT.Untrust(stream));

            XmlElement init = doc["INIT"] as XmlElement;

            if (init == null)
            {
                throw new InvalidScriptFileException("script file: " + scriptFile + " is missing INIT element");
            }

            TokenList tokens = new TokenList(init);

            tokens.Merge(commandLineTokens);

            Variation.SetGlobalParameters(tokens);
            CreateVariations(init);
        }
Esempio n. 8
0
 private static object Shutdown(object notUsed)
 {
     PT.Trust(RenderingTest.application).Shutdown();
     return(null);
 }
Esempio n. 9
0
        /// <summary>
        /// This summary has not been prepared yet. NOSUMMARY - pantal07
        /// </summary>
        public object MakeValue(string value, Type type)
        {
            TrustedType t = PT.Trust(typeof(StringConverter));

            return(t.InvokeMember("To" + type.Name, BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, new object[] { value }));
        }