コード例 #1
0
        /// <summary>
        /// Parses the Image XML into a UI component.
        /// </summary>
        /// <param name="reader">XML reader object.</param>
        /// <returns>Image object.</returns>
        private static UI.Image LoadImage(XmlReader reader)
        {
            string name    = reader.GetAttribute("Name");
            ushort alpha   = (reader.GetAttribute("Alpha") != null) ? Convert.ToUInt16(reader.GetAttribute("Alpha")) : _defaultDisplayObject.Alpha;
            int    x       = Convert.ToInt32(reader.GetAttribute("X"));
            int    y       = Convert.ToInt32(reader.GetAttribute("Y"));
            int    width   = Convert.ToInt32(reader.GetAttribute("Width"));
            int    height  = Convert.ToInt32(reader.GetAttribute("Height"));
            bool   visible = (reader.GetAttribute("Visible") != null) ? (reader.GetAttribute("Visible") == bool.TrueString) : _defaultDisplayObject.Visible;
            bool   enabled = (reader.GetAttribute("Enabled") != null) ? (reader.GetAttribute("Enabled") == bool.TrueString) : _defaultDisplayObject.Enabled;

            UI.Image image = new UI.Image(name, alpha, x, y, width, height);
            image.Visible = visible;
            image.Enabled = enabled;

            return(image);
        }
コード例 #2
0
        void initWindow()
        {
            btnEnter         = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnEnter");
            btnExit          = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnExit");
            btnOk            = (GHI.Glide.UI.Button)mainWindow.GetChildByName("btnOk");
            txtNetworkStatus = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtNetworkStatus");
            txtScreen        = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtText");
            txtRectangle     = (GHI.Glide.UI.TextBlock)mainWindow.GetChildByName("txtRectangle");
            barProgress      = (GHI.Glide.UI.ProgressBar)mainWindow.GetChildByName("barRfidTime");
            imgPhoto         = (GHI.Glide.UI.Image)mainWindow.GetChildByName("imgPhoto");
            imgPhoto.Stretch = true;    //fits the 320x240 streaming picture in 160x120 image component on window
            displayDefaultScreen();

            btnEnter.TapEvent += btnEnter_TapEvent;
            btnExit.TapEvent  += btnExit_TapEvent;
            btnOk.TapEvent    += btnOk_TapEvent;
        }
コード例 #3
0
        // Handles the pictures button tap event.
        static void btnPics_TapEvent(object sender)
        {
            //check for sd card
            if (picCounter < 0)
            {
                Glide.MessageBoxManager.Show("SD Card not found.", "SD Card");
                return;
            }

            RoverJoystickControlTimer.Change(-1, -1); //stop timer
            UpdateMainWindowTimer.Change(-1, -1);     //stop timer

            string[] sdCardfiles   = Directory.GetFiles(SD_ROOT_DIRECTORY);
            string[] tempFileNames = new string[sdCardfiles.Length];

            //string[] folders = Directory.GetDirectories(SD_ROOT_DIRECTORY);
            FileStream fileStream = null;

            picCounter = 0;

            var i = 0;

            foreach (string sdfile in sdCardfiles)
            {
                if (sdfile.IndexOf(".jpg") != -1)
                {
                    tempFileNames[i++] = sdfile;
                }
            }

            if (tempFileNames.Length > 0)
            {
                sdCardJpgFileNames = new string[i];
                Array.Copy(tempFileNames, sdCardJpgFileNames, i);

                Tween.SlideWindow(_mainWindow, pictureWindow, GHI.Glide.Direction.Up);

                //Use FileStream to read a text file
                //fileStream = new FileStream(SD_ROOT_DIRECTORY + @"\" + sdCardJpgFileNames[0] + ".jpg", FileMode.Open);
                fileStream = new FileStream(sdCardJpgFileNames[picCounter], FileMode.Open);

                //load the data from the stream
                byte[] data = new byte[fileStream.Length];
                fileStream.Read(data, 0, data.Length);

                Bitmap myPic = new Bitmap(data, Bitmap.BitmapImageType.Jpeg);

                GHI.Glide.UI.Image image = (GHI.Glide.UI.Image)pictureWindow.GetChildByName("imgPicture");
                //image.Bitmap = Resources.GetBitmap(Resources.BitmapResources.logo);
                image.Bitmap.DrawImage(0, 0, myPic, 0, 0, 320, 240);

                fileStream.Close();

                image.Invalidate();

                PictureViewerTimer.Change(0, PictureViewerTimerPeriod);
            }
            else
            {
                Glide.MessageBoxManager.Show("No Pictures found.", "Picture Viewer");
                RoverJoystickControlTimer.Change(0, RoverJoystickTimerPeriod);
                UpdateMainWindowTimer.Change(0, UpdateMainWindowTimerPeriod);
            }
        }