private void ShowEditWindow(ListObject listObject, bool addObjectToSettings) { ItemWindow window = new ItemWindow(listObject); window.Owner = App.Current.MainWindow; bool?result = window.ShowDialog(); if (result.HasValue && result.Value) { // OK pressed listObject.Name = window.InputName; listObject.Path = window.InputPath; listObject.BundleId = window.InputBundleId; if (addObjectToSettings) { SettingsManager.Settings.ItemCollection.Add(listObject); } SettingsManager.Settings.SelectedListObject = listObject.Name; SettingsManager.SaveSettings(); UpdateUIFromSettings(SettingsManager.Settings); } else { // Cancel pressed, discard window by doing nothing } }
private void SetFromListObject(ListObject listObject) { cachedListObject = listObject; textBoxName.Text = listObject.Name; textBoxPath.Text = listObject.Path; textBoxBundleId.Text = listObject.BundleId; }
private void ShowDeleteItemConfirmation() { ListObject listObject = FindCurrentSelectedItem(); if (listObject != null) { MessageBoxResult result = MessageBox.Show(App.Current.MainWindow, string.Format("Are you sure you want to delete '{0}'? This action can not be reverted.", listObject.Name), "Confirm Deletion", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Yes) { SettingsManager.Settings.ItemCollection.Remove(listObject); // TODO: Proper selection of next item //int index = SettingsManager.Settings.ItemCollection.IndexOf(listObject); //int nextSelectedIndex = Math.Min(index, SettingsManager.Settings.ItemCollection.Count - 1); string nextItem = string.Empty; if (SettingsManager.Settings.ItemCollection.Count > 0) { nextItem = SettingsManager.Settings.ItemCollection[0].Name; } SettingsManager.Settings.SelectedListObject = nextItem; SettingsManager.SaveSettings(); UpdateUIFromSettings(SettingsManager.Settings); } } else { // This should never happen, the remove button should be disabled in such scenario throw new Exception(); } }
private void UpdateLabels(ListObject objectInfo) { string bundleId = objectInfo != null ? objectInfo.BundleId : ""; string path = objectInfo != null ? objectInfo.Path : ""; labelBundleId.Content = bundleId; labelPath.Content = path; }
private void ActionInstall(ListObject listObject) { //Output(string.Format(INSTALL, listObject.Name)); if (!File.Exists(listObject.Path)) { Output(string.Format("Invalid path \"{0}\"", listObject.Path)); return; } _connection.StartExecuteCommand(string.Format(ACTION_INSTALL, listObject.Path)); }
private void OnItemCollectionSelectionChanged() { ListObject objectInfo = FindCurrentSelectedItem(); UpdateLabels(objectInfo); if (objectInfo != null) { // Temp (?) UpdateSettingsFromUI(); } }
public ItemWindow(ListObject listObject = null) { InitializeComponent(); if (listObject != null) { SetFromListObject(listObject); } else { SetToDefault(); } }
private void OpenWindowEditItem() { ListObject selectedItem = FindCurrentSelectedItem(); if (selectedItem != null) { ShowEditWindow(selectedItem, true); } else { // This should never happen, the edit button should be disabled in such scenario throw new Exception(); } }
private bool ValidateInput() { ListObject foundObject = SettingsManager.Settings.ItemCollection.Find(x => x != cachedListObject && x.Name == InputName); if (foundObject != null) { MessageBox.Show("Name is already in use."); return(false); } // We only want to make sure it's an APK, it doesn't matter if the file doesn't exist if (!InputPath.EndsWith(".apk", StringComparison.InvariantCultureIgnoreCase)) { MessageBox.Show("Invalid path, it must direct to a valid .apk"); return(false); } return(true); }
private void ActionClear(ListObject listObject) { //Output(string.Format(CLEAR_DATA, listObject.Name)); _connection.StartExecuteCommand(string.Format(ACTION_CLEAR_DATA, listObject.BundleId)); }
private void ActionKill(ListObject listObject) { //Output(string.Format(KILL, listObject.Name)); _connection.StartExecuteCommand(string.Format(ACTION_KILL, listObject.BundleId)); }
private void ActionUninstall(ListObject listObject) { //Output(string.Format(UNINSTALL, listObject.Name)); _connection.StartExecuteCommand(string.Format(ACTION_UNINSTALL, listObject.BundleId)); }
private void ActionLaunch(ListObject listObject) { //Output(string.Format(LAUNCH, listObject.Name)); _connection.StartExecuteCommand(string.Format(ACTION_LAUNCH, listObject.BundleId)); }
private void OpenWindowAddItem() { ListObject listObject = new ListObject(); ShowEditWindow(listObject, true); }