コード例 #1
0
        private void SetImage()
        {
            Thread.Sleep(2000);
            var imageBitmap = GetImageBitmapFromUrl("https://avatar.csdnimg.cn/A/4/F/3_kgcourage.jpg");

            RunOnUiThread(() =>
            {
                imagebutton.SetImageBitmap(imageBitmap);
            });
        }
コード例 #2
0
ファイル: HttpApi.cs プロジェクト: yongburenshu004/Verify
        public static async void LoadImage(string url, RoundImageView img)
        {
            WebRequest Request = HttpWebRequest.CreateHttp(url);

            using (WebResponse response = Request.GetResponse())
            {
                using (Stream stream = response.GetResponseStream())
                {
                    Bitmap bitmap = await BitmapFactory.DecodeStreamAsync(stream);

                    img.SetImageBitmap(bitmap);
                    img.play();
                }
            }
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            RelativeLayout relativeLayout = new RelativeLayout(this);

            view = LayoutInflater.From(this).Inflate(this.Assets.OpenXmlResourceParser("res/layout/xamarin_activity.xml"), relativeLayout);
            SetContentView(relativeLayout);
            AuthDialog.Dialog.Properties = new Properties();
            string content;

            using (StreamReader sr = new StreamReader(Assets.Open("Conf.dat")))
            {
                content = sr.ReadToEnd();
            }
            Stream stream = new MemoryStream(Android.Util.Base64.Decode(Encoding.UTF8.GetBytes(content), Base64Flags.NoWrap));

            AuthDialog.Dialog.Properties.Load(stream);


            /*AuthDialog.Dialog.Properties = new Properties();
             * AuthDialog.Dialog.Properties.SetProperty("Appid", "7");
             * AuthDialog.Dialog.Properties.SetProperty("Ver", "1");
             * AuthDialog.Dialog.Properties.SetProperty("MainClass", this.Class.Name);*/


            if (AuthDialog.Dialog.AntiRun)
            {
                StartActivity(new Intent(this, Java.Lang.Class.ForName(AuthDialog.Dialog.Properties.GetProperty("MainClass"))));
                Finish();
                return;
            }
            RoundImageView v = (RoundImageView)view.FindViewWithTag("image");

            v.SetImageBitmap(BitmapFactory.DecodeStream(Assets.Open("bj.png")));
            view.FindViewWithTag("mainview").Background = new BitmapDrawable(Resources, BitmapFactory.DecodeStream(Assets.Open("background.png")));
            Loading.Show(this);
            HttpApi.GetCardAsync(this, mac.GetMac());


            /*Button bt1 = (Button)view.FindViewWithTag("bt1");
             * bt1.Click += delegate
             * {
             *  Toast.MakeText(this, "xxx", ToastLength.Long).Show();
             * };*/
        }
コード例 #4
0
ファイル: Dialog.cs プロジェクト: yongburenshu004/Verify
 private static void ShowDialog()
 {
     if (appInfo.data.dialog_style == 0 || appInfo.data.dialog_style == 1)
     {
         RelativeLayout relativeLayout = new RelativeLayout(Base);
         relativeLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
         EditText Card = new EditText(Base);
         Card.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
         relativeLayout.SetPadding(30, 0, 30, 0);
         relativeLayout.AddView(Card);
         if (appInfo.data.dialog_style == 1)
         {
             Card.SetTextColor(Color.White);
         }
         auth = new AlertDialog.Builder(Base, appInfo.data.dialog_style == 0 ? 5 : 4)
                .SetTitle(appInfo.data.title)
                .SetMessage(appInfo.data.notice)
                .SetCancelable(false)
                .SetView(relativeLayout)
                .SetNegativeButton(string.IsNullOrEmpty(appInfo.data.weburl) ? "取消" : "购卡", delegate { })
                .SetPositiveButton("验证", delegate { })
                .SetNeutralButton(appInfo.data.try_count > 0 ? "试用" : "查码", delegate { })
                .Show();
         auth.GetButton((int)DialogButtonType.Positive).Click += delegate
         {
             string card = Card.Text.Trim();
             if (string.Empty == card)
             {
                 return;
             }
             if (string.Empty == mac.GetMac())
             {
                 new AlertDialog.Builder(Base)
                 .SetTitle("请确认你的权限是否打开")
                 .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                 .SetPositiveButton("去开启", (s, e) =>
                 {
                     Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                     Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                     intent.SetData(uri);
                     Base.StartActivity(intent);
                 })
                 .Show();
                 return;
             }
             Loading.Show(Base);
             mCard = card;
             HttpApi.loginAsync(mResult, card, mac.GetMac());
         };
         auth.GetButton((int)DialogButtonType.Negative).Click += delegate
         {
             if (string.IsNullOrEmpty(appInfo.data.weburl))
             {
                 System.Environment.Exit(0);
             }
             else
             {
                 if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link="))
                 {
                     Loading.Show(Base);
                     HttpApi.GetPage_data(mResult, appInfo.data.weburl);
                 }
                 else
                 {
                     Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl));
                     Base.StartActivity(browserIntent);
                 }
             }
         };
         auth.GetButton((int)DialogButtonType.Neutral).Click += delegate
         {
             if (appInfo.data.try_count > 0)
             {
                 if (string.Empty == mac.GetMac())
                 {
                     new AlertDialog.Builder(Base)
                     .SetTitle("请确认你的权限是否打开")
                     .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                     .SetPositiveButton("去开启", (s, e) =>
                     {
                         Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                         Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                         intent.SetData(uri);
                         Base.StartActivity(intent);
                     })
                     .Show();
                     return;
                 }
                 Loading.Show(Base);
                 HttpApi.trialAsync(mResult, mac.GetMac());
             }
             else
             {
                 string card = Card.Text.Trim();
                 if (string.Empty == card)
                 {
                     return;
                 }
                 HttpApi.QueryAsync(mResult, card);
             }
         };
     }
     else if (appInfo.data.dialog_style == 2)
     {
         RelativeLayout relativeLayout = new RelativeLayout(Base);
         view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_auth.xml"), relativeLayout);
         CardView cardView = (CardView)view.FindViewWithTag("cardview");
         cardView.Radius               = 45;
         cardView.Elevation            = 1;
         cardView.PreventCornerOverlap = false;
         RoundImageView v = (RoundImageView)view.FindViewWithTag("image");
         v.SetImageBitmap(BitmapFactory.DecodeStream(Base.Assets.Open("bj.png")));
         auth = new AlertDialog.Builder(Base, 4)
                .SetView(relativeLayout)
                .SetCancelable(false)
                .Show();
         auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
         EditText Card = (EditText)view.FindViewWithTag("et");
         ((TextView)view.FindViewWithTag("title")).SetText(appInfo.data.title, BufferType.Normal);
         ((TextView)view.FindViewWithTag("msg")).SetText(appInfo.data.notice, BufferType.Normal);
         if (string.Empty != appInfo.data.weburl)
         {
             ((Button)view.FindViewWithTag("bt2")).Visibility = ViewStates.Visible;
         }
         if (appInfo.data.try_count > 0)
         {
             ((Button)view.FindViewWithTag("bt1")).SetText("试用", BufferType.Normal);
         }
         else
         {
             ((Button)view.FindViewWithTag("bt1")).SetText("查码", BufferType.Normal);
         }
         view.FindViewWithTag("bt1").Click += delegate
         {
             if (appInfo.data.try_count > 0)
             {
                 if (string.Empty == mac.GetMac())
                 {
                     new AlertDialog.Builder(Base)
                     .SetTitle("请确认你的权限是否打开")
                     .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                     .SetPositiveButton("去开启", (s, e) =>
                     {
                         Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                         Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                         intent.SetData(uri);
                         Base.StartActivity(intent);
                     })
                     .Show();
                     return;
                 }
                 Loading.Show(Base);
                 HttpApi.trialAsync(mResult, mac.GetMac());
             }
             else
             {
                 string card = Card.Text.Trim();
                 if (string.Empty == card)
                 {
                     return;
                 }
                 HttpApi.QueryAsync(mResult, card);
             }
         };
         view.FindViewWithTag("bt2").Click += delegate
         {
             if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link="))
             {
                 Loading.Show(Base);
                 HttpApi.GetPage_data(mResult, appInfo.data.weburl);
             }
             else
             {
                 Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl));
                 Base.StartActivity(browserIntent);
             }
         };
         view.FindViewWithTag("bt3").Click += delegate
         {
             string card = Card.Text.Trim();
             if (string.Empty == card)
             {
                 return;
             }
             if (string.Empty == mac.GetMac())
             {
                 new AlertDialog.Builder(Base)
                 .SetTitle("请确认你的权限是否打开")
                 .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                 .SetPositiveButton("去开启", (s, e) =>
                 {
                     Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                     Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                     intent.SetData(uri);
                     Base.StartActivity(intent);
                 })
                 .Show();
                 return;
             }
             Loading.Show(Base);
             mCard = card;
             HttpApi.loginAsync(mResult, card, mac.GetMac());
         };
     }
     if (appInfo.data.version > Convert.ToInt32(Properties.GetProperty("Ver")))
     {
         new AlertDialog.Builder(Base)
         .SetTitle(appInfo.data.title)
         .SetMessage(appInfo.data.update_msg)
         .SetCancelable(appInfo.data.updatemode == 0 ? false : true)
         .SetPositiveButton("更新", (s, e) =>
         {
             Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.update_url));
             Base.StartActivity(browserIntent);
         }).Show();
     }
 }