protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            btnTranslate = FindViewById <Button>(Resource.Id.btnTranslate);
            txtMessage   = FindViewById <TextView>(Resource.Id.textMessage);
            spinner      = FindViewById <Spinner>(Resource.Id.select_language);



            btnTranslate.Click += BtnTranslate_Click;


            Context context = this;  // Get the Resources object from our context

            res = context.Resources; // Get the string
            Content.Res.Configuration conf = res.Configuration;
            DisplayMetrics            dm   = res.DisplayMetrics;

            conf.SetLocale(new Locale("ak")); //Set local to Akan ak

            res.UpdateConfiguration(conf, dm);

            var lang    = Resources.Configuration.Locale;
            var country = lang.GetDisplayCountry(lang);

            Toast.MakeText(this, "Your current locale is " + lang, ToastLength.Long).Show();
            Toast.MakeText(this, "Country " + country, ToastLength.Long).Show();
            Toast.MakeText(this, "Display Name " + lang.DisplayName, ToastLength.Long).Show();
            Toast.MakeText(this, "Language " + lang.Language, ToastLength.Long).Show();
        }
        public void NotifyVersion26(Context context, Android.Content.Res.Resources res, Android.App.NotificationManager manager)
        {
            string channelName = "Secondary Channel";
            var    importance  = NotificationImportance.High;
            var    channel     = new NotificationChannel(PRIMARY_CHANNEL, channelName, importance);

            var path           = Android.Net.Uri.Parse("android.resource://com.ufinix.uberdriver/" + Resource.Raw.alert);
            var audioattribute = new AudioAttributes.Builder()
                                 .SetContentType(AudioContentType.Sonification)
                                 .SetUsage(AudioUsageKind.Notification).Build();

            channel.EnableLights(true);
            channel.EnableLights(true);
            channel.SetSound(path, audioattribute);
            channel.LockscreenVisibility = NotificationVisibility.Public;

            manager.CreateNotificationChannel(channel);

            Intent intent = new Intent(context, typeof(MainActivity));

            intent.AddFlags(ActivityFlags.SingleTop);
            PendingIntent pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.CancelCurrent);

            Notification.Builder builder = new Notification.Builder(context)
                                           .SetContentTitle("Uber Driver")
                                           .SetSmallIcon(Resource.Drawable.ic_location)
                                           .SetLargeIcon(BitmapFactory.DecodeResource(res, Resource.Drawable.iconimage))
                                           .SetContentText("You have a new trip request")
                                           .SetChannelId(PRIMARY_CHANNEL)
                                           .SetAutoCancel(true)
                                           .SetContentIntent(pendingIntent);

            manager.Notify(NOTIFY_ID, builder.Build());
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here

            SetContentView(Resource.Layout.MachineDetailView);
            string  xml     = Intent.GetStringExtra("Machine");
            Machine machine = Newtonsoft.Json.JsonConvert.DeserializeObject <Machine>(xml);


            //// Remove the file extention from the image filename
            Android.Content.Res.Resources res = Resources;

            BitmapFactory.Options options = ImageHelper.GetBitmapOptionsOfImage(res, machine.PictureUrl);
            //// Converting Drawable Resource to Bitmap
            Bitmap bitmapToDisplay = ImageHelper.LoadScaledDownBitmapForDisplay(res, options, 150, 150, machine.PictureUrl);


            FindViewById <TextView>(Resource.Id.machineName).Text = machine.Name;
            //convertView.FindViewById<TextView>(Resource.Id.shortDescription).Text = item.shortDesc;
            ////    convertView.FindViewById<ImageView>(Android.Resource.Id.Icon).;
            FindViewById <ImageView>(Resource.Id.machineImageView).SetImageBitmap(bitmapToDisplay);
            //return convertView;
            //var selectedHotDogId = Intent.Extras.GetInt("selectedHotDogId");
            //selectedHotDog = dataService.GetHotDogById(selectedHotDogId);

            //FindViews();

            //BindData();

            //HandleEvents();
        }
Example #4
0
        public void PrintDrawable(Android.Content.Res.Resources res, int id)
        {
            try
            {
                int    maxWidth = GetDrawableMaxWidth();
                Bitmap image    = ScalingBitmap(res, id, maxWidth);

                if (image == null)
                {
                    return;
                }

                byte[] command = PrinterUtils.DecodeBitmap(image, heightParting);
                image.Recycle();

                try
                {
                    if (command != null)
                    {
                        Write(command);
                    }
                }
                catch (IOException e)
                {
                    throw new IOException(e.Message);
                }
            }
            catch (System.Exception ex)
            {
                throw new IOException(ex.Message);
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            base.OnCreate(savedInstanceState);
            Context context = this;

            res = context.Resources;
            SessionManager.SetLocale(res);
            SetContentView(Resource.Layout.add_secret_lock);
            SpinnerHint = FindViewById <Spinner>(Resource.Id.spinner_hint);

            TILPIN          = FindViewById <TextInputLayout>(Resource.Id.til_pin);
            TILCPIN         = FindViewById <TextInputLayout>(Resource.Id.til_cpin);
            TILHintResponse = FindViewById <TextInputLayout>(Resource.Id.til_hint_response);

            TextPIN          = FindViewById <EditText>(Resource.Id.text_pin);
            TextCPIN         = FindViewById <EditText>(Resource.Id.text_cpin);
            TextHintResponse = FindViewById <EditText>(Resource.Id.text_hint_response);

            FAB = FindViewById <ImageButton>(Resource.Id.btn_floating_action);

            Hints = SessionManager.Hints();
            var hintsAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, Hints);

            hintsAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            SpinnerHint.Adapter = hintsAdapter;

            CheckAgree = FindViewById <CheckBox>(Resource.Id.checkbox_confirm);
            InitHandlers();
            Title = "Add PIN";
        }
Example #6
0
        public void CreateLocalNotification(string titolo, string descrizione, int id, string rifordine, int idriga)
        {
            Context             ctx = Forms.Context;
            NotificationManager nm  = (NotificationManager)ctx.GetSystemService(Context.NotificationService);


            int notId = id + 9999;
            //esecuzione dell'intent
            //Yes intent
            Intent yesReceive = new Intent( );

            yesReceive.SetAction("YES_ACTION");
            Bundle yesBundle = new Bundle();

            yesBundle.PutInt("risp", 1);//This is the value I want to pass
            yesBundle.PutInt("id", id);
            yesBundle.PutString("ordine", rifordine);
            yesBundle.PutInt("idriga", idriga);
            yesReceive.PutExtras(yesBundle);
            PendingIntent pendingIntentYes = PendingIntent.GetBroadcast(ctx, notId, yesReceive, PendingIntentFlags.CancelCurrent);
            //no intent
            Intent noReceive = new Intent();

            noReceive.SetAction("NO_ACTION");
            Bundle noBundle = new Bundle();

            noBundle.PutInt("risp", 0);//This is the value I want to pass
            noBundle.PutInt("id", id);
            noReceive.PutExtras(noBundle);
            PendingIntent pendingIntentNo = PendingIntent.GetBroadcast(ctx, notId, noReceive, PendingIntentFlags.CancelCurrent);



            Android.Content.Res.Resources res = ctx.Resources;
            Bitmap bm = BitmapFactory.DecodeResource(res, FishOnLine.Droid.Resource.Drawable.icon);

            System.Text.Encoding utf8 = System.Text.Encoding.UTF8;
            System.Text.Encoding iso  = System.Text.Encoding.GetEncoding("ISO-8859-1");
            string msg = iso.GetString(utf8.GetBytes(descrizione));

            NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx)
                                                 .SetPriority(NotificationCompat.PriorityMax)
                                                 .SetAutoCancel(true)
                                                 .SetLargeIcon(Bitmap.CreateScaledBitmap(bm, 80, 80, false))
                                                 .SetSmallIcon(Resource.Drawable.IcDialogInfo)
                                                 .SetContentTitle(titolo)
                                                 .SetContentText(msg)
                                                 .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification))
                                                 .SetOngoing(true)
                                                 .AddAction(Resource.Drawable.IcDelete, "Cancella", pendingIntentYes)
                                                 .AddAction(Resource.Drawable.IcMenuCloseClearCancel, "Chiudi", pendingIntentNo);
            NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
            bigTextStyle.SetBigContentTitle(titolo);
            bigTextStyle.BigText(descrizione);

            builder.SetStyle(bigTextStyle);


            nm.Notify(notId, builder.Build());
        }
Example #7
0
 public BookingsListAdapter(LayoutInflater inflater, Android.Content.Res.Resources resources, bool ShowLocation)
 {
     this.inflater     = inflater;
     WorkshopList      = new List <WorkshopPreview>();
     this.resources    = resources;
     this.ShowLocation = ShowLocation;
 }
Example #8
0
        public static string GetCategoryName(Android.Content.Res.Resources res, PoiCategory category)
        {
            switch (category)
            {
            case PoiCategory.Historic:
                return(res.GetText(Resource.String.Category_Historic));

            case PoiCategory.Cities:
                return(res.GetText(Resource.String.Category_Cities));

            case PoiCategory.Other:
                return(res.GetText(Resource.String.Category_Other));

            case PoiCategory.Mountains:
                return(res.GetText(Resource.String.Category_Mountains));

            case PoiCategory.Lakes:
                return(res.GetText(Resource.String.Category_Lakes));

            case PoiCategory.ViewTowers:
                return(res.GetText(Resource.String.Category_ViewTowers));

            case PoiCategory.Transmitters:
                return(res.GetText(Resource.String.Category_Transmitters));

            case PoiCategory.Churches:
                return(res.GetText(Resource.String.Category_Churches));

            case PoiCategory.ElevationData:
                return(res.GetText(Resource.String.Category_ElevationData));

            default:
                return("Unknown category");
            }
        }
Example #9
0
        internal static void BasicInitializeApp(Context context)
        {
#if DEBUG
            isReleaseMode = false;
#endif

            //sharedPreferences = null; //Preferences.PreferenceManager.GetDefaultSharedPreferences(context);
            useLightTheme = Preferences.Get("UseLightTheme", false);// sharedPreferences.GetBoolean("UseLightTheme", false);

            SetDialogTheme();
            SetLanguage(context);

            Resources = baseContext.Resources;

            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NTE2ODY2QDMxMzkyZTMzMmUzMEVBSGh6djR3NGszRnJaUERtZVZPT3dXdGgxVDJ4WC9tKzhnOTZlc1hKNWc9");

            if (isReleaseMode)
            {
                AppCenter.Start("aca0ed39-4b25-4548-bf2a-ac92ccee2977", typeof(Analytics), typeof(Crashes));//, typeof(Push));
            }
            else
            {
                //AppCenter.Start("aca0ed39-4b25-4548-bf2a-ac92ccee2977", typeof(Push));
            }

            //sdCardPath = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
            appDataPath = FileSystem.AppDataDirectory; //baseContext.GetExternalFilesDir(null).AbsolutePath; //Path.Combine(sdCardPath, "Android", "data", "com.gfl.dic");
            tempPath    = Path.Combine(appDataPath, "GFDTemp");
            dbPath      = Path.Combine(appDataPath, "DB");
            systemPath  = Path.Combine(appDataPath, "System");
            cachePath   = Path.Combine(appDataPath, "Cache");
            logPath     = Path.Combine(systemPath, "Log");
        }
Example #10
0
 public BookingsListAdapter(LayoutInflater inflater, Android.Content.Res.Resources resources, bool ShowLocation)
 {
     this.inflater = inflater;
     WorkshopList = new List<WorkshopPreview>();
     this.resources = resources;
     this.ShowLocation = ShowLocation;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Context context = this;

            Android.Content.Res.Resources res = context.Resources;
            SessionManager.SetLocale(res);

            SetContentView(Resource.Layout.language_options);
            BtnEnglish = FindViewById <RadioButton>(Resource.Id.ChkEnglish);
            BtnShona   = FindViewById <RadioButton>(Resource.Id.ChkShona);
            BtnNdebele = FindViewById <RadioButton>(Resource.Id.ChkNdebele);

            Title = res.GetString(Resource.String.select_language);
            FindViewById <ImageButton>(Resource.Id.btn_floating_action).Click += (o, ev) =>
            {
                if (BtnEnglish.Checked == true)
                {
                    SessionManager.LanguageCodevalue = "en";
                }
                if (BtnShona.Checked == true)
                {
                    SessionManager.LanguageCodevalue = "sh";
                }
                if (BtnNdebele.Checked == true)
                {
                    SessionManager.LanguageCodevalue = "nd";
                }
                SetResult(Result.Ok);
                Finish();
                OverridePendingTransition(Resource.Animation.side_in_right, Resource.Animation.side_out_left);
            };
        }
Example #12
0
        private int dipToPixels(int dip)
        {
            Android.Content.Res.Resources r = Resources;
            float px = TypedValue.ApplyDimension(ComplexUnitType.Dip, dip, r.DisplayMetrics);

            return((int)px);
        }
Example #13
0
        public static PictureBitmapDrawable GetDrawable(Android.Content.Res.Resources resources,
                                                        int resID,
                                                        ISvgColorMapper colorMapper = null)
        {
            var svg = SVGParser.ParseSVGFromResource(resources, resID, colorMapper);

            return(new PictureBitmapDrawable(svg.Picture));
        }
Example #14
0
        public static Bitmap GetBitmap(Android.Content.Res.Resources resources,
                                       int resID,
                                       int width, int height,
                                       ISvgColorMapper colorMapper = null)
        {
            var svg = SVGParser.ParseSVGFromResource(resources, resID, colorMapper);

            return(MakeBitmapFromSvg(svg, width, height));
        }
Example #15
0
File: ETC.cs Project: URK96/TSGPDic
        internal static void BasicInitializeApp(Activity context)
        {
            sharedPreferences = PreferenceManager.GetDefaultSharedPreferences(context);
            Resources         = context.Resources;

            CheckInitFolder();
            //SetDialogTheme();
            //Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("NTQzNDRAMzEzNjJlMzQyZTMwZHNFSDUyRjdlWXZ6WXNtelNkRWV3QVh1WmR0Q3hSbTFqZ0dKTTVsQlBOQT0=");
        }
        private void SetLabel()
        {
            Context context = this;

            Android.Content.Res.Resources res = context.Resources;
            string recordTable = this.Resources.GetString(Resource.String.statisticsText);

            this.Title = recordTable;
        }
Example #17
0
 public static BitmapDrawable GetBackgroung(Android.Content.Res.Resources resources, float width, float height)
 {
     using (var bitmap = Bitmap.CreateBitmap((int)width, (int)height, Bitmap.Config.Argb4444))
         using (var canvas = new Canvas(bitmap))
         {
             var background = new DrawStatistics(canvas);
             background.DrawBackground(6, 6, Paints.Background, Paints.Border, Paints.Gradient);
             return(new BitmapDrawable(resources, bitmap));
         }
 }
Example #18
0
 public static RelativeLayout.LayoutParams ButtonLayoutParams(Android.Content.Res.Resources r)
 {
     RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
     layoutParams.AddRule(LayoutRules.CenterVertical);
     layoutParams.LeftMargin  = (int)r.GetDimension(Resource.Dimension.action_bar_button_left_margin);
     layoutParams.RightMargin = (int)r.GetDimension(Resource.Dimension.action_bar_button_right_margin);
     layoutParams.Height      = (int)r.GetDimension(Resource.Dimension.action_bar_button_height);
     layoutParams.Width       = (int)r.GetDimension(Resource.Dimension.action_bar_button_width);
     return(layoutParams);
 }
Example #19
0
        void SendNotification(RemoteMessage message)
        {
            try
            {
                var intent = new Intent(this, typeof(MainActivity));
                intent.AddFlags(ActivityFlags.ClearTop);

                foreach (var item in message.Data)
                {
                    if (item.Key == "Id")
                    {
                        intent.PutExtra("Id", item.Value);
                    }
                    if (item.Key == "Type")
                    {
                        intent.PutExtra("Type", item.Value);
                    }
                    if (item.Key == "GroupId")
                    {
                        intent.PutExtra("GroupId", item.Value);
                    }
                }


                var     pendingIntent             = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot);
                Context context                   = this;
                Android.Content.Res.Resources res = context.Resources;
                Bitmap aBitmap = BitmapFactory.DecodeResource(res, Resource.Drawable.Splash);

                // Instantiate the Image (Big Picture) style:
                Notification.BigPictureStyle picStyle = new Notification.BigPictureStyle();
                // Convert the image to a bitmap before passing it into the style:
                picStyle.BigPicture(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Splash));
                picStyle.SetSummaryText("Test");

                var notificationBuilder = new Notification.Builder(this)
                                          .SetLargeIcon(aBitmap)
                                          //.SetFullScreenIntent(pendingIntent, true)
                                          .SetSmallIcon(Resource.Drawable.icon)
                                          .SetContentTitle(message.GetNotification().Title)
                                          .SetContentText(message.GetNotification().Body)
                                          .SetAutoCancel(true)
                                          .SetStyle(picStyle)
                                          .SetDefaults(NotificationDefaults.Vibrate | NotificationDefaults.Sound)
                                          .SetContentIntent(pendingIntent);

                var notificationManager = NotificationManager.FromContext(this);
                notificationManager.Notify(0, notificationBuilder.Build());
            }
#pragma warning disable CS0168 // The variable 'ex' is declared but never used
            catch (Exception ex)
#pragma warning restore CS0168 // The variable 'ex' is declared but never used
            {
            }
        }
Example #20
0
        public Helperlanguage(string language, Context context)
        {
            Android.Content.Res.Resources res = context.Resources;

            string recordTable = res.GetString(Resource.String.EnOk);

            if (language == "English")
            {
                _ok             = res.GetString(Resource.String.EnOk);
                _cancel         = res.GetString(Resource.String.EnCancel);
                _startGame      = res.GetString(Resource.String.EnStartGame);
                _setBet         = res.GetString(Resource.String.EnSetBet);
                _stand          = res.GetString(Resource.String.EnStand);
                _getCard        = res.GetString(Resource.String.EnGetCard);
                _doubleBet      = res.GetString(Resource.String.EnDoubleBet);
                _continue       = res.GetString(Resource.String.EnContinue);
                _balance        = res.GetString(Resource.String.EnBalance);
                _bet            = res.GetString(Resource.String.EnBet);
                _chooseLanguage = res.GetString(Resource.String.EnChooseLanguage);
                _textViewLang   = res.GetString(Resource.String.EntextViewLang);
                _incorrectBet   = res.GetString(Resource.String.EnIncorrectBet);
            }
            else if (language == "Russian")
            {
                _ok             = res.GetString(Resource.String.RuOk);
                _cancel         = res.GetString(Resource.String.RuCancel);
                _startGame      = res.GetString(Resource.String.RuStartGame);
                _setBet         = res.GetString(Resource.String.RuSetBet);
                _stand          = res.GetString(Resource.String.RuStand);
                _getCard        = res.GetString(Resource.String.RuGetCard);
                _doubleBet      = res.GetString(Resource.String.RuDoubleBet);
                _continue       = res.GetString(Resource.String.RuContinue);
                _balance        = res.GetString(Resource.String.RuBalance);
                _bet            = res.GetString(Resource.String.RuBet);
                _chooseLanguage = res.GetString(Resource.String.RuChooseLanguage);
                _textViewLang   = res.GetString(Resource.String.RutextViewLang);
                _incorrectBet   = res.GetString(Resource.String.RuIncorrectBet);
            }
            else
            {
                _ok             = res.GetString(Resource.String.UkOk);
                _cancel         = res.GetString(Resource.String.UkCancel);
                _startGame      = res.GetString(Resource.String.UkStartGame);
                _setBet         = res.GetString(Resource.String.UkSetBet);
                _stand          = res.GetString(Resource.String.UkStand);
                _getCard        = res.GetString(Resource.String.UkGetCard);
                _doubleBet      = res.GetString(Resource.String.UkDoubleBet);
                _continue       = res.GetString(Resource.String.UkContinue);
                _balance        = res.GetString(Resource.String.UkBalance);
                _bet            = res.GetString(Resource.String.UkBet);
                _chooseLanguage = res.GetString(Resource.String.UkChooseLanguage);
                _textViewLang   = res.GetString(Resource.String.UktextViewLang);
                _incorrectBet   = res.GetString(Resource.String.UkIncorrectBet);
            }
        }
 public static Bitmap GetBitmapFromResource(Android.Content.Res.Resources res, int resourceId)
 {
     try
     {
         return(BitmapFactory.DecodeResource(res, resourceId));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #22
0
 public MainAdapter(
     Android.Content.Res.Resources resources,
     Action <Guid> onExecuted,
     Action <Guid, Dictionary <int, bool> > setRestingCycle,
     Action <Guid> onPause,
     Action <Guid> onActivated)
 {
     this.resources       = resources;
     OnExecuted           = onExecuted;
     this.setRestingCycle = setRestingCycle;
     this.onPause         = onPause;
     this.onActivated     = onActivated;
 }
Example #23
0
        public static View getFlowersView(View givenView, Android.Content.Res.Resources Resources)
        {
            var gridView2 = givenView.FindViewById <GridView>(Resource.Id.gridView2);

            gridView2.Adapter    = new Adapters.GridviewAdapters.flowerGridviewAdapter(givenView.Context);
            gridView2.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs args)
            {
                int id = (int)args.Id;
                ViewCreaters.processView.setFlowers(BitmapFactory.DecodeResource(Resources, id));
                Toast.MakeText(givenView.Context, "Flower has been selected!", ToastLength.Short).Show();
            };
            return(givenView);
        }
Example #24
0
        public Bitmap drawTextToBitmap(Photo photo)
        {
            Android.Content.Res.Resources resources = context.Resources;
            BitmapFactory.Options         options   = new BitmapFactory.Options();
            options.InScaled = false;
            Bitmap bitmap = BitmapFactory.DecodeResource(resources, photo.mPhotoID, options);

            try
            {
                float         scale        = resources.DisplayMetrics.Density;
                Bitmap.Config bitmapConfig = bitmap.GetConfig();
                // set default bitmap config if none
                if (bitmapConfig == null)
                {
                    bitmapConfig = Bitmap.Config.Argb8888;
                }
                // resource bitmaps are imutable,
                // so we need to convert it to mutable one
                bitmap = bitmap.Copy(bitmapConfig, true);
                Console.WriteLine("Height:" + bitmap.Height + " Width:" + bitmap.Width);
                Canvas canvas = new Canvas(bitmap);
                Console.WriteLine("Canvas Height:" + canvas.Height + " Width:" + canvas.Width);
                TextPaint mTextPaint = new TextPaint(PaintFlags.AntiAlias);
                mTextPaint.Color = Color.ParseColor(photo.Hex);
                mTextPaint.SetTypeface(Typeface.Create(Typeface.DefaultBold, TypefaceStyle.Bold));
                int size = 30;
                mTextPaint.TextSize = ((int)(size * scale));
                StaticLayout mTextLayout = new StaticLayout(TrophyName, mTextPaint, (int)photo.W, Layout.Alignment.AlignCenter, 1.0f, 0.0f, false);
                while (true)
                {
                    if (mTextLayout.Height > photo.H)
                    {
                        mTextPaint.TextSize = (((size--) * scale));
                        mTextLayout         = new StaticLayout(TrophyName, mTextPaint, (int)photo.W, Layout.Alignment.AlignCenter, 1.0f, 0.0f, false);
                    }
                    else
                    {
                        break;
                    }
                }
                canvas.Save();
                canvas.Translate(photo.X, photo.Y + (photo.H - mTextLayout.Height) / 2);
                mTextLayout.Draw(canvas);
                canvas.Restore();
            }
            catch (Exception e)
            {
                Console.WriteLine("Bitmap Text Merge Exception:" + e.ToString());
            }
            return(bitmap);
        }
Example #25
0
        private static void PrepareResources(Context context)
        {
            if (mMetrics != null)
            {
                return;
            }
            mMetrics = new Android.Util.DisplayMetrics();
            Activity act = (Activity)context;

            act.WindowManager.DefaultDisplay.GetMetrics(mMetrics);
            var mgr = context.Assets;

            mResources = new Android.Content.Res.Resources(mgr, mMetrics, context.Resources.Configuration);
        }
Example #26
0
            public Bitmap decodeSampledBitmapFromResource(Android.Content.Res.Resources res, int resId, int reqWidth, int reqHeight)
            {
                // First decode with inJustDecodeBounds=true to check dimensions
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.InJustDecodeBounds = true;
                BitmapFactory.DecodeResource(res, resId, options);

                // Calculate inSampleSize
                options.InSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

                // Decode bitmap with inSampleSize set
                options.InJustDecodeBounds = false;
                return(BitmapFactory.DecodeResource(res, resId, options));
            }
Example #27
0
        public static Bitmap GetBitmapFromSvgRes(Android.Content.Res.Resources resources, int resID,
                                                 int width, int height)
        {
            var svg = SVGParser.ParseSVGFromResource(resources,
                                                     resID);
            var bmp = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);

            using (var c = new Canvas(bmp)) {
                var dst = new RectF(0, 0, width, height);
                c.DrawPicture(svg.Picture, dst);
            }
            // Returns an immutable copy
            return(Bitmap.CreateBitmap(bmp));
        }
Example #28
0
        public static ListView CreateListView(string header, LinearLayout rootView, Android.Content.Res.Resources res, LayoutInflater inflater)
        {
            var listView      = inflater.Inflate(Resource.Layout.MyGamesListView, null) as ListView;
            var myGamesHeader = inflater.Inflate(Resource.Layout.GamesListDividerItem, null);

            myGamesHeader.FindViewById <TextView> (Resource.Id.textView1).Text = header;
            listView.AddHeaderView(myGamesHeader);

            rootView.AddView(listView);
            var margin = 10.0 * res.DisplayMetrics.Density;

            ((LinearLayout.LayoutParams)listView.LayoutParameters).SetMargins(0, 0, 0, (int)margin);

            return(listView);
        }
Example #29
0
        /// <summary>
        /// 获取图片数据流
        /// </summary>
        /// <param name="res"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <byte[]> GetImageByte(Android.Content.Res.Resources res, int id)
        {
            int    maxWidth = GetDrawableMaxWidth();
            Bitmap image    = ScalingBitmap(res, id, maxWidth);

            if (image == null)
            {
                return(null);
            }

            List <byte[]> data = PrinterUtils.DecodeBitmapToDataList(image, heightParting);

            image.Recycle();
            return(data);
        }
Example #30
0
        /// <summary>
        /// OnLocationChanged
        /// </summary>
        /// <param name="location"></param>
        public void OnLocationChanged(Location location)
        {
            try
            {
                double lat = location.Latitude;
                double lon = location.Longitude;

                _lat.Text = lat.ToString();
                _lon.Text = lon.ToString();

                GeoCoordinate currentloc = new GeoCoordinate(lat, lon);

                foreach (KeyValuePair <string, Loc> v in _storeLocations)
                {
                    GeoCoordinate storelocation = new GeoCoordinate(v.Value.Latitude, v.Value.Longitude);
                    double        distance      = currentloc.GetDistanceTo(storelocation);
                    _distanceTo.Text = distance.ToString();

                    Context context = this;
                    Android.Content.Res.Resources res = context.Resources;
                    string minRadius = res.GetString(Resource.String.minRadiusinMeters);

                    if (distance < Convert.ToInt16(minRadius))
                    {
                        var tescoPromo = GetOffers(urlGetOffers, _deviceId, v.Key, false);

                        List <string> soffers = tescoPromo.Select(e => e.Promotion).ToList();

                        if (soffers.Count != 0)
                        {
                            new AlertDialog.Builder(this)
                            .SetMessage("You have " + soffers.Count + " in hand!...")
                            .SetNeutralButton("Ok", delegate { }).Show();
                        }

                        new AlertDialog.Builder(this)
                        .SetMessage("Hey you are near to store, happy shopping!..")
                        .SetNeutralButton("Ok", delegate { }).Show();
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this)
                .SetMessage("Location Changed **culprit** " + ex.Message).Show();
            }
        }
Example #31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Context context = this;

            // Get the Resources object from our context
            Android.Content.Res.Resources res = context.Resources;
            SetContentView(Resource.Layout.register);
            string sott = Intent.GetStringExtra("sott") ?? "please-go-back-and-put-sott-value";

            apikey          = res.GetString(Resource.String.apikey);
            verificationurl = res.GetString(Resource.String.verificationurl);

            EditText email     = FindViewById <EditText>(Resource.Id.email);
            EditText password  = FindViewById <EditText>(Resource.Id.password);
            EditText FirstName = FindViewById <EditText>(Resource.Id.firstname);
            EditText LastName  = FindViewById <EditText>(Resource.Id.lastname);

            email.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                emiltext = e.Text.ToString();
            };
            password.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                passwordtext = e.Text.ToString();
            };
            FirstName.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                FirstNametext = e.Text.ToString();
            };
            LastName.TextChanged += (object sender, Android.Text.TextChangedEventArgs e) => {
                LastNametext = e.Text.ToString();
            };
            Button register = FindViewById <Button>(Resource.Id.register);

            register.Click += delegate
            {
                UserIdentityCreateModel user = new UserIdentityCreateModel();
                user.FirstName = FirstNametext;
                user.LastName  = LastNametext;
                user.Password  = passwordtext;

                Email email1 = new Email();
                email1.Type  = "Primary";
                email1.Value = emiltext;
                user.Email   = new List <Email>();
                user.Email.Add(email1);
                GetUserRegistrationbyEmail(apikey, sott, verificationurl, user);
            };
        }
Example #32
0
		private static void PrepareResources(Context context) 
		{
	        if (mMetrics != null)
	            return;
			mMetrics = new Android.Util.DisplayMetrics();
	        Activity act = (Activity)context;
			act.WindowManager.DefaultDisplay.GetMetrics(mMetrics);
			var mgr = context.Assets;
	        mResources = new Android.Content.Res.Resources(mgr, mMetrics, context.Resources.Configuration);
	    }
 public MyOutlineProvider (Android.Content.Res.Resources res, FabSize size)
 {
   this.res = res;
   this.fabSize = size;
 }