Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
     }
 }
Ejemplo n.º 5
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);
        }