// Software action changed evetns private void SoftwareUi_PathChanged(object sender, RoutedEventArgs e) { if (!eventBlock) { SoftwareAction action = (SoftwareAction)Shortcut.Actions[0]; action.Path = SoftwareUi_Path.Text; } eventBlock = false; }
public static void ExecuteShortcut(Shortcut shortcut) { foreach (Action action in shortcut.Actions) { switch (action.Type) { case "command": CommandAction ca = action as CommandAction; System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); if (!ca.KeepOpen) { startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.Arguments = $"/C {ca.Command}"; } else { startInfo.Arguments = $"/k {ca.Command}"; } startInfo.FileName = "cmd.exe"; process.StartInfo = startInfo; process.Start(); break; case "file": FileAction fa = action as FileAction; System.Diagnostics.Process.Start(fa.Path); break; case "folder": FolderAction foa = action as FolderAction; System.Diagnostics.Process.Start(foa.Path); break; case "software": SoftwareAction sa = action as SoftwareAction; System.Diagnostics.Process.Start(sa.Path); break; case "website": WebsiteAction wa = action as WebsiteAction; System.Diagnostics.Process.Start(wa.Url); break; } } }
private void SetFieldValuesFromShortcut() { eventBlock = true; ShortcutTitleName.Text = $"{Enum.GetName(typeof(ShortcutType), ShortcutType)} Action"; eventBlock = true; ShortcutTypeComboBox.SelectedIndex = (int)ShortcutType; switch (ShortcutType) { case ShortcutType.Web: WebsiteAction webaction = (WebsiteAction)Shortcut.Actions[0]; eventBlock = true; WebsiteUriField.Text = webaction.Url; eventBlock = true; break; case ShortcutType.File: FileAction fileAction = (FileAction)Shortcut.Actions[0]; eventBlock = true; FileUi_Path.Text = fileAction.Path; break; case ShortcutType.Folder: FolderAction folderAction = (FolderAction)Shortcut.Actions[0]; eventBlock = true; FolderUi_Path.Text = folderAction.Path; break; case ShortcutType.Software: SoftwareAction softwareAction = (SoftwareAction)Shortcut.Actions[0]; eventBlock = true; SoftwareUi_Path.Text = softwareAction.Path; break; case ShortcutType.Command: CommandAction comaction = (CommandAction)Shortcut.Actions[0]; eventBlock = true; CommandUi_Comand.Text = comaction.Command; eventBlock = true; CommandUi_KeepOpen.IsChecked = comaction.KeepOpen; break; } eventBlock = false; }
private void SoftwareUi_PathSelectPressed(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Exe Files (*.exe)|*.exe|All files (*.*)|*.*"; openFileDialog.InitialDirectory = Environment.SpecialFolder.ProgramFiles.ToString(); if (openFileDialog.ShowDialog() == true) { if (!string.IsNullOrEmpty(openFileDialog.FileName)) { SoftwareAction action = (SoftwareAction)Shortcut.Actions[0]; action.Path = openFileDialog.FileName; if (SoftwareUi_Path.Text != openFileDialog.FileName) { eventBlock = true; SoftwareUi_Path.Text = openFileDialog.FileName; } } } }
public ValidationError IsValid() { if (string.IsNullOrEmpty(Name)) { return(new ValidationError("Shortcut Name Cannot be Empty.", this)); } foreach (Action action in Actions) { switch (action.Type) { case "command": CommandAction a1 = action as CommandAction; ValidationError a1Err = a1.IsValid(); if (a1Err != null) { a1Err.Shortcut = this; return(a1Err); } break; case "file": FileAction a2 = action as FileAction; ValidationError a2Err = a2.IsValid(); if (a2Err != null) { a2Err.Shortcut = this; return(a2Err); } break; case "folder": FolderAction a3 = action as FolderAction; ValidationError a3Err = a3.IsValid(); if (a3Err != null) { a3Err.Shortcut = this; return(a3Err); } break; case "software": SoftwareAction a4 = action as SoftwareAction; ValidationError a4Err = a4.IsValid(); if (a4Err != null) { a4Err.Shortcut = this; return(a4Err); } break; case "website": WebsiteAction a5 = action as WebsiteAction; ValidationError a5Err = a5.IsValid(); if (a5Err != null) { a5Err.Shortcut = this; return(a5Err); } break; } } return(null); }
private void SetFieldValuesFromShortcut() { eventBlock = true; ShortcutNameField.Text = Shortcut.Name; ShortcutTitleName.Text = Shortcut.Name; eventBlock = true; ShortcutTypeComboBox.SelectedIndex = (int)ShortcutType; if (!string.IsNullOrEmpty(Shortcut.IconPath)) { if (!File.Exists(Shortcut.IconPath)) { Shortcut.IconPath = string.Empty; ShotcutNameText.Text = "No icon selected."; } else { ShotcutNameText.Text = Path.GetFileName(Shortcut.IconPath); } } else { ShotcutNameText.Text = "No icon selected."; } switch (ShortcutType) { case ShortcutType.Web: WebsiteAction webaction = (WebsiteAction)Shortcut.Actions[0]; eventBlock = true; WebsiteUriField.Text = webaction.Url; eventBlock = true; break; case ShortcutType.File: FileAction fileAction = (FileAction)Shortcut.Actions[0]; eventBlock = true; FileUi_Path.Text = fileAction.Path; break; case ShortcutType.Folder: FolderAction folderAction = (FolderAction)Shortcut.Actions[0]; eventBlock = true; FolderUi_Path.Text = folderAction.Path; break; case ShortcutType.Software: SoftwareAction softwareAction = (SoftwareAction)Shortcut.Actions[0]; eventBlock = true; SoftwareUi_Path.Text = softwareAction.Path; break; case ShortcutType.Command: CommandAction comaction = (CommandAction)Shortcut.Actions[0]; eventBlock = true; CommandUi_Comand.Text = comaction.Command; eventBlock = true; CommandUi_KeepOpen.IsChecked = comaction.KeepOpen; break; case ShortcutType.Multi: break; } eventBlock = false; }