void FinalizeAndLaunch(object sender, EventArgs e) { #region Replace w/ settings file RegistryKey iSettings = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\eKasa"); iSettings.SetValue("install_path", InstallPath); iSettings.Close(); #endregion Dispatcher.Invoke(() => { #region Shortcuts if ((bool)MainWindow.ucoptions.scDesktop.IsChecked) { var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); WinShortcut.Create($"{desktopPath}\\eKasa.lnk", $"{InstallPath}\\App\\eKasa.exe", "", InstallPath, "eKasa. Şifre yöneticiniz", "", ""); } if ((bool)MainWindow.ucoptions.scStart.IsChecked) { var startmenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); WinShortcut.Create($"{startmenuPath}\\eKasa.lnk", $"{InstallPath}\\App\\eKasa.exe", "", startmenuPath, "eKasa. Şifre yöneticiniz", "", ""); } if ((bool)MainWindow.ucoptions.launchAtStartup.IsChecked) { var startupPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup); WinShortcut.Create($"{startupPath}\\eKasa.lnk", $"{InstallPath}\\App\\eKasa.exe", "", startupPath, "eKasa. Şifre yöneticiniz", "", ""); } #endregion #region Colors and Actions var canvas = (Canvas)Parent; var grid = (Grid)canvas.Parent; var window = (MainWindow)grid.Parent; window.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 120, 215)); window.topBar.Fill = new SolidColorBrush(Color.FromRgb(0, 120, 215)); window.topBar.Stroke = new SolidColorBrush(Color.FromRgb(0, 120, 215)); window.next.Content = "ÇIK"; window.next.IsEnabled = true; window.next.Foreground = new SolidColorBrush(Color.FromRgb(0, 120, 215)); window.next.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 120, 215)); window.next.Click += Terminate; window.back.Visibility = Visibility.Hidden; window.terminate.Visibility = Visibility.Hidden; #endregion canvas.Children.Clear(); canvas.Children.Add(MainWindow.uclaunch); }); }
public void WinShortcut_FileCorrectlyParsed() { var basePath = Path.GetFullPath(@".\test files"); // { location, target path, is direstory, hotkey } var shortcuts = new List <Tuple <string, string, bool, string> > { Tuple.Create(Path.Combine(basePath, "file.lnk"), Path.Combine(basePath, @"Program Files\Corporation Name\App.exe"), false, ""), Tuple.Create(Path.Combine(basePath, "file with hotkey.lnk"), Path.Combine(basePath, @"Program Files\Utility.exe"), false, "ctrl+alt+a"), Tuple.Create(Path.Combine(basePath, "directory.lnk"), Path.Combine(basePath, @"娱乐\电影"), true, ""), Tuple.Create(Path.Combine(basePath, "directory with hotkey.lnk"), Path.Combine(basePath, @"娱乐\音乐"), true, "ctrl+alt+b"), Tuple.Create(Path.Combine(basePath, "directory with hotkey 1.lnk"), Path.Combine(basePath, @"娱乐\游戏"), true, "ctrl+shift+c") }; if (Directory.Exists(basePath)) { Directory.Delete(basePath, true); } Directory.CreateDirectory(basePath); foreach (var i in shortcuts) { if (i.Item3) { Directory.CreateDirectory(i.Item2); } else { var dir = Path.GetDirectoryName(i.Item2); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } System.IO.File.Create(i.Item2); } CreateShortcut(i.Item1, i.Item2, i.Item4); } foreach (var i in shortcuts) { var shortcut = new WinShortcut(i.Item1); Assert.AreEqual(shortcut.HotKey.ToLower(), i.Item4.ToLower(), "the hotkey isn't parsed correctly"); Assert.AreEqual(shortcut.IsDirectory, i.Item3, "the isdirectory isn't parsed correctly"); Assert.AreEqual(shortcut.TargetPath.ToLower(), i.Item2.ToLower(), "the target path isn't parsed correctly"); } }