Exemplo n.º 1
0
        private void _SetAsDesktopBackgroundCallback(object sender, SaveImageCompletedEventArgs e)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((SaveImageAsyncCallback)_SetAsDesktopBackgroundCallback, sender, e);
                return;
            }

            if (e.Cancelled || e.Error != null)
            {
                MessageBox.Show("Unable to use this photo for the desktop background");
                return;
            }

            string photoLocalPath = e.ImagePath;
            string wallpaperPath  = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Fishbowl\\Wallpaper") + Path.GetExtension(photoLocalPath);

            try
            {
                // Clear the current wallpaper (releases lock on current bitmap)
                NativeMethods.SystemParametersInfo(SPI.SETDESKWALLPAPER, 0, String.Empty, SPIF.UPDATEINIFILE | SPIF.SENDWININICHANGE);

                // Delete the old wallpaper if it exists
                Utility.SafeDeleteFile(wallpaperPath);
                Utility.EnsureDirectory(Path.GetDirectoryName(wallpaperPath));

                File.Copy(photoLocalPath, wallpaperPath);
                NativeMethods.SystemParametersInfo(SPI.SETDESKWALLPAPER, 0, wallpaperPath, SPIF.UPDATEINIFILE | SPIF.SENDWININICHANGE);
            }
            catch (Exception)
            { }
        }
Exemplo n.º 2
0
        private void _OnImageSaved(object sender, SaveImageCompletedEventArgs e)
        {
            if (e.Cancelled || e.Error != null)
            {
                return;
            }

            _contactManager.Dispatcher.BeginInvoke((Action)(() =>
            {
                try
                {
                    var fbMeContact = (FacebookContact)e.UserState;
                    Contact meContact = _contactManager.MeContact;
                    if (meContact == null)
                    {
                        meContact = _contactManager.CreateContact();
                        meContact.Names.Default = new Name(fbMeContact.Name);
                        meContact.CommitChanges();
                        _contactManager.MeContact = meContact;
                    }

                    using (var fs = new FileStream(e.ImagePath, FileMode.Open))
                    {
                        meContact.Photos[PhotoLabels.UserTile] = new Photo(fs, "image/jpeg");
                        meContact.CommitChanges();
                    }
                }
                catch (IOException)
                {
                    // This is just an opportunistic operation.  Failure is acceptable.
                }
            }), null);
        }
Exemplo n.º 3
0
        private void _OnAlbumSaveProgressCallback(object sender, SaveImageCompletedEventArgs e)
        {
            if (e.Error != null || e.Cancelled)
            {
                //FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress(1F);
                return;
            }

            //FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress((float)e.CurrentImageIndex / (float)e.TotalImageCount);
        }
Exemplo n.º 4
0
        private void _OnPhotoSaveProgressCallback(object sender, SaveImageCompletedEventArgs e)
        {
            if (e.Error != null || e.Cancelled)
            {
                //FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress(1F);
                return;
            }

            Process.Start(new ProcessStartInfo {
                FileName = e.ImagePath
            });

            //FacebookClientApplication.Current2.MainWindow.SetTaskbarProgress((float)e.CurrentImageIndex / (float)e.TotalImageCount);
        }
Exemplo n.º 5
0
        private void _PrintFileCallback(object sender, SaveImageCompletedEventArgs e)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((SaveImageAsyncCallback)_PrintFileCallback, new [] { sender, e });
                return;
            }

            if (e.Cancelled || e.Error != null)
            {
                MessageBox.Show("Unable to print the image");
                return;
            }

            object path = e.ImagePath;

            WIA.CommonDialog dialog = new WIA.CommonDialogClass();
            dialog.ShowPhotoPrintingWizard(ref path);
        }