Exemplo n.º 1
0
        static void AddApp(Pebble pebble, string watch = null, bool removeFirst = false)
        {
            string watchdir = null;

            if (String.IsNullOrEmpty(watch))
            {
                watchdir = ConfigurationManager.AppSettings["watch-dir"];
                if (watchdir == null)
                {
                    Console.WriteLine("Missing .config entry for 'watch-dir'");
                    return;
                }
                if (!Directory.Exists(watchdir))
                {
                    Console.WriteLine("watch-dir not found: {0}", watchdir);
                    return;
                }
            }
            var appbank = pebble.GetAppbankContents().AppBank;
            var applist = appbank.Apps;

            if (applist.Count == appbank.Size)
            {
                Console.WriteLine("All {0} banks are full", appbank.Size);
                return;
            }
            try
            {
                if (String.IsNullOrEmpty(watch))
                {
                    Console.WriteLine("Choose an app to install");
                    var watches = Directory.GetFiles(watchdir, "*.pbw");
                    watch = SharpMenu <string> .WriteAndPrompt(watches);

                    watch = Path.Combine(watchdir, watch);
                }
                if (removeFirst)
                {
                    PebbleBundle pb         = new PebbleBundle(watch);
                    var          app2remove = applist.Find(delegate(AppBank.App app) { return(app.Name == pb.Application.AppName); });
                    if (app2remove.Name != null)
                    {
                        Console.WriteLine("Removing existing...");
                        pebble.RemoveApp(app2remove);
                        Thread.Sleep(2000); // let things settle
                    }
                }
                Console.WriteLine("Installing...");
                pebble.InstallApp(watch, applist.Count);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        static async Task DeleteApp(Pebble pebble)
        {
            var applist = (await pebble.GetAppbankContentsAsync()).AppBank.Apps;

            Console.WriteLine("Choose an app to remove");
            AppBank.App result = SharpMenu <AppBank.App> .WriteAndPrompt(applist);

            AppbankInstallResponse ev = await pebble.RemoveAppAsync(result);

            Console.WriteLine(ev.MsgType);
        }
Exemplo n.º 3
0
        static void DeleteApp(Pebble pebble)
        {
            var applist = pebble.GetAppbankContents().AppBank.Apps;

            Console.WriteLine("Choose an app to remove");
            AppBank.App result = SharpMenu <AppBank.App> .WriteAndPrompt(applist);

            AppbankInstallMessageEventArgs ev = pebble.RemoveApp(result);

            if (ev != null)
            {
                Console.WriteLine(ev.MsgType);
            }
        }