/// <summary>
        /// <description>Upload User Profile Picture</description>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onImgProfileClick(object sender, EventArgs e)
        {
            try
            {
                string[] items = { "Take Photo", "Choose from Library", "Cancel" };
                Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this);
                alertDiag.SetTitle("Add Photo");
                alertDiag.SetItems(items, (d, args) =>
                {
                    //Take photo
                    if (args.Which == 0)
                    {
                        TakePhoto();
                    }

                    else if (args.Which == 1)
                    {
                        UploadPhoto();
                    }
                    else
                    {
                        alertDiag.Dispose();
                    }
                });
                Dialog diag = alertDiag.Create();
                alertDiag.Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, GetString(Resource.String.somthing_wrong), ToastLength.Short).Show();
            }
        }
        private void PromptMacros()
        {
            var builderSingle = new Android.App.AlertDialog.Builder(this);

            builderSingle.SetTitle("Select Macro");

            var negative = new EventHandler <DialogClickEventArgs>(
                (s, args) =>
            {
            });

            var positive = new EventHandler <DialogClickEventArgs>(
                async(s, args) =>
            {
                if (_macrosValues != null && _macrosValues.Count > args.Which)
                {
                    var value       = _macrosValues[args.Which];
                    var currentHtml = await _richEditorWebView.GetHtmlAsync();
                    _richEditorWebView.SetHTML(currentHtml + value + "<br/>");
                }
            });

            builderSingle.SetItems(_macros?.ToArray(), positive);
            builderSingle.SetNegativeButton("Cancel", negative);

            var adialog = builderSingle.Create();

            adialog.Show();
        }
        private void ListaDeCancionesAdapter_ItemLongClick(object sender, ListaDeCancionesRecyclerViewAdapterClickEventArgs e)
        {
            Android.App.AlertDialog.Builder alerta = new Android.App.AlertDialog.Builder(View.Context);
            alerta.SetTitle("Seleccione una opción");

            string[] items = { "Agregar al final de cola", "Agregar a siguiente en cola", "Agregar a lista" };

            alerta.SetItems(items, new EventHandler <DialogClickEventArgs> (delegate(object o, DialogClickEventArgs args)
            {
                if (args.Which == (int)OpcionesLista.AgregarAlFinalDeCola)
                {
                    Reproductor.AñadirAlFinal(e.Cancion);
                }
                else if (args.Which == (int)OpcionesLista.AgregarASiguienteEnCola)
                {
                    Reproductor.AñadirSiguiente(e.Cancion);
                }
                else if (args.Which == (int)OpcionesLista.AgregarALista)
                {
                    MostrarSeleccionDeListasDeReproduccionYAgregarla(e.Cancion);
                }
                else
                {
                    Toast.MakeText(View.Context, "Error al manejar alerta.", ToastLength.Long);
                }
            }));
            alerta.Show();
        }
 private void ImgEventPic_Click(object sender, EventArgs e)
 {
     string[] items = { "Take photo", "Choose from gallery", "Cancel" };
     Android.App.AlertDialog.Builder alertDialog = new Android.App.AlertDialog.Builder(this);
     alertDialog.SetTitle("Upload event picture");
     alertDialog.SetItems(items, new dialogeItemClickListner(this));
     alertDialog.Show();
 }
        private void ShowUploadPicDialog()
        {
            if (Extensions.CheckPermissionForPicsRead(this) && Extensions.CheckPermissionForPicsWrite(this))
            {
                string[] items =
                {
                    "Take Photo", "Choose from Library"
                };

                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("Add Photo!");
                builder.SetItems(items, this);
                builder.Show();
            }
        }
Beispiel #6
0
 /// <summary>
 /// 打印测试
 /// </summary>
 /// <param name="activity"></param>
 public BluetoothPrinter(Android.App.Activity activity)
 {
     this.activity = activity;
     //获得本地的蓝牙适配器
     localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
     //打开蓝牙设备
     if (!localAdapter.IsEnabled)
     {
         Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable);
         activity.StartActivityForResult(enableIntent, 1);
     }
     //静默打开
     if (!localAdapter.IsEnabled)
     {
         localAdapter.Enable();
     }
     if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限
     {
         Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //获得已配对的设备列表
     bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices);
     if (bondedDevices.Count <= 0)
     {
         Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show();
         return;
     }
     string[] items = new string[bondedDevices.Count];
     //查看本地已设置的printer名称
     string ls_localPrinterName = baseclass.MyConfig.of_GetMySysSet("printer", "name");
     if (!string.IsNullOrEmpty(ls_localPrinterName))
     {
         for (int j = 0; j < bondedDevices.Count; j++)
         {
             if(ls_localPrinterName== bondedDevices[j].Name)
             {
                 as_BluetoothName = ls_localPrinterName;
                 System.Threading.Thread thr2 = new System.Threading.Thread(new System.Threading.ThreadStart(Printer));
                 thr2.Start(activity);
                 return;
             }
         }
     }
     //弹窗选择
     for (int i = 0; i < bondedDevices.Count; i++)
     {
         items[i] = bondedDevices[i].Name;
     }
     Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity);
     builder.SetTitle("请选择打印设备:");
     builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click));
     builder.SetNegativeButton("取消", delegate { return; });
     builder.Show();
 }
Beispiel #7
0
 public BluetoothPrinter(Android.App.Activity activity, PrinterType type, string Number)
 {
     this.as_Number = Number;
     this.printerType = type;
     this.activity = activity;
     //获得本地的蓝牙适配器
     localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
     if (string.IsNullOrEmpty(Number))
     {
         Android.Widget.Toast.MakeText(activity, "传入的单号为空,打印失败", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //打开蓝牙设备
     if (!localAdapter.IsEnabled)
     {
         Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable);
         activity.StartActivityForResult(enableIntent, 1);
     }
     //静默打开
     if (!localAdapter.IsEnabled)
     {
         localAdapter.Enable();
     }
     if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限
     {
         Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //获得已配对的设备列表
     bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices);
     if (bondedDevices.Count <= 0)
     {
         Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show();
         return;
     }
     string[] items = new string[bondedDevices.Count];
     for (int i = 0; i < bondedDevices.Count; i++)
     {
         items[i] = bondedDevices[i].Name;
     }
     Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity);
     builder.SetTitle("请选择打印设备:");
     builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click));
     builder.SetNegativeButton("取消", delegate { return; });
     builder.Show();
 }
        private void MostrarSeleccionDeListasDeReproduccionYAgregarla(Cancion cancion)
        {
            APIGatewayService api             = new APIGatewayService();
            bool huboExcepcionCargandoListas  = false;
            List <ListaDeReproduccion> listas = null;

            try
            {
                listas = api.ObtenerTodasLasListasPorIdUsuario(Usuario.Id);
            }
            catch (System.Exception ex)
            {
                huboExcepcionCargandoListas = true;
            }

            if (!huboExcepcionCargandoListas && listas != null)
            {
                listas.RemoveAll(l => l.EsHistorialDeReproduccion);

                List <string> nombresDeListas = new List <string>();
                foreach (var lista in listas)
                {
                    nombresDeListas.Add(lista.Nombre);
                }

                Android.App.AlertDialog.Builder alerta = new Android.App.AlertDialog.Builder(View.Context);
                alerta.SetTitle("Seleccione la lista");

                alerta.SetItems(nombresDeListas.ToArray(), new EventHandler <DialogClickEventArgs>(delegate(object o, DialogClickEventArgs args)
                {
                    var lista = listas[args.Which];
                    lista.IdsCanciones.Add(cancion.Id);
                    bool resultado     = false;
                    bool huboExcepcion = false;

                    try
                    {
                        resultado = api.ActualizarListaDeReproduccion(lista.Id, lista);
                    }
                    catch (System.Exception ex)
                    {
                        huboExcepcion = true;
                    }

                    if (!huboExcepcion)
                    {
                        if (resultado)
                        {
                            Toast.MakeText(View.Context, "Cancion añadida correctamente.", ToastLength.Short);
                        }
                        else
                        {
                            Toast.MakeText(View.Context, "Lo sentimos, no se pudo agregar la cancion a la lista.", ToastLength.Short);
                        }
                    }
                    else
                    {
                        Toast.MakeText(View.Context, "Error al conectarse al servidor. Intente mas tarde.", ToastLength.Short);
                    }
                }));
                alerta.Show();
            }
            else if (listas == null)
            {
                Toast.MakeText(View.Context, "No hay ninguna lista de canciones.", ToastLength.Short);
            }
            else
            {
                Toast.MakeText(View.Context, "Error al conectarse al servidor. Intente mas tarde.", ToastLength.Short);
            }
        }