Example #1
0
        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
            }
        }
Example #2
0
 private void SetFromListObject(ListObject listObject)
 {
     cachedListObject     = listObject;
     textBoxName.Text     = listObject.Name;
     textBoxPath.Text     = listObject.Path;
     textBoxBundleId.Text = listObject.BundleId;
 }
Example #3
0
        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();
            }
        }
Example #4
0
        private void UpdateLabels(ListObject objectInfo)
        {
            string bundleId = objectInfo != null ? objectInfo.BundleId : "";
            string path     = objectInfo != null ? objectInfo.Path : "";

            labelBundleId.Content = bundleId;
            labelPath.Content     = path;
        }
Example #5
0
        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));
        }
Example #6
0
        private void OnItemCollectionSelectionChanged()
        {
            ListObject objectInfo = FindCurrentSelectedItem();

            UpdateLabels(objectInfo);

            if (objectInfo != null)
            {
                // Temp (?)
                UpdateSettingsFromUI();
            }
        }
Example #7
0
        public ItemWindow(ListObject listObject = null)
        {
            InitializeComponent();

            if (listObject != null)
            {
                SetFromListObject(listObject);
            }
            else
            {
                SetToDefault();
            }
        }
Example #8
0
        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();
            }
        }
Example #9
0
        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);
        }
Example #10
0
        private void ActionClear(ListObject listObject)
        {
            //Output(string.Format(CLEAR_DATA, listObject.Name));

            _connection.StartExecuteCommand(string.Format(ACTION_CLEAR_DATA, listObject.BundleId));
        }
Example #11
0
        private void ActionKill(ListObject listObject)
        {
            //Output(string.Format(KILL, listObject.Name));

            _connection.StartExecuteCommand(string.Format(ACTION_KILL, listObject.BundleId));
        }
Example #12
0
        private void ActionUninstall(ListObject listObject)
        {
            //Output(string.Format(UNINSTALL, listObject.Name));

            _connection.StartExecuteCommand(string.Format(ACTION_UNINSTALL, listObject.BundleId));
        }
Example #13
0
        private void ActionLaunch(ListObject listObject)
        {
            //Output(string.Format(LAUNCH, listObject.Name));

            _connection.StartExecuteCommand(string.Format(ACTION_LAUNCH, listObject.BundleId));
        }
Example #14
0
        private void OpenWindowAddItem()
        {
            ListObject listObject = new ListObject();

            ShowEditWindow(listObject, true);
        }