Esempio n. 1
0
        /// <summary>
        /// Loads a Window from XML bytes.
        /// </summary>
        /// <param name="xmlBytes">XML bytes.</param>
        /// <returns>Window object.</returns>
        public static GlideWindow LoadWindow(byte[] xmlBytes)
        {
            ElementContainer  tmp;
            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

            xmlReaderSettings.IgnoreComments = true;
            xmlReaderSettings.IgnoreProcessingInstructions = true;
            xmlReaderSettings.IgnoreWhitespace             = true;

            MemoryStream stream = new MemoryStream(xmlBytes);

            XmlReader reader = XmlReader.Create(stream, xmlReaderSettings);


            if (!reader.ReadToDescendant("Glide"))
            {
                throw new ArgumentException("Glide not detected.");
            }

            stream.Seek(0, SeekOrigin.Begin);
            reader = XmlReader.Create(stream, xmlReaderSettings);

            if (!reader.ReadToDescendant("Window"))
            {
                throw new ArgumentException("XML does not contain a Window element.");
            }

            _window = ParseWindow(reader);

            UIElement component;

            _canvas = new Canvas();

            while (reader.Read() && !(reader.NodeType == XmlNodeType.EndElement && reader.Name == "Window"))
            {
                tmp       = GetComponent(reader);
                component = tmp.Element;

                if (component != null)
                {
                    _canvas.Children.Add(component);
                    _window.AddControls(tmp.ElementName, tmp.Element);
                }
                else
                {
                    throw new Exception(reader.Name + " is not a valid UI component.");
                }
            }
            _window.Child = _canvas;

            reader.Close();

            _window.Invalidate();

            return(_window);
        }
Esempio n. 2
0
 public static void Flush(int x, int y, int width, int height)
 {
     // Ignore flushes if no MainWindow is set.
     if (_mainWindow == null)
     {
         return;
     }
     _mainWindow.Invalidate();
     //GlideX.screen.Flush();
 }