public static void TakeOwnership() { HelperLib.TakeOwnership(Config.LogonFolder); HelperLib.TakeOwnership(Config.PriFileLocation); if (!File.Exists(Config.BakPriFileLocation)) { File.Copy(Config.PriFileLocation, Config.BakPriFileLocation); } HelperLib.TakeOwnership(Config.BakPriFileLocation); File.Copy(Config.BakPriFileLocation, TempPriFile, true); if (File.Exists(NewPriLocation)) { File.Delete(NewPriLocation); } }
public MainWindow() { InitializeComponent(); Debug.WriteLine("[User Picture]: " + Helpers.GetUserTilePath(null)); Settings.Init(Config.SettingsFilePath, new DesEncrpytion("W10Logon", "W10Logon")); var currentLang = CultureInfo.CurrentCulture.ToString().ToLower().Replace("-", "_"); if (!LanguageLibrary.Language.GetLangNames().ContainsValue(currentLang)) { currentLang = "en_us"; } Debug.WriteLine(currentLang); //default all strings to en-us LanguageLibrary.Language.Init(); LanguageLibrary.Language.Set(Settings.Default.Get("language", currentLang)); Debug.WriteLine((string)LanguageLibrary.Language.Default.title_error); if (!Settings.Default.Get("eula", false)) { var dlg = WpfMessageBox.Show( LanguageLibrary.Language.Default.EULA, LanguageLibrary.Language.Default.title_eula, MessageBoxButton.YesNo, MessageBoxImage.Question); if (dlg == MessageBoxResult.No) { Close(); } } if (Helpers.IsBackgroundDisabled()) { WpfMessageBox.Show(LanguageLibrary.Language.Default.background_disabled, LanguageLibrary.Language.Default.title_bg_disabled, MessageBoxButton.OK, MessageBoxImage.Information); } Debug.WriteLine( $"[AccentColor]: {ColorFunctions.GetImmersiveColor(ImmersiveColors.ImmersiveStartBackground)}"); Title += $" - {AssemblyInfo.Version}"; Settings.Default.Set("eula", true); Settings.Default.Save(); Debug.WriteLine("[EULA Test] {0}", Settings.Default.Get <bool>("eula")); ApplicationSettingsFlyout.Content = new SettingsMenuControl(this); SettingFlyout.Content = new BgEditorControl(this); SettingFlyout.IsOpen = true; AboutFlyout.Content = new AboutControl(this); HelperLib.TakeOwnership(Config.LogonFolder); HelperLib.TakeOwnership(Config.PriFileLocation); if (!File.Exists(Config.BakPriFileLocation)) { Debug.WriteLine("[Warning]: Could not find Windows.UI.Logon.pri.bak file. Creating new."); File.Copy(Config.PriFileLocation, Config.BakPriFileLocation); } HelperLib.TakeOwnership(Config.BakPriFileLocation); File.Copy(Config.BakPriFileLocation, _tempPriFile, true); if (File.Exists(Config.CurrentImageLocation)) { var temp = Path.GetTempFileName(); File.Copy(Config.CurrentImageLocation, temp, true); Settings.Default.Set("current.img", File.ReadAllBytes(temp)); Settings.Default.Save(); File.Delete(Config.CurrentImageLocation); } Loaded += (o, i) => { SettingFlyout.Position = Settings.Default.Get("flyout", Position.Right); GlyphsViewer.ToolTip = Settings.Default.Get("filename", "No File"); }; if (Settings.Default.Exist("current.img")) { var temp = Path.GetTempFileName(); File.WriteAllBytes(temp, Settings.Default.Get <byte[]>("current.img")); WallpaperViewer.Source = new BitmapImage(new Uri(temp)); } EditBackgroundLabel.Text = LanguageLibrary.Language.Default.main_top_edit; LockWindowsLabel.Text = LanguageLibrary.Language.Default.main_top_lock; AboutButton.Content = LanguageLibrary.Language.Default.main_top_about; SettingFlyout.Header = LanguageLibrary.Language.Default.flyout_edit_title; AboutFlyout.Header = LanguageLibrary.Language.Default.flyout_about_title; ApplicationSettingsFlyout.Header = LanguageLibrary.Language.Default.flyout_settings_title; settingsName.Text = LanguageLibrary.Language.Default.flyout_settings_title; #if !DEBUG UsernameFeild.Text = Environment.UserName; #endif UserDisplayPicture.Source = Image.FromFile(Helpers.GetUserTilePath(null)) .ResizeImage(new Size(300, 300)) .ToBitmapSource(); }