//Initializes setup window.
        void initSetupWindow(GW.Window window)
        {
            // Create a Canvas
            GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas();
            _window.AddChild(canvas);

            // Draw a separator line.
            //canvas.DrawLine(GHI.Glide.Colors.White, 1, 30, 35, window.Width - 30, 35);

            // Draw a fieldset around our "Login" text block.
            _txtTitle           = (TextBlock)window.GetChildByName("txtTitle");
            _txtTitle.FontColor = GHI.Glide.Colors.White;
            canvas.DrawFieldset(_txtTitle, 90, 110, 220, GHI.Glide.Colors.White, 1);

            _txtBlWheelOut   = (TextBlock)_window.GetChildByName("txtBlWheelOut");
            _txtBlTriggerOut = (TextBlock)_window.GetChildByName("txtBlTriggerOut");
            _txtBlTrigScaled = (TextBlock)_window.GetChildByName("txtBlTrigScaled");
            _txtBlWhlScaled  = (TextBlock)_window.GetChildByName("txtBlWhlScaled");
            _txtBlSpeedLimit = (TextBlock)_window.GetChildByName("txtBlSpeedLimit");

            _chkBoxSpeedLimit           = (CheckBox)_window.GetChildByName("chkBoxSpeedLimit");
            _chkBoxSpeedLimit.TapEvent += _chkBoxSpeedLimit_TapEvent;

            _btnBackSetup           = (Button)_window.GetChildByName("btnBack");
            _btnBackSetup.TapEvent += new OnTap(btnBackSetup_TapEvent);

            _btnMode           = (Button)_window.GetChildByName("btnMode");
            _btnMode.TapEvent += new OnTap(btnMode_TapEvent);

            DiagnosticWindowTimer = new Timer(new TimerCallback(SetupWindowTimer_Tick), null, -1, diagnosticWindowTimerPeriod);
        }
Exemple #2
0
        /// <summary>
        /// Loads a Window from XML bytes.
        /// </summary>
        /// <param name="xmlBytes">XML bytes.</param>
        /// <returns>Window object.</returns>
        public static Window LoadWindow(byte[] xmlBytes, bool render = true)
        {
            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);

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

                if (component != null)
                    _window.AddChild(component);
                else
                    throw new Exception(reader.Name + " is not a valid UI component.");
            }

            reader.Close();

            if (render)
            {
                _window.Render();
            }

            return _window;
        }
        //Initializes ground efx window.
        void initGndEfxWindow(GW.Window window)
        {
            // Create a Canvas
            GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas();
            window.AddChild(canvas);

            // Draw a separator line.
            //canvas.DrawLine(GHI.Glide.Colors.White, 1, 30, 50, window.Width - 30, 50);

            // Draw a fieldset around our "Login" text block.
            _txtTitle           = (TextBlock)window.GetChildByName("txtTitle");
            _txtTitle.FontColor = GHI.Glide.Colors.White;
            canvas.DrawFieldset(_txtTitle, 40, 160, 220, GHI.Glide.Colors.White, 1);

            _btnGndEfxShow           = (Button)_window.GetChildByName("btnGndEfxShow");
            _btnGndEfxShow.TapEvent += new OnTap(btnGndEfxShow_TapEvent);

            _btnBackGndEfx           = (Button)_window.GetChildByName("btnBack");
            _btnBackGndEfx.TapEvent += new OnTap(btnBackGndEfx_TapEvent);
        }
        // Initializes main window buttons
        void initWindow(GW.Window window)
        {
            //Image imgLogo = (Image)window.GetChildByName("imgLogo");
            //imgLogo.Bitmap = Resources.GetBitmap(Resources.BitmapResources.Stinkmeaner_Thumb);

            // Create a Canvas
            GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas();
            window.AddChild(canvas);

            // Draw a separator line.
            canvas.DrawLine(GHI.Glide.Colors.White, 1, 30, 50, window.Width - 30, 50);

            // Draw a fieldset around our "Login" text block.
            _txtTitle           = (TextBlock)window.GetChildByName("txtTitle");
            _txtTitle.FontColor = GHI.Glide.Colors.White;
            canvas.DrawFieldset(_txtTitle, 30, 100, 220, GHI.Glide.Colors.White, 1);

            _pBarConnected       = (ProgressBar)_window.GetChildByName("pBarConnected");
            _pBarConnected.Value = 0;

            _txtStatus      = (TextBlock)_window.GetChildByName("txtStatus");
            _txtStatus.Text = "Status:";

            _btnBack           = (Button)_window.GetChildByName("btnBack");
            _btnBack.TapEvent += new OnTap(btnBack_TapEvent);

            _btnStop           = (Button)_window.GetChildByName("btnStop");
            _btnStop.TapEvent += new OnTap(btnStop_TapEvent);

            _btnSerialCam           = (Button)_window.GetChildByName("btnSerialCam");
            _btnSerialCam.TapEvent += new OnTap(btnSerialCam_TapEvent);

            _btnVideo           = (Button)_window.GetChildByName("btnVideo");
            _btnVideo.TapEvent += new OnTap(btnVideo_TapEvent);

            _btnSingleCam           = (Button)_window.GetChildByName("btnSingleCam");
            _btnSingleCam.TapEvent += new OnTap(btnSingleCam_TapEvent);
        }