コード例 #1
0
        private bool TryGetInputEndPoint(ILeafUI ui, TextAttrManager texts, out IPEndPoint endPoint)
        {
            Task <object> dialogTask = null;

            do
            {
                if (dialogTask?.Result is bool)
                {
                    ui.ShowMessage(texts["PleaseInputRightIP"]);
                }
                dialogTask = ui.ShowDialogById("inputIpEndPoint");
                dialogTask.Wait();
            } while (dialogTask.Result is bool);
            if (dialogTask.Result is IPEndPoint endPointResult)
            {
                endPoint = endPointResult;
                return(true);
            }
            else if (dialogTask.Result is string str && str == "iloveyou")
            {
                //我喜欢你,曹娜(*^▽^*)
                System.Diagnostics.Process.Start("https://lovecaona.cn");
            }
            endPoint = null;
            return(false);
        }
コード例 #2
0
 private void EntryPoint(ILeafUI ui, IDevice device, TextAttrManager texts)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Show();
         if (device is UsbDevice usbDevice)
         {
             Task <object> dialogTask = null;
             dialogTask = ui.ShowDialogById("portInputView");
             dialogTask.Wait();
             if (ushort.TryParse(dialogTask.Result?.ToString(), out ushort result))
             {
                 try
                 {
                     usbDevice.OpenNetDebugging(result, true);
                 }
                 catch (AdbCommandFailedException e)
                 {
                     ui.WriteOutput(e.Message);
                     ui.ShowMessage(texts["Failed"]);
                 }
             }
         }
         else
         {
             ui.ShowMessage("ERROR!");
         }
         ui.Shutdown();
     }
 }
コード例 #3
0
        private void EntryPoint(ILeafUI ui, IDevice device, TextAttrManager texts)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();
                if (device is NetDevice netDevice)
                {
                    Task <object> dialogTask = ui.ShowDialogById("disconnectChoiceView");
                    dialogTask.Wait();
                    bool?choice = (bool?)dialogTask.Result;
                    switch (choice)
                    {
                    case null:
                        ui.Shutdown();
                        break;

                    default:
                        netDevice.Disconnect((bool)choice);
                        break;
                    }
                    ui.Shutdown();
                }
                else
                {
                    ui.ShowMessage("THIS DEVICE IS NOT NET DEVICE!");
                    ui.Shutdown();
                }
            }
        }
コード例 #4
0
 private void EntryPoint(ILeafUI ui, TextAttrManager texts)
 {
     using (ui)
     {
         ui.Title = this.GetName();
         ui.Show();
         if (TryGetInputEndPoint(ui, texts, out IPEndPoint endpoint))
         {
             using (var executor = new CommandExecutor())
             {
                 ui.Tip = texts["ConnectingDevice"];
                 ui.WriteLine(texts["ConnectingDevice"]);
                 executor.To(e => ui.WriteOutput(e.Text));
                 var result = executor.Adb($"connect {endpoint.Address}:{endpoint.Port}");
                 if (result.Output.Contains("fail", true))
                 {
                     ui.WriteLine(texts["fail"]);
                     ui.Finish(texts["Fail"]);
                 }
                 else
                 {
                     ui.Finish(result.ExitCode);
                 }
             }
         }
         else
         {
             ui.Shutdown();
         }
     }
 }
        public void EntryPoint(IDevice device, ILeafUI ui, TextAttrManager text, IEmbeddedFileManager emb, ITemporaryFloder tmp)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();

                ui.Tip = text[EXTRACTING];
                tmp.Create();
                var filePath = Path.Combine(tmp.DirInfo.ToString(), "daemon");
                var tgtFile  = new FileInfo(filePath);
                var file     = emb.Get("daemon");

                ui.Tip = text[PUSHING];
                file.ExtractTo(tgtFile);

                ui.Tip = text[PUSHING];
                ICommandResult result = null;
                using (var executor = new CommandExecutor())
                {
                    executor.To(e => ui.WriteOutput(e.Text));
                    executor.Adb(device, $"push {tgtFile.FullName} /data/local/tmp/daemon");
                    executor.AdbShell(device, "chmod 777 /data/local/tmp/daemon");
                    result = executor.AdbShell(device, "./data/local/tmp/daemon &");
                }
                ui.Finish(result.ExitCode);
            }
        }
コード例 #6
0
        private bool TryGetInputEndPoint(ILeafUI ui, TextAttrManager texts, out IPEndPoint endPoint)
        {
            Task <object> dialogTask = null;

            do
            {
                if (dialogTask?.Result is bool)
                {
                    ui.ShowMessage(texts["PleaseInputRightIP"]);
                }
                dialogTask = ui.ShowDialogById("inputIpEndPoint");
                dialogTask.Wait();
            } while (dialogTask.Result is bool);
            if (dialogTask.Result is IPEndPoint endPointResult)
            {
                endPoint = endPointResult;
                return(true);
            }
            else if (dialogTask.Result is string str)
            {
                switch (str.ToLower())
                {
                case "iloveyou":
                    ui.ShowMessage("经历了这么多,我才明白最珍贵的其实是你也爱我。\n抱歉曾经对你的冷漠,现在,我只爱你,Yin Yin。");
                    break;

                case "future":
                    ui.ShowMessage("你要相信我,我们一定可以成功,我们的未来一定是可期的。这不是空口无凭,我一直在努力去让自己变得更好,即便现在的我在最错误的道路上,但总有一天,冰会化成水的,我也会回到正确的方向上");
                    break;

                case "fear":
                    ui.ShowMessage("猫猫,那天晚上你真的吓到我了...我真的好害怕失去你,这么多年以来,我第一次如此珍视一个人...我是男子汉,我不敢哭...求求你,不要这样对我了,好吗");
                    break;

                case "dream":
                    ui.ShowMessage("我总是在梦里梦到你,好开心鸭!!!!我一定要在把你紧紧抱住,抱2分钟!!!然后松开,摸摸你的头,然后吻上去!!!");
                    break;

                case "somuch":
                    ui.ShowMessage("我有太多太多想说的了,可我不知道该怎么对你说,我,爱,你");
                    break;
                }
            }
            endPoint = null;
            return(false);
        }
コード例 #7
0
        public void EntryPoint(IDevice device, ILeafUI ui, TextAttrManager texts)
        {
            using (ui)
            {
                ui.Title = this.GetName();
                ui.Icon  = this.GetIconBytes();
                ui.Show();
                if (!ui.DoYN(texts[ISINSTALL]))
                {
                    ui.EShutdown();
                }

                using (var executor = new CommandExecutor())
                {
                    executor.To(e => ui.WriteOutput(e.Text));
                    ui.WriteLine("启动AppOpsX主界面");
                    executor.AdbShell(device, "am start -n com.zzzmode.appopsx/com.zzzmode.appopsx.ui.main.MainActivity");
                    Thread.Sleep(1500);
                    var result = executor.AdbShell(device, "sh /sdcard/Android/data/com.zzzmode.appopsx/opsx.sh ");
                    ui.Finish(result.ExitCode);
                }
            }
        }
コード例 #8
0
 public object GetByType(Type type)
 {
     if (type == typeof(ILeafUI))
     {
         return(OpenFx.BaseApi.NewLeafUI());
     }
     else if (type.Name.StartsWith(nameof(ILogger)))
     {
         return(LoggerFactory.Auto(type, leafType));
     }
     else if (type == typeof(IUx))
     {
         return(ctx.Ux);
     }
     else if (type == typeof(IAppManager))
     {
         return(ctx.App);
     }
     else if (type == typeof(ITemporaryFloder))
     {
         return(ctx.Tmp);
     }
     else if (type == typeof(IEmbeddedFileManager))
     {
         return(ctx.EmbeddedManager);
     }
     else if (type == typeof(IOSApi))
     {
         return(ctx.GetService <IOSApi>(ServicesNames.OS));
     }
     else if (type == typeof(IDeviceSelector))
     {
         return(ctx.GetService <IDeviceSelector>(ServicesNames.DEVICE_SELECTOR));
     }
     else if (type == typeof(IMd5Service))
     {
         return(ctx.GetService <IMd5Service>(ServicesNames.MD5));
     }
     else if (type == typeof(IResourcesManager))
     {
         return(ctx.GetService <IResourcesManager>(ServicesNames.RESOURCES));
     }
     else if (type == typeof(ICompApi))
     {
         return(ctx.Comp);
     }
     else if (type == typeof(ISoundService))
     {
         return(ctx.GetService <ISoundService>(ServicesNames.SOUND));
     }
     else if (type == typeof(Context))
     {
         return(ctx);
     }
     else if (type == typeof(IDevice))
     {
         return(ctx.GetService <IDeviceSelector>(ServicesNames.DEVICE_SELECTOR).GetCurrent(ctx));
     }
     else if (type == typeof(TextAttrManager))
     {
         var m = new TextAttrManager(leafType);
         m.Load();
         return(m);
     }
     return(null);
 }
コード例 #9
0
 public void Main(IDevice device, IAppManager app, ILogger <string> logger, Context context, ILeafUI ui, IUx ux, Dictionary <string, object> data, TextAttrManager manager)
 {
     using (ui)
     {
         ui.Show();
         logger.Debug("WTF");
         using (CommandExecutor executor = new CommandExecutor())
         {
             ui.CloseButtonClicked += (s, e) =>
             {
                 e.CanBeClosed = true;
                 executor.Dispose();
             };
             executor.To(e => ui.WriteOutput(e.Text));
             executor.Adb("help");
         }
         CoreLib.Current.TEST = false;
         app.RefreshExtensionView();
         ui.ShowMessage("meile!");
         CoreLib.Current.TEST = true;
         app.RefreshExtensionView();
         ui.WriteLine(manager["f**k"]);
         ui.WriteOutput("f**k asdasjkdshadskjhkj");
         ui.ShowMessage("WTF\n\n\n\n\n\nasdadas\n\n\nasdasdsahsdkajghsdakjfhsdjkaghsdfjkghjkfsdhgjkshfdjkgfhsjdgkhdskfjghjW");
         bool?choice = ui.DoChoice("FUCcqwjeiwqeqehqWK");
         ui.WriteLine(choice.ToString());
         bool yn = ui.DoYN("FUCK2c   2rqwhewqhehqweqhwewqhejwqhewqjhqwejkqwhewqhWW");
         ui.WriteLine(yn.ToString());
         //object result = ui.SelectFrom(new object[] { "a", "qqdasdsadasb", "c", "a", "s", "c", "a" }, "选择你要做的SB操作");
         //ui.WriteLine(result);
         ui.Finish();
     }
 }
コード例 #10
0
 public void Main(IDevice device, IAppManager app, ILogger <string> logger, Context context, ILeafUI ui, IUx ux, Dictionary <string, object> data, TextAttrManager manager)
 {
     using (ui)
     {
         ui.Show();
         var storageManager = new StorageManagerImpl(context);
         using (var fs = storageManager.OpenFile("wtf"))
         {
             using (StreamWriter sw = new StreamWriter(fs))
             {
                 sw.Write("hello!");
             }
         }
         List <string> list = new List <string>()
         {
             "1", "2"
         };
         storageManager.SaveJsonObject("main", list);
         ui.Finish();
     }
 }
コード例 #11
0
        public void Main(ILeafUI ui, Context context, TextAttrManager textManager)
        {
            /*
             * 一定要进行using,此处是为了确保LeafUI被正确释放
             * 否则当该函数内发生异常,LeafUI将无法被关闭
             */
            using (ui)
            {
                /*初始化UI,此时UI仍然不可见*/
                //将LeafUI的图标设置为本模块的图标
                ui.Icon = this.GetIconBytes();
                //将LeafUI的标题设置为本模块的名称
                ui.Title = this.GetName();
                //绑定LeafUI关闭事件,并非必要的操作
                ui.CloseButtonClicked += (s, e) =>
                {
                    /*
                     * 当用户点击停止按钮时发生
                     * 请在此处销毁你调用的资源
                     * 如果你不想你的模块被中途停止,请返回false
                     */
                    e.CanBeClosed = false;
                };

                /*完成初始化,调用展示方法后,UI将可见*/
                //显示UI
                ui.Show();

                if (ui.DoYN("是否需要参看本拓展源代码?", "是", "否"))
                {
                    Process.Start("https://github.com/zsh2401/AutumnBox/blob/master/AutumnBox.CoreModules/Extensions/NoMatter/ELeafUIDemo.cs");
                }

                if (ui.DoYN("是否需要开启右上角问号?", "是", "否"))
                {
                    ui.EnableHelpBtn(() =>
                    {
                        Process.Start("https://github.com/zsh2401/AutumnBox/blob/master/AutumnBox.CoreModules/Extensions/NoMatter/ELeafUIDemo.cs");
                    });
                }

                //在输出框打印东西
                ui.WriteLine("这是普通输出,用于对用户的提示等");

                /*设置进度与说明
                 * 当然,你也可以不进行设置
                 * LeafUI默认进度条是无限循环的(进度值为-1)
                 * 默认提示是正在进行中等类似话语
                 */
                Thread.Sleep(1000);
                ui.ShowMessage("进度条以及提示信息的演示");

                ui.Tip      = "第一步";
                ui.Progress = 10;
                Thread.Sleep(500);
                //设置进度与说明
                ui.Tip      = "第二步";
                ui.Progress = 40;
                Thread.Sleep(500);
                //设置进度与说明
                ui.Tip      = "第三步";
                ui.Progress = 60;
                Thread.Sleep(500);

                ui.ShowMessage("进度条将变回无限循环");
                ui.Progress = -1;

                //进行带有取消选项的选择
                var choiceResult = ui.DoChoice("这是一个选择示例,请做出选择", "ping测试", "启动别的拓展模块", "什么也不做");
                switch (choiceResult)
                {
                case true:
                    var executor = new CommandExecutor();
                    executor.To(e => ui.WriteOutput(e.Text));    //重定向输出
                    executor.Cmd("ping www.baidu.com");
                    //通过此函数,可以显示专业输出,但不建议调用,此权利应该尽可能交给用户
                    ui.WriteLine("显示专业输出!");
                    ui.ProOutputVisible = true;
                    executor.Dispose();
                    break;

                case false:
                    var thread = context.NewExtensionThread("EHoldMyHand");
                    thread.Data["wtf"] = "aaa";    //可以传参数哦
                    thread.Start();
                    thread.WaitForExit();
                    break;

                default:
                    ui.ShowMessage("哼,气得我变大了!");
                    ui.WriteLine($"原大小:{ui.Width}x{ui.Height}");
                    ui.Width  += 200;
                    ui.Height += 200;
                    ui.WriteLine($"后大小:{ui.Width}x{ui.Height}");
                    break;
                }

                ui.ShowMessage($"让我们来看看根据语言自动匹配的语言值: {textManager["testkey"]}");

                //进行单选,让用户决定用那个方式结束
                const string hint   = "好了,该选择一个方式结束了";
                const string item0  = "默认的完成方式";
                const string item1  = "传入错误码1";
                const string item2  = "直接设定完成提示信息";
                const string item3  = "通过EFinish结束";
                var          result = ui.SelectFrom(hint,
                                                    item0,
                                                    item1,
                                                    item2,
                                                    item3);

                /*
                 * 当完成函数流程时.一定要手动调用Finish()函数
                 * 如果不进行调用,那么当C# using将调用LeafUI的Dispose函数时
                 * LeafUI将视本模块执行过程出现问题,将直接关闭
                 */
                switch (result as string)
                {
                case item0:
                    ui.Finish();    //LeafUI将视为本模块执行成功,显示成功提示
                    break;

                case item1:
                    ui.Finish(1);    //LeafUI将根据传入的错误码进行分析,并设置完成提示
                    break;

                case item2:
                    ui.Finish("功能结束");    //LeafUI不进行结果判断,而是将传入的字符串作为结束提示
                    break;

                default:
                    /*EFinish调用后将抛出一个可以信号异常
                     * 也就是说会立刻停止当前函数的流程,而不像
                     * 普通的Finish那样继续执行之后的语句
                     */
                    ui.EFinish();
                    //由于EFinish抛出异常,下面的代码无法被执行
                    System.Environment.Exit(1);
                    break;
                }
            }
        }