Пример #1
0
        private static void ChangeImage(string filedir)
        {
            File.Copy(Config.BakPriFileLocation, TempPriFile, true);

            LogonPriEditor.ModifyLogonPri(TempPriFile, NewPriLocation, filedir);

            File.Copy(NewPriLocation, Config.PriFileLocation, true);
        }
Пример #2
0
        public void ApplyChanges()
        {
            //Lets just delete the old one maybe this was getting bugged?
            if (File.Exists(_newPriLocation))
            {
                File.Delete(_newPriLocation);
            }

            //File.Copy(SelectedFile, Config.CurrentImageLocation, true);

            Settings.Default.Set("current.img", File.ReadAllBytes(SelectedFile));
            Settings.Default.Save();

            File.Copy(Config.BakPriFileLocation, _tempPriFile, true);

            var imagetemp = Path.GetTempFileName();
            //ResizeImage(Image.FromFile(SelectedFile), 1920, 1080).Save(imagetemp, ImageFormat.Png);

            var img = PixelateImage(new Bitmap(Image.FromFile(SelectedFile)), (int)SystemParameters.PrimaryScreenWidth,
                                    (int)SystemParameters.PrimaryScreenHeight, BgEditorControl.Pixelate);

            if (img != null)
            {
                img.Save(imagetemp, ImageFormat.Png);
                SelectedFile = imagetemp;
            }

            switch (BgEditorControl.Scaling)
            {
            case 0:
                ResizeImage(Image.FromFile(SelectedFile), 1280, 720).Save(imagetemp, ImageFormat.Png);
                break;

            case 1:
                ResizeImage(Image.FromFile(SelectedFile), 1920, 1080).Save(imagetemp, ImageFormat.Png);
                break;

            case 2:
                ResizeImage(Image.FromFile(SelectedFile), 3840, 2160).Save(imagetemp, ImageFormat.Png);
                break;

            case 3:
                ResizeImage(Image.FromFile(SelectedFile), (int)SystemParameters.PrimaryScreenWidth,
                            (int)SystemParameters.PrimaryScreenHeight).Save(imagetemp, ImageFormat.Png);
                break;

            case 4:
                imagetemp = SelectedFile;
                break;
            }



            LogonPriEditor.ModifyLogonPri(_tempPriFile, _newPriLocation, imagetemp);

            File.Copy(_newPriLocation, Config.PriFileLocation, true);
        }
Пример #3
0
        private static void ChangeColor(Color c)
        {
            var image = FillImageColor(c);

            File.Copy(Config.BakPriFileLocation, TempPriFile, true);

            LogonPriEditor.ModifyLogonPri(TempPriFile, NewPriLocation, image);

            File.Copy(NewPriLocation, Config.PriFileLocation, true);
        }
        public static void ChangeColor(string hexColorCode)
        {
            var convertFromString = new ColorConverter().ConvertFromString(hexColorCode);

            if (convertFromString != null)
            {
                var color     = (Color)convertFromString;
                var imagePath = Path.GetTempFileName();
                DrawFilledRectangle(3840, 2160, new SolidBrush(color)).Save(imagePath, ImageFormat.Jpeg);
                File.Copy(Config.BakPriFileLocation, TempPriFile, true);
                LogonPriEditor.ModifyLogonPri(TempPriFile, NewPriLocation, imagePath);
            }
            File.Copy(NewPriLocation, Config.PriFileLocation, true);
        }
Пример #5
0
        /// <summary>
        /// Updates the system PRI file with the new image
        /// </summary>
        /// <param name="resourceFileName">Path to new image</param>
        private static void UpdatePri(string resourceFileName)
        {
            TakeOwnershipPri();

            if (File.Exists(Config.NewPriPath))
            {
                File.Delete(Config.NewPriPath);
            }

            LogonPriEditor.ModifyLogonPri(Config.TempPriPath, Config.NewPriPath, resourceFileName);
            File.Copy(Config.NewPriPath, Config.PriFileLocation, true);

            Logger.WriteInformation("Wallpaper Set!", true);
        }
        public void SelectImageEvent_Clicked(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog
            {
                Filter      = "Image Files|*.png;*.jpg;*.jpeg;*.bmp;*.tif;*.tiff",
                Title       = LanguageLibrary.Language.Default.title_select_image,
                Multiselect = false
            };

            var initialDirectory = Settings.Default.Get("last_folder", string.Empty);

            if (!string.IsNullOrEmpty(initialDirectory))
            {
                if (Directory.Exists(initialDirectory))
                {
                    ofd.InitialDirectory = initialDirectory;
                }
            }

            var dialog = ofd.ShowDialog();

            if (dialog != true)
            {
                return;
            }
            var fileName = ofd.FileName;

            if (!File.Exists(fileName))
            {
                WpfMessageBox.Show($"'{fileName}' does not exist!",
                                   LanguageLibrary.Language.Default.title_error, MessageBoxButton.OK, MessageBoxImage.Error);

                return;
            }

            Settings.Default.Set("last_folder", Path.GetDirectoryName(ofd.FileName));
            var extension = Path.GetExtension(fileName);

            if (extension != null)
            {
                var ext = extension.ToLower();
                if (ext != ".png" || ext != ".jpg" || ext != ".jpeg")
                {
                    var temp = Path.GetTempFileName();
                    Image.FromFile(fileName).Save(temp, ImageFormat.Png);
                    fileName = temp;
                }
            }

            SelectedFile.Text = ofd.SafeFileName;
            //ColorPreview.Background = _orgColor;

            /*var c = ((SolidColorBrush)ColorPreview.Background).Color;
             * var color = Color.FromArgb(c.R, c.G, c.B);
             * pickColor.Foreground = new SolidColorBrush(Helpers.ContrastColor(color).ToMediaColor());
             */
            SolidColorPicker.SelectedColor = _orgColor;
            _mainWindow.SelectedFile       = fileName;

            Settings.Default.Set("dcolor", System.Drawing.Color.FromArgb(_orgColor.R, _orgColor.G, _orgColor.B));
            Settings.Default.Set("filename", ofd.FileName);
            Settings.Default.Save();
            _mainWindow.GlyphsViewer.ToolTip = ofd.FileName;

            var t = Path.GetTempFileName();
            var f = Path.GetTempFileName();

            File.Copy(Config.BakPriFileLocation, f, true);
            LogonPriEditor.ModifyLogonPri(f, t, ofd.FileName);

            var loadedMeta = SharedHelpers.GetFileSize(ofd.FileName);

            ActualFileSizeTp.Text = loadedMeta.ActualFileSizeHuman;
            LoadedFileSizeTp.Text = loadedMeta.LoadedFileSizeHuman;
            PriFileSizeTp.Text    = SharedHelpers.GetFileSize(t).ActualFileSizeHuman;

            File.Delete(t);
            File.Delete(f);
        }