private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            // RemoveEmptyEntries does not remove an entry that has a space, so don't waste time with it
            string[] files = txtXapFile.Text.Split(';');

            Analytics.Instance.Track(Analytics.Categories.App, "Update", "Count", files.Length);

            Xap xap;
            IRemoteApplication existingInstall;

            RememberXapPaths(files);

            foreach (string file in files)
            {
                if (string.IsNullOrWhiteSpace(file))
                    continue;

                // trim filename, otherwise the native side of UpdateApplication gets annoyed
                xap = new Xap(file.Trim());

                if (!_device.CurrentDevice.IsApplicationInstalled(xap.Guid))
                {
                    // TODO: notification to user
                    continue;
                }

                existingInstall = _device.CurrentDevice.GetApplication(xap.Guid);

                existingInstall.UpdateApplication("genre", "noicon", xap.FilePath);
            }
        }
        private void btnInstall_Click(object sender, RoutedEventArgs e)
        {
            // RemoveEmptyEntries does not remove an entry that has a space, so don't waste time with it
            string[] files = txtXapFile.Text.Split(';');

            Analytics.Instance.Track(Analytics.Categories.App, "Install", "Count", files.Length);

            Xap xap;
            IRemoteApplication existingInstall;

            RememberXapPaths(files);

            foreach (string file in files)
            {
                if (string.IsNullOrWhiteSpace(file))
                    continue;

                // trim filename, otherwise the native side of UpdateApplication gets annoyed
                xap = new Xap(file.Trim());

                if (_device.CurrentDevice.IsApplicationInstalled(xap.Guid))
                {
                    existingInstall = _device.CurrentDevice.GetApplication(xap.Guid);

                    existingInstall.Uninstall();
                }

                try
                {
                    _device.CurrentDevice.InstallApplication(xap.Guid, Guid.Empty, "genre", "noicon", xap.FilePath);
                }
                catch (SmartDeviceException ex)
                {
                    if (ex.Message == "0x8103010B")
                    {
                        ShowError("Your xap (" + xap.Name + ") appears to target a newer OS than the one you are deploying to. Are you trying to deploy an 8.0 app to the 7.5 emulator?");
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (OutOfMemoryException ex)
                {
                    ShowError("You've run out of space on your device! Please try again (this can sometimes be a device API issue) and if the error persists remove some apps and then try again.\n\nRaw Error: " + ex.Message);
                    break;
                }
            }

            _device.RefreshInstalledApps();
        }
        private static void UnInstall(string xapFile)
        {
            Xap xap = new Xap(xapFile);

            UnInstall(xap.Guid);
        }
        private static void Launch(string xapFile)
        {
            Xap xap = new Xap(xapFile);

            Launch(xap.Guid);
        }
        private static void Install(string xapFile)
        {
            Xap xap = new Xap(xapFile);
            RemoteApplicationEx app = GetApp(xap.Guid);

            // first uninstall any existing instances
            if (app != null)
            {
                app.RemoteApplication.Uninstall();
            }

            _device.CurrentDevice.InstallApplication(xap.Guid, Guid.Empty, "genre", "noicon", xapFile);
        }
        private static RemoteApplicationEx GetApp(string xapFile)
        {
            Xap xap = new Xap(xapFile);

            return GetApp(xap.Guid);
        }