Exemple #1
0
        async void cameraCaptureTask_Completed(object sender, PhotoResult e)
        {
            progressBar.Text = "Uploading the picture...";
            try
            {
                if (e.TaskResult == TaskResult.OK)
                {
                    // MessageBox.Show(e.ChosenPhoto.Length.ToString());
                    System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                    bmp.SetSource(e.ChosenPhoto);
                    photoImage.Source = bmp;

                    byte[] imageBytes;
                    using (BinaryReader br = new BinaryReader(e.ChosenPhoto))
                    {
                        e.ChosenPhoto.Position = 0;
                        imageBytes             = br.ReadBytes(Convert.ToInt32(e.ChosenPhoto.Length));
                    }

                    await a.UploadFile(imageBytes, "Photos", "/teams/LCBO/Photos/", string.Format("Photo_{0}.jpg", Guid.NewGuid()));

                    btnPhoto.Visibility = System.Windows.Visibility.Visible;
                    progressBar.Text    = "Uploaded!";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        // Called when an existing photo is chosen with the photo chooser.
        private void OnPhotoChooserTaskCompleted(object sender, PhotoResult e)
        {
            // Hide text messages
            txtError.Visibility   = Visibility.Collapsed;
            txtMessage.Visibility = Visibility.Collapsed;

            // Make sure the PhotoChooserTask is resurning OK
            if (e.TaskResult == TaskResult.OK)
            {
                // initialize the result photo stream
                photoStream = new MemoryStream();

                // Save the stream result (copying the resulting stream)
                e.ChosenPhoto.CopyTo(photoStream);

                // save the original file name
                fileName = e.OriginalFileName;

                // display the chosen picture
                var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
                bitmapImage.SetSource(photoStream);
                imgSelectedImage.Source = bitmapImage;

                // enable the upload button
                btnUpload.IsEnabled = true;
            }
            else
            {
                // if result is not ok, make sure user can't upload
                btnUpload.IsEnabled = false;
            }
        }
Exemple #3
0
        private void showImage()
        {
            if (App.ViewModel.forShare != null)
            {
                imagePicker.Content = App.ViewModel.forShare.ItemName;
                imagePicker.Opacity = 0.5;
                System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                //点击超链接后图片存在
                if (isf.FileExists(App.ViewModel.forShare.ItemName + ".jpg"))
                {
                    isf.CopyFile(App.ViewModel.forShare.ItemName + ".jpg", "abc.jpg", true);
                    System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.OpenFile("abc.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    System.Windows.Media.Imaging.BitmapImage            bmp1        = new System.Windows.Media.Imaging.BitmapImage();
                    bmp1.SetSource(PhotoStream); //把文件流转换为图片
                    PhotoStream.Close();         //读取完毕,关闭文件流

                    System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                    ib.ImageSource = bmp1;
                    tip.Background = ib;      //把图片设置为控件的背景图
                    //imageTip.Visibility = System.Windows.Visibility.Collapsed;
                }
            }
            //如果存在背景,则显示关联按钮
            if (tip.Background != null)
            {
                appBar3();
            }
        }
        // Called when an existing photo is chosen with the photo chooser.
        private void OnPhotoChooserTaskCompleted(object sender, PhotoResult e)
        {
            // Hide text messages
            txtError.Visibility = Visibility.Collapsed;
            txtMessage.Visibility = Visibility.Collapsed;

            // Make sure the PhotoChooserTask is resurning OK
            if (e.TaskResult == TaskResult.OK)
            {
                // initialize the result photo stream
                photoStream = new MemoryStream();

                // Save the stream result (copying the resulting stream)
                e.ChosenPhoto.CopyTo(photoStream);

                // save the original file name
                fileName = e.OriginalFileName;

                // display the chosen picture
                var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
                bitmapImage.SetSource(photoStream);
                imgSelectedImage.Source = bitmapImage;

                // enable the upload button
                btnUpload.IsEnabled = true;
            }
            else
            {
                // if result is not ok, make sure user can't upload
                btnUpload.IsEnabled = false;
            }
        }
Exemple #5
0
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        bmp.SetSource(e.Result);
                        imgCCTV.Source = bmp;

                    }
                    catch
                    {

                    }
                    finally
                    {
                        if (!ISExit)
                            BeginReadCCTV();
                    }
                }
                );

            }
            catch
            { ;}
        }
Exemple #6
0
        void cameraTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult != TaskResult.OK) return;

            System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
            bmp.SetSource(e.ChosenPhoto);
            photoImage.Source = bmp;
        }
Exemple #7
0
        private void loadExisting()
        {
            string fName = host.UI.isoName.Text;

            if (fName == "")
            {
                return;
            }

            //Lg
            {
                string sIco = ImgFolderPath() + fName + ".ico.jpg";

                RscStore store = new RscStore();

                if (!store.FileExists(sIco))
                {
                    return;
                }

                System.IO.Stream stream = store.GetReaderStream(sIco);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.
                                                               Imaging.BitmapImage();

                bmp.SetSource(stream);

                stream.Close();

                host.UI.isoImg.Source     = bmp;
                host.UI.isoImg.Visibility = System.Windows.Visibility.Visible;
            }

            //Sm
            {
                string sIco = ImgFolderPath() + fName + ".ico.sm.jpg";

                RscStore store = new RscStore();

                if (!store.FileExists(sIco))
                {
                    return;
                }

                System.IO.Stream stream = store.GetReaderStream(sIco);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.
                                                               Imaging.BitmapImage();

                bmp.SetSource(stream);

                stream.Close();

                host.UI.isoImgSm.Source     = bmp;
                host.UI.isoImgSm.Visibility = System.Windows.Visibility.Visible;
            }
        }
Exemple #8
0
 void photoChooserTask_Completed(object sender, PhotoResult e)
 {
     if (e.TaskResult == TaskResult.OK)
     {
         System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
         bmp.SetSource(e.ChosenPhoto);
         imageInput.Source = bmp;
     }
 }
        /// <summary>
        /// une fois que la photo est prise on l'affiche
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void mCameraCaptureTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                mImage.Source = bmp;
            }
        }
        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}
    
        void CaptureTaskComplete(object sender, PhotoResult e)
        { 
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named CurrentImage
                System.Windows.Media.Imaging.BitmapImage lBmp = new System.Windows.Media.Imaging.BitmapImage();
                lBmp.SetSource(e.ChosenPhoto);
                uImageHolder.Source = lBmp;
            }
        }
 private void Init()
 {
     if (File.Exists(uri))
     {
         FileStream file = new FileStream(uri, FileMode.Open);
         System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
         bmp.SetSource(file);
         image.Source = bmp;
     }
 }
Exemple #12
0
        public static int[][] DecodeJpegToRaw(ref byte[] image)
        {
            int[][] rawImage = null;
            try
            {
                using (MemoryStream stream = new MemoryStream(image))
                {
                    var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
                    bitmapImage.SetSource(stream);

                    var bitmap = new System.Windows.Media.Imaging.WriteableBitmap(bitmapImage);
                    int width  = bitmap.PixelWidth;
                    int height = bitmap.PixelHeight;

                    rawImage = new int[width][];
                    for (int col = 0; col < width; col++)
                    {
                        rawImage[col] = new int[height];
                        for (int row = 0; row < height; row++)
                        {
                            rawImage[col][row] = bitmap.Pixels[(row * width) + col];
                        }
                    }

                    bitmap      = null;
                    bitmapImage = null;
                    GC.Collect();
                }
            }
            catch (Exception)
            {
                //- Notice!
                //On Server or Desktop plataform, call the reference function by using reflection
                //Equals made in Android plataform, because this libaries aren't portable between WP and .NET 4.0!
                Type   bitmapType = Type.GetType("Ufc.MiscNet.ImageUtilities, MiscNet, Version=1.0.0.0, Culture=neutral");
                object instance   = Activator.CreateInstance(bitmapType);
                Type[] typeParam  = new Type[1] {
                    typeof(byte[])
                };

                MethodInfo method = bitmapType.GetMethod("DecodeJpegToRaw", typeParam);
                rawImage = (int[][])method.Invoke(instance, new object[1] {
                    image
                });
            }
            finally
            {
                image = null;
                GC.Collect();
            }
            return(rawImage);
        }
Exemple #13
0
        public System.Windows.Media.Imaging.BitmapImage GetAvatarImage(string strHash)
        {
            System.Windows.Media.Imaging.BitmapImage objImage = null;
            IsolatedStorageFile storage = null;

#if WINDOWS_PHONE
            storage = IsolatedStorageFile.GetUserStoreForApplication();
#else
            storage = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);
#endif

            string strFileName = string.Format("{0}/{1}", AccountFolder, strHash);
            if (storage.FileExists(strFileName) == false)
            {
                storage.Dispose();
                return(null);
            }

            IsolatedStorageFileStream stream = null;
            try
            {
                stream   = new IsolatedStorageFileStream(strFileName, System.IO.FileMode.Open, storage);
                objImage = new System.Windows.Media.Imaging.BitmapImage();
#if WINDOWS_PHONE
                objImage.SetSource(stream);
#else
                objImage.BeginInit();
                objImage.CacheOption   = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
                objImage.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.None;

                objImage.StreamSource = stream;
                objImage.EndInit();

                double nWith   = objImage.Width;
                double nHeight = objImage.Height;
#endif
            }
            catch (Exception)
            {
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }

                storage.Dispose();
            }

            return(objImage);
        }
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                MessageBox.Show(e.ChosenPhoto.Length.ToString());
                duplicate(e.ChosenPhoto);

                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                image.Source = bmp;
            }
        }
Exemple #15
0
        void photoChooser_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                AddImageButton.Visibility = System.Windows.Visibility.Collapsed;
                ImageButton.Visibility    = System.Windows.Visibility.Visible;

                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                myImage.Source = bmp;
            }
        }
        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            _mmsContent = null;
            if (e.TaskResult == TaskResult.OK)
            {                
                _mmsContent = new ContentInfo();
                _mmsContent.Name = e.OriginalFileName;
                _mmsContent.Content = ToByteArray(e.ChosenPhoto);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                selectedImage.Source = bmp;
            }
        }
Exemple #17
0
        private void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            _mmsContent = null;
            if (e.TaskResult == TaskResult.OK)
            {
                _mmsContent         = new ContentInfo();
                _mmsContent.Name    = e.OriginalFileName;
                _mmsContent.Content = ToByteArray(e.ChosenPhoto);

                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                selectedImage.Source = bmp;
            }
        }
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //    MessageBox.Show(e.ChosenPhoto.Length.ToString());

                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                myImage.Source = bmp;

                //    PhoneApp2.ServiceReference1.Service1Client clients = new PhoneApp2.ServiceReference1.Service1Client();
            }
        }
Exemple #19
0
        void cameraCaptureMotorInsuranceTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                string str = ImageConvert.ImageConvert.convertImageToBase64(myImgage);

                imgMotorInsurance.Source = ImageConvert.ImageConvert.convertBase64ToImage(str);
            }
        }
Exemple #20
0
        private void cameraCaptureVehiclePlateTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                string str = ImageConvert.ImageConvert.convertImageToBase64(myImgage);

                imgLicensePlate.Source = ImageConvert.ImageConvert.convertBase64ToImage(str);
            }
        }
        /// <summary>
        /// Retrieves a BitmapImage object for the specified image source uri.
        /// </summary>
        /// <remarks>
        /// If the specified source uri is a relative path, the image is loaded as an embedded resource stream.
        /// </remarks>
        /// <param name="value">The value that is produced by the binding target.</param>
        /// <param name="targetType">The type to convert to.</param>
        /// <param name="parameter">Not required.</param>
        /// <param name="culture">The culture to use in the converter (unused).</param>
        /// <returns>A converted value.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Uri sourceUri;

            if (value is string)
            {
                var sourceUrl = (string)value;
                if (!Uri.TryCreate(sourceUrl, UriKind.RelativeOrAbsolute, out sourceUri))
                {
                    return value;
                }
            }
            else if (value is Uri)
            {
                sourceUri = value as Uri;
            }
            else
            {
                return value;
            }

            var bmp = new System.Windows.Media.Imaging.BitmapImage();

            if (sourceUri.IsAbsoluteUri)
            {
                bmp.UriSource = sourceUri;
                return bmp;
            }
            else
            {
                var library = typeof(ImageSourceUriConverter).Assembly;
                var libraryName = library.GetName().Name;
                var resourceName = string.Format(CultureInfo.InvariantCulture, "{0}{1}", libraryName, sourceUri.ToString().Replace("/", "."));

                using (var stream = library.GetManifestResourceStream(resourceName))
                {
                    if (stream != null)
                    {
                        bmp.SetSource(stream);
                        return bmp;
                    }
                }
            }

            return value;
        }
Exemple #22
0
        public static void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                photoPick       = ImageConvert.convertImageToBase64(myImgage);

                //myImg.Source = ImageConvert.convertBase64ToImage(str);
                //MessageBox.Show(str);
            }
        }
Exemple #23
0
        void clien_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var stream = new IsolatedStorageFileStream(apps[listBox1.SelectedIndex].guid + ".jpg", FileMode.OpenOrCreate, store))
                {
                    e.Result.CopyTo(stream);

                    System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                    bmp.SetSource(stream);
                    bmp.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.None; //force load
                    image1.Source     = bmp;

                    stream.Close();
                }
            }
        }
        /// <summary>
        /// Retrieves a BitmapImage object for the specified image source uri.
        /// </summary>
        /// <remarks>
        /// If the specified source uri is a relative path, the image is loaded as an embedded resource stream.
        /// </remarks>
        /// <param name="value">The value that is produced by the binding target.</param>
        /// <param name="targetType">The type to convert to.</param>
        /// <param name="parameter">Not required.</param>
        /// <param name="culture">The culture to use in the converter (unused).</param>
        /// <returns>A converted value.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Uri sourceUri;

            if (value is string)
            {
                var sourceUrl = (string)value;
                if (!Uri.TryCreate(sourceUrl, UriKind.RelativeOrAbsolute, out sourceUri))
                {
                    return(value);
                }
            }
            else if (value is Uri)
            {
                sourceUri = value as Uri;
            }
            else
            {
                return(value);
            }

            var bmp = new System.Windows.Media.Imaging.BitmapImage();

            if (sourceUri.IsAbsoluteUri)
            {
                bmp.UriSource = sourceUri;
                return(bmp);
            }
            else
            {
                var library      = typeof(ImageSourceUriConverter).Assembly;
                var libraryName  = library.GetName().Name;
                var resourceName = string.Format(CultureInfo.InvariantCulture, "{0}{1}", libraryName, sourceUri.ToString().Replace("/", "."));

                using (var stream = library.GetManifestResourceStream(resourceName))
                {
                    if (stream != null)
                    {
                        bmp.SetSource(stream);
                        return(bmp);
                    }
                }
            }

            return(value);
        }
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                var app = Application.Current as App;
                if (app == null)
                    return;

                var imageBrush = new ImageBrush
                {
                    ImageSource = bmp
                };
                app.RootFrame.Background = imageBrush;
                LayoutRoot.Background = new SolidColorBrush();
            }
        }
Exemple #26
0
        void cameraCaptureAvaTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                string str = ImageConvert.ImageConvert.convertImageToBase64(myImgage);

                imgAvatar.Source = ImageConvert.ImageConvert.convertBase64ToImage(str);

                //updateUserInfo(txtbFullname.Text, txtbEmail.Text, txtbPersonalID.Text, txtbPhone.Text);
            }
        }
Exemple #27
0
        public static void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {


                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                photoPick = ImageConvert.convertImageToBase64(myImgage);

                //myImg.Source = ImageConvert.convertBase64ToImage(str);
                //MessageBox.Show(str);
            }
        }
Exemple #28
0
        void photoChooserTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                var app = Application.Current as App;
                if (app == null)
                {
                    return;
                }

                var imageBrush = new ImageBrush
                {
                    ImageSource = bmp
                };
                app.RootFrame.Background = imageBrush;
                LayoutRoot.Background    = new SolidColorBrush();
            }
        }
Exemple #29
0
        private void showBackground()
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            //点击超链接后图片存在

            if (isf.FileExists("back_temp.jpg"))
            {
                System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.OpenFile("back_temp.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                System.Windows.Media.Imaging.BitmapImage            bmp1        = new System.Windows.Media.Imaging.BitmapImage();
                bmp1.SetSource(PhotoStream); //把文件流转换为图片
                PhotoStream.Close();         //读取完毕,关闭文件流

                System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                ib.ImageSource      = bmp1;
                MainPano.Background = ib;  //把图片设置为控件的背景图
                //imageTip.Visibility = System.Windows.Visibility.Collapsed;
            }
            // else
            //  {
            //     MainPano.Background = null;
            //  }
        }
Exemple #30
0
        void PhotoTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
            {
                System.Windows.Media.Imaging.WriteableBitmap  bmp = Microsoft.Phone.PictureDecoder.DecodeJpeg(e.ChosenPhoto);
                System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                if (isf.FileExists("abc.jpg"))
                {
                    isf.DeleteFile("abc.jpg");
                }
                System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.CreateFile("abc.jpg");
                System.Windows.Media.Imaging.Extensions.SaveJpeg(bmp, PhotoStream, 432, 645, 0, 100);      //这里设置保存后图片的大小、品质
                PhotoStream.Close();                                                                       //写入完毕,关闭文件流

                PhotoStream = isf.OpenFile("abc.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read); //读取刚刚保存的图片的文件流
                System.Windows.Media.Imaging.BitmapImage bmp1 = new System.Windows.Media.Imaging.BitmapImage();
                bmp1.SetSource(PhotoStream);                                                               //把文件流转换为图片
                PhotoStream.Close();                                                                       //读取完毕,关闭文件流

                System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                ib.ImageSource      = bmp1;
                tip.Background      = ib;//把图片设置为控件的背景图
                imageTip.Visibility = System.Windows.Visibility.Collapsed;
                if (imagePicker.Content.ToString() == txtnote.Resources.StringLibrary.imagename)
                {
                    if (MessageBox.Show(txtnote.Resources.StringLibrary.imagename, txtnote.Resources.StringLibrary.guanlian, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {
                        NavigationService.Navigate(new Uri("/txtnote;component/Pick.xaml", UriKind.Relative));
                    }
                }
                else
                {
                    appBar3();
                }
            }
        }
        public InternalBrowserPage()
        {
            InitializeComponent();

            System.IO.Stream resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_BACK_BUTTON_RESOURCE);
            System.Windows.Media.Imaging.BitmapImage bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            backImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_FORWARD_BUTTON_RESOURCE);
            bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            forwardImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_REFRESH_BUTTON_RESOURCE);
            bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            refreshImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_OPEN_BUTTON_RESOURCE);
            bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            openImage.Source = bitmapImage;
        }
Exemple #32
0
        public InternalBrowserPage()
        {
            InitializeComponent();

            System.IO.Stream resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_BACK_BUTTON_RESOURCE);
            System.Windows.Media.Imaging.BitmapImage bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            backImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_FORWARD_BUTTON_RESOURCE);
            bitmapImage    = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            forwardImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_REFRESH_BUTTON_RESOURCE);
            bitmapImage    = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            refreshImage.Source = bitmapImage;

            resourceStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(Defaults.IB_OPEN_BUTTON_RESOURCE);
            bitmapImage    = new System.Windows.Media.Imaging.BitmapImage();
            bitmapImage.SetSource(resourceStream);
            openImage.Source = bitmapImage;
        }
Exemple #33
0
        void cameraCaptureAvaTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);

                //MessageBox.Show(bmp.ToString());
                Image myImgage = new Image();
                myImgage.Source = bmp;
                string str = ImageConvert.ImageConvert.convertImageToBase64(myImgage);

                imgAvatar.Source = ImageConvert.ImageConvert.convertBase64ToImage(str);

                //updateUserInfo(txtbFullname.Text, txtbEmail.Text, txtbPersonalID.Text, txtbPhone.Text);
            }
        }
Exemple #34
0
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            NavigationContext.QueryString.TryGetValue("folder", out folderName);
            if (folderName != "")
            {
                PageTitle.Text = "edit: " + folderName;
                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var stream = new IsolatedStorageFileStream(folderName + ".folder", FileMode.OpenOrCreate, store))
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            curMenu = new menu();
                            try
                            {
                                var serial = new XmlSerializer(typeof(menu));
                                curMenu = (menu)serial.Deserialize(stream);
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                if (curMenu.apps == null)
                {
                    curMenu.apps = new System.Collections.ObjectModel.Collection <appentry>();
                }
            }
            else
            {
                MessageBox.Show("I didn't get any arguments...", "Well this is awkward", MessageBoxButton.OK);
            }

            Rectangle rect = new Rectangle();

            rect.Width  = 62;
            rect.Height = 62;
            rect.Fill   = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);


            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                int y = 0;

                foreach (appentry app in clsData.installedApps)
                {
                    try
                    {
                        System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(52, 52);
                        StackPanel panel = new StackPanel();

                        panel.Orientation = System.Windows.Controls.Orientation.Horizontal;

                        wb.Render(rect, null);

                        Image img = new Image();

                        img.Margin = new Thickness(1, 1, 10, 1);
                        img.Width  = 52;
                        img.Height = 52;
                        System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                        using (var file = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read))
                        {
                            bmp.SetSource(file);
                        }
                        System.Diagnostics.Debug.WriteLine("apps/" + app.guid + ".jpg");
                        //bmp.SetSource(Application.GetResourceStream(new Uri("apps/" + app.guid + ".jpg", UriKind.Relative)).Stream);
                        //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(new Uri("/" + app.image, UriKind.Relative));
                        img.Source = bmp;
                        wb.Render(img, null);
                        wb.Invalidate();
                        img.Source            = wb;
                        img.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                        TextBlock text = new TextBlock();
                        text.Text              = app.name;
                        text.FontSize          = 30;
                        text.FontWeight        = FontWeights.Light;
                        text.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                        CheckBox cb = new CheckBox();
                        cb.Name = "app_" + app.guid;

                        foreach (appentry folderapp in curMenu.apps)
                        {
                            if (folderapp.guid == app.guid)
                            {
                                cb.IsChecked = true;
                            }
                        }

                        cb.Checked   += new RoutedEventHandler(cb_Checked);
                        cb.Unchecked += new RoutedEventHandler(cb_Unchecked);

                        selectedApps.Add(cb);

                        //panel.Name = app.guid;
                        panel.Name = "panel_" + y;
                        //panel.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(panel_Tap);
                        panel.Margin = new Thickness(0, 1, 1, 10);

                        panel.Children.Add(cb);
                        panel.Children.Add(img);
                        panel.Children.Add(text);

                        stackPanel1.Children.Add(panel);
                        y += 1;
                        //wb = null;
                    }
                    catch (Exception ez)
                    {
                        //MessageBox.Show(ez.Message + " " + ez.StackTrace);
                    }
                }
            }
        }
Exemple #35
0
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            string str = "";

            if (NavigationContext.QueryString.TryGetValue("tile", out str))
            {
                Rectangle rect = new Rectangle();
                rect.Width  = 62;
                rect.Height = 62;
                rect.Fill   = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);

                using (var store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (var stream = new IsolatedStorageFileStream(str + ".folder", FileMode.OpenOrCreate, store))
                    {
                        using (var reader = new StreamReader(stream))
                        {
                            curMenu = new menu();
                            try
                            {
                                var serial = new XmlSerializer(typeof(menu));
                                curMenu = (menu)serial.Deserialize(stream);
                            }
                            catch
                            {
                            }
                        }
                    }


                    int y = 0;

                    foreach (appentry app in curMenu.apps)
                    {
                        StackPanel panel = new StackPanel();

                        panel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(62, 62);

                        wb.Render(rect, null);

                        Image img = new Image();

                        img.Margin = new Thickness(1, 1, 10, 1);
                        img.Width  = 62;
                        img.Height = 62;
                        System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                        using (var file = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read))
                        {
                            bmp.SetSource(file);
                        }

                        img.Source = bmp;
                        wb.Render(img, null);
                        wb.Invalidate();
                        img.Source            = wb;
                        img.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                        panel.Children.Add(img);
                        TextBlock text = new TextBlock();
                        text.Text              = app.name;
                        text.FontSize          = 31;
                        text.FontWeight        = FontWeights.Light;
                        text.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                        panel.Children.Add(text);

                        panel.Name   = "panel_" + y;
                        panel.Margin = new Thickness(1, 1, 1, 10);



                        ListBoxItem foo = new ListBoxItem();
                        foo.Content = panel;
                        foo.Tap    += new EventHandler <GestureEventArgs>(panel_Tap);
                        foo.Name    = "danel_" + y;


                        stackPanel1.Children.Add(foo);
                        y += 1;
                        wb = null;
                    }

                    PageTitle.Text        = curMenu.name;
                    PageTitle.Opacity     = op;
                    scrollViewer1.Opacity = op;
                    scrollViewer1.Margin  = new Thickness(46, top, 0, 0);
                }
            }
            else
            {
                //Not a folder. Go to the editor
                NavigationService.Navigate(new Uri("/MainPage.xaml?init=true", UriKind.Relative));
            }
            tim          = new System.Windows.Threading.DispatcherTimer();
            tim.Interval = new TimeSpan(0, 0, 0, 0, 10);
            tim.Tick    += new EventHandler(tim_Tick);
            tim.Start();
        }
        void photoChooser_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                AddImageButton.Visibility = System.Windows.Visibility.Collapsed;
                ImageButton.Visibility = System.Windows.Visibility.Visible;

                //Code to display the photo on the page in an image control named myImage.
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                bmp.SetSource(e.ChosenPhoto);
                myImage.Source = bmp;
            }
        }
Exemple #37
0
        //浏览模式
        private void BindView()
        {
            fileName = NavigationContext.QueryString["id"];
            titleName = fileName.Substring(20);
            titleName = titleName.Substring(0, titleName.Length - 4);
            TitleTextBlock.Text = titleName;

            var appStorage = IsolatedStorageFile.GetUserStoreForApplication();

            using (var file = appStorage.OpenFile(fileName, FileMode.Open))
            {
                using (StreamReader sr = new StreamReader(file))
                {
                    DisplayTextBlock.Text = sr.ReadToEnd();
                }
            }

            if (appStorage.FileExists(fileName + ".jpg"))
            {
                System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();
                Image image = new Image();
                using (IsolatedStorageFileStream filestream = appStorage.OpenFile(fileName + ".jpg", FileMode.Open, FileAccess.Read))
                {
                    bitmap.SetSource(filestream);
                    image.Source = bitmap;
                    ShowImage.Source = bitmap;
                }
            }
            else
            {
                ShowImage.Visibility = System.Windows.Visibility.Collapsed;
            }
        } 
        void regenList()
        {
            /*
             * listBox1.Items.Clear();
             * foreach (appentry app in curMenu.apps)
             * {
             *  listBox1.Items.Add(app.name);
             * }
             */
            stackPanel1.Children.Clear();
            Rectangle rect = new Rectangle();

            rect.Width  = 62;
            rect.Height = 62;
            rect.Fill   = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                int y = 0;
                foreach (appentry app in curMenu.apps)
                {
                    try
                    {
                        System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(52, 52);
                        StackPanel panel = new StackPanel();

                        panel.Orientation = System.Windows.Controls.Orientation.Horizontal;

                        wb.Render(rect, null);

                        Image img = new Image();

                        img.Margin = new Thickness(1, 1, 10, 1);
                        img.Width  = 52;
                        img.Height = 52;
                        System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                        using (var file = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read))
                        {
                            bmp.SetSource(file);
                        }
                        System.Diagnostics.Debug.WriteLine("apps/" + app.guid + ".jpg");
                        //bmp.SetSource(Application.GetResourceStream(new Uri("apps/" + app.guid + ".jpg", UriKind.Relative)).Stream);
                        //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(new Uri("/" + app.image, UriKind.Relative));
                        img.Source = bmp;
                        wb.Render(img, null);
                        wb.Invalidate();
                        img.Source            = wb;
                        img.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                        TextBlock text = new TextBlock();
                        text.Text              = app.name;
                        text.FontSize          = 30;
                        text.FontWeight        = FontWeights.Light;
                        text.VerticalAlignment = System.Windows.VerticalAlignment.Center;


                        //selectedApps.Add(cb);

                        //panel.Name = app.guid;
                        panel.Name   = "panel_" + y;
                        panel.Tap   += new EventHandler <GestureEventArgs>(panel_Tap);
                        panel.Margin = new Thickness(0, 1, 1, 10);

                        //panel.Children.Add(cb);
                        panel.Children.Add(img);
                        panel.Children.Add(text);

                        stackPanel1.Children.Add(panel);
                        y += 1;
                        //wb = null;
                    }
                    catch (Exception ez)
                    {
                        //MessageBox.Show(ez.Message + " " + ez.StackTrace);
                    }
                }
            }
        }
        //her
        private void ConnectCallback2(IAsyncResult asynchronousResult)
        {
            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);

            String file;
            using (StreamReader streamReader1 = new StreamReader(response.GetResponseStream()))
            {

                String resultString = streamReader1.ReadToEnd();
                XDocument xdoc = XDocument.Parse(resultString, LoadOptions.None);
                response.GetResponseStream().Close();
                response.Close();
                file = xdoc.Element("api").Element("query").Element("pages").Element("page").Element("imageinfo").Element("ii").Attribute("url").Value;

                System.Diagnostics.Debug.WriteLine("file: " + file);
                if (!(file.Trim().ToLower().EndsWith(".png") || file.Trim().ToLower().EndsWith(".jpg")))
                {
                    System.Diagnostics.Debug.WriteLine("unsupported file: " + file);
                    return;
                }
            }
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(file));
                webRequest.BeginGetResponse((result) =>
                {
                    request = (HttpWebRequest)result.AsyncState;

                    response = (HttpWebResponse)request.EndGetResponse(result);
                    var streamReader2 = new StreamReader(response.GetResponseStream());

                    Dispatcher.BeginInvoke(() =>
                    {
                        var bmp = new System.Windows.Media.Imaging.BitmapImage();
                        bmp.SetSource(streamReader2.BaseStream);

                        var imageBrush = new ImageBrush
                        {
                            ImageSource = bmp,
                            //Opacity = 0.5d,
                            Stretch = Stretch.UniformToFill
                        };

                        this.ContentPanel.Background = imageBrush;
                        streamReader2.BaseStream.Close();
                        response.GetResponseStream().Close();
                        response.Close();
                    });

                }, webRequest);
        }
Exemple #40
0
        private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
            filename = NavigationContext.QueryString["id"];
            System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();

            IsolatedStorageFile appStore = IsolatedStorageFile.GetUserStoreForApplication();
            using (IsolatedStorageFileStream filestream = appStore.OpenFile(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                bitmap.SetSource(filestream);
            }
            ShowImageControler.Source = bitmap;
            Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
        }
Exemple #41
0
		public static int[][] DecodeJpegToRaw(ref byte[] image)
		{
			int[][] rawImage = null;
			try
			{
				using (MemoryStream stream = new MemoryStream(image))
				{
					var bitmapImage = new System.Windows.Media.Imaging.BitmapImage();
					bitmapImage.SetSource(stream);

					var bitmap = new System.Windows.Media.Imaging.WriteableBitmap(bitmapImage);
					int width = bitmap.PixelWidth;
					int height = bitmap.PixelHeight;

					rawImage = new int[width][];
					for (int col = 0; col < width; col++)
					{
						rawImage[col] = new int[height];
						for (int row = 0; row < height; row++)
						{
							rawImage[col][row] = bitmap.Pixels[(row * width) + col];
						}
					}

					bitmap = null;
					bitmapImage = null;
					GC.Collect();
				}				
			}
			catch (Exception)
			{
				//- Notice!
				//On Server or Desktop plataform, call the reference function by using reflection
				//Equals made in Android plataform, because this libaries aren't portable between WP and .NET 4.0!
				Type bitmapType = Type.GetType("Ufc.MiscNet.ImageUtilities, MiscNet, Version=1.0.0.0, Culture=neutral");
				object instance = Activator.CreateInstance(bitmapType);
				Type[] typeParam = new Type[1] { typeof(byte[]) };

				MethodInfo method = bitmapType.GetMethod("DecodeJpegToRaw", typeParam);
				rawImage = (int[][])method.Invoke(instance, new object[1] { image });
			}
			finally
			{
				image = null;
				GC.Collect();
			}
			return rawImage;
		}
Exemple #42
0
        void PhotoTask_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
            {

                System.Windows.Media.Imaging.WriteableBitmap bmp = Microsoft.Phone.PictureDecoder.DecodeJpeg(e.ChosenPhoto);
                System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                if (isf.FileExists("abc.jpg")) isf.DeleteFile("abc.jpg");
                System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.CreateFile("abc.jpg");
                System.Windows.Media.Imaging.Extensions.SaveJpeg(bmp, PhotoStream, 432, 645, 0, 100); //这里设置保存后图片的大小、品质
                PhotoStream.Close();    //写入完毕,关闭文件流

                PhotoStream = isf.OpenFile("abc.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);   //读取刚刚保存的图片的文件流
                System.Windows.Media.Imaging.BitmapImage bmp1 = new System.Windows.Media.Imaging.BitmapImage();
                bmp1.SetSource(PhotoStream);  //把文件流转换为图片
                PhotoStream.Close();    //读取完毕,关闭文件流

                System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                ib.ImageSource = bmp1;
                tip.Background = ib;//把图片设置为控件的背景图
                imageTip.Visibility = System.Windows.Visibility.Collapsed;
                if (imagePicker.Content.ToString() == txtnote.Resources.StringLibrary.imagename)
                {
                    if (MessageBox.Show(txtnote.Resources.StringLibrary.imagename, txtnote.Resources.StringLibrary.guanlian, MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                    {

                        NavigationService.Navigate(new Uri("/txtnote;component/Pick.xaml", UriKind.Relative));

                    }
                }
                else
                {
                    appBar3();
                }
            }
        }
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            try
            {
                System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        bmp.SetSource(e.Result);
                        this.cctv.Source = bmp;
                       
                    }
                    catch
                    {
                        ;
                    }
                    finally
                    {

                        if (ISExit || (this.TimeLimit && DateTime.Now.Subtract(DateTimeBegin) > TimeSpan.FromMinutes(3)    ))
                            tmr.Stop();
                        //    BeginReadCCTV();
                    }

                   

                }
                );

            }
            catch
            { ;}
        }
        void context_UpdateControlSettingsEvent(ControlSettingsModel controlSettings)
        {
           
            _controlSettings = controlSettings;
          
                plateControlhidden.PointData = plateControl.PointData;
            
           
         
            #region Update thumbnail
            if (leftMenu != null)
            {
                if (leftMenu.Items.Count > 0)
                {
                    leftMenu.SelectedIndex = 0;
                    if (leftMenu.SelectedItem != null)
                    {
                        var image = new System.Windows.Media.Imaging.BitmapImage();
                        image.SetSource(plateControl.SaveAsImage());
                        ((LeftMenuModel)leftMenu.SelectedItem).Image = image;

                        leftMenu.ItemsSource = null;
                        leftMenu.ItemsSource = LeftMenuContent;
                    }

                }

            }
            #endregion


            btnSaveClose.IsEnabled = controlSettings.IsSaveAvailable;
            btnUndo.IsEnabled = controlSettings.IsUndoAvailable;
            btnRedo.IsEnabled = controlSettings.IsRedoAvailable;

            btnClear.IsEnabled = controlSettings.IsClearAvailable;
            btnClear.Visibility = controlSettings.IsClearAvailable ? Visibility.Visible : Visibility.Collapsed;

            btnErase.Visibility = controlSettings.AllowFillMode ? Visibility.Visible : Visibility.Collapsed;
            btnFill.Visibility = controlSettings.AllowFillMode ? Visibility.Visible : Visibility.Collapsed;
            btnFillSettings.Visibility = controlSettings.SelectionCommand == Models.SelectionCommand.Fill ?
                Visibility.Visible : Visibility.Collapsed;

            spGroupNumEditor.Visibility = controlSettings.AllowFillMode ?
                Visibility.Visible : Visibility.Collapsed;
            lbSampleTypes.IsEnabled = controlSettings.AllowFillMode;

            SelectionCommand = controlSettings.SelectionCommand;
            if (CurrentStateChangeCommand != null && CurrentStateChangeCommand.CanExecute(controlSettings.CurrentState))
                CurrentStateChangeCommand.Execute(controlSettings.CurrentState);
        }
Exemple #45
0
        public System.Windows.Media.Imaging.BitmapImage GetAvatarImage(string strHash)
        {
            System.Windows.Media.Imaging.BitmapImage objImage = null;
            IsolatedStorageFile storage = null;

            #if WINDOWS_PHONE
            storage = IsolatedStorageFile.GetUserStoreForApplication();
            #else
            storage = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);
            #endif

            string strFileName = string.Format("{0}/{1}", AccountFolder, strHash);
            if (storage.FileExists(strFileName) == false)
            {
                storage.Dispose();
                return null;
            }

            IsolatedStorageFileStream stream = null;
            try
            {
                stream = new IsolatedStorageFileStream(strFileName, System.IO.FileMode.Open, storage);
                objImage = new System.Windows.Media.Imaging.BitmapImage();
            #if WINDOWS_PHONE
                objImage.SetSource(stream);
            #else
                objImage.BeginInit();
                objImage.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
                objImage.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.None;

                objImage.StreamSource = stream;
                objImage.EndInit();

                double nWith = objImage.Width;
                double nHeight = objImage.Height;
            #endif

            }
            catch (Exception)
            {
            }
            finally
            {
                if (stream != null)
                    stream.Close();

                storage.Dispose();
            }

            return objImage;
        }
        private void UpdateLeftMenuContent()
        {
            if (UserSettings != null && UserSettings.IsMultiple)
            {
                if (UserSettings.IsMultiple)
                {
                    btnAdd.Visibility = Visibility.Visible;
                    btnAdd.Content = UserSettings.ContainerName;

                    btnRemove.Visibility = Visibility.Visible;
                    btnRemove.Content = UserSettings.ContainerName;

                    btnDuplicate.Visibility = Visibility.Visible;
                    btnDuplicate.Content = UserSettings.ContainerName;
                }
                else
                {
                    btnAdd.Visibility = Visibility.Collapsed;
                    btnRemove.Visibility = Visibility.Collapsed;
                    btnDuplicate.Visibility = Visibility.Collapsed;
                }

                var stream = SaveAsImage();
                LeftMenuContent.Clear();
                //TODO: To place the business logic of filling the left menu here
                //      add a logic of parsing the MultipleLayout
                if (stream != null)
                {
                    var leftMenuItem = new LeftMenuModel();
                    var image = new System.Windows.Media.Imaging.BitmapImage();
                    image.SetSource(stream);
                    var scale = Math.Max(plateControl.ActualWidth, plateControl.ActualHeight) / (leftMenu.Width - 100);
                    leftMenuItem.Width = plateControl.ActualWidth / scale;
                    leftMenuItem.Height = plateControl.ActualHeight / scale;
                    leftMenuItem.Image = image;
                    leftMenuItem.Key = LeftMenuContent.Count;
                    leftMenuItem.DiagramModel = LayoutContent;
                    LeftMenuContent.Add(leftMenuItem);
                    leftMenu.SelectedItem = leftMenuItem;
                }

            }
            else
                LeftMenuContent.Clear();
        }
Exemple #47
0
        private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
            string state = "";
            if (settings.Contains("state"))
            {
                if (settings.TryGetValue<string>("state",out state))
                {
                    if (state == "edit")
                    {
                        string value = "";
                        string title = "";
                        if (settings.Contains("value"))
                        {
                            if (settings.Contains("filename"))
                            {
                                if (settings.TryGetValue<string>("filename", out value))
                                {
                                    fileName = value;
                                }
                            }
                            if (settings.Contains("title"))
                            {
                                if (settings.TryGetValue<string>("title", out title))
                                {
                                    titleName = title;
                                }
                            }
                            if (settings.TryGetValue<string>("value", out value))
                            {
                                BindEdit(value);

                                var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
                                if (appStorage.FileExists(fileName + ".jpg"))
                                {
                                    System.Windows.Media.Imaging.BitmapImage bitmap = new System.Windows.Media.Imaging.BitmapImage();
                                    Image image = new Image();
                                    using (IsolatedStorageFileStream filestream = appStorage.OpenFile(fileName + ".jpg", FileMode.Open, FileAccess.Read))
                                    {
                                        bitmap.SetSource(filestream);
                                        image.Source = bitmap;
                                        ShowImage.Source = bitmap;
                                    }
                                }
                                else
                                {
                                    ShowImage.Visibility = System.Windows.Visibility.Collapsed;
                                }
                            }

                        }
                    }
                    else
                    {
                        BindView();
                    }
                }
                else
                {
                    BindView();
                }
            }
            else
            {
                BindView();
            }

        }
        public addSystemApp()
        {
            InitializeComponent();
            Rectangle rect = new Rectangle();

            rect.Width  = 62;
            rect.Height = 62;
            rect.Fill   = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                int y = 0;
                foreach (string app in clsData.appTitles)
                {
                    try
                    {
                        System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(52, 52);
                        StackPanel panel = new StackPanel();

                        panel.Orientation = System.Windows.Controls.Orientation.Horizontal;

                        wb.Render(rect, null);

                        Image img = new Image();

                        img.Margin = new Thickness(1, 1, 10, 1);
                        img.Width  = 52;
                        img.Height = 52;
                        System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
                        using (var file = store.OpenFile(app + ".jpg", FileMode.Open, FileAccess.Read))
                        {
                            bmp.SetSource(file);
                        }

                        img.Source = bmp;
                        wb.Render(img, null);
                        wb.Invalidate();
                        img.Source            = wb;
                        img.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                        TextBlock text = new TextBlock();
                        text.Text              = app;
                        text.FontSize          = 30;
                        text.FontWeight        = FontWeights.Light;
                        text.VerticalAlignment = System.Windows.VerticalAlignment.Center;

                        panel.Name   = "panel_" + y;
                        panel.Tap   += new EventHandler <GestureEventArgs>(panel_Tap);
                        panel.Margin = new Thickness(0, 1, 1, 10);

                        panel.Children.Add(img);
                        panel.Children.Add(text);

                        stackPanel1.Children.Add(panel);
                        y += 1;
                    }
                    catch (Exception ez)
                    {
                        MessageBox.Show(ez.Message + " " + ez.StackTrace);
                    }
                }
            }
        }
Exemple #49
0
        private void showBackground()
        {
            System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
            //点击超链接后图片存在

            if (isf.FileExists("back_temp.jpg"))
            {

                System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.OpenFile("back_temp.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                System.Windows.Media.Imaging.BitmapImage bmp1 = new System.Windows.Media.Imaging.BitmapImage();
                bmp1.SetSource(PhotoStream);  //把文件流转换为图片
                PhotoStream.Close();    //读取完毕,关闭文件流

                System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                ib.ImageSource = bmp1;
                MainPano.Background = ib;  //把图片设置为控件的背景图
                //imageTip.Visibility = System.Windows.Visibility.Collapsed;
            }
               // else
              //  {
               //     MainPano.Background = null;
              //  }
        }
Exemple #50
0
        private void showImage()
        {
            if (App.ViewModel.forShare != null)
                {
                    imagePicker.Content = App.ViewModel.forShare.ItemName;
                    imagePicker.Opacity = 0.5;
                    System.IO.IsolatedStorage.IsolatedStorageFile isf = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                    //点击超链接后图片存在
                    if (isf.FileExists(App.ViewModel.forShare.ItemName + ".jpg"))
                    {
                        isf.CopyFile(App.ViewModel.forShare.ItemName + ".jpg", "abc.jpg", true);
                        System.IO.IsolatedStorage.IsolatedStorageFileStream PhotoStream = isf.OpenFile("abc.jpg", System.IO.FileMode.Open, System.IO.FileAccess.Read);
                        System.Windows.Media.Imaging.BitmapImage bmp1 = new System.Windows.Media.Imaging.BitmapImage();
                        bmp1.SetSource(PhotoStream);  //把文件流转换为图片
                        PhotoStream.Close();    //读取完毕,关闭文件流

                        System.Windows.Media.ImageBrush ib = new System.Windows.Media.ImageBrush();
                        ib.ImageSource = bmp1;
                        tip.Background = ib;  //把图片设置为控件的背景图
                        //imageTip.Visibility = System.Windows.Visibility.Collapsed;
                    }
               }
            //如果存在背景,则显示关联按钮
                   if (tip.Background != null)
                   {

                       appBar3();
                   }
        }