public static void UpdateExecPath() { using (var adapter = new TaskSchedulerWrapper()) { if (adapter.CheckExecPathIsCorrect()) { return; } if (adapter.CheckTaskExists()) { if (UacHelper.IsRunningAsAdmin() == false) { // we can do nothing if the app is not started in admin mode return; } adapter.DeleteTaskIfNeeded(); adapter.CreateTask(); } else { ShortcutHelper.CreateStartupShortcut(); } } }
private void applyCommand_action(object obj) { string msg = "更新失败!请尝试重启程序或删除配置文件Config.xml!"; if (config.Save()) { msg = "选项已成功更新"; //处理开机启动 if (!ShortcutHelper.SetStartup(config.options.General.Startup)) { msg = "选项已成功更新。但是开机启动选项可能未生效。"; } //处理离开监听开关 if (config.options.General.LeaveListener) { mainService.OpenLeaveListener(); } else { mainService.CloseLeaveListener(); } //处理休息间隔调整 mainService.SetWarnTime(config.options.General.WarnTime); //处理主题切换 theme.SetTheme(config.options.Style.Theme.ThemeName); } MessageBox.Show(msg, "提示"); }
void Start() { string shortcut = (PickShortcut != null ? PickShortcut : "Control+MiddleClick"); LOGGER.debug("Using pick shortcut: {0}", shortcut); partPickerShortcut = ShortcutHelper.CompileShortcut(shortcut); }
public OpenFolderRoot GetFavorites() { OpenFolderRoot root = new OpenFolderRoot(); root.Name = "Favorites"; root.Image = FileInfoHelper.GetFavoritesImage(false); root.Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Links"); if (Directory.Exists(root.Path)) { List <OpenFolderItem> items = new List <OpenFolderItem>(); foreach (string file in Directory.GetFiles(root.Path)) { if (ShortcutHelper.IsShortcut(file)) { OpenFolderItem item = new OpenFolderItem(); string resolved = ShortcutHelper.ResolveShortcut(file); item.Path = resolved; item.Name = Path.GetFileNameWithoutExtension(file); item.Image = FileInfoHelper.GetImage(file, false); items.Add(item); } } root.Children = items; } return(root); }
private void CheckWritebacksVerifyValues(bool isRegMode, RegistryHelper reg, ShortcutHelper shortcut, OpenTarget target, Tabs tabs, SliderMeta.ExpectedPosition sliderExpected, bool checkboxValue, Tabs.GlobalState consoleVersion) { foreach (TabBase tab in tabs.AllTabs) { CheckWritebacksVerifyValues(isRegMode, reg, shortcut, target, tab, sliderExpected, checkboxValue, consoleVersion); } }
bool isPartSelectionClick() { // NOTE We're checking for "down" state so that we process the click/press sooner than EditorLogic // (and our popup is supposed to block "up" state so that it doesn't go to the EditorLogic). return(editorLogic.editorScreen == EditorLogic.EditorScreen.Parts && editorLogic.PartSelected == null && editorLogic.state != EditorLogic.EditorState.PAD_SELECTED && !editorLogic.mouseOverGUI && ShortcutHelper.IsMatch(partPickerShortcut, MainKeyState.DOWN)); }
private void createShortcutSelectedProg() { if (progsListView.SelectedItems.Count == 1) { Prog prog = progList.Get(Int32.Parse(progsListView.SelectedItems[0].Name)); ShortcutHelper.CreateShortcut(prog); } }
private void btnSetClient_Click(object sender, EventArgs e) { var file = Path.Combine(Environment.CurrentDirectory, "UploadClient.exe"); var shortcut = _lnkList[0]; MessageBox.Show(ShortcutHelper.CreateShortcut(shortcut, file, "", Path.GetDirectoryName(file), "") ? @"客户端设置成功!" : @"客户端设置失败!"); }
private static DirInfo GetAllDirInfo(string srcPath, DirInfo info) { DirInfo inf = info; // Get the subdirectories for the specified directory. var directories = new List <string>(Directory.GetDirectories(srcPath)); //inf.totalDirs += directories.Count(); var files = Directory.EnumerateFiles(srcPath); foreach (var file in files) { FileInfo currentFile = new FileInfo(file); if (currentFile.Extension == @".lnk") { // Change the current file info to the linked target file currentFile = new FileInfo(ShortcutHelper.ResolveShortcut(file)); // Check to see if file is a directory if (currentFile.Extension == String.Empty) { MessageBox.Show(String.Format("File {0} is a linked directory", file)); if (true) { string path = ShortcutHelper.ResolveShortcut(file); directories.Add(path); continue; } } if (!currentFile.Exists) { // This file had a bad or missing target link // MessageBox.Show(String.Format("File {0} does not exist", currentFile.FullName)); info.badLinks.Add(file); //info.totalFiles++; // Count it anyway continue; } } info.totalFiles++; info.totalBytes += (long)currentFile.Length; } // Now do the subdirectories if (!info.dirOpts.HasFlag(Options.TopDirectoryOnly)) { inf.totalDirs += directories.Count(); foreach (string path in directories) { //inf.totalFiles = countAllFiles(path, inf.totalFiles); inf = GetAllDirInfo(path, inf); } } return(inf); }
private void inkCommand_action(object obj) { string msg = "创建桌面快捷方式失败!"; if (ShortcutHelper.CreateDesktopShortcut()) { msg = "创建桌面快捷方式成功!"; } MessageBox.Show(msg, "提示"); }
private void inkCommand_action(object obj) { string msg = $"{Application.Current.Resources["Lang_Failed"]}"; if (ShortcutHelper.CreateDesktopShortcut()) { msg = $"{Application.Current.Resources["Lang_Success"]}"; } Modal(msg); }
private void InitShortcuts() { string mainNick = TbNickHelper.GetWwMainNickFromPubOrPrvDbAccount(_dbAccount); var ses = ShortcutHelper.GetShopShortcuts(mainNick); foreach (var et in ses) { AddOrUpdateInputPromptWordCite(et); } }
void Init() { var listViewShortcuts = (IModelListViewShortcuts)Application.Model.Options; filterShortcut = ShortcutHelper.ParseBarShortcut(listViewShortcuts.FilterShortcut); groupShortcut = ShortcutHelper.ParseBarShortcut(listViewShortcuts.GroupShortcut); sortShortcut = ShortcutHelper.ParseBarShortcut(listViewShortcuts.SortShortcut); navigateBackShortcut = ShortcutHelper.ParseBarShortcut(listViewShortcuts.NavigateBackShortcut); navigateForwardShortcut = ShortcutHelper.ParseBarShortcut(listViewShortcuts.NavigateForwardShortcut); }
private static void _AddToAutostart() { if (UacHelper.IsRunningAsAdmin()) { ShortcutHelper.DeleteStartupShortcut(); } else { ShortcutHelper.CreateStartupShortcut(); } }
public ShortcutThemeDialog(Settings settings) { _settings = settings; _helper = new ShortcutHelper(); InitializeComponent(); InitializeLabels(); InitializeThemes(); themes.ListViewItemSorter = this; }
public static bool IsSetAsAutoStartup() { using (var adapter = new TaskSchedulerWrapper()) { if (adapter.CheckExecPathIsCorrect()) { return(true); } } return(ShortcutHelper.IsSetAsAutoStartup()); }
public void DeleteShortcuts() { try { List <string> stringList = new List <string>(); stringList.AddRange((IEnumerable <string>)Directory.GetFiles(ShortcutHelper.sDesktopPath, "*.lnk", SearchOption.AllDirectories)); stringList.AddRange((IEnumerable <string>)Directory.GetFiles(ShortcutHelper.CommonStartMenuPath, "*.lnk", SearchOption.AllDirectories)); if (Oem.Instance.IsCreateDesktopIconForApp) { foreach (string str in stringList) { try { if (Utils.IsTargetForShortcut(str, "HD-RunApp.exe")) { File.Delete(str); } } catch (Exception ex) { Logger.Warning("Could not delete app shortcut, err: {0}", (object)ex.Message); } } } if (!Oem.Instance.CreateDesktopIcons) { return; } foreach (string vmDisplayName in UninstallerProperties.VmDisplayNameList) { try { ShortcutHelper.DeleteDesktopShortcut(vmDisplayName); } catch (Exception ex) { } } ShortcutHelper.DeleteCommonDesktopShortcut(Oem.Instance.DesktopShortcutFileName); string shortcutFileName = Oem.Instance.DesktopShortcutFileName; if (!string.IsNullOrEmpty(shortcutFileName)) { ShortcutHelper.DeleteCommonStartMenuShortcut(shortcutFileName); } ShortcutHelper.DeleteCommonDesktopShortcut(Oem.Instance.MultiInstanceManagerShortcutFileName); ShortcutHelper.DeleteCommonStartMenuShortcut(Oem.Instance.MultiInstanceManagerShortcutFileName); } catch (Exception ex) { Logger.Error(ex.ToString()); } }
private static void _RemoveFromAutostart() { // remove shortcut if needed ShortcutHelper.DeleteStartupShortcut(); // Try to remove the task from the task scheduler if needed. // This is only possible if admin rights are present. Otherwise an exception // will be thrown which is catched in the settingsview model. using (var adapter = new TaskSchedulerWrapper()) { adapter.DeleteTaskIfNeeded(); } }
public override bool ProcessKey(KeyEvent kb) { switch (ShortcutHelper.GetModifiersKey(kb)) { case Key.Enter: CommandEntered?.Invoke(this, Text.ToString()); Text = string.Empty; return(true); default: return(base.ProcessKey(kb)); } }
private async Task DirectoryCopy(string srcPath, string dstPath) { var dirs = Directory.EnumerateDirectories(srcPath); var files = Directory.EnumerateFiles(srcPath); // Does not process linked subdirectories yet! foreach (string filename in files) { string path = filename; if (chkBoxDereferenceLinks.Checked && ShortcutHelper.IsShortcut(filename)) { path = ShortcutHelper.ResolveShortcut(filename); if (!File.Exists(path)) // Ignore bad link { continue; } } using (FileStream SourceStream = File.Open(path, FileMode.Open)) { using (FileStream DestinationStream = File.Create(dstPath + path.Substring(path.LastIndexOf('\\')))) { await SourceStream.CopyToAsync(DestinationStream); fileCount++; } } } // Now copy the subdirectories recursively foreach (string path in dirs) { string dirName = path.Substring(path.LastIndexOf('\\')); string fullDirName = dstPath + dirName; // string tmpPath = Path.Combine(dstPath, path.Substring(path.LastIndexOf('\\'))); // If the subdirectory doesn't exist, create it. if (!Directory.Exists(fullDirName)) { Directory.CreateDirectory(fullDirName); } await DirectoryCopy(path, fullDirName); } }
private void SaveFileDialogSettings_FileOk(object sender, CancelEventArgs e) { if (Path.GetExtension(saveFileDialogSettings.FileName).ToLower() == ".lnk") { var file = saveFileDialogSettings.FileName; var settings = Path.ChangeExtension(file, "json"); ShortcutHelper.CreateShortcut(Program.Assembly.Location, Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file), null, $"/settings {settings}", Path.GetDirectoryName(Program.Assembly.Location)); Program.SaveToFile(settings, Model); } else { Program.SaveToFile(saveFileDialogSettings.FileName, Model); } }
/// <summary> /// 载入Icon /// </summary> public void LoadIcon() { var iconPath = ShortcutHelper.GetShortcutIconPath(FullPath, out var iconId); if (string.IsNullOrWhiteSpace(iconPath)) { //targetPath对应icon iconPath = TargetPath; } BitmapSource logo; if (iconPath.EndsWith(".exe", StringComparison.CurrentCultureIgnoreCase) || iconPath.EndsWith(".dll", StringComparison.CurrentCultureIgnoreCase)) { try { var tmp = Helper.GetLargeIconsFromExeFile(iconPath, iconId); if (tmp != null) { logo = tmp.ToBitmap().ToBitmapSource(); Helper.DestroyIcon(tmp.Handle); tmp.Dispose(); } else { logo = Unknown; } } catch { //catch(NotImplementedException) { logo = Unknown; } } else { //ico try { var ico = new Icon(iconPath); logo = ico.ToBitmap().ToBitmapSource(); ico.Dispose(); } catch { //catch (NotImplementedException) { logo = Unknown; } } Logo = logo; }
private void btnSave_Click(object sender, EventArgs e) { loader.SaveConfig(); MessageBoxHelper.Show("±£´æÅäÖóɹ¦£¡"); if (this.checkAutoStart.Checked) { ShortcutHelper.CreateStartUpShortcut(); //RegisterHelper.SetAutoStart("PhotoMonitor_Drv"); } else { ShortcutHelper.DeleteStartUpShortcut(); //RegisterHelper.ClearAutoStart("PhotoMonitor_Drv"); } }
public RpApplicationCore(IConfig config, IRpApiHandler apiHandler, IToastHandler toastHandler, Foobar2000Watcher foobar2000Watcher, MusicBeeWatcher musicBeeWatcher, ISongInfoListener songInfoListener, ILog log, RpTrayIcon rpTrayIcon, ShortcutHelper shortcutHelper) { _log = log; _apihandler = apiHandler; _config = config; _toastHandler = toastHandler; _songInfoListener = songInfoListener; _foobar2000Watcher = foobar2000Watcher; _musicBeeWatcher = musicBeeWatcher; _rpTrayIcon = rpTrayIcon; _shortcutHelper = shortcutHelper; EventCounter = 0; Init(); }
private void Init_CreateShortcuts() { ShortcutUnit[] shortcutList = new ShortcutUnit[] { new ShortcutUnit(AppSetting.Shortcut_Desktop, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description), new ShortcutUnit(AppSetting.Shortcut_SendTo, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description), new ShortcutUnit(AppSetting.Shortcut_StartMenu, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description), new ShortcutUnit(AppSetting.Shortcut_NetworkShortcuts, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description), new ShortcutUnit(AppSetting.Shortcut_Links, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description), }; foreach (ShortcutUnit scu in shortcutList) { if (!File.Exists(scu.LinkName)) { ShortcutHelper.CreateShortcut(scu); } } }
private void CheckWritebacksVerifyValues(bool isRegMode, RegistryHelper reg, ShortcutHelper shortcut, OpenTarget target, TabBase tab, SliderMeta.ExpectedPosition sliderExpected, bool checkboxValue, Tabs.GlobalState consoleVersion) { if (isRegMode) { VerifyBoxes(tab, reg, checkboxValue, target, consoleVersion); VerifySliders(tab, reg, sliderExpected, target, consoleVersion); } else { // Have to wait for shortcut to get written. // There isn't really an event to know when this occurs, so just wait. Globals.WaitForTimeout(); VerifyBoxes(tab, shortcut, checkboxValue, consoleVersion); VerifySliders(tab, shortcut, sliderExpected, consoleVersion); } }
private void VerifySliders(TabBase tab, ShortcutHelper shortcut, SliderMeta.ExpectedPosition expected, Tabs.GlobalState consoleVersion) { IEnumerable <SliderMeta> sliders = tab.GetSlidersForVerification(); // collect up properties that we need to retrieve keys for IEnumerable <SliderMeta> propSliders = sliders.Where(slider => slider.PropKey != null); IEnumerable <Wtypes.PROPERTYKEY> keys = propSliders.Select(slider => slider.PropKey).Cast <Wtypes.PROPERTYKEY>(); // fetch data for keys IDictionary <Wtypes.PROPERTYKEY, object> propertyData = shortcut.GetFromPropertyStore(keys); // enumerate each slider and validate data foreach (SliderMeta meta in sliders) { string sliderName = AutoHelpers.FormatInvariant("Slider: {0}", meta.ValueName); Wtypes.PROPERTYKEY key = (Wtypes.PROPERTYKEY)meta.PropKey; short value = (short)propertyData[key]; int transparency = 0; switch (expected) { case SliderMeta.ExpectedPosition.Maximum: transparency = meta.GetMaximum(); break; case SliderMeta.ExpectedPosition.Minimum: transparency = meta.GetMinimum(); break; default: throw new NotImplementedException(); } if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property) { AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName); } else { Verify.AreEqual(value, RescaleSlider(transparency), sliderName); } } }
public override bool Run() { if (!CanRun) { return(true); } this.CommandStatus = CommandStatus.Running; Watch?.SetStep("创建快捷方式"); if (!Directory.Exists(iconDir)) { Directory.CreateDirectory(iconDir); this.createIconDir = true; } foreach (var shortcut in shortCutInfos) { var name = shortcut.Name; if (!name.EndsWith(".url", StringComparison.OrdinalIgnoreCase) && !name.EndsWith(".lnk", StringComparison.OrdinalIgnoreCase)) { name += ".lnk"; } var targetPath = InstallContext.ConvertPath(shortcut.TargetDir); if (Directory.Exists(targetPath)) { var path = Path.Combine(targetPath, name); FileHelper.RemoveReadonly(path); if (name.EndsWith(".url", StringComparison.OrdinalIgnoreCase)) { ShortcutHelper.CreateWebShortcutFile(path, shortcut.TargetDir); } else { var target = InstallContext.ConvertPath(shortcut.Target); ShortcutHelper.CreateShortcutFile(path, target, shortcut.Args); } Watch?.Info("-->" + path); Watch?.AddValue(1); InstallContext.UninstallData.Shortcuts.Add(path); } } this.CommandStatus = CommandStatus.Complete; return(true); }
[TestProperty("Ignore", "True")] // GH#7282 - investigate and reenable public void CheckShortcutWritebacks() { using (RegistryHelper reg = new RegistryHelper()) { // The global state changes can still impact the registry, so back up the registry anyway despite this being the shortcut test. reg.BackupRegistry(); using (ShortcutHelper shortcut = new ShortcutHelper()) { shortcut.CreateTempCmdShortcut(); using (CmdApp app = new CmdApp(CreateType.ShortcutFile, TestContext, shortcut.ShortcutPath)) { this.CheckShortcutWritebacks(shortcut, app, OpenTarget.Specifics); } } } }
private void TravelRequestApproved(TravelRequest travelRequest) { if (travelRequest != null) { this.travelRequestNotified = travelRequest; // Create the sortcut ShortcutHelper.TryCreateShortcut("MyCompany.Travel"); // Create the toast and attach event listeners XmlDocument toastXml = CreateToast(); var node = toastXml.FirstChild.FirstChild.FirstChild; ((XmlElement)node).SetAttribute("addImageQuery", "true"); this.toast = new ToastNotification(toastXml); this.toast.Activated += ToastActivated; ToastNotificationManager.CreateToastNotifier("MyCompany.Travel").Show(toast); } }
private void AddToSaveList(ShortcutHelper helper, string shortcutText) { if (_newShortcuts.ContainsKey(helper)) { _newShortcuts[helper] = GetShortcut(shortcutText); } else { _newShortcuts.Add(helper, GetShortcut(shortcutText)); } }