Пример #1
0
 public async void ApplyWallpaper(Wallpaper w)
 {
     WallpaperManager.VideoAspect = AppManager.Setting.Wallpaper.VideoAspect;
     WallpaperManager.Show(w);
     AppManager.AppData.Wallpaper = w.AbsolutePath;
     await AppManager.ApplyAppDataAsync();
 }
Пример #2
0
        /// <summary>
        /// Used to asyncronously download images.
        /// </summary>
        /// <param name="result">The search result to download</param>
        private void AddImageToCache(Wallpaper result)
        {
            try
            {
                string path0 = Settings.Instance.CacheDirectory + "\\" + result.id + Path.GetExtension(result.url_image);


                result.Image.Save(path0);
                Thread.Sleep(500);          //Needed because without it GDI+ may/will throw an exception.
                result.ClearCachedImages(); //Once saved clear the image to reduce memory.
                Settings.Instance.AddCachedResults(result, path0);

                //If nothing is being shown put it up there right away!
                if (this.BackgroundImage == null && Settings.Instance.CachedResults.Count > 0)
                {
                    int rand = ThreadSafeRandom.ThisThreadsRandom.Next(0, Settings.Instance.CachedResults.Count - 1);
                    SetImage(Settings.Instance.CachedResults[rand]);
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("MainForm.AddImageToCache: " + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }
Пример #3
0
        private static async Task PostRequestAsync()
        {
            WebRequest request = WebRequest.Create("https://api.tiktok.com/aweme/v1/data/insighs/?tz_offset=7200&aid=1233&carrier_region=RU");

            request.Method = "POST";
            string data = "type_requests=" + GET_CONTENT;

            byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(data);
            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Set(HttpRequestHeader.Cookie, COOKIE_STR);
            request.ContentLength = byteArray.Length;
            using (Stream dataStream = request.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }

            WebResponse response = await request.GetResponseAsync();

            using (Stream stream = response.GetResponseStream())
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    Root json = JsonConvert.DeserializeObject <Root>(reader.ReadToEnd());

                    Image img = DrawWall(json.user_info.follower_count, new Font(FontFamily.GenericSansSerif, 80, FontStyle.Bold), Color.White, Color.Black);
                    Wallpaper.Set(img, Wallpaper.Style.Centered);
                }
            }
            response.Close();
        }
Пример #4
0
 public FakeWallpaper(Wallpaper item)
 {
     isFloor          = item.isFloor;
     parentSheetIndex = item.parentSheetIndex;
     name             = isFloor ? "Flooring" : "Wallpaper";
     price            = 100;
 }
Пример #5
0
        public static bool CanReallyBePlacedHere(
            this Wallpaper wallpaper,
            DecoratableLocation location,
            Vector2 tileLocation)
        {
            int x = (int)tileLocation.X;
            int y = (int)tileLocation.Y;

            if (wallpaper.isFloor.Value)
            {
                List <Rectangle> floors = location.getFloors();
                for (int i = 0; i < floors.Count; i++)
                {
                    if (floors[i].Contains(x, y))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                List <Rectangle> walls = location.getWalls();
                for (int j = 0; j < walls.Count; j++)
                {
                    if (walls[j].Contains(x, y))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #6
0
        public void SetWallpaperTest()
        {
            Wallpaper wallpaper = new Wallpaper(new BingWallpaperGetter());

            wallpaper.SetWallpaper(Style.Fill);
            Assert.IsTrue(true);
        }
Пример #7
0
        private void Completed(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Cancelled == true)
            {
            }
            else
            {
                if (isCredit.Checked == true)
                {
                    string   new_destination = filePath + "/desktoper/" + textBox2.Text + "_credit" + ".jpg";;
                    Bitmap   bit             = (Bitmap)Image.FromFile(destination);
                    Graphics g = Graphics.FromImage(bit);


                    g.DrawString(txtOwnerName.Text, new Font("Segoe UI light", 20), Brushes.White, new PointF(0, 0));
                    bit.Save(new_destination);
                    Wallpaper.SetDesktopWallpaper(new_destination, SelectedWallpaperStyle);
                }
                else
                {
                    Wallpaper.SetDesktopWallpaper(destination, WallpaperStyle.Fill);
                }

                MetroMessageBox.Show(this, textBox2.Text + " has been set as your wallpaper !", "Congratulation ! ", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Пример #8
0
        public static void RefreshLocalWallpapers()
        {
            Wallpapers = new List <Wallpaper>();

            if (!SettingInitialized)
            {
                return;
            }

            try
            {
                if (!Directory.Exists(LocalWallpaperDir))
                {
                    Directory.CreateDirectory(LocalWallpaperDir);
                }

                var wallpapers = Wallpaper.GetWallpapers(LocalWallpaperDir);
                foreach (var item in wallpapers)
                {
                    Wallpapers.Add(item);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
Пример #9
0
        private static Dictionary <ISalable, int[]> GetAllWallpapersAndFloors()
        {
            Dictionary <ISalable, int[]> decors = new Dictionary <ISalable, int[]>();
            Wallpaper f;

            for (int i = 0; i < 112; i++)
            {
                f = new Wallpaper(i, false);
                decors.Add(new Wallpaper(i, false)
                {
                    Stack = int.MaxValue
                }, new int[]
                {
                    Config.FreeCatalogue  ? 0 : (int)Math.Round(f.salePrice() * Config.PriceMult),
                    int.MaxValue
                });
            }
            for (int j = 0; j < 56; j++)
            {
                f = new Wallpaper(j, false);
                decors.Add(new Wallpaper(j, true)
                {
                    Stack = int.MaxValue
                }, new int[]
                {
                    Config.FreeCatalogue  ? 0 : (int)Math.Round(f.salePrice() * Config.PriceMult),
                    int.MaxValue
                });
            }
            return(decors);
        }
Пример #10
0
        public void ExploreWallpaper(Wallpaper s)
        {
            var currentDir = Directory.GetCurrentDirectory();
            var target     = currentDir + s.PackInfo.Dir;

            Process.Start("Explorer.exe", target);
        }
Пример #11
0
 public FakeWallpaper(Wallpaper item)
 {
     this.isFloor.Value    = item.isFloor.Value;
     this.ParentSheetIndex = item.ParentSheetIndex;
     this.name             = this.isFloor.Value ? "Flooring" : "Wallpaper";
     this.Price            = 100;
 }
Пример #12
0
        public static void Start()
        {
            if (!Directory.Exists(Settings.DownloadPath))
            {
                return;
            }
            var wallpapers = Locales.Wallpapers;

            Wallpaper.ResetDownloadedInfo().Wait();
            try
            {
                foreach (var wallpaper in wallpapers)
                {
                    wallpaper.DownloadInfo().Wait();
                }
                foreach (var wallpaper in wallpapers)
                {
                    wallpaper.Download().Wait();
                }
            }
            catch (Exception ex)
                when(ex is WebException || (ex is AggregateException && ex.InnerException is WebException))
                {
                    return;
                }
        }
Пример #13
0
 public void SetCurrentWallpaper(string id)
 {
     if (_wallpapers.Any(x => x.ToString() == id))
     {
         this._current = _wallpapers.First(x => x.ToString() == id);
     }
 }
Пример #14
0
        private static void CambiarFondo() //payload 1.a -> cambiar fondo de pantalla desde uno interno en la app
        {
            string temp = Path.GetTempPath() + "fondo.jpg";

            Kenose.Properties.Resources.fondo.Save(temp); //guardar el fondo en una localización temporal
            Wallpaper.Set(temp, Wallpaper.Style.Stretch);
        }
Пример #15
0
        internal static async Task ShowWallpaper(Wallpaper w, params uint[] screenIndexs)
        {
            await WallpaperManager.Instance.ShowWallpaper(new WallpaperModel()
            {
                Path = w.AbsolutePath
            }, screenIndexs);

            if (AppData.Wallpapers == null)
            {
                AppData.Wallpapers = new List <DisplayWallpaper>();
            }

            foreach (var index in screenIndexs)
            {
                var exist = AppData.Wallpapers.FirstOrDefault(m => m.DisplayIndex == index);
                if (exist == null)
                {
                    exist = new DisplayWallpaper()
                    {
                        DisplayIndex = index, Path = w.AbsolutePath
                    };
                    AppData.Wallpapers.Add(exist);
                }
                exist.Path = w.AbsolutePath;
            }


            await ApplyAppDataAsync();
        }
Пример #16
0
        // Fonction qui réaffiche le fond d'écran initial
        public static void AncienFond()
        {
            try // On essaye de remettre le fond
            {
                if (File.Exists(cheminAncienFond))
                {
                    Wallpaper fond = new Wallpaper(cheminAncienFond, Func.ConvertirAffichage(ancienAffichage), ancienneCouleur);
                    fond.Afficher(false);
                }
                else
                {
                    Wallpaper fond = new Wallpaper(null, Func.ConvertirAffichage(ancienAffichage), ancienneCouleur);
                    fond.Afficher(false, true);

                    if (!string.IsNullOrEmpty(cheminAncienFond))
                    {
                        MessageBox.Show(Texte.AncienFondSupprimé, Texte.ErreurTitre, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
            catch (Exception e) // Si il y a eu une erreur, on l'affiche
            {
                MessageBox.Show(Texte.ErreurAncienFond + "\n\n" +
                                "DEBUG :\nFichier : " + cheminAncienFond + "\nMode : " + ancienAffichage + "\nCouleur :" + ancienneCouleur + "\n\n" + Texte.ErreurTitre + " :\n" + e
                                , Texte.ErreurTitre, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Пример #17
0
        public async Task UpdateWallpaper()
        {
            if (Settings.PauseWallpaperUpdate)
            {
                return;
            }

            MainWindow.log.Info("Updating wallpaper - starting...");
            Settings.CurrentDate = DateTime.Now;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if (Settings.SelectedMonthDays[(i * 7) + j].Date.ToString("MM/dd/yyyy") == Settings.CurrentDate.ToString("MM/dd/yyyy"))
                    {
                        CurrentDateCell.X = j + 1;
                        CurrentDateCell.Y = i + 1;
                    }
                }
            }

            await Task.Run(() => Wallpaper.CreateCalendar(Settings.DarkMode, Settings.CurrentDate,
                                                          CurrentDateCell, Settings.SelectedMonthDays.ToList(), Settings.HabitDays.ToList()));

            Wallpaper.Set(IOPath.Combine(AppDomain.CurrentDomain.BaseDirectory, "output.png"));
        }
 public void ApplyWallpaper(Wallpaper wallpaper)
 {
     if (IsForegroundFullScreen())
     {
         LoggerService.Instance.WriteLog("Full-screen app detected.");
         return;
     }
     if (_currentWallpaper != null && _currentWallpaper.Equals(wallpaper) &&
         _currentResolution == Screen.PrimaryScreen.Bounds.Size)
     {
         return;
     }
     _currentResolution = Screen.PrimaryScreen.Bounds.Size;
     if (!string.IsNullOrEmpty(wallpaper.ImagePath))
     {
         var originalPic = new Bitmap(wallpaper.ImagePath);
         var resizedPic  = ResizePicture(originalPic, wallpaper.ResizeMode);
         resizedPic.Save(Consts.TempWallpaperPath);
         SetWallpaper(Consts.TempWallpaperPath);
     }
     else
     {
         File.Create(Consts.TempWallpaperPath).Close();
         SetWallpaper(Consts.TempWallpaperPath);
     }
     SetWallcolor(wallpaper.WallColor);
     // Wallpaper is MUTABLE!!
     _currentWallpaper = (Wallpaper)wallpaper.Clone();
 }
Пример #19
0
        public static void wallpaper()
        {
            while (true)
            {
                int i2 = System.Convert.ToInt32(readFPS());


                // Change Wallpaper
                System.IO.DirectoryInfo di = new DirectoryInfo(f);
                int i3 = 0;
                foreach (FileInfo file in di.GetFiles())
                {
                    if (file.Name.Contains(".jpg"))
                    {
                        i3++;
                    }
                }


                for (int i = 1; i < i3; i++)
                {
                    Wallpaper.Set(new Uri(f + i + ".jpg"), Wallpaper.Style.Stretched);
                }
            }
        }
Пример #20
0
 public void Dispose()
 {
     ReflectionTexture.Clear();
     BgTexture.Clear();
     SkyTexture.Clear();
     Wallpaper.Clear();
 }
Пример #21
0
 public FakeWallpaper(Wallpaper item)
 {
     this.isFloor          = item.isFloor;
     this.parentSheetIndex = item.parentSheetIndex;
     this.name             = this.isFloor ? "Flooring" : "Wallpaper";
     this.price            = 100;
 }
Пример #22
0
        public static void Prefix_placement(Wallpaper __instance, GameLocation location, int x, int y, Farmer who = null)
        {
            if (skip || __instance is CustomWallpaper || !Game1.IsMasterGame)
            {
                return;
            }

            skip = true;

            if (who == null)
            {
                who = Game1.player;
            }
            if (who.currentLocation is DecoratableLocation dec)
            {
                if (__instance.isFloor.Value)
                {
                    CustomWallpaper.floorReset = (r, w) => CustomWallpaper.Floor_OnChange1(r, w, dec);
                    dec.floor.OnChange        += CustomWallpaper.floorReset;
                }
                else
                {
                    CustomWallpaper.wallReset = (r, w) => CustomWallpaper.WallPaper_OnChange1(r, w, dec);
                    dec.wallPaper.OnChange   += CustomWallpaper.wallReset;
                }

                __instance.placementAction(location, x, y, who);
            }
            PyTK.PyUtils.setDelayedAction(500, () => skip = false);
        }
Пример #23
0
        public override RewardsDTO Edit_Wall(int id)
        {
            using (var context = new PHCEntities())
            {
                try
                {
                    RewardsDTO dto = new RewardsDTO();

                    Wallpaper wall = new Wallpaper();
                    wall = context.Wallpapers.Where(p => p.WID == id).SingleOrDefault();
                    if (wall != null)
                    {
                        dto.WID       = wall.WID;
                        dto.Title     = wall.Title;
                        dto.WallImage = wall.WallImage;
                    }

                    return(dto);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Пример #24
0
        public override string Update_Wall(RewardsDTO dto)
        {
            string msg = "";

            using (var context = new PHCEntities())
            {
                try
                {
                    Wallpaper wall = new Wallpaper();
                    wall = context.Wallpapers.Where(p => p.WID == dto.WID).SingleOrDefault();
                    if (wall != null)
                    {
                        wall.Title     = dto.Title;
                        wall.WallImage = dto.WallImage;
                        context.SaveChanges();
                        msg = "success";
                    }
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }
            }
            return(msg);
        }
Пример #25
0
        public void IncreaseToViewCount(Wallpaper wallpaper)
        {
            wallpaper.ViewCount = wallpaper.ViewCount + 1;

            _unitOfWork.WallpaperRepository.Update(wallpaper);
            _unitOfWork.Save();
        }
Пример #26
0
        protected override void OnShown(EventArgs e)
        {
            ScaledScreen windowScreen = ScaledScreen.AllScaledScreens[0];

            // if mode = top-right
            // Left = windowScreen.UnscaledBounds.Width - Width; //Size.Width;
            // Top = 0;

            // if mode = bottom-right
            //Left = windowScreen.UnscaledWorkingArea.Width - Width; //Size.Width;
            //Top = windowScreen.UnscaledWorkingArea.Height - Height;

            // position this window to legenda position
            Rectangle legendaRect = Wallpaper.GetLegendaRect(_photoDesktop.GetMainScreenName());

            this.Left = legendaRect.Left + offset.X;
            this.Top  = legendaRect.Top - this.Height + offset.Y;


            base.OnShown(e);

            //Width = 400;
            //Height = 100;
            //Left = windowScreen.UnscaledWorkingArea.Width - Width; //Size.Width;
            //Top = windowScreen.UnscaledWorkingArea.Height - Height;

            // if debug mode; show settings
#if DEBUG
            SettingsForm settingsForm = new SettingsForm(_photoDesktop);
            if (settingsForm.ShowDialog() == DialogResult.OK)
            {
                LoadSettings(settingsForm.RefreshImageList);
            }
#endif
        }
Пример #27
0
        private void button3_Click(object sender, EventArgs e)
        {
            string ssid;

            using (var f = new AddEntryDialog())
            {
                f.ShowDialog();
                ssid = f.SelectedSsid;
            }

            if (!string.IsNullOrEmpty(ssid))
            {
                if (_wpCollection.ContainsSsid(ssid))
                {
                    MessageBox.Show(Properties.Resources.Already_registered_, Properties.Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                var wp = new Wallpaper();
                wp.Ssid       = ssid;
                wp.WallColor  = Color.Black;
                wp.ResizeMode = Models.ResizeMode.Original;
                _wpCollection.Add(wp);
                _wallpaperVms.Add(new WallpaperViewModel(wp));
            }
        }
Пример #28
0
        public void AddWallpaper(string path)
        {
            if (!File.Exists(path))
            {
                return;
            }
            if (collection.Count >= MAX_COLLECTION_SIZE)
            {
                throw new CollectionLimitExceededException();
            }
            if (new FileInfo(path).Length > MAX_FILE_SIZE)
            {
                throw new WallpaperSizeException();
            }
            var wallpaper = new Wallpaper()
            {
                Name  = Path.GetFileName(path),
                Image = ImageFileHelper.ReadFile(path)
            };

            var created = wallpaperDAO.Create(wallpaper);

            if (created)
            {
                RefreshItems();

                if (collection.Count == 1)
                {
                    ResetTimer();
                    PaintWallpaper();
                }
            }
        }
Пример #29
0
 /// <summary>
 /// Download the actual wallpaper image file
 /// </summary>
 /// <param name="wallpaper">The wallpaper object</param>
 private static void DownloadPhoto(Wallpaper wallpaper)
 {
     using (var client = new WebClient())
     {
         client.DownloadFile(wallpaper.RemoteLocation, wallpaper.LocalLocation);
     }
 }
Пример #30
0
        public async Task <(Int32 wapperId, String url)> AddWallpaperAsync(Wallpaper wallpaper)
        {
            Check.IfNullOrZero(wallpaper);
            return(await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    try
                    {
                        #region 前置条件验证
                        {
                            var result = mapper.Query <Wallpaper>().Where(w => w.UserId == wallpaper.UserId).Count();
                            if (result > 6)
                            {
                                throw new BusinessException("最多只能上传6张图片");
                            }
                        }
                        #endregion

                        #region 插入壁纸
                        {
                            wallpaper = mapper.Add(wallpaper);
                            return (wallpaper.Id, wallpaper.Url);
                        }
                        #endregion
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }));
        }
Пример #31
0
        private void MakeBackground(string saveName, bool imageTooBig)
        {
            Wallpaper w = new Wallpaper();
            WallpaperStyle style;

            if (userSettings.Style == WallpaperStyle.Centered || userSettings.Style == WallpaperStyle.Stretched || userSettings.Style == WallpaperStyle.Tiled)
            {
                style = userSettings.Style;
            }
            else if (imageTooBig)
            {
                style = WallpaperStyle.Stretched;
            }
            else
            {
                style = WallpaperStyle.Centered;
            }

            w.Set(new Uri(saveName), style);

            UpdateConsole("Background updated!");
        }
 public ScreenConfigurationViewModel(Wallpaper.ScreenConfiguration config)
 {
     ScreenConfig = config;
 }
Пример #33
0
    private void Set_Wallpaper(object sender, RoutedEventArgs e) {
      Wallpaper.Style ThisStyle;

      if (sender == btnWallpaper)
        ThisStyle = Wallpaper.Style.Stretched;
      else if (sender == miWallFill)
        ThisStyle = Wallpaper.Style.Fill;
      else if (sender == miWallFit)
        ThisStyle = Wallpaper.Style.Fit;
      else if (sender == miWallStretch)
        ThisStyle = Wallpaper.Style.Stretched;
      else if (sender == miWallTile)
        ThisStyle = Wallpaper.Style.Tiled;
      else if (sender == miWallCenter)
        ThisStyle = Wallpaper.Style.Centered;
      else
        throw new Exception("Invalid Sender");

      Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)(() => {
        Wallpaper TheWall = new Wallpaper();
        TheWall.Set(new Uri(_ShellListView.GetFirstSelectedItem().ParsingName), ThisStyle);
      }));
    }