示例#1
0
        public ActionResult Edit(HttpPostedFileBase avatarFile, FlavorViewModel flavorVM)
        {
            try
            {
                var flavor = db.Flavors.Find(flavorVM.Id);
                if (flavor.IsApproved == true)
                {
                    return(RedirectToAction("Flavors", "Customer"));
                }
                flavor.Name = flavorVM.Name;
                if (avatarFile != null)
                {
                    flavor.Images = SaveImages.SaveImagesFile(avatarFile, flavorVM.Name);
                }
                flavor.Description     = flavorVM.Description;
                flavor.PreparationTime = flavorVM.PreparationTime;
                flavor.TotalTime       = flavorVM.TotalTime;
                flavor.Ingredients     = flavorVM.Ingredients;
                flavor.Slug            = Slugify.GenerateSlug(flavor.Name);
                flavor.UpdatedAt       = DateTime.Now;
                flavor.Recipe          = flavorVM.Recipe;
                flavor.IsApproved      = false;

                db.Entry(flavor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Flavors", "Customer"));
            }
            catch
            {
                return(View());
            }
        }
示例#2
0
    private void AddSponser()
    {
        int    maxOrdNo = GetMaxOrdNo();
        string path     = "";

        try
        {
            DBconnection obj = new DBconnection();
            obj.SetCommandSP = "z_AddSponser_Dist";

            SaveImages img = new SaveImages();
            path = img.AddImages(FileUpload1.PostedFile, "Sponsers_Logo");

            obj.AddParam("@start_date", DateTime.Parse(StartDate.SelectedDate.ToString()));
            obj.AddParam("@end_date", DateTime.Parse(EndDate.SelectedDate.ToString()));

            obj.AddParam("@title", txtTitle.Text.ToString());
            obj.AddParam("@url", txtURL.Text.ToString());
            obj.AddParam("@status", DDLStatus.SelectedItem.Text.Trim().ToString());
            obj.AddParam("@logo", path);
            obj.AddParam("@display_order", maxOrdNo + 1);


            int exe = obj.ExecuteNonQuery();

            if (exe > 0)
            {
                clear();
                string jv = "<script>alert('Record has been added successfully');</script>";
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", jv, false);
            }
        }
        catch { }
    }
示例#3
0
        public ActionResult Create(HttpPostedFileBase avatarFile, FlavorViewModel flavorViewModel)
        {
            if (ModelState.IsValid)
            {
                Flavor flavor = new Flavor()
                {
                    UserId          = ((Customer)Session["Customer"]).Id,
                    UserType        = Flavor.CUSTOMER,
                    Name            = flavorViewModel.Name,
                    Description     = flavorViewModel.Description,
                    Images          = SaveImages.SaveImagesFile(avatarFile, flavorViewModel.Name),
                    PreparationTime = flavorViewModel.PreparationTime,
                    TotalTime       = flavorViewModel.TotalTime,
                    Ingredients     = flavorViewModel.Ingredients,
                    Recipe          = flavorViewModel.Recipe,
                    IsApproved      = false,
                    Slug            = Slugify.GenerateSlug(flavorViewModel.Name),
                    CreatedAt       = DateTime.Now,
                    UpdatedAt       = DateTime.Now
                };
                Session["Image"] = "/" + ConfigurationManager.AppSettings["CusImages"] + flavor.Images;
                db.Flavors.Add(flavor);
                db.SaveChanges();
                return(RedirectToAction("Flavors", "Customer"));
            }

            return(View());
        }
        public ActionResult Me(HttpPostedFileBase avatarFile, UpdateProfileViewModel input)
        {
            int staffId = ((Staff)Session["Staff"]).Id;

            if (staffId != input.Id)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                var staff = db.Staffs.Where(q => q.Id == staffId).FirstOrDefault();

                staff.Id      = input.Id;
                staff.Name    = input.Name;
                staff.Address = input.Address;
                staff.Phone   = input.Phone;
                if (avatarFile != null)
                {
                    staff.Avatar = SaveImages.SaveAvatarFile(avatarFile, staff.Email);
                }

                Session["Avatar"]     = "/" + ConfigurationManager.AppSettings["CusAvatar"] + staff.Avatar;
                db.Entry(staff).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("Me"));
        }
示例#5
0
        public async Task <IHttpActionResult> PostTRN_SchemeAuditChild(TRN_SchemeAuditChild tRN_SchemeAuditChild)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                string     _imagePath = string.Empty;
                SaveImages saveImages = new SaveImages();

                _imagePath = saveImages.isImageSaved(tRN_SchemeAuditChild);
                var ImageLocation = db.TRN_SchemeAuditChild.Where(x => x.ImageLocation == _imagePath).Select(x => x.ImageLocation);
                if (ImageLocation.Count() > 0)
                {
                    return(BadRequest("Data Allready added"));
                }
                else
                {
                    if (_imagePath.Length != 0)
                    {
                        tRN_SchemeAuditChild.ImageLocation = string.Empty;
                        tRN_SchemeAuditChild.ImageLocation = _imagePath;
                        db.TRN_SchemeAuditChild.Add(tRN_SchemeAuditChild);
                        await db.SaveChangesAsync();
                    }
                }

                return(CreatedAtRoute("DefaultApi", new { id = tRN_SchemeAuditChild.Id }, tRN_SchemeAuditChild));
            }
        }
    void OnPostRender()
    {
        //DrawVignetteLine();
        screenFade();
        int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex];

        // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString());
        Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId);
        if (Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            cube.transform.Rotate(0, 0, 360 * Time.deltaTime);
            SaveImages.SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + (int)eye * 3], eye.ToString());
        }
#if !UNITY_EDITOR && UNITY_ANDROID
        if (eye == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow)
        {
            AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI");
            Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread");
            setLevel = true;
            Debug.Log("Viewer setVrThread");
        }
        else
        {
            return;
        }
#endif
    }
示例#7
0
 public ActionResult Create(HttpPostedFileBase avatarFile, FlavorViewModel flavorVM)
 {
     try
     {
         Flavor flavor = new Flavor()
         {
             UserId          = ((Staff)Session["Staff"]).Id,
             UserType        = Flavor.STAFF,
             Name            = flavorVM.Name,
             Description     = flavorVM.Description,
             Images          = SaveImages.SaveImagesFile(avatarFile, flavorVM.Name),
             PreparationTime = flavorVM.PreparationTime,
             TotalTime       = flavorVM.TotalTime,
             Ingredients     = flavorVM.Ingredients,
             Recipe          = flavorVM.Recipe,
             IsApproved      = true,
             Slug            = Slugify.GenerateSlug(flavorVM.Name),
             CreatedAt       = DateTime.Now,
             UpdatedAt       = DateTime.Now
         };
         Session["Image"] = "/" + ConfigurationManager.AppSettings["CusImages"] + flavor.Images;
         db.Flavors.Add(flavor);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
示例#8
0
 void OnPostRender()
 {
     if (Input.GetKeyDown(KeyCode.JoystickButton0))
     {
         cube.transform.Rotate(0, 0, 360 * Time.deltaTime);
         SaveImages.SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + (int)eyeSide * 3]);
     }
 }
示例#9
0
        /// <summary>
        /// Open a File Dialog, where the user can save a supported file type.
        /// </summary>
        internal static void SaveFiles()
        {
            string fileName;

            if (Pics.Count > 0)
            {
                if (string.IsNullOrEmpty(Pics[FolderIndex]))
                {
                    return;
                }
                fileName = Path.GetFileName(Pics[FolderIndex]);
            }
            else
            {
                fileName = Path.GetRandomFileName();
            }

            var Savedlg = new SaveFileDialog()
            {
                Filter   = FilterFiles,
                Title    = Application.Current.Resources["Save"] as string + $" - {SetTitle.AppName}",
                FileName = fileName
            };

            if (!Savedlg.ShowDialog().Value)
            {
                return;
            }

            IsDialogOpen = true;

            if (Pics.Count > 0)
            {
                if (!SaveImages.TrySaveImage(Rotateint, Flipped, Pics[FolderIndex], Savedlg.FileName))
                {
                    ShowTooltipMessage(Application.Current.Resources["SavingFileFailed"]);
                }
            }
            else
            {
                if (!SaveImages.TrySaveImage(Rotateint, Flipped, LoadWindows.GetMainWindow.MainImage.Source as BitmapSource, Savedlg.FileName))
                {
                    ShowTooltipMessage(Application.Current.Resources["SavingFileFailed"]);
                }
            }

            if (Savedlg.FileName == fileName)
            {
                //Refresh the list of pictures.
                Reload();
            }

            Close_UserControls();
            IsDialogOpen = false;
        }
    private void AddRIPresident()
    {
        try
        {
            RIPresident rip = new RIPresident();

            try
            {
                rip.District_no = int.Parse(txtDistNo.Text.Trim().ToString());
            }
            catch { rip.District_no = 0; }
            try
            {
                rip.Participant = int.Parse(txtParticepant.Text.Trim().ToString());
            }
            catch
            {
                rip.Participant = 0;
            }
            rip.Description = txtData.Content;

            rip.Year       = DDLYear.SelectedItem.Text.Trim().ToString();
            rip.Fname      = txtFName.Text.Trim().ToString();
            rip.Mname      = txtMName.Text.Trim().ToString();
            rip.Lname      = txtLName.Text.Trim().ToString();
            rip.Club_name  = txtClubName.Text.Trim().ToString();
            rip.District   = txtDistrict.Text.Trim().ToString();// Location
            rip.Country    = txtCountry.Text.Trim().ToString();
            rip.Theme      = txtTheme.Text.Trim().ToString();
            rip.Convention = txtConvention.Text.Trim().ToString();

            SaveImages img = new SaveImages();

            string pimg = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentPhotos");
            rip.President_image = pimg;

            string theme_logo = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentLogo");
            rip.Theme_logo = theme_logo;

            string convention_image = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentLogo");
            rip.Convention_image = convention_image;

            int exe = rip.AddRIPresident();

            if (exe > 0)
            {
                clear();
                string jv = "<script>alert('Record Added Successfully');</script>";
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", jv, false);
            }
        }
        catch { }
    }
    private void UpdateRIPresident(int id)
    {
        try
        {
            RIPresident rip = new RIPresident();
            try
            {
                rip.District_no = int.Parse(txtDistNo.Text.Trim().ToString());
            }
            catch { rip.District_no = 0; }
            try
            {
                rip.Participant = int.Parse(txtParticepant.Text.Trim().ToString());
            }
            catch
            {
                rip.Participant = 0;
            }
            rip.Description = txtData.Content;

            rip.Id         = id;
            rip.Year       = DDLYear.SelectedItem.Text.Trim().ToString();
            rip.Fname      = txtFName.Text.Trim().ToString();
            rip.Mname      = txtMName.Text.Trim().ToString();
            rip.Lname      = txtLName.Text.Trim().ToString();
            rip.Club_name  = txtClubName.Text.Trim().ToString();
            rip.District   = txtDistrict.Text.Trim().ToString();
            rip.Country    = txtCountry.Text.Trim().ToString();
            rip.Theme      = txtTheme.Text.Trim().ToString();
            rip.Convention = txtConvention.Text.Trim().ToString();

            SaveImages img = new SaveImages();

            string pimg = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentPhotos");
            rip.President_image = pimg;

            string theme_logo = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentLogo");
            rip.Theme_logo = theme_logo;

            string convention_image = img.AddImages(FileUploadPhoto.PostedFile, "RIPresidentLogo");
            rip.Convention_image = convention_image;

            int exe = rip.UpdateRIPresident();
            if (exe > 0)
            {
                clear();
                showmsg("Record updated successfully !", "view_ri_president.aspx");
            }
        }
        catch { }
    }
示例#12
0
        internal static async Task SaveCrop()
        {
            var fileName = Pics.Count == 0 ? Path.GetRandomFileName()
                : Path.GetFileName(Pics[FolderIndex]);

            var Savedlg = new SaveFileDialog
            {
                Filter   = Open_Save.FilterFiles,
                Title    = $"{Application.Current.Resources["SaveImage"]} - {SetTitle.AppName}",
                FileName = fileName
            };

            if (!Savedlg.ShowDialog().Value)
            {
                return;
            }

            Open_Save.IsDialogOpen = true;

            var crop    = GetCrop();
            var success = false;

            if (Pics.Count > 0)
            {
                await Task.Run(() =>
                               success = SaveImages.TrySaveImage(
                                   crop,
                                   Pics[FolderIndex],
                                   Savedlg.FileName)).ConfigureAwait(false);
            }
            else
            {
                // Fixes saving if from web
                // TODO add working method for copied images
                var source = ConfigureWindows.GetMainWindow.MainImage.Source as BitmapSource;
                await Task.Run(() =>
                               success = SaveImages.TrySaveImage(
                                   crop,
                                   source,
                                   Savedlg.FileName)).ConfigureAwait(false);
            }
            await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke((Action)(() =>
            {
                if (!success)
                {
                    Tooltip.ShowTooltipMessage(Application.Current.Resources["SavingFileFailed"]);
                }

                ConfigureWindows.GetMainWindow.ParentContainer.Children.Remove(GetCropppingTool);
            }));
        }
        public void SaveTabletImagesToDisk()
        {
            List <string> tabletNames         = AllTabletNames.GetTextOfElements();
            List <string> allTabletImageLinks = AllTabletImages.GetSpecifiedAttributeOfElements("data-src");

            var tabletImageInfoDictionary = new Dictionary <string, List <string> >()
            {
                { "TabletName", tabletNames },
                { "TabletImageLink", allTabletImageLinks }
            };

            var tabletImageInfoDataTable = tabletImageInfoDictionary.GetDataTable();

            SaveImages.SaveImagesToDisk(tabletImageInfoDataTable);
        }
 public ActionResult Create(HttpPostedFileBase avatarFile, BookViewModel viewModel)
 {
     SetViewBag();
     if (ModelState.IsValid)
     {
         Random rd   = new Random();
         var    book = MappingProfile.mapper.Map <BookViewModel, Book>(viewModel);
         book.StaffId   = ((Staff)Session["Staff"]).Id;
         book.Slug      = Slugify.GenerateSlug(book.Name);
         book.CreatedAt = DateTime.Now;
         book.UpdatedAt = DateTime.Now;
         book.Sku       = rd.Next(1000, 9999).ToString();
         book.Images    = SaveImages.SaveImagesFile(avatarFile, viewModel.Name);
         db.Books.Add(book);
         db.SaveChanges();
     }
     ;
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit(HttpPostedFileBase avatarFile, BookViewModel viewModel)
 {
     SetViewBag(viewModel.CategoryId);
     if (ModelState.IsValid)
     {
         var book = db.Books.Where(x => x.Id == viewModel.Id).FirstOrDefault();
         book.Name            = viewModel.Name;
         book.Price           = viewModel.Price;
         book.Slug            = Slugify.GenerateSlug(viewModel.Name);
         book.CategoryId      = viewModel.CategoryId;
         book.Images          = SaveImages.SaveImagesFile(avatarFile, viewModel.Name);
         book.Description     = viewModel.Description;
         book.Discount        = viewModel.Discount;
         book.UpdatedAt       = DateTime.Now;
         db.Entry(book).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
示例#16
0
    private void UpdateSponser(int id)
    {
        string path = "";

        try
        {
            DBconnection obj = new DBconnection();
            obj.SetCommandSP = "z_UpdateSponser_Dist";

            if (FileUpload1.PostedFile != null)
            {
                path = Session["logo"].ToString();
            }
            else
            {
                SaveImages img = new SaveImages();
                path = img.AddImages(FileUpload1.PostedFile, "Sponsers_Logo");
            }

            obj.AddParam("@id", id);
            obj.AddParam("@start_date", DateTime.Parse(StartDate.SelectedDate.ToString()));
            obj.AddParam("@end_date", DateTime.Parse(EndDate.SelectedDate.ToString()));
            obj.AddParam("@title", txtTitle.Text.ToString());
            obj.AddParam("@url", txtURL.Text.ToString());
            obj.AddParam("@status", DDLStatus.SelectedItem.Text.Trim().ToString());
            obj.AddParam("@logo", path);

            int exe = obj.ExecuteNonQuery();

            if (exe > 0)
            {
                clear();

                showmsg("Record has been updated successfully !", "view_sponsors.aspx");
            }
        }
        catch { }
    }
示例#17
0
    private void AddBulletin()
    {
        string path, mast_head = "";

        try
        {
            DBconnection obj = new DBconnection();
            obj.SetCommandSP = "z_AddBulletin";

            obj.AddParam("@added_by", "Admin");

            int i = int.Parse(rbtnFor.SelectedValue.ToString());
            if (i == 0)
            {
                obj.AddParam("@DistrictClubID", 0);
            }

            else
            {
                int cid = int.Parse(DDLClubName.SelectedValue.ToString());
                obj.AddParam("@DistrictClubID", cid);
            }

            SaveImages img = new SaveImages();
            path      = img.AddImages(FileUpload1.PostedFile, "Bulletin");
            mast_head = img.AddImages(FileUpload2.PostedFile, "Bulletin");


            //try
            //{
            //    foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
            //    {
            //        fileSize = file.ContentLength;
            //        file_name = file.FileName;
            //        file_name = file_name.Substring(file_name.LastIndexOf("\\") + 1);
            //        string imageTime = System.DateTime.Now.ToString();
            //        imageTime = imageTime.Replace("/", "");
            //        imageTime = imageTime.Replace("-", "");
            //        imageTime = imageTime.Replace(":", "");
            //        imageTime = imageTime.Replace(" ", "");
            //        ext = file_name.Substring(file_name.LastIndexOf("."));
            //        file_name = file_name.Substring(0, file_name.LastIndexOf("."));
            //        file_name = file_name + "_" + imageTime + ext;
            //        path = Server.MapPath("~/Bulletin/");
            //        path = path + "/" + file_name;
            //        file.SaveAs(path);
            //    }
            //}
            //catch { }

            obj.AddParam("@title", txtTitle.Text.ToString());
            obj.AddParam("@frequency", rbtnFrequency.SelectedItem.Text.ToString());
            obj.AddParam("@status", DDLStatus.SelectedItem.Text.Trim().ToString());
            obj.AddParam("@bulletin", path);
            obj.AddParam("@mast_head", mast_head);



            int exe = obj.ExecuteNonQuery();

            if (exe > 0)
            {
                clear();
                string jv = "<script>alert('Record Added Successfully');</script>";
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", jv, false);
            }
        }
        catch { }
    }
示例#18
0
    private void UpdateBulletin(int id)
    {
        string path, mast_head = "";

        try
        {
            DBconnection obj = new DBconnection();
            obj.SetCommandSP = "z_UpdateBulletin";

            SaveImages img = new SaveImages();
            path      = img.AddImages(FileUpload1.PostedFile, "Bulletin");
            mast_head = img.AddImages(FileUpload2.PostedFile, "Bulletin");


            try
            {
                if (path == "")
                {
                    obj.AddParam("@bulletin", Session["Bulletin"].ToString());
                }
                else
                {
                    obj.AddParam("@bulletin", path);
                }
            }
            catch { obj.AddParam("@bulletin", ""); }

            try
            {
                if (mast_head == "")
                {
                    obj.AddParam("@mast_head", Session["MastHead"].ToString());
                }
                else
                {
                    obj.AddParam("@mast_head", mast_head);
                }
            }
            catch { obj.AddParam("@mast_head", ""); }

            obj.AddParam("@id", id);
            obj.AddParam("@title", txtTitle.Text.ToString());
            obj.AddParam("@frequency", rbtnFrequency.SelectedItem.Text.ToString());
            obj.AddParam("@status", DDLStatus.SelectedItem.Text.Trim().ToString());

            int i = int.Parse(rbtnFor.SelectedValue.ToString());
            if (i == 0)
            {
                obj.AddParam("@DistrictClubID", 0);
            }

            else
            {
                int cid = int.Parse(DDLClubName.SelectedValue.ToString());
                obj.AddParam("@DistrictClubID", cid);
            }



            int exe = obj.ExecuteNonQuery();

            if (exe > 0)
            {
                clear();

                showmsg("Record updated successfully !", "view_bulletin.aspx");
                //    string jv = "<script>alert('Record Added Successfully');</script>";
                //    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "alert", jv, false);
            }
        }
        catch { }
    }
示例#19
0
 public AsyncImagesRepository(SaveImages upload, bahia_estateContext context) : base(context)
 {
     this._upload  = upload;
     this._context = context;
 }
示例#20
0
        /// <summary>
        /// Set the desktop wallpaper.
        /// </summary>
        /// <param name="path">Path of the wallpaper</param>
        /// <param name="style">Wallpaper style</param>
        public static void SetDesktopWallpaper(string path, WallpaperStyle style)
        {
            // Set the wallpaper style and tile.
            // Two registry values are set in the Control Panel\Desktop key.
            // TileWallpaper
            //  0: The wallpaper picture should not be tiled
            //  1: The wallpaper picture should be tiled
            // WallpaperStyle
            //  0:  The image is centered if TileWallpaper=0 or tiled if TileWallpaper=1
            //  2:  The image is stretched to fill the screen
            //  6:  The image is resized to fit the screen while maintaining the aspect
            //      ratio. (Windows 7 and later)
            //  10: The image is resized and cropped to fill the screen while
            //      maintaining the aspect ratio. (Windows 7 and later)
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);

            switch (style)
            {
            case WallpaperStyle.Tile:
                key.SetValue(@"WallpaperStyle", "0");
                key.SetValue(@"TileWallpaper", "1");
                break;

            case WallpaperStyle.Center:
                key.SetValue(@"WallpaperStyle", "0");
                key.SetValue(@"TileWallpaper", "0");
                break;

            case WallpaperStyle.Stretch:
                key.SetValue(@"WallpaperStyle", "2");
                key.SetValue(@"TileWallpaper", "0");
                break;

            case WallpaperStyle.Fit:     // (Windows 7 and later)
                key.SetValue(@"WallpaperStyle", "6");
                key.SetValue(@"TileWallpaper", "0");
                break;

            default:
            case WallpaperStyle.Fill:     // (Windows 7 and later)
                key.SetValue(@"WallpaperStyle", "10");
                key.SetValue(@"TileWallpaper", "0");
                break;
            }

            key.Close();

            /// TODO Check if support for execotic file formats can be converted and
            /// works for Windows supported standard images, such as PSD to jpg?

            // If the specified image file is neither .bmp nor .jpg, - or -
            // if the image is a .jpg file but the operating system is Windows Server
            // 2003 or Windows XP/2000 that does not support .jpg as the desktop
            // wallpaper, convert the image file to .bmp and save it to the
            // %appdata%\Microsoft\Windows\Themes folder.
            string ext = Path.GetExtension(path);

            if ((!ext.Equals(".bmp", StringComparison.OrdinalIgnoreCase) &&
                 !ext.Equals(".jpg", StringComparison.OrdinalIgnoreCase))
                ||
                (ext.Equals(".jpg", StringComparison.OrdinalIgnoreCase) &&
                 !SupportJpgAsWallpaper))
            {
                var dest = string.Format(CultureInfo.CurrentCulture, @"{0}\Microsoft\Windows\Themes\{1}.jpg",
                                         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                         Path.GetFileNameWithoutExtension(path));
                SaveImages.TrySaveImage(Rotateint, Flipped, path, dest);
                path = dest;
            }

            // Set the desktop wallpapaer by calling the Win32 API SystemParametersInfo
            // with the SPI_SETDESKWALLPAPER desktop parameter. The changes should
            // persist, and also be immediately visible.
            if (!NativeMethods.SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, path,
                                                    SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE))
            {
                throw new Win32Exception();
            }
        }