Esempio n. 1
3
 static void DrawCode(string code, ImageView barcode)
 {
     var writer = new BarcodeWriter
     {
         Format = BarcodeFormat.CODE_39,
         Options = new EncodingOptions
         {
             Height = 200,
             Width = 600
         }
     };
     var bitmap = writer.Write(code);
     Drawable img = new BitmapDrawable(bitmap);
     barcode.SetImageDrawable(img);
 }
        public override void SetValue(object value)
        {
            var imageView = ImageView;
            if (imageView == null)
            {
                // weak reference is garbage collected - so just return
                return;
            }

            try
            {
                var assetStream = GetStream(value);
                if (assetStream == null)
                    return;

                var options = new BitmapFactory.Options {InPurgeable = true};
                var bitmap = BitmapFactory.DecodeStream(assetStream, null, options);
                var drawable = new BitmapDrawable(Resources.System, bitmap);
                imageView.SetImageDrawable(drawable);
            }
            catch (Exception ex)
            {
                MvxTrace.Error(ex.ToLongString());
                throw;
            }
        }
Esempio n. 3
0
        //protected override void OnSizeChanged(int w, int h, int oldw, int oldh)
        //{
        //    base.OnSizeChanged(w, h, oldw, oldh);
        //    mX = w * 0.5f; // remember the center of the screen
        //}

        public Drawable ResizeBitmap(Bitmap bitmapOrg, int desiredWidth, int desiredHeight)
        {
            try
            {
                int width     = bitmapOrg.Width;
                int height    = bitmapOrg.Height;
                int newWidth  = desiredWidth;
                int newHeight = desiredHeight;

                // calculate the scale - in this case = 0.4f
                float scaleWidth  = ((float)newWidth) / width;
                float scaleHeight = ((float)newHeight) / height;

                // createa matrix for the manipulation
                Matrix matrix = new Matrix();
                // resize the bit map
                matrix.PostScale(scaleWidth, scaleHeight);
                // rotate the Bitmap
                //matrix.PostRotate(45);

                // re*create the new Bitmap
                Bitmap resizedBitmap = Bitmap.CreateBitmap(bitmapOrg, 0, 0, width, height, matrix, true);

                // make a Drawable from Bitmap to allow to set the BitMap
                // to the ImageView, ImageButton or what ever

                Drawable bmpDraw = new Android.Graphics.Drawables.BitmapDrawable(resizedBitmap);
                return(bmpDraw);
            }
            catch (Exception ex)
            {
                //FirstLog.Error(FirstApplication.ApplicationName + "Log", "ResizeBitmap: " + ex.Message);
                return(new Android.Graphics.Drawables.BitmapDrawable(bitmapOrg));
            }
        }
			public override Android.Graphics.Drawables.Drawable GetBackgroundForPage (int row, int column)
			{
				Point pt = new Point (column, row);
				Drawable drawable;
				if (!mBackgrounds.ContainsKey(pt))
				{
					// the key wasn't found in Dictionary
					var bm = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb8888);
					var c = new Canvas(bm);
					var p = new Paint();
					// Clear previous image.
					c.DrawRect(0, 0, 200, 200, p);
					p.AntiAlias = true;
					p.SetTypeface(Typeface.Default);
					p.TextSize = 64;
					p.Color = Color.LightGray;
					p.TextAlign = Paint.Align.Center;
					c.DrawText(column + "-" + row, 100, 100, p);
					drawable = new BitmapDrawable(owner.Resources, bm);
					mBackgrounds.Add(pt, drawable);
				}
				else
				{
					// the key was found
					drawable = mBackgrounds[pt];
				}
				return drawable;
			}
Esempio n. 5
0
        private string ImageViewToBase64String(ImageView obj)
        {
            Android.Graphics.Drawables.BitmapDrawable bd1 = (Android.Graphics.Drawables.BitmapDrawable)obj.Drawable;
            Bitmap bitmap = bd1.Bitmap;

            if (bitmap.Height > 1000 || bitmap.Width > 1000)
            {
                if (bitmap.Height > bitmap.Width)
                {
                    int newWidth = Convert.ToInt32((double)bitmap.Width / (double)bitmap.Height * 1000.0);
                    if (newWidth > 0)
                    {
                        bitmap = Bitmap.CreateScaledBitmap(bitmap, newWidth, 1000, true);
                    }
                }
                else
                {
                    int newHeight = Convert.ToInt32((double)bitmap.Height / (double)bitmap.Width * 1000.0);
                    if (newHeight > 0)
                    {
                        bitmap = Bitmap.CreateScaledBitmap(bitmap, 1000, newHeight, true);
                    }
                }
            }
            MemoryStream ms = new MemoryStream();

            bitmap.Compress(CompressFormat.Png, 100, ms);
            byte[] bb = ms.ToArray();
            return(Convert.ToBase64String(bb));
        }
Esempio n. 6
0
        // Get a bitmap drawable from a local file that is scaled down
        // to fit the current window size
        public static BitmapDrawable GetScaledDrawable(Activity a, string path)
        {
            Display display = a.WindowManager.DefaultDisplay;
            float destWidth = display.Width;
            float destHeight = display.Height;

            // Read in the dimensions of the image on disk
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InJustDecodeBounds = true;
            BitmapFactory.DecodeFile(path, options);

            float srcWidth = options.OutWidth;
            float srcHeight = options.OutHeight;

            double inSampleSize = 1.0;
            if (srcHeight > destHeight || srcWidth > destWidth) {
                if (srcWidth > srcHeight) {
                    inSampleSize = Math.Round(srcHeight / destHeight);
                }
                else {
                    inSampleSize = Math.Round(srcWidth / destWidth);
                }
            }

            options = new BitmapFactory.Options();
            options.InSampleSize = (int)inSampleSize;

            Bitmap bitmap = BitmapFactory.DecodeFile(path, options);
            var bDrawable= new BitmapDrawable(a.Resources, bitmap);
            bitmap = null;

            return bDrawable;
        }
        private void HighContrast(ImageView imageoutput)
        {
            Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageoutput.Drawable;
            Android.Graphics.Bitmap bitmap = bd.Bitmap;

            if (bitmap != null)
            {
                Android.Graphics.Bitmap copyBitmap = bitmap.Copy(Android.Graphics.Bitmap.Config.Argb8888, true);
                for (int i = 0; i < bitmap.Width; i++)
                {
                    for (int j = 0; j < bitmap.Height; j++)
                    {
                        int p = bitmap.GetPixel(i, j);
                        Android.Graphics.Color c = new Android.Graphics.Color(p);

                        c.R = (byte)(ContrastPixelValue(c.R));
                        c.G = (byte)(ContrastPixelValue(c.G));
                        c.B = (byte)(ContrastPixelValue(c.B));

                        copyBitmap.SetPixel(i, j, c);
                    }
                }
                if (copyBitmap != null)
                {
                    imageoutput.SetImageBitmap(copyBitmap);
                    bitmap     = null;
                    copyBitmap = null;
                }
                System.GC.Collect();
            }
        }
 public Android.Graphics.Drawables.Drawable GetDrawable(string source)
 {
     byte[] data = Convert.FromBase64String(source.Substring(source.IndexOf(",") + 1));
     Bitmap bitmap = BitmapFactory.DecodeByteArray(data, 0, data.Length);
     BitmapDrawable brawable = new BitmapDrawable(bitmap);
     brawable.SetBounds(0, 0, bitmap.Width, bitmap.Height);
     return brawable;
 }
Esempio n. 9
0
		public FFBitmapDrawable(Resources res, Bitmap bitmap, BitmapDrawable placeholder, float fadingTime, bool fadeEnabled)
			: base(res, bitmap)
		{
			_placeholder = placeholder;
			_fadingTime = fadingTime;
			_animating = fadeEnabled;
			_startTimeMillis = SystemClock.UptimeMillis();
		}
        public static Drawable ToDrawableFromBase64(this string base64Image)
        {
            byte[] image = System.Convert.FromBase64String(base64Image);
            BitmapDrawable drawable = null;
            drawable = new BitmapDrawable(BitmapFactory.DecodeByteArray(image, 0, (int)image.Length));

            return drawable;
        }
Esempio n. 11
0
		public static int GetBitmapSize(BitmapDrawable bmp)
		{
			if (Utils.HasKitKat())
				return bmp.Bitmap.AllocationByteCount;

			if (Utils.HasHoneycombMr1())
				return bmp.Bitmap.ByteCount;

			return bmp.Bitmap.RowBytes*bmp.Bitmap.Height;
		}
 private void ButtonAddNew_Click(object sender, EventArgs e)
 {
     //Decode bitmap
     Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageViewMain.Drawable;
     Android.Graphics.Bitmap bitmap = bd.Bitmap;
     //Clicked add new address, broadcast the event
     OnAddNewAddressComplete.Invoke(this, new OnAddNewAddress(editAddressLine.Text, editCity.Text, editState.Text, editZipCode.Text, editDesc.Text, bitmap));
     //dismiss diaglog fragment
     this.Dismiss();
 }
 public void SetPlaceholder(SelfDisposingBitmapDrawable drawable, int animationDuration)
 {
     if (!animating)
     {
         alpha = 255;
         fadeDuration = animationDuration;
         startTimeMillis = SystemClock.UptimeMillis();
         placeholder = drawable.GetConstantState().NewDrawable() as BitmapDrawable;
         animating = true;
     }
 }
Esempio n. 14
0
            private void HandleFileLoaded(CacheValue value, BitmapType bitmap)
            {
                var pending = value.GetPendingCallbacks();

                if (null != pending)
                {
                    handler.Post(() => {
                        // notify from GUI thread
                        pending(bitmap);
                    });
                }
            }
Esempio n. 15
0
            public async void DownloadImageAsync(string url, int?maxWidth, int?maxHeight, Action <BitmapType> callbackOnUiThread, OutBitmap outCachedResult = null)
            {
                Contract.Requires(!String.IsNullOrEmpty(url));

                CacheFile  file;
                CacheValue value;

                lock (this) {
                    if (!cachedFiles.TryGetValue(url, out file))
                    {
                        file = new CacheFile(url, this.CachePath);

                        cachedFiles [url] = file;
                    }
                    else
                    {
                        Logger.Trace("Cached file is already present, url={0}", url);
                    }

                    // create a custom bitmap loader key
                    CacheKey key = new CacheKey(url, maxWidth == null ? -1 : (int)maxWidth, maxHeight == null ? -1 : (int)maxHeight);

                    if (!cachedBitmaps.TryGetValue(key, out value))
                    {
                        value = new CacheValue(key);

                        cachedBitmaps [key] = value;
                    }
                    else
                    {
                        Logger.Trace("Cached bitmap key is already present, url={0}", url);

                        BitmapType existingBitmap = value.Bitmap;
                        if (null != existingBitmap)
                        {
                            if (null != outCachedResult)
                            {
                                Logger.Trace("Cached bitmap shortcircuited result, url={0}", url);

                                outCachedResult.Bitmap = existingBitmap;
                                return;
                            }
                        }
                    }

                    file.AddToNotifyList(value);
                    value.NotifyOnceReady(callbackOnUiThread);
                }

                await file.Download(HandleDownloaded);
            }
Esempio n. 16
0
		public void ini(){

			var textFormat = Android.Util.ComplexUnitType.Px;

			mainLayout = new RelativeLayout (context);
			mainLayout.LayoutParameters = new RelativeLayout.LayoutParams (-1,-1);

			Drawable d = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/fondo.png"), 1024, 768, true));
			mainLayout.SetBackgroundDrawable (d);


			title = new TextView (context);
			imgLinea = new ImageView (context);
			listNotification = new ListView (context);
			linearList = new LinearLayout (context);
			imgPoint = new ImageView (context);


			title.Text = "Notificaciones";
			title.Typeface =  Typeface.CreateFromAsset(context.Assets, "fonts/HelveticaNeue.ttf");
			title.SetTextColor (Color.ParseColor ("#ffffff"));
			title.SetTextSize (textFormat, Configuration.getHeight (48));
			title.SetX (Configuration.getHeight (35));
			title.SetY (Configuration.getWidth (142));

			linearList.SetBackgroundColor (Color.ParseColor ("#ffffff"));
			linearList.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight (886));
			linearList.SetX (Configuration.getWidth (0));	linearList.SetY (Configuration.getHeight(250));

			listNotification.SetX (Configuration.getWidth (0));	listNotification.SetY (Configuration.getHeight(250));
			listNotification.LayoutParameters = new LinearLayout.LayoutParams(-1, Configuration.getHeight (886));

			imgLinea.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/lineanotificaciones.png"), 4,2000 , true));
			imgLinea.SetX (Configuration.getWidth (61));	imgLinea.SetY (Configuration.getHeight(240));

			imgPoint.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/circblanco.png"), 30,30 , true));
			imgPoint.SetX (Configuration.getWidth (52));	imgPoint.SetY (Configuration.getHeight(228));

			//linearList.AddView (listNotification);


			mainLayout.AddView (title);

			mainLayout.AddView(linearList);
			mainLayout.AddView (listNotification);
			mainLayout.AddView (imgLinea);
			mainLayout.AddView (imgPoint);


		}
Esempio n. 17
0
		void showAd(int idAd)
		{
			adOpen = true;
			_adLayout = new LinearLayout (context);
			_adLayout.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight (255));
			Drawable dr = new BitmapDrawable (getBitmapFromAsset (adsImagesPath[idAd]));
			_adLayout.SetBackgroundDrawable (dr);
			_adLayout.SetY (Configuration.getHeight(1136-85-255));
			_mainLayout.AddView (_adLayout);

			_adLayout.Click += delegate {
				context.StartActivity(Configuration.getOpenFacebookIntent(context,"fb://page/114091405281757","http://www.hi-tec.com/pe/"));
			};
		}
        /// <summary>
        /// Sets the image source.
        /// </summary>
        /// <param name="targetButton">The target button.</param>
        /// <param name="model">The model.</param>
        /// <returns>A <see cref="Task"/> for the awaited operation.</returns>
        private async Task SetImageSourceAsync(Android.Widget.Button targetButton, ImageButton model)
        {
            const int Padding = 10;
            var source = model.IsEnabled ? model.Source : model.DisabledSource ?? model.Source;

            using (var bitmap = await this.GetBitmapAsync(source))
            {
                if (bitmap != null)
                {
                    var drawable = new BitmapDrawable(bitmap);
                    var tintColor = model.IsEnabled ? model.ImageTintColor : model.DisabledImageTintColor;
                    if (tintColor != Xamarin.Forms.Color.Transparent)
                    {
                        drawable.SetTint(tintColor.ToAndroid());
                        drawable.SetTintMode(PorterDuff.Mode.SrcIn);
                    }

                    var scaledDrawable = GetScaleDrawable(drawable, GetWidth(model.ImageWidthRequest),
                        GetHeight(model.ImageHeightRequest));

                    Drawable left = null;
                    Drawable right = null;
                    Drawable top = null;
                    Drawable bottom = null;
                    targetButton.CompoundDrawablePadding = Padding;
                    switch (model.Orientation)
                    {
                        case ImageOrientation.ImageToLeft:
                            targetButton.Gravity = GravityFlags.Left | GravityFlags.CenterVertical;
                            left = scaledDrawable;
                            break;
                        case ImageOrientation.ImageToRight:
                            targetButton.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
                            right = scaledDrawable;
                            break;
                        case ImageOrientation.ImageOnTop:
                            top = scaledDrawable;
                            break;
                        case ImageOrientation.ImageOnBottom:
                            bottom = scaledDrawable;
                            break;
                    }

                    targetButton.SetCompoundDrawables(left, top, right, bottom);
                }
            }
        }
Esempio n. 19
0
                public void HandleDownloaded(BitmapType bitmap)
                {
                    ViewHolder holder = (ViewHolder)binding;

                    if (this != holder.CurrentDownloader)
                    {
                        Logger.Trace("ContactsAdapter original view is no longer bound");
                        return;
                    }

                    if (null == bitmap)
                    {
                        holder.AvatarImageView.SetImageDrawable(holder.OriginalEmptyAvatarDrawable);
                        return;
                    }

                    UseBitmap(holder, bitmap);
                }
Esempio n. 20
0
                public void HandleDownloaded(BitmapType bitmap)
                {
                    DataViewHolder holder = (DataViewHolder)binding;

                    if (this != holder.CurrentDownloader)
                    {
                        Logger.Trace("ChatAdapter original view is no longer bound");
                        return;
                    }
                    object temp = bitmap;

                    if (bitmap is Drawable)
                    {
                        holder.AvatarImageView.SetImageDrawable((Drawable)temp);
                    }
                    else
                    {
                        holder.AvatarImageView.SetImageBitmap((Bitmap)temp);
                    }
                }
Esempio n. 21
0
		public override void Draw(Canvas canvas)
		{
			try 
			{
                if (!IsBitmapDrawableValid(this))
                    return;

				if (!_animating)
				{
					base.SetAlpha(_alpha);
					base.Draw(canvas);
				}
				else
				{
					var uptime = SystemClock.UptimeMillis();
					float normalized = (uptime - _startTimeMillis) / _fadingTime;
					if (normalized >= 1f)
					{
						_animating = false;
						_placeholder = null;
						base.Draw(canvas);
					}
					else
					{
                        if (IsBitmapDrawableValid(_placeholder))
						{
							_placeholder.Draw(canvas);	
						}

						int partialAlpha = (int)(_alpha * normalized);
						base.SetAlpha(partialAlpha);
						base.Draw(canvas);
						base.SetAlpha(_alpha);
					}
				}
			} 
			catch (Exception ex)
			{
                ImageService.Instance.Config.Logger?.Error("FFBitmapDrawable Draw", ex);
			}
		}
Esempio n. 22
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// set our layout to be the home screen
			SetContentView(Resource.Layout.NotasScreen);

			//Find our controls
			mainLayout = FindViewById<LinearLayout>(Resource.Id.LayoutAllNotas);
			taskListView = new ListView(this);
			taskListView.LayoutParameters = new LinearLayout.LayoutParams (-1,-1);
			//addTaskButton = FindViewById<Button> (Resource.Id.AddButton);

			// wire up add task button handler
			/*if(addTaskButton != null) {
				addTaskButton.Click += (sender, e) => {
					StartActivity(typeof(NotasItemScreen));
				};
			}*/

			// wire up task click handler
			if(taskListView != null) {
				taskListView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
					var taskDetails = new Intent (this, typeof (NotasItemScreen));
					taskDetails.PutExtra ("TaskID", tasks[e.Position].ID);
					StartActivity (taskDetails);
					Finish();
				};
			}

			Drawable dr = new BitmapDrawable (getBitmapFromAsset("images/header5.png"));
			header = new LinearLayout(this);
			header.LayoutParameters = new LinearLayout.LayoutParams (-1,Configuration.getHeight(125));
			header.Orientation = Orientation.Vertical;

			header.SetBackgroundDrawable (dr);


			mainLayout.AddView(header);
			mainLayout.AddView (taskListView);
		}
        /// <summary>
        /// Sets the image source.
        /// </summary>
        /// <param name="targetButton">The target button.</param>
        /// <param name="model">The model.</param>
        /// <returns>A <see cref="Task"/> for the awaited operation.</returns>
        private async Task SetImageSourceAsync(Android.Widget.Button targetButton, Labs.Controls.ImageButton model)
        {
            const int Padding = 10;
            var source = model.Source;

            using (var bitmap = await this.GetBitmapAsync(source))
            {
                if (bitmap != null)
                {
                    Drawable drawable = new BitmapDrawable(bitmap);
                    var scaledDrawable = GetScaleDrawable(drawable, GetWidth(model.ImageWidthRequest),
                        GetHeight(model.ImageHeightRequest));

                    Drawable left = null;
                    Drawable right = null;
                    Drawable top = null;
                    Drawable bottom = null;
                    targetButton.CompoundDrawablePadding = Padding;
                    switch (model.Orientation)
                    {
                        case ImageOrientation.ImageToLeft:
                            targetButton.Gravity = GravityFlags.Left | GravityFlags.CenterVertical;
                            left = scaledDrawable;
                            break;
                        case ImageOrientation.ImageToRight:
                            targetButton.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
                            right = scaledDrawable;
                            break;
                        case ImageOrientation.ImageOnTop:
                            top = scaledDrawable;
                            break;
                        case ImageOrientation.ImageOnBottom:
                            bottom = scaledDrawable;
                            break;
                    }

                    targetButton.SetCompoundDrawables(left, top, right, bottom);
                }
            }
        }
Esempio n. 24
0
        private void RandomNoise(ImageView imageoutput)

        {
            Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageoutput.Drawable;
            Android.Graphics.Bitmap bitmap = bd.Bitmap;

            System.Random rnd = new Random();

            if (bitmap != null)
            {
                Android.Graphics.Bitmap copyBitmap = bitmap.Copy(Android.Graphics.Bitmap.Config.Argb8888, true);
                for (int i = 0; i < bitmap.Width; i++)
                {
                    for (int j = 0; j < bitmap.Height; j++)
                    {
                        int noise = rnd.Next(-7, 7);
                        int p     = bitmap.GetPixel(i, j);
                        Android.Graphics.Color c = new Android.Graphics.Color(p);
                        // int red = c.R + noise;
                        // int green = c.G + noise;
                        // int blue = c.B + noise;

                        c.R = (byte)(AdjustPixelValue(c.R + noise));
                        c.G = (byte)(AdjustPixelValue(c.G + noise));
                        c.B = (byte)(AdjustPixelValue(c.B + noise));


                        copyBitmap.SetPixel(i, j, c);
                    }
                }
                if (copyBitmap != null)
                {
                    imageoutput.SetImageBitmap(copyBitmap);
                    bitmap     = null;
                    copyBitmap = null;
                }
                System.GC.Collect();
            }
        }
Esempio n. 25
0
		public override void Draw(Canvas canvas)
		{
			try 
			{
				if (!_animating)
				{
					base.SetAlpha(_alpha);
					base.Draw(canvas);
				}
				else
				{
					var uptime = SystemClock.UptimeMillis();
					float normalized = (uptime - _startTimeMillis) / _fadingTime;
					if (normalized >= 1f)
					{
						_animating = false;
						_placeholder = null;
						base.Draw(canvas);
					}
					else
					{
						if (_placeholder != null && _placeholder.Handle != IntPtr.Zero && _placeholder.Bitmap != null 
							&& _placeholder.Handle != IntPtr.Zero && !_placeholder.Bitmap.IsRecycled)
						{
							_placeholder.Draw(canvas);	
						}

						int partialAlpha = (int)(_alpha * normalized);
						base.SetAlpha(partialAlpha);
						base.Draw(canvas);
						base.SetAlpha(_alpha);
					}
				}
			} 
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
		}
Esempio n. 26
0
            protected override void OnCreate(Bundle savedInstanceState)
            {
                imageEditor = new SfImageEditor(this);
                imageEditor.ToolbarSettings.ToolbarItemSelected += OnToolbarItemSelected;
                imageEditor.ImageSaving += ImageEditor_ImageSaving;
                imageEditor.ImageLoaded += ImageEditor_ImageLoaded;

                Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)ProfileEditor.ImageView.Drawable;
                imageEditor.Bitmap = bd.Bitmap;
                SetContentView(imageEditor);
                base.OnCreate(savedInstanceState);

                imageEditor.SetToolbarItemVisibility("Text, Shape, Brightness, Effects, Bradley Hand, Path, 3:1, 3:2, 4:3, 5:4, 16:9, Undo, Redo, Transform", false);

                // Add the custom tool bar items
                var item = new FooterToolbarItem()
                {
                    Text       = "Crop",
                    TextHeight = 20,
                };

                imageEditor.ToolbarSettings.ToolbarItems.Add(item);
            }
Esempio n. 27
0
        protected override void OnCreate(Bundle bundle)
        {
			this.Window.AddFlags(WindowManagerFlags.Fullscreen);
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.MainView);

			vm = this.ViewModel as MainViewModel;
			vm.PropertyChanged += Vm_PropertyChanged;
			loWallView = new WallView(this);
			currentIndexLO = 0;

			LinearLayout linearMainLayout = FindViewById<LinearLayout>(Resource.Id.left_drawer);

			/*scrollIndice = new ScrollView (this);
			scrollIndice.LayoutParameters = new ScrollView.LayoutParams (-1,400);
			linearContentIndice = new LinearLayout (this);
			linearContentIndice.LayoutParameters = new LinearLayout.LayoutParams (-1, 800);
			linearContentIndice.Orientation = Orientation.Vertical;
			linearContentIndice.SetBackgroundColor (Color.Red);

			scrollIndice.AddView (linearContentIndice); */


			var metrics = Resources.DisplayMetrics;
			widthInDp = ((int)metrics.WidthPixels);
			heightInDp = ((int)metrics.HeightPixels);
			Configuration.setWidthPixel (widthInDp);
			Configuration.setHeigthPixel (heightInDp);

			task = new TaskView (this);

			iniMenu ();

			mToolbar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
			SetSupportActionBar(mToolbar);
			mToolbar.SetNavigationIcon (Resource.Drawable.hamburger);

			mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
			mLeftDrawer = FindViewById<LinearLayout>(Resource.Id.left_drawer);
			mRightDrawer = FindViewById<LinearLayout>(Resource.Id.right_drawer);

			mLeftDrawer.Tag = 0;
			mRightDrawer.Tag = 1;

			frameLayout = FindViewById<FrameLayout> (Resource.Id.content_frame);

			main_ContentView = new RelativeLayout (this);
			main_ContentView.LayoutParameters = new RelativeLayout.LayoutParams (-1, -1);


			// main_ContentView.AddView (scrollIndice);
			//main_ContentView.AddView(linearContentIndice);

			LOContainerView LOContainer = new LOContainerView (this);

			//main_ContentView.AddView (LOContainer);
			//WallView wallview = new WallView(this);

			//wallview.OpenLO.Click += Lo_ImagenLO_Click;
			//lo.OpenTasks.Click += ListTasks_ItemClick;

			//wallview.OpenChat.Click += imBtn_Chat_Click;
			//wallview.OpenUnits.Click += imBtn_Units_Click;

			loWallView.OpenChat.Click += imBtn_Chat_Click;
			loWallView.OpenUnits.Click += imBtn_Units_Click;

			main_ContentView.AddView (loWallView);


			frameLayout.AddView (main_ContentView);


			RelativeLayout RL = FindViewById<RelativeLayout> (Resource.Id.main_view_relativeLayoutCL);

			Drawable dr = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/nubeactivity.png"), 768, 1024, true));
			RL.SetBackgroundDrawable (dr);

			dr = null;

			//seting up chat view content


			title_view = FindViewById<TextView> (Resource.Id.chat_view_title);


			info1= FindViewById<TextView> (Resource.Id.chat_view_info1);
			info2 = FindViewById<TextView> (Resource.Id.chat_view_info2);
			title_list = FindViewById<TextView> (Resource.Id.chat_list_title);

			mListViewChat = FindViewById<ListView> (Resource.Id.chat_list_view);

			title_view.SetX (Configuration.getWidth(74));
			title_view.SetY (Configuration.getHeight (202));

			title_view.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			title_view.SetTypeface (null, TypefaceStyle.Bold);

			info1.SetX (Configuration.getWidth (76));
			info1.SetY (Configuration.getHeight (250));
			info1.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			info2.SetX (Configuration.getWidth (76));
			info2.SetY (Configuration.getHeight (285));
			info2.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			title_list.SetX (Configuration.getWidth (76));
			title_list.SetY (Configuration.getHeight (391));

			title_list.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			title_list.SetTypeface (null, TypefaceStyle.Bold);

			mListViewChat.SetX (0);
			mListViewChat.SetY (Configuration.getHeight (440));

			//end setting



			linearMainLayout.AddView (mainLayout);

            vm.PropertyChanged += new PropertyChangedEventHandler(logout_propertyChanged);

            RegisterWithGCM();

			mDrawerToggle = new MyActionBarDrawerToggle(
				this,							//Host Activity
				mDrawerLayout,					//DrawerLayout
				Resource.String.openDrawer,		//Opened Message
				Resource.String.closeDrawer		//Closed Message
			);

			mDrawerLayout.SetDrawerListener(mDrawerToggle);
			SupportActionBar.SetHomeButtonEnabled (true);
			SupportActionBar.SetDisplayShowTitleEnabled(false);

			mDrawerToggle.SyncState();

			if (bundle != null)
			{
				if (bundle.GetString("DrawerState") == "Opened")
				{
					SupportActionBar.SetTitle(Resource.String.openDrawer);
				}

				else
				{
					SupportActionBar.SetTitle(Resource.String.closeDrawer);
				}
			}
			else
			{
				SupportActionBar.SetTitle(Resource.String.closeDrawer);
			}
				
			initListCursos ();
			iniPeoples ();
			initListTasks ();

			//main_ContentView.AddView (scrollIndice);

        }
Esempio n. 28
0
        private void NegateColor(char color, ImageView imageoutput)
        {
            //Weird hoops you gotta go through to get some bitmaps :/
            Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageoutput.Drawable;
            Android.Graphics.Bitmap bitmap = bd.Bitmap;

            Android.Graphics.Bitmap copyBitmap = bitmap.Copy(Android.Graphics.Bitmap.Config.Argb8888, true);

            if (bitmap != null)
            {
                switch (color)
                {
                case 'r':
                {
                    for (int i = 0; i < bitmap.Width; i++)
                    {
                        for (int j = 0; j < bitmap.Height; j++)
                        {
                            int p = bitmap.GetPixel(i, j);
                            Android.Graphics.Color c = new Android.Graphics.Color(p);
                            c.R = (byte)(255 - c.R);
                            copyBitmap.SetPixel(i, j, c);
                        }
                    }
                    break;
                }

                case 'g':
                {
                    for (int i = 0; i < bitmap.Width; i++)
                    {
                        for (int j = 0; j < bitmap.Height; j++)
                        {
                            int p = bitmap.GetPixel(i, j);
                            Android.Graphics.Color c = new Android.Graphics.Color(p);
                            c.G = (byte)(255 - c.G);
                            copyBitmap.SetPixel(i, j, c);
                        }
                    }
                    break;
                }

                case 'b':
                {
                    for (int i = 0; i < bitmap.Width; i++)
                    {
                        for (int j = 0; j < bitmap.Height; j++)
                        {
                            int p = bitmap.GetPixel(i, j);
                            Android.Graphics.Color c = new Android.Graphics.Color(p);
                            c.B = (byte)(255 - c.B);
                            copyBitmap.SetPixel(i, j, c);
                        }
                    }
                    break;
                }

                default:
                {
                    break;
                }
                }
                if (copyBitmap != null)
                {
                    imageoutput.SetImageBitmap(copyBitmap);
                    bitmap     = null;
                    copyBitmap = null;
                }
                System.GC.Collect();
            }
        }
Esempio n. 29
0
		private void initItems()
		{

			var textFormat = Android.Util.ComplexUnitType.Px;

			_linearContentLayout = new LinearLayout (context);
			_linearContentLayout.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
			_linearContentLayout.Orientation = Orientation.Vertical;


			List<string> title = new List<string> ();
			List<string> type = new List<string> ();
			List<string> coverImagePath = new List<string> ();
			List<string> numLikes = new List<string> ();
			List<string> numTypes = new List<string> ();

			numLikes.Add ("10");
			numLikes.Add ("10");
			numLikes.Add ("10");
			numLikes.Add ("10");

			numTypes.Add ("3");
			numTypes.Add ("7");
			numTypes.Add ("4");
			numTypes.Add ("9");

			title.Add (Resources.GetText(Resource.String.THE_ROUTES));
			title.Add (Resources.GetText(Resource.String.TOURIST_SERVICE_GUIDE));
			title.Add (Resources.GetText(Resource.String.WILDLIFE_IDENTIFICATION_GUIDE));
			title.Add (Resources.GetText(Resource.String.INCA_TRIAL_IN_NUMBERS));

			type.Add ("rutas");
			type.Add ("guias");
			type.Add ("guias");
			type.Add ("cifras");

			coverImagePath.Add ("images/fondorutas.png");
			coverImagePath.Add ("images/fondoguias.png");
			coverImagePath.Add ("images/fondovidasilvestre.png");
			coverImagePath.Add ("images/fondocaminoinca.png");

			int heightItem = Configuration.getHeight (310);

			//Bitmap likeBitmap = Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/like.png"), Configuration.getWidth (30), Configuration.getWidth (30), true);


			for (int i = 0; i < title.Count; i++) 
			{
				LinearLayout item = new LinearLayout (context);
				item.LayoutParameters = new LinearLayout.LayoutParams (-1, heightItem);
				item.Orientation = Orientation.Horizontal;
				item.SetGravity (GravityFlags.Center);

				Drawable cover = new BitmapDrawable (getBitmapFromAsset(coverImagePath[i]));
				item.SetBackgroundDrawable (cover);
				_coverImages.Add (cover);

				TextView itemTitle = new TextView (context);
				itemTitle.Text = title [i];
				itemTitle.SetTextColor (Color.ParseColor("#ffffff"));
				itemTitle.Typeface =  Typeface.CreateFromAsset(context.Assets, "fonts/ArcherMediumPro.otf");
				itemTitle.SetTextSize (ComplexUnitType.Fraction, Configuration.getHeight(45));

				LinearLayout linearTitle = new LinearLayout (context);
				linearTitle.LayoutParameters = new LinearLayout.LayoutParams(Configuration.getWidth(465),Configuration.getHeight(180));
				linearTitle.Orientation = Orientation.Vertical;
				linearTitle.SetGravity (GravityFlags.Center);

				linearTitle.AddView (itemTitle);

				ImageView iconlike = new ImageView (context);
				//iconlike.SetImageBitmap(likeBitmap);


				LinearLayout linearLike = new LinearLayout (context);
				linearLike.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
				linearLike.Orientation = Orientation.Vertical;
				linearLike.SetGravity (GravityFlags.CenterHorizontal);

				TextView txtnumLike = new TextView (context);
				txtnumLike.Text = numLikes[i];
				txtnumLike.Gravity = GravityFlags.CenterHorizontal;
				txtnumLike.SetTextColor (Color.ParseColor ("#ffffff"));


				//linearLike.AddView (iconlike);
				//linearLike.AddView (txtnumLike);


				LinearLayout linearType = new LinearLayout (context);
				linearType.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
				linearType.Orientation = Orientation.Vertical;
				linearType.SetGravity (GravityFlags.CenterHorizontal);

				TextView txtnumType = new TextView (context);
				txtnumType.Text = numTypes[i];
				txtnumType.Typeface =  Typeface.CreateFromAsset(context.Assets, "fonts/ArcherMediumPro.otf");
				txtnumType.TextSize = Configuration.getHeight (15);
				txtnumType.Gravity = GravityFlags.CenterHorizontal;
				txtnumType.SetTextColor (Color.ParseColor ("#ffffff"));

				TextView txtType = new TextView (context);
				txtType.Text = type[i];
				txtType.Typeface =  Typeface.CreateFromAsset(context.Assets, "fonts/ArcherMediumPro.otf");
				txtType.TextSize = Configuration.getHeight (15);
				txtType.Gravity = GravityFlags.CenterHorizontal;
				txtType.SetTextColor (Color.ParseColor ("#ffffff"));

				int space = Configuration.getHeight (20);

				linearLike.SetPadding (0, 0, 0, space);
				linearType.SetPadding (space, 0, 0, 0);


				linearType.AddView (txtnumType);
				linearType.AddView (txtType);







				LinearLayout linearExtraInfo = new LinearLayout (context);
				linearExtraInfo.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth(100), -2);
				linearExtraInfo.Orientation = Orientation.Vertical;
				linearExtraInfo.SetGravity (GravityFlags.CenterHorizontal);

				linearExtraInfo.AddView (linearLike);
				linearExtraInfo.AddView (linearType);

				item.AddView (linearTitle);
				//item.AddView (linearExtraInfo);

				_listLinearItem.Add (item);
				_linearContentLayout.AddView (_listLinearItem [i]);

			}

		}
Esempio n. 30
0
		private void initUi()
		{
			_mainLayout = new RelativeLayout (context);
			_mainLayout.LayoutParameters = new RelativeLayout.LayoutParams (-1, -1);

			_scrollItems = new VerticalScrollView (context);
			_scrollItems.LayoutParameters = new VerticalScrollView.LayoutParams (-1, Configuration.getHeight(965));
			_scrollItems.SetY (Configuration.getHeight (125));

			initItems ();
			_scrollItems.AddView (_linearContentLayout);

			_mainLayout.AddView (_scrollItems);
			_publicidadLayout = new LinearLayout (context);
			_publicidadLayout.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight (85));
			Drawable dr = new BitmapDrawable (getBitmapFromAsset ("images/footerad.jpg"));
			_publicidadLayout.SetBackgroundDrawable (dr);
			_publicidadLayout.SetY (Configuration.getHeight(1136-85));
			_mainLayout.AddView (_publicidadLayout);
			_publicidadLayout.Click += delegate {
				if (adOpen) {
					hideAd ();
				} else {
					Random rnd = new Random();
					showAd (rnd.Next(adsImagesPath.Count));
				}
			};


		}
Esempio n. 31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);



            // Button gallybtn = FindViewById<Button>(Resource.Id.gallerybutton);
            Button cambtn   = FindViewById <Button>(Resource.Id.camerabutton);
            Button savebtn  = FindViewById <Button>(Resource.Id.savebutton);
            Button clrbtn   = FindViewById <Button>(Resource.Id.clearbutton);
            Button gallybtn = FindViewById <Button>(Resource.Id.gallerybutton);
            Button refresh  = FindViewById <Button>(Resource.Id.refresh);

            // Effect Buttons
            Button rmvred   = FindViewById <Button>(Resource.Id.removeredbutton);
            Button rmvblue  = FindViewById <Button>(Resource.Id.removebluebutton);
            Button rmvgreen = FindViewById <Button>(Resource.Id.removegreenbutton);

            Button negatered   = FindViewById <Button>(Resource.Id.negateredbutton);
            Button negateblue  = FindViewById <Button>(Resource.Id.negatebluebutton);
            Button negategreen = FindViewById <Button>(Resource.Id.negategreenbutton);

            Button noisebtn    = FindViewById <Button>(Resource.Id.noisebutton);
            Button contrastbtn = FindViewById <Button>(Resource.Id.contrastbutton);
            Button greyscale   = FindViewById <Button>(Resource.Id.greyscalebutton);

            ImageView imageView = FindViewById <ImageView>(Resource.Id.imageoutput);

            imageView.Visibility = Android.Views.ViewStates.Invisible;


            rmvred.Click   += delegate { RemoveColor('r', imageView); };
            rmvblue.Click  += delegate { RemoveColor('b', imageView); };
            rmvgreen.Click += delegate { RemoveColor('g', imageView); };

            negatered.Click   += delegate { NegateColor('r', imageView); };
            negateblue.Click  += delegate { NegateColor('b', imageView); };
            negategreen.Click += delegate { NegateColor('g', imageView); };

            noisebtn.Click += delegate { RandomNoise(imageView); };

            contrastbtn.Click += delegate { HighContrast(imageView); };

            greyscale.Click += delegate { GreyScale(imageView); };

            clrbtn.Click += delegate { imageView.SetImageBitmap(null);
                                       mainbp = null; };

            refresh.Click += delegate { imageView.SetImageBitmap(mainbp); };

            savebtn.Click += delegate
            {
                Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageView.Drawable;
                Android.Graphics.Bitmap bitmap = bd.Bitmap;

                ExportBitmapAsPNG(bitmap);
            };

            if (IsThereAnAppToTakePictures() == true)
            {
                CreateDirectoryForPictures();
                cambtn.Click += TakePicture;
            }


            gallybtn.Click += delegate
            {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 1);
            };
        }
        public override void Draw(Canvas canvas)
        {
            try
            {
                if (!animating)
                {
                    base.Draw(canvas);
                }
                else
                {
                    var normalized = (SystemClock.UptimeMillis() - startTimeMillis) / fadeDuration;
                    if (normalized >= 1f)
                    {
                        animating = false;
                        placeholder = null;
                        normalized = 1f;
                        base.Draw(canvas);
                    }
                    else
                    {
                        if (placeholder.IsValidAndHasValidBitmap())
                        {
                            if (!placeholderInitialized)
                            {
                                var placeholderSizeRatio = canvas.Width > canvas.Height ?
                                                                 (double)orgRect.Right / placeholder.IntrinsicWidth
                                                                 : (double)orgRect.Bottom / placeholder.IntrinsicHeight;

                                var scaledWidth = placeholderSizeRatio * placeholder.IntrinsicWidth;
                                var newOffset = (double)orgRect.CenterX() - scaledWidth / 2;
                                placeholder.Gravity = Android.Views.GravityFlags.Fill;
                                placeholder.SetBounds((int)newOffset, orgRect.Top, orgRect.Right, orgRect.Bottom);

                                placeholderInitialized = true;
                            }

                            placeholder.Draw(canvas);
                        }

                        int partialAlpha = (int)(alpha * normalized);
                        base.SetAlpha(partialAlpha);
                        base.Draw(canvas);
                        base.SetAlpha(alpha);
                    }
                }
            }
            catch (Exception) { }
        }
Esempio n. 33
0
                public async Task HandleDownloaded(CacheFile file, Action <CacheValue, BitmapType> callback)
                {
                    bool       startedLoading = false;
                    BitmapType bitmap         = null;

                    try {
                        if (file.DownloadFailed)
                        {
                            Logger.Warning(Logger.Level.Debug, "Notifying image download failure, url={0}", file.Url);
                            goto completed;
                        }

                        lock (this) {
                            bitmap = this.Bitmap;
                        }

                        if (null != bitmap)
                        {
                            Logger.Trace("Bitmap already present, url={0}", file.Url);
                            goto completed;
                        }

                        lock (this) {
                            if (this.decodeFailed)
                            {
                                Logger.Warning(Logger.Level.Trace, "Previous decoding failed, url={0}", file.Url);
                            }
                            if (loadInProgess)
                            {
                                Logger.Trace("Load already in progress (must wait for it to complete, url={0}", file.Url);
                                return;
                            }

                            startedLoading = this.loadInProgess = true;
                        }

                        Logger.Debug("Loading image url from cache, url=" + file.Url);

                        string localFile = file.LocalFilePath;

                        try {
                            BitmapFactory.Options options = new BitmapFactory.Options();
                            options.InJustDecodeBounds = true;
                            await BitmapFactory.DecodeFileAsync(localFile, options);

                            int scale = 1;

                            if (this.Key.MaxHeight > 0)
                            {
                                scale = options.OutHeight / Key.MaxHeight;
                            }
                            if (this.Key.MaxHeight > 0)
                            {
                                int temp = options.OutWidth / Key.MaxWidth;
                                scale = (temp > scale ? temp : scale);
                            }

                            options.InSampleSize       = scale;
                            options.InJustDecodeBounds = false;

                            Bitmap tempBitmap = await BitmapFactory.DecodeFileAsync(localFile, options);

                            bitmap = Convert(tempBitmap, bitmap);
                        } catch (Exception e) {
                            Logger.Warning(Logger.Level.Debug, "Decoding of image failed, url={0}, expection={1}", file.Url, e.ToString());
                        } finally {
                            lock (this) {
                                if (null != bitmap)
                                {
                                    this.bitmapWeak    = bitmap;
                                    this.bitmapCreated = DateTime.UtcNow;
                                }
                            }
                        }

                        Logger.Debug("Loading image url from cache completed, url={0}", file.Url);
                        goto completed;
                    } finally {
                        if (startedLoading)
                        {
                            lock (this) {
                                if (bitmap == null)
                                {
                                    this.decodeFailed  = true;
                                    this.bitmapCreated = default(DateTime);
                                }
                                this.loadInProgess = false;
                            }
                        }
                    }

completed:
                    callback(this, bitmap);
                }
Esempio n. 34
0
		public void setItemLogin(){



			var txtFormat = Android.Util.ComplexUnitType.Px;

			linearButtonLogin = new LinearLayout (this);
			linearEditTextLogin = new LinearLayout (this);
			linearTextLogin = new LinearLayout (this);



			etxtUser = new EditText (this);
			etxtPassword = new EditText (this);
			btnLoginInto = new ImageButton (this);
			txtLogin_a = new TextView (this);
			txtLogin_b = new TextView (this);
			txtInicioSesion = new TextView (this);

			linearButtonLogin.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearEditTextLogin.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearTextLogin.LayoutParameters = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.WrapContent, LinearLayout.LayoutParams.WrapContent);

			etxtUser.LayoutParameters = new ViewGroup.LayoutParams (Configuration.getWidth (507), Configuration.getHeight (78));
			etxtPassword.LayoutParameters = new ViewGroup.LayoutParams (Configuration.getWidth (507), Configuration.getHeight (78));


			linearButtonLogin.Orientation = Orientation.Horizontal;
			linearButtonLogin.SetGravity (GravityFlags.Center);
			linearEditTextLogin.Orientation = Orientation.Vertical;
			linearEditTextLogin.SetGravity (GravityFlags.Center);
			linearTextLogin.Orientation = Orientation.Vertical;
			linearTextLogin.SetGravity (GravityFlags.Center);



			etxtUser.Hint = "  Usuario"; 
			etxtUser.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			etxtPassword.Hint = "  Contraseña";
			etxtPassword.InputType = Android.Text.InputTypes.TextVariationPassword | Android.Text.InputTypes.ClassText;
			etxtPassword.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			etxtPassword.InputType = InputTypes.TextVariationVisiblePassword;

			txtLogin_a.Text = "FORGOT PASSWORD?";
			txtLogin_a.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtLogin_b.Text = "            CHANGE";
			txtLogin_b.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtLogin_a.SetTextSize (txtFormat,Configuration.getHeight(30));
			txtLogin_b.SetTextSize (txtFormat, Configuration.getHeight (30));


			txtInicioSesion.Text = "Iniciar Sesión";
			txtInicioSesion.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			txtInicioSesion.SetTextColor (Color.ParseColor("#ffffff"));
			txtInicioSesion.SetTextSize (Android.Util.ComplexUnitType.Px, Configuration.getHeight (36));

			btnLoginInto.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/otherlogin.png"),Configuration.getWidth (242), Configuration.getHeight (78),true));
			etxtUser.SetTextColor (Color.ParseColor ("#ffffff"));
			etxtPassword.SetTextColor (Color.ParseColor ("#ffffff"));



			btnLoginInto.Click += delegate {
				_dialog.Show();
				var com = ((LoginViewModel)this.DataContext).LoginCommand;
				com.Execute(null);
				//AlertDialog.Builder popupBuilder = new AlertDialog.Builder(this);




			};

			initButtonColor (btnLoginInto);

			etxtPassword.InputType = InputTypes.TextVariationVisiblePassword;
			etxtPassword.TransformationMethod = Android.Text.Method.PasswordTransformationMethod.Instance;

			txtLogin_a.SetTextColor (Color.ParseColor ("#ffffff"));
			txtLogin_b.SetTextColor (Color.ParseColor ("#00c6ff"));


			Drawable drawableEditText = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/cajatexto.png"), Configuration.getWidth(507), Configuration.getHeight(80), true));
			etxtUser.SetBackgroundDrawable (drawableEditText);
			etxtPassword.SetBackgroundDrawable (drawableEditText);

			etxtUser.SetSingleLine (true);
			etxtPassword.SetSingleLine (true);

			LinearLayout space = new LinearLayout (this);
			space.LayoutParameters = new LinearLayout.LayoutParams (-1, 20);


			linearTextLogin.AddView (txtLogin_a);

			linearTextLogin.AddView (txtLogin_b);

			//linearButtonLogin.AddView (btnLoginInto);
			//linearButtonLogin.AddView (linearTextLogin);

			linearEditTextLogin.AddView (etxtUser);
			linearEditTextLogin.AddView (space);
			linearEditTextLogin.AddView (etxtPassword);


			txtInicioSesion.SetX (Configuration.getWidth(75)); txtInicioSesion.SetY (Configuration.getHeight(680));
			linearEditTextLogin.SetX (0); linearEditTextLogin.SetY (Configuration.getHeight(741));
			//linearButtonLogin.SetX (0); linearButtonLogin.SetY (Configuration.getHeight(978));


			btnLoginInto.SetX (Configuration.getWidth (45));btnLoginInto.SetY (Configuration.getHeight (980));
			linearTextLogin.SetX (Configuration.getWidth (345));linearTextLogin.SetY (Configuration.getHeight(995));

			relLogin.AddView (txtInicioSesion);
			relLogin.AddView (linearEditTextLogin);
			//relLogin.AddView (linearButtonLogin);
			relLogin.AddView(btnLoginInto);
			relLogin.AddView (linearTextLogin);

			((LoginViewModel)this.ViewModel).PropertyChanged += Login_propertyChanged;;



			var set = this.CreateBindingSet<LoginView, LoginViewModel>();
			set.Bind(etxtUser).To(vm => vm.Username);
			set.Bind(etxtPassword).To(vm => vm.Password);
			set.Apply(); 

			mainLayout.AddView (relLogin);
		}
 protected override void SetImageBitmap(ImageView imageView, Bitmap bitmap)
 {
     var drawable = new BitmapDrawable(Resources.System, bitmap);
     imageView.SetImageDrawable(drawable);
 }
Esempio n. 36
0
        public Drawable GetIconDrawable(Resources res, PwDatabase db, PwUuid icon)
        {
            InitBlank (res);
            if (icon.Equals(PwUuid.Zero)) {
                return _blank;
            }
            Drawable draw;
            if (!_customIconMap.TryGetValue(icon, out draw))
            {
                Bitmap bitmap = db.GetCustomIcon(icon);

                // Could not understand custom icon
                if (bitmap == null) {
                    return _blank;
                }

                bitmap = resize (bitmap);

                draw = new BitmapDrawable(res, bitmap);
                _customIconMap[icon] = draw;
            }

            return draw;
        }
Esempio n. 37
0
		public void ini(){

			Drawable dr = new BitmapDrawable (getBitmapFromAsset("images/1header.png"));
			header = new LinearLayout(context);
			header.LayoutParameters = new LinearLayout.LayoutParams (-1,Configuration.getHeight(125));
			header.Orientation = Orientation.Horizontal;
			header.SetGravity (GravityFlags.Center);
			header.SetBackgroundDrawable (dr);


			titulo_header = new TextView (context);
			titulo_header.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth(550), -1);
			titulo_header.SetTextSize (ComplexUnitType.Fraction, Configuration.getHeight(38));
			titulo_header.Typeface =  Typeface.CreateFromAsset(context.Assets, "fonts/ArcherMediumPro.otf");
			titulo_header.SetTextColor (Color.White);
			titulo_header.Gravity = GravityFlags.Center;
			//titulo_header.TextAlignment = TextAlignment.Center;

			placesInfoLayout = new LinearLayout (context);
			placesInfoLayout.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
			int space = Configuration.getWidth (30);
			placesInfoLayout.SetPadding(space,space,space,space);
			placesInfoLayout.Orientation = Orientation.Vertical;

			_mainLayout = new RelativeLayout (context);
			_mainLayout.LayoutParameters = new RelativeLayout.LayoutParams (-1,-1);

			_mainLayout.AddView (header);

			mapImage = new ScaleImageView (context, null);
			mapImage.LayoutParameters = new LinearLayout.LayoutParams (-1, -1);
			mapSpace = new LinearLayout (context);
			mapSpace.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth(640), Configuration.getWidth(640));
			mapSpace.SetY (Configuration.getHeight (125));
			mapSpace.SetGravity (GravityFlags.Left);
			mapSpace.SetBackgroundColor (Color.ParseColor ("#DFC6BB"));
			//HUILLCA-----------------------------------------
			mapSpaceMarker = new RelativeLayout (context);
			mapSpaceMarker.LayoutParameters = new RelativeLayout.LayoutParams (Configuration.getWidth(640), Configuration.getWidth(640));
			mapSpaceMarker.SetY (Configuration.getHeight (125));
			mapSpaceMarker.SetGravity (GravityFlags.Left);
			mapSpaceMarker.SetBackgroundColor (Color.Transparent);

			iconMarker = new ImageIconMap (context);
			iconMarker.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth (60), Configuration.getWidth (60));
			int w = Configuration.getWidth (70);
			int h = Configuration.getWidth (70);
			iconMarker.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/iconmap12.png"), w, h, true));
			iconMarker.SetX (-100);
			iconMarker.SetY (-100);
			mapSpaceMarker.AddView (iconMarker);

			var fadeIn = new AlphaAnimation(0, 1);
			fadeIn.Interpolator = new AccelerateInterpolator();
			fadeIn.Duration = 1000;

			fadeOut = new AlphaAnimation(1, 0);
			fadeOut.Interpolator = new DecelerateInterpolator();
			fadeOut.Duration = 3000;
			fadeOut.AnimationEnd += (s, e) => 
			{
				 /*ThreadPool.QueueUserWorkItem(state =>
					{
						Thread.Sleep(2000); //wait 2 sec
						//RunOnUiThread(() => iconMarker.StartAnimation(fadeOut));
					});*/
					iconMarker.StartAnimation(fadeIn);
					iconMarker.Visibility = ViewStates.Invisible;
			};
			//-------------------------------------------------------
			mapSpace.AddView (mapImage);



			placeSpace = new VerticalScrollView (context);
			placeSpace.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight(375-85));
			placeSpace.SetY (Configuration.getHeight (125)+Configuration.getWidth(640));
			placeSpace.SetBackgroundColor (Color.White);

			placesContainer = new LinearLayout (context);
			placesContainer.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight(375-85));
			placesContainer.Orientation = Orientation.Vertical;


			_mainLayout.AddView (mapSpace);
			_mainLayout.AddView (mapSpaceMarker);//HUILLCA
			_mainLayout.AddView (placeSpace);

			_publicidadLayout = new LinearLayout (context);
			_publicidadLayout.LayoutParameters = new LinearLayout.LayoutParams (-1, Configuration.getHeight (85));
			Drawable drp = new BitmapDrawable (getBitmapFromAsset ("images/footerad.jpg"));
			_publicidadLayout.SetBackgroundDrawable (drp);
			_publicidadLayout.SetY (Configuration.getHeight(1136-85));
			_mainLayout.AddView (_publicidadLayout);
			_publicidadLayout.Click += delegate {
				if (adOpen) {


					hideAd ();
				} else {
					Random rnd = new Random();
					showAd (rnd.Next(3));
				}
			};



			_mainLayout.AddView (leyendaLayout);

			scrollPlaces = new VerticalScrollView (context);
			scrollPlaces.LayoutParameters = new VerticalScrollView.LayoutParams (-1,Configuration.getHeight(1136-125-85));
			scrollPlaces.AddView (placesInfoLayout);
			scrollPlaces.SetY (Configuration.getHeight (125));


			//mainLayout.AddView (placesInfoLayout);

			//iniPlancesList ();

		}
Esempio n. 38
0
		public void StopFadeAnimation()
		{
			_animating = false;
			_placeholder = null;
		}
Esempio n. 39
0
		private void iniMenu(){
			mainLayout = new RelativeLayout (this);
	



			_foro = new LOContainerView (this);

			_dialogDownload = new ProgressDialog (this);
			_dialogDownload.SetCancelable (false);
			_dialogDownload.SetMessage ("Downloading...");

			txtUserName = new TextView (this);
			txtCurse = new TextView (this);
			txtSchoolName = new TextView (this);
			txtUserRol = new TextView (this);
			txtPorcentaje = new TextView (this);
			txtCurseTitle = new TextView (this);
			txtTaskTitle = new TextView (this);
			txtPendiente = new TextView (this);
			txtValorBarra = new TextView (this);

			imgChat = new ImageView (this);
			imgUser = new ImageView (this);
			imgSchool = new ImageView (this);
			imgNotificacion = new ImageView (this);
			imgCurse = new ImageView (this);
			imgTask = new ImageView (this);

			linearBarraCurso = new LinearLayout (this);
			linearCurse= new LinearLayout (this);
			linearSchool= new LinearLayout (this);
			linearTask= new LinearLayout (this);
			linearUserData= new LinearLayout (this);
			linearUser = new LinearLayout (this);
			linearListCurso = new LinearLayout (this);
			linearListTask = new LinearLayout (this);
			linearList = new LinearLayout (this);
			linearPendiente = new LinearLayout (this);

			linearTxtValorBarra = new LinearLayout (this);

			listCursos = new ListView (this);
			listTasks = new ListView (this);	
			mItemsChat = new List<ChatDataRow> ();

			mainLayout.LayoutParameters = new RelativeLayout.LayoutParams (-1,-1);
			Drawable d = new BitmapDrawable (getBitmapFromAsset ("icons/fondo.png"));
			mainLayout.SetBackgroundDrawable (d);
			d = null;

			linearBarraCurso.LayoutParameters = new LinearLayout.LayoutParams (-1,LinearLayout.LayoutParams.WrapContent);
			linearCurse.LayoutParameters = new LinearLayout.LayoutParams (-1,Configuration.getHeight(50));
			linearTask.LayoutParameters = new LinearLayout.LayoutParams (-1,Configuration.getHeight(50));
			linearSchool.LayoutParameters = new LinearLayout.LayoutParams (-1,LinearLayout.LayoutParams.WrapContent);
			linearUserData.LayoutParameters = new LinearLayout.LayoutParams (-1,LinearLayout.LayoutParams.WrapContent);
			linearUser.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearListCurso.LayoutParameters = new LinearLayout.LayoutParams (-1,Configuration.getHeight(250));
			linearListTask.LayoutParameters = new LinearLayout.LayoutParams (-1,LinearLayout.LayoutParams.WrapContent);
			linearList.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearPendiente.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth (30), Configuration.getWidth (30));
			linearTxtValorBarra.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);

			linearBarraCurso.Orientation = Orientation.Vertical;
			linearBarraCurso.SetGravity (GravityFlags.Center);

			linearTxtValorBarra.Orientation = Orientation.Vertical;
			linearTxtValorBarra.SetGravity (GravityFlags.Center);
			txtValorBarra.Gravity = GravityFlags.Center;

			linearCurse.Orientation = Orientation.Horizontal;
			linearCurse.SetGravity (GravityFlags.CenterVertical);

			linearTask.Orientation = Orientation.Horizontal;
			linearTask.SetGravity (GravityFlags.CenterVertical);

			linearSchool.Orientation = Orientation.Horizontal;
			//linearSchool.SetGravity (GravityFlags.CenterVer);

			linearUserData.Orientation = Orientation.Vertical;
			linearUserData.SetGravity (GravityFlags.Center);

			linearUser.Orientation = Orientation.Vertical;
			linearUser.SetGravity (GravityFlags.CenterHorizontal);

			linearListCurso.Orientation = Orientation.Vertical;
			linearListTask.Orientation = Orientation.Vertical;

			linearList.Orientation = Orientation.Vertical;

			linearPendiente.Orientation = Orientation.Horizontal;
			linearPendiente.SetGravity (GravityFlags.Center);
			//linearList.SetGravity (GravityFlags.CenterVertical);

			progressBar = new ProgressBar (this,null,Android.Resource.Attribute.ProgressBarStyleHorizontal);
			progressBar.LayoutParameters = new ViewGroup.LayoutParams (Configuration.getWidth (274), Configuration.getHeight (32));
			progressBar.ProgressDrawable = Resources.GetDrawable (Resource.Drawable.progressBackground);
			progressBar.Progress = 60;
			txtValorBarra.Text = "60%";
			//progressBar.text
			txtValorBarra.SetY(13);

			txtCurse.Text = "Cursos del 2015";
			txtCurse.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");


		//	txtUserName.Text ="David Spencer";
			txtUserName.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtUserRol.Text ="Alumno";
			txtUserRol.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtSchoolName.Text ="Colegio Sagrados Corazones";
			txtSchoolName.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtPorcentaje.Text = "60%";
			txtPorcentaje.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtCurseTitle.Text = "CURSOS";
			txtCurseTitle.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtTaskTitle.Text = "TAREAS";	
			txtTaskTitle.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtPendiente.Text = "1";
			txtPendiente.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			txtPendiente.SetY (-10);


			txtPendiente.SetTextSize (Android.Util.ComplexUnitType.Px, Configuration.getHeight (30));
			txtUserName.SetTextSize (Android.Util.ComplexUnitType.Px, Configuration.getHeight (35));
			txtUserRol.SetTextSize (Android.Util.ComplexUnitType.Px, Configuration.getHeight (30));


			txtCurseTitle.SetPadding (Configuration.getWidth (48), 0, 0, 0);
			txtTaskTitle.SetPadding (Configuration.getWidth (48), 0, 0, 0);

			txtCurse.SetTextColor (Color.ParseColor ("#ffffff"));
			txtUserName.SetTextColor (Color.ParseColor ("#ffffff"));
			txtUserRol.SetTextColor (Color.ParseColor ("#999999"));
			txtSchoolName.SetTextColor (Color.ParseColor ("#ffffff"));
			txtPorcentaje.SetTextColor (Color.ParseColor ("#ffffff"));
			txtPendiente.SetTextColor (Color.ParseColor ("#ffffff"));
			txtTaskTitle.SetTextColor (Color.ParseColor ("#ffffff"));
			txtCurseTitle.SetTextColor (Color.ParseColor ("#ffffff"));
			txtValorBarra.SetTextColor (Color.ParseColor ("#ffffff"));

			txtUserName.Gravity = GravityFlags.CenterHorizontal;
			txtUserRol.Gravity = GravityFlags.CenterHorizontal;
			txtCurse.Gravity = GravityFlags.CenterHorizontal;


			imgChat.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/chat.png"),Configuration.getWidth (45), Configuration.getWidth (40),true));
			imgUser.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/user.png"),Configuration.getWidth (154), Configuration.getHeight (154),true));
			imgSchool.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/colegio.png"),Configuration.getWidth (29), Configuration.getHeight (29),true));
			imgNotificacion.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/notif.png"),Configuration.getWidth (35), Configuration.getWidth (40),true));
			imgCurse.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/curso.png"),Configuration.getWidth (23), Configuration.getHeight (28),true));
			imgTask.SetImageBitmap (Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/vertareas.png"),Configuration.getWidth (23), Configuration.getHeight (28),true));

			Drawable drPendiente = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/pendiente.png"), Configuration.getWidth(30), Configuration.getWidth(30), true));
			linearPendiente.SetBackgroundDrawable (drPendiente);
			drPendiente = null;

			imgCurse.SetPadding (Configuration.getWidth (68), 0, 0, 0);
			imgTask.SetPadding(Configuration.getWidth(68),0,0,0);


			linearCurse.SetBackgroundColor(Color.ParseColor("#0d1216"));
			linearTask.SetBackgroundColor (Color.ParseColor ("#0d1216"));

			linearBarraCurso.AddView (txtCurse);
			linearBarraCurso.AddView (progressBar);

			linearTxtValorBarra.AddView (txtValorBarra);

			linearCurse.AddView (imgCurse);
			linearCurse.AddView (txtCurseTitle);
			linearTask.AddView (imgTask);
			linearTask.AddView (txtTaskTitle);
			linearPendiente.AddView (txtPendiente);



			imgSchool.SetPadding (Configuration.getWidth(68),0,0,0);
			txtSchoolName.SetPadding (Configuration.getWidth(40),0,0,0);
			linearSchool.AddView (imgSchool);
			linearSchool.AddView (txtSchoolName);

			linearUser.AddView (txtUserName);
			linearUser.AddView (txtUserRol);

			linearUserData.AddView (imgUser);
			linearUserData.AddView (linearUser);

			linearListCurso.AddView (listCursos);
			linearListTask.AddView (listTasks);

			linearList.AddView (linearCurse);
			linearList.AddView (linearListCurso);
			linearList.AddView (linearTask);
			linearList.AddView (linearListTask);


			imgChat.SetX (Configuration.getWidth(59)); imgChat.SetY (Configuration.getHeight(145));
			imgChat.Click += delegate {
				mDrawerLayout.CloseDrawer (mLeftDrawer);
				mDrawerLayout.OpenDrawer (mRightDrawer);
			};
				
			imgNotificacion.SetX (Configuration.getWidth(59));  imgNotificacion.SetY (Configuration.getHeight(233)); 
			imgNotificacion.Click += delegate {
				mDrawerLayout.CloseDrawer (mLeftDrawer);
				main_ContentView.RemoveAllViews ();
				main_ContentView.AddView(new NotificationView(this));
			};


			linearPendiente.SetX (Configuration.getWidth(94));  linearPendiente.SetY (Configuration.getHeight(217)); 

			linearUserData.SetX (0); linearUserData.SetY (Configuration.getHeight(130));
			linearBarraCurso.SetX (0); linearBarraCurso.SetY (Configuration.getHeight(412));
			linearTxtValorBarra.SetX (0); linearTxtValorBarra.SetY (Configuration.getHeight(443));
			linearSchool.SetX (0); linearSchool.SetY (Configuration.getHeight(532));
			linearList.SetX (0); linearList.SetY (Configuration.getHeight(583));

			Bitmap bm;
			txtUserName.Text = vm.UserFirstName + " "+ vm.UserLastName;

			if (vm.UserImage != null) {
				bm = BitmapFactory.DecodeByteArray (vm.UserImage, 0, vm.UserImage.Length);

				Bitmap newbm = Configuration.GetRoundedCornerBitmap (Bitmap.CreateScaledBitmap (bm,Configuration.getWidth (154), Configuration.getHeight (154),true));
				imgUser.SetImageBitmap (newbm);
			
				newbm = null;
			}
			bm = null;



			mainLayout.AddView (imgChat);
			mainLayout.AddView (imgNotificacion);
			mainLayout.AddView (linearPendiente);
			mainLayout.AddView (linearUserData);
			mainLayout.AddView (linearBarraCurso);
			mainLayout.AddView (linearTxtValorBarra);
			mainLayout.AddView (linearSchool);
			mainLayout.AddView (linearList);

			imgChat = null;
			imgNotificacion = null;
			imgCurse = null;
			imgTask = null;
			imgSchool = null;
			imgUser = null;
		}
Esempio n. 40
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);


            if (requestCode == 1)
            {
                if (resultCode == Result.Ok)
                {
                    var imageView = FindViewById <ImageView>(Resource.Id.imageoutput);

                    imageView.SetImageURI(data.Data);

                    Android.Graphics.Drawables.BitmapDrawable bd = (Android.Graphics.Drawables.BitmapDrawable)imageView.Drawable;
                    Android.Graphics.Bitmap bitmap = bd.Bitmap;

                    //Gotta shrink down the bitmaps because they tend to be too big



                    int height = bitmap.Height;
                    int width  = bitmap.Width;

                    ScaleBounds(ref height, ref width);

                    Android.Graphics.Bitmap smallBitmap =
                        Android.Graphics.Bitmap.CreateScaledBitmap(bitmap, width, height, true);

                    imageView.SetImageBitmap(smallBitmap);
                    mainbp = smallBitmap;
                    imageView.Visibility = Android.Views.ViewStates.Visible;
                }
            }
            else if (requestCode == 0)
            {
                if (resultCode == Result.Ok)
                {
                    ImageView imageView = FindViewById <ImageView>(Resource.Id.imageoutput);
                    int       height    = Resources.DisplayMetrics.HeightPixels;
                    int       width     = imageView.Height;

                    //AC: workaround for not passing actual files
                    Android.Graphics.Bitmap bitmap     = (Android.Graphics.Bitmap)data.Extras.Get("data");
                    Android.Graphics.Bitmap copyBitmap =
                        bitmap.Copy(Android.Graphics.Bitmap.Config.Argb8888, true);


                    if (copyBitmap != null)
                    {
                        imageView.SetImageBitmap(copyBitmap);
                        mainbp = copyBitmap;
                        imageView.Visibility = Android.Views.ViewStates.Visible;
                        bitmap     = null;
                        copyBitmap = null;
                    }

                    // Dispose of the Java side bitmap.
                    System.GC.Collect();
                }
            }
        }
Esempio n. 41
0
        /// <summary>
        /// Sets the color of the action bar.
        /// </summary>
        /// <param name="color">Color.</param>
        protected void SetActionBarColor(Color color)
        {
            Resources res = this.Resources;
            var maskDrawable = res.GetDrawable(Resource.Drawable.actionbar_icon_mask) as BitmapDrawable;
            if (maskDrawable == null)
            {
                return;
            }

            var maskBitmap = maskDrawable.Bitmap;
            int width = maskBitmap.Width;
            int height = maskBitmap.Height;

            var outBitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(outBitmap);
            canvas.DrawBitmap(maskBitmap, 0, 0, null);

            var maskedPaint = new Paint();
            maskedPaint.Color = color;
            maskedPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcAtop));

            canvas.DrawRect(0, 0, width, height, maskedPaint);
            var outDrawable = new BitmapDrawable(res, outBitmap);
            SupportActionBar.SetIcon(outDrawable);
        }
Esempio n. 42
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                View view = convertView;                 // re-use an existing view, if one is available

                ViewHolder holder;
                bool       firstTimeResourceLoaded = false;

                if (view == null)                   // otherwise create a new one
                {
                    firstTimeResourceLoaded = true;

                    view = context.LayoutInflater.Inflate(Resource.Layout.ContactListItem, null);

                    TextView badgeTextView = view.FindViewById <TextView> (Resource.Id.badgeAnchorTextView);

                    BadgeView badgeView = new BadgeView(context, badgeTextView);
                    badgeView.BadgePosition = BadgeView.Position.TopLeft;

                    holder = new ViewHolder();
                    holder.AvatarImageView             = view.FindViewById <ImageView> (Resource.Id.avatarImageView);
                    holder.OriginalEmptyAvatarDrawable = holder.AvatarImageView.Drawable;
                    holder.BadgeView        = badgeView;
                    holder.NameTextView     = view.FindViewById <TextView> (Resource.Id.nameTextView);
                    holder.UsernameTextView = view.FindViewById <TextView> (Resource.Id.usernameTextView);

                    holder.AvatarWidth  = holder.AvatarImageView.LayoutParameters.Width;
                    holder.AvatarHeight = holder.AvatarImageView.LayoutParameters.Height;

                    // if these fail, you'll need to recode the source to delay the fetching of the avatar until after the render figures out the exact dimensions of the image
                    Contract.Assume(((holder.AvatarWidth != ViewGroup.LayoutParams.MatchParent) && (holder.AvatarWidth != ViewGroup.LayoutParams.WrapContent)));
                    Contract.Assume(((holder.AvatarHeight != ViewGroup.LayoutParams.MatchParent) && (holder.AvatarHeight != ViewGroup.LayoutParams.WrapContent)));

                    view.Tag = holder;
                }
                else
                {
                    holder = (ViewHolder)view.Tag;
                }

                object source = this [position];

                holder.NameTextView.Text     = "My Name " + position.ToString();
                holder.UsernameTextView.Text = "Username" + position.ToString();

                holder.BadgeView.Text = position.ToString();
                holder.BadgeView.Show();

                holder.CurrentDownloader = new AvatarDownloader(holder);

                BitmapType bitmap = downloader.FetchNowOrAsyncDownload(
                    bogusUrls [position % bogusUrls.Length],
                    holder.AvatarWidth,
                    holder.AvatarHeight,
                    holder.CurrentDownloader.HandleDownloaded
                    );

                if (null != bitmap)
                {
                    holder.AvatarImageView.SetImageDrawable(bitmap);
                }
                else
                {
                    if (!firstTimeResourceLoaded)
                    {
                        holder.AvatarImageView.SetImageDrawable(holder.OriginalEmptyAvatarDrawable);                            // reset back to original drawable
                    }
                }

                return(view);
            }
Esempio n. 43
0
		public void init(){



			var textFormat = Android.Util.ComplexUnitType.Px;

			_dialog = new ProgressDialog(this);


			//popupBuilder.SetView(_dialog);


			_dialog.SetMessage("Espere por favor...");
			_dialog.SetCancelable(false);
			//_dialog.Show();

			mainLayout = new RelativeLayout (this);
			relSingup = new RelativeLayout (this);
			relLogin = new RelativeLayout (this);
			linearLicencia = new LinearLayout (this);
			linearLogin = new LinearLayout (this);
			linearSingup = new LinearLayout (this);
			linearLogo = new LinearLayout (this);

			imgLogo = new ImageView (this);
			btnLogin = new ImageButton (this);
			btnSingUp = new ImageButton (this);
			btnFacebook = new ImageButton (this);
			chkLogin = new CheckBox (this);
			txtLicencia_a = new TextView (this);
			txtLicencia_b = new TextView (this);

			txtlogin_a1 = new TextView (this);
			txtlogin_a2 = new TextView (this);
			txtlogin_b1 = new TextView (this);
			txtlogin_b2 = new TextView (this);
			txtlogin_c1 = new TextView (this);
			txtlogin_c2 = new TextView (this);

			initText (txtlogin_a1, "", "#00c6ff");
			txtlogin_a1.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			initText (txtlogin_a2, "", "#ffffff");
			txtlogin_a2.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			initText (txtlogin_b1, "", "#00c6ff");
			txtlogin_b1.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			initText (txtlogin_b2, "","#ffffff");
			txtlogin_b2.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			initText (txtlogin_c1, "", "#00c6ff");
			txtlogin_c1.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			initText (txtlogin_c2, "", "#ffffff");
			txtlogin_c2.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
		

			linearTxta = new LinearLayout (this);
			linearTxtb = new LinearLayout (this);
			linearTxtc = new LinearLayout (this);
			linearContentText = new LinearLayout (this);

			linearTxta.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
			linearTxtb.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
			linearTxtc.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);
			linearContentText.LayoutParameters = new LinearLayout.LayoutParams (-1, -2);

			linearTxta.Orientation = Orientation.Horizontal;
			linearTxta.SetGravity (GravityFlags.Center);
			linearTxtb.Orientation = Orientation.Horizontal;
			linearTxtb.SetGravity (GravityFlags.Center);
			linearTxtc.Orientation = Orientation.Horizontal;
			linearTxtc.SetGravity (GravityFlags.Center);

			linearContentText.Orientation = Orientation.Vertical;
			linearContentText.SetGravity (GravityFlags.Center);


			linearTxta.AddView (txtlogin_a1); linearTxta.AddView (txtlogin_a2);
			linearTxtb.AddView (txtlogin_b1); linearTxtb.AddView (txtlogin_b2);
			linearTxtc.AddView (txtlogin_c1); linearTxtc.AddView (txtlogin_c2);

			linearContentText.AddView (linearTxta);
			linearContentText.AddView (linearTxtb);
			linearContentText.AddView (linearTxtc);


			mainLayout.LayoutParameters = new RelativeLayout.LayoutParams (-1, -1);
			Drawable d = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/afondo.png"), 768, 1024, true));
			mainLayout.SetBackgroundDrawable (d);

			relSingup.LayoutParameters = new RelativeLayout.LayoutParams (-1,-1);
			relLogin.LayoutParameters = new RelativeLayout.LayoutParams (-1,-1);


			linearLicencia.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearLicencia.Orientation = Orientation.Horizontal;
			linearLicencia.SetGravity (GravityFlags.Center);

			linearLogin.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearLogin.Orientation = Orientation.Horizontal;
			linearLogin.SetGravity (GravityFlags.Right);

			linearSingup.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearSingup.Orientation = Orientation.Vertical;
			linearSingup.SetGravity (GravityFlags.Center);


			linearLogo.LayoutParameters = new LinearLayout.LayoutParams (-1, LinearLayout.LayoutParams.WrapContent);
			linearLogo.Orientation = Orientation.Vertical;
			linearLogo.SetGravity (GravityFlags.Center);



			txtLicencia_a.Text = "TO REGISTER, ACCEPT THE";
			txtLicencia_a.SetTextSize(textFormat,Configuration.getHeight(25));
			txtLicencia_a.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");
			txtLicencia_a.SetTextColor (Color.ParseColor ("#ffffff"));
			txtLicencia_b.Text = " TERMS OF USE";
			txtLicencia_b.Typeface =  Typeface.CreateFromAsset(this.Assets, "fonts/HelveticaNeue.ttf");

			txtLicencia_b.SetTextSize(textFormat,Configuration.getHeight(25));
			txtLicencia_b.SetTextColor (Color.ParseColor ("#00c6ff"));
			chkLogin.Checked = false;

			chkLogin.SetBackgroundColor(Color.ParseColor("#ffffff"));

			imgLogo.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/logo.png"), Configuration.getWidth(360), Configuration.getHeight(230),true));
			btnLogin.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/login.png"), Configuration.getWidth(210), Configuration.getHeight(60),true));
			btnFacebook.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/signupface.png"), Configuration.getWidth(507), Configuration.getHeight(80),true));
			btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/signupnolisto.png"), Configuration.getWidth(507), Configuration.getHeight(80),true));

			Drawable dc = new BitmapDrawable (Bitmap.CreateScaledBitmap (getBitmapFromAsset ("icons/toregister.png"), Configuration.getWidth(47), Configuration.getHeight(47), true));
			chkLogin.SetBackgroundDrawable (dc);

			initButtonColor (btnLogin);
			initButtonColor (btnFacebook);
			initButtonColor (btnSingUp);
			linearLicencia.AddView (chkLogin);
			linearLicencia.AddView (txtLicencia_a);
			linearLicencia.AddView (txtLicencia_b);

			linearLogin.AddView (btnLogin);
			linearSingup.AddView (linearLicencia);
			linearSingup.AddView (btnSingUp);
			linearSingup.AddView (btnFacebook);

			linearLogo.AddView (imgLogo);

			linearLogo.SetX (0); linearLogo.SetY (Configuration.getHeight(373));
			linearContentText.SetX (0); linearContentText.SetY (Configuration.getHeight(557));
			linearLogin.SetX (0); linearLogin.SetY (Configuration.getHeight(30));
			linearSingup.SetX (0); linearSingup.SetY (Configuration.getHeight(785));

			relSingup.AddView (linearLogo);
			relSingup.AddView (linearContentText);
			relSingup.AddView (linearLogin);
			relSingup.AddView (linearSingup);
			mainLayout.AddView (relSingup);


			btnSingUp.Click+= delegate {

				if(chkLogin.Checked==true){
					var com = ((LoginViewModel)this.DataContext).SignUpCommand;
					com.Execute(null);
				}
			};


			btnLogin.Click+= BtnLogin_Click;

			btnFacebook.Click += async delegate {


				await Authenticate(MobileServiceAuthenticationProvider.Facebook);

				/*var com = ((LoginViewModel)this.DataContext).FacebookLoginCommand;
				com.Execute(null);
				*/
			};


			chkLogin.CheckedChange += delegate {
				if(chkLogin.Checked==true){
					btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/signuplisto.png"), Configuration.getWidth(507), Configuration.getHeight(80),true));
				}
				if(chkLogin.Checked==false){
					btnSingUp.SetImageBitmap(Bitmap.CreateScaledBitmap (getBitmapFromAsset("icons/signupnolisto.png"), Configuration.getWidth(507), Configuration.getHeight(80),true));
				}

			};
		}
        protected override void SetImageBitmap(ImageView imageView, Bitmap bitmap)
        {
#warning ASK STEVE @ SEQUENCE - WHY IS THIS NEEDED?
            var drawable = new BitmapDrawable(Resources.System, bitmap);
            imageView.SetImageDrawable(drawable);
        }
Esempio n. 45
0
        private BitmapDrawable MakeTagChip (String tagText)
        {
            var Inflater = LayoutInflater.FromContext (Context);
            var tagChipView = (TextView)Inflater.Inflate (Resource.Layout.TagViewChip, this, false);
            tagChipView.Text = tagText.ToUpper ();
            int spec = MeasureSpec.MakeMeasureSpec (0, MeasureSpecMode.Unspecified);
            tagChipView.Measure (spec, spec);
            tagChipView.Layout (0, 0, tagChipView.MeasuredWidth, tagChipView.MeasuredHeight);

            var b = Bitmap.CreateBitmap (tagChipView.Width, tagChipView.Height, Bitmap.Config.Argb8888);

            var canvas = new Canvas (b);
            canvas.Translate (-tagChipView.ScrollX, -tagChipView.ScrollY);
            tagChipView.Draw (canvas);
            tagChipView.DrawingCacheEnabled = true;

            var cacheBmp = tagChipView.DrawingCache;
            var viewBmp = cacheBmp.Copy (Bitmap.Config.Argb8888, true);
            tagChipView.DestroyDrawingCache ();
            var bmpDrawable = new BitmapDrawable (Resources, viewBmp);
            bmpDrawable.SetBounds (0, 0, bmpDrawable.IntrinsicWidth, bmpDrawable.IntrinsicHeight);
            return bmpDrawable;
        }
Esempio n. 46
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                View view = convertView;                 // re-use an existing view, if one is available

                ViewHolder       holder       = null;
                HeaderViewHolder headerHolder = null;
                DataViewHolder   dataHolder   = null;

                bool firstTimeResourceLoaded = false;

                ListItemType @type = (ListItemType)GetItemViewType(position);

                if (view == null)                   // otherwise create a new one
                {
                    firstTimeResourceLoaded = true;

                    {
                        switch (@type)
                        {
                        case ListItemType.LeftHeader:
                            view              = context.LayoutInflater.Inflate(Resource.Layout.ChatLeftSideHeaderListItem, null);
                            holder            = headerHolder = new HeaderViewHolder();
                            headerHolder.Name = view.FindViewById <TextView> (Resource.Id.nameTextView);
                            headerHolder.Time = view.FindViewById <TextView> (Resource.Id.timeTextView);
                            break;

                        case ListItemType.RightHeader:
                            view              = context.LayoutInflater.Inflate(Resource.Layout.ChatRightSideHeaderListItem, null);
                            holder            = headerHolder = new HeaderViewHolder();
                            headerHolder.Name = view.FindViewById <TextView> (Resource.Id.nameTextView);
                            headerHolder.Time = view.FindViewById <TextView> (Resource.Id.timeTextView);
                            break;

                        case ListItemType.Left:
                            view   = context.LayoutInflater.Inflate(Resource.Layout.ChatLeftSideListItem, null);
                            holder = dataHolder = new DataViewHolder();
                            dataHolder.AvatarImageView = view.FindViewById <ImageView> (Resource.Id.avatarImageView);
                            dataHolder.Message         = view.FindViewById <TextView> (Resource.Id.bubbleTextView);
                            break;

                        case ListItemType.Right:
                            view   = context.LayoutInflater.Inflate(Resource.Layout.ChatRightSideListItem, null);
                            holder = dataHolder = new DataViewHolder();
                            dataHolder.AvatarImageView = view.FindViewById <ImageView> (Resource.Id.avatarImageView);
                            dataHolder.Message         = view.FindViewById <TextView> (Resource.Id.bubbleTextView);
                            break;

                        case ListItemType.Margin:
                            view = context.LayoutInflater.Inflate(Resource.Layout.ChatMarginHeaderListItem, null);
                            break;

                        default:
                            throw new NotImplementedException();
                        }
                    }

                    if (null != dataHolder)
                    {
                        dataHolder.OriginalEmptyAvatarDrawable = dataHolder.AvatarImageView.Drawable;
                        dataHolder.AvatarWidth  = dataHolder.AvatarImageView.LayoutParameters.Width;
                        dataHolder.AvatarHeight = dataHolder.AvatarImageView.LayoutParameters.Height;

                        // if these fail, you'll need to recode the source to delay the fetching of the avatar until after the render figures out the exact dimensions of the image
                        Contract.Assume(((dataHolder.AvatarWidth != ViewGroup.LayoutParams.MatchParent) && (dataHolder.AvatarWidth != ViewGroup.LayoutParams.WrapContent)));
                        Contract.Assume(((dataHolder.AvatarHeight != ViewGroup.LayoutParams.MatchParent) && (dataHolder.AvatarHeight != ViewGroup.LayoutParams.WrapContent)));
                    }

                    //				holder.LabelTextView = view.FindViewById<TextView> (Resource.Id.labelTextView);

                    view.Tag = holder;
                }
                else
                {
                    holder = view.Tag as ViewHolder;
                    switch (@type)
                    {
                    case ListItemType.LeftHeader:
                    case ListItemType.RightHeader:
                        holder = headerHolder = (HeaderViewHolder)view.Tag;
                        break;

                    case ListItemType.Left:
                    case ListItemType.Right:
                        holder = dataHolder = (DataViewHolder)view.Tag;
                        break;

                    case ListItemType.Margin:
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }

                int person = 0;

                {
                    switch (position % (7 * 2))
                    {
                    case 0:
                        headerHolder.Name.Text = "Alice Apples";
                        headerHolder.Time.Text = "2014-02-08 11:11 am";
                        break;

                    case 1:
                        dataHolder.Message.Text = "Hello?";
                        break;

                    case 2:
                        headerHolder.Name.Text = "Bob Baker";
                        headerHolder.Time.Text = "2014-02-08 11:12 am";
                        break;

                    case 3:
                        person = 1;
                        dataHolder.Message.Text = "Hello!";
                        break;

                    case 4:
                        break;

                    case 5:
                        person = 1;
                        dataHolder.Message.Text = "Wassup?";
                        break;

                    case 6:
                        headerHolder.Name.Text = "Alice Apples";
                        headerHolder.Time.Text = "2014-02-08 11:12 am";
                        break;

                    case 7:
                        dataHolder.Message.Text = "Can you come get me at the steak house? My date turned out to be a real jerk.";
                        break;

                    case 8:
                        headerHolder.Name.Text = "Bob Baker";
                        headerHolder.Time.Text = "2014-02-08 11:13 am";
                        break;

                    case 9:
                        person = 1;
                        dataHolder.Message.Text = "Of course";
                        break;

                    case 10:
                        break;

                    case 11:
                        person = 1;
                        dataHolder.Message.Text = "Are you somewhere warm? It's sure cold out this time of the year.";
                        break;

                    case 12:
                        headerHolder.Name.Text = "Alice Apples";
                        headerHolder.Time.Text = "2014-02-08 11:14 am";
                        break;

                    case 13:
                        dataHolder.Message.Text = "Yes, I am warm and safe. Thanks for asking.";
                        break;

                    default:
                        break;
                    }
                }

                if (null != dataHolder)
                {
                    dataHolder.CurrentDownloader = new AvatarDownloader(dataHolder);

                    BitmapType bitmap = downloader.FetchNowOrAsyncDownload(
                        bogusUrls [person],
                        dataHolder.AvatarWidth,
                        dataHolder.AvatarHeight,
                        dataHolder.CurrentDownloader.HandleDownloaded
                        );

                    if (null != bitmap)
                    {
                        dataHolder.AvatarImageView.SetImageDrawable(bitmap);
                    }
                    else
                    {
                        if (!firstTimeResourceLoaded)
                        {
                            dataHolder.AvatarImageView.SetImageDrawable(dataHolder.OriginalEmptyAvatarDrawable);                                // reset back to original drawable
                        }
                    }
                }

                return(view);
            }