示例#1
0
        protected async void Handle_FinishedPickingMedia(object sender, UIImagePickerMediaPickedEventArgs e)
        {
            try
            {
                //Console.WriteLine("Enterd into Gallery pick");
                // determine what was selected, video or image
                bool isImage = false;
                switch (e.Info[UIImagePickerController.MediaType].ToString())
                {
                case "public.image":
                    //Console.WriteLine("Image selected");
                    isImage = true;
                    break;

                case "public.video":
                    //Console.WriteLine("Video selected");
                    break;
                }
                if (isImage)
                {
                    // get the original image

                    UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage;
                    if (originalImage != null)
                    {
                        // do something with the image

                        //Console.WriteLine("got the original image");
                        imgprofilepic.Image = originalImage;                         // display
                        using (NSData imagedata = originalImage.AsJPEG())
                        {
                            byte[] myByteArray = new byte[imagedata.Length];
                            System.Runtime.InteropServices.Marshal.Copy(imagedata.Bytes,
                                                                        myByteArray, 0, Convert.ToInt32(imagedata.Length));

                            byte[] img = BlobWrapper.ResizeImageIOS(myByteArray, 250, 300);
                            int    i   = img.Length;
                            await BlobWrapper.UploadProfilePic(img, i);
                        }
                    }
                }
                else
                {                 // if it's a video
                                  // get video url
                    NSUrl mediaURL = e.Info[UIImagePickerController.MediaURL] as NSUrl;
                    if (mediaURL != null)
                    {
                        //Console.WriteLine(mediaURL.ToString());
                    }
                }
                // dismiss the picker
                imagePicker.DismissModalViewController(true);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
 //public override void ViewDidAppear(bool animated)
 //{
 //	base.ViewDidAppear(animated);
 //	//NavigationController.Title = "Locations";
 //	//NavigationController.NavigationBar.TopItem.Title = "Locations";
 //	string validUser = CurrentUser.RetreiveUserName();
 //	LoggingClass.LogInfo("opened app " + validUser, screenid);
 //	if (validUser == "" || validUser == null)
 //	{
 //		LoginViewController yourController = new LoginViewController();
 //		yourController.nav = NavigationController;
 //		yourController.root = this;
 //		yourController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
 //		this.PresentModalViewController(yourController, false);
 //	}
 //}
 public async void UploadProfilePic(UIImage originalImage)
 {
     if (originalImage != null)
     {
         imgProfile.Image = originalImage;                 // display
         using (NSData imagedata = originalImage.AsJPEG())
         {
             byte[] myByteArray = new byte[imagedata.Length];
             System.Runtime.InteropServices.Marshal.Copy(imagedata.Bytes, myByteArray, 0, Convert.ToInt32(imagedata.Length));
             byte[] img = BlobWrapper.ResizeImageIOS(myByteArray, 250, 300);
             int    i   = img.Length;
             await BlobWrapper.UploadProfilePic(img, i);
         }
     }
 }
示例#3
0
        public static UIImage GetResizedImage(string wineId, CGRect bounds, string storeid)
        {
            UIImage image = BlobWrapper.GetImageBitmapFromWineId(wineId);

            if (image != null)
            {
                nfloat boxHeight = bounds.Height;
                nfloat imgHeight = image.Size.Height;
                nfloat ratio     = boxHeight / imgHeight;
                //if (ratio < 1)
                {
                    CGSize newSize = new CGSize(image.Size.Width * ratio, image.Size.Height * ratio);
                    image = image.Scale(newSize);
                }
                return(image);
            }

            return(null);           //new UIImage("Wines/wine3.png");
        }
示例#4
0
        public void UpdateCell(Review review)
        {
            try
            {
                UIImage img = BlobWrapper.GetProfileImageforUser(review.ReviewUserId);
                if (img != null)
                {
                    imageView.Image = img;
                }
                else
                {
                    imageView.Image = new UIImage("user1.png");
                }
                userName.Text   = review.Username;
                ReviewDate.Text = review.Date.ToString("MM-dd-yyyy");
                Comments.Text   = review.RatingText;
                if (review.RatingText.Length > 97)
                {
                    Readmore.Frame          = new CGRect(160, 71, ContentView.Bounds.Width, 20);
                    Readmore.TouchUpInside += delegate {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = review.RatingText,
                            //Message = "Coming Soon..."
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    };
                }
                //CGSize sTemp = new CGSize(ContentView.Bounds.Width - 50, 100);
                //sTemp = Comments.SizeThatFits(sTemp);
                //Comments.Frame = new CGRect(0, 40, ContentView.Bounds.Width - 50, sTemp.Height);
                //stars = new PDRatingView(new CGRect(150, 2, 60, 20), ratingConfig, review.Stars);
                //ContentView.Bounds.Height = 90;
                stars.AverageRating = review.RatingStars;
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace);
            }
        }
        public void UpdateCell(Review review)
        {
            try
            {
                string url = review.SmallImageURL;
                if (url == null)
                {
                    url = review.Barcode + ".jpg";
                }
                imageView.SetImage(BlobWrapper.GetResizedImage(url, new CGRect(0, 0, 100, 155), review.PlantFinal), UIControlState.Normal);
                separator.Image = UIImage.FromFile("separator.png");
                if (review.Vintage.Length < 4)
                {
                    btnItemname.SetTitle(review.Name + " ", UIControlState.Normal);
                }
                else
                {
                    btnItemname.SetTitle(review.Name + " " + review.Vintage, UIControlState.Normal);
                }
                ReviewDate.Text = review.Date.ToString("MM-dd-yyyy");
                Comments.Text   = review.RatingText;
                if (review.RatingText.Length > 97)
                {
                    ReadMore.Frame          = new CGRect(ContentView.Bounds.Width - 25, 160, 70, 25);
                    ReadMore.TouchUpInside += delegate {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = review.RatingText,
                            //Message = "Coming Soon..."
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    };
                }
                if (review.Liked == 1)
                {
                    btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                    //btnLike.TouchUpInside +=async delegate {
                    //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    //		SKULike like = new SKULike();
                    //		like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId());
                    //		like.BarCode = WineIdLabel.Text;
                    //		like.Liked = Convert.ToBoolean(0);
                    //		myItem.IsLike = Convert.ToBoolean(0);
                    //		await sw.InsertUpdateLike(like);
                    //};
                    btnLike.Tag = 1;
                }
                else
                {
                    btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    btnLike.Tag = 0;
                }
                //if (review.  == true)
                //	{
                //		heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                //	}
                //CGSize sTemp = new CGSize(ContentView.Frame.Width, 100);
                //sTemp = Comments.SizeThatFits(sTemp);
                //if (review.RatingText.Length > 100)
                //{
                //	//ContentView.AddSubview(ReadMore);
                //	ReadMore.TouchUpInside += delegate {
                //		{
                //			UIAlertView alert = new UIAlertView()
                //			{
                //				Title = review.RatingText,
                //				//Message = "Coming Soon..."
                //			};

                //			alert.AddButton("OK");
                //			alert.Show();
                //		};
                //	};
                //	//ReadMore.Hidden = false;
                //}
                //Vintage.Text = " ";//"Vintage:"+review.Vintage.ToString();
                storeid          = Convert.ToInt32(review.PlantFinal);
                WineIdLabel.Text = review.Barcode.ToString();
                ReadMore.SetTitle("... Read More", UIControlState.Normal);
                ReadMore.SetTitleColor(UIColor.Black, UIControlState.Normal);
                ReadMore.BackgroundColor = UIColor.White;
                stars.AverageRating      = Convert.ToDecimal(review.RatingStars);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
示例#6
0
        public void UpdateCell(Tastings tasting)
        {
            try
            {
                string url = tasting.SmallImageUrl;
                if (url == null)
                {
                    url = tasting.Barcode + ".jpg";
                }
                imageView.SetImage(BlobWrapper.GetResizedImage(url, new CGRect(0, 0, 100, 155), tasting.PlantFinal.ToString()), UIControlState.Normal);
                separator.Image = UIImage.FromFile("separator.png");
                WineName.Text   = tasting.Name;
                ReviewDate.Text = "Tasted on :" + tasting.TastingDate.ToString("MM-dd-yyyy");
                double l = Math.Floor(Math.Log10(tasting.Vintage) + 1);
                if (l < 4)
                {
                    Vintage.Text = " ";
                }
                else
                {
                    Vintage.Text = tasting.Vintage.ToString();
                }
                if (tasting.PlantFinal == 1)
                {
                    location.Text = "Tasted at : " + LoggingClass.txtstore1;
                }
                else
                {
                    location.Text = "Tasted at : " + LoggingClass.txtstore2;
                }
                WineIdLabel.Text = tasting.Barcode;
                btnItemname.SetTitle(tasting.Name, UIControlState.Normal);
                btnItemname.LineBreakMode       = UILineBreakMode.WordWrap;
                btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                storeid = tasting.PlantFinal;
                if (tasting.IsLike == true)
                {
                    heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
//						heartImage.TouchUpInside +=async delegate {
//						heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
//							SKULike like = new SKULike();
//							like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId());
//							like.BarCode = WineIdLabel.Text;
//							like.Liked = Convert.ToBoolean(0);
//							myItem.IsLike = Convert.ToBoolean(0);
//							ServiceWrapper sw = new ServiceWrapper();
//							await sw.InsertUpdateLike(like);
//					};
                }
                else
                {
                    heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                }
            }
            catch (Exception ex)
            {
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Sorry",
                    Message = "Something went wrong. We are on it"
                };
                alert.AddButton("OK");
                alert.Show();
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace);
            }
        }
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            try
            {
                //downloading all wine images
                BlobWrapper.DownloadAllImages();
                // Override point for customization after application launch.
                // If not required for your application you can safely delete this method
                UITabBarController RootTab = (UITabBarController)Window.RootViewController;
                //CurrentUser.Clear();
                CurrentUser.Store("48732", "user Simulator");
                //for direct log in
                //CurrentUser.PutCa	rdNumber("7207589007");
                //Console.WriteLine(DateTime.Now + " App opened");
                UIImage profile = UIImage.FromFile("profile.png");
                profile = ResizeImage(profile, 25, 25);
                _window = Window;
                UIImage info = UIImage.FromFile("Info.png");
                info = ResizeImage(info, 25, 25);
                //Checking the user already logged in or not
                if (CurrentUser.RetreiveUserId() != 0)
                {
                    ManageTabBar(RootTab);
                    LoggingClass.LogInfo("App opened " + CurrentUser.RetreiveUserId(), screen);
                    nav = new UINavigationController(RootTab);
                    //Window.RootViewController = RootTab;
                    AddNavigationButtons(nav);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
                //Checking Guest logged in or not
                else if (CurrentUser.GetGuestId() != "0" && CurrentUser.GetGuestId() != null)
                {
                    CurrentUser.Store("0", "Guest");
                    ManageTabBar(RootTab);
                    //Console.WriteLine(DateTime.Now + " App opened");
                    nav = new UINavigationController(RootTab);
                    //Window.RootViewController = RootTab;
                    AddNavigationButtons(nav);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
                else
                {
                    ManageTabBar(RootTab);
                    var login = new LoginViewController();
                    login.RootTabs = Window.RootViewController;
                    login._window  = Window;
                    nav            = new UINavigationController(login);
                    //nav.NavigationBar.BackgroundColor = UIColor.FromRGB(97, 100, 142);
                    UIBarButtonItem.Appearance.TintColor = UIColor.FromRGB(128, 0, 128);
                    Window.RootViewController            = nav;
                }
            }
            catch (Exception exe)
            {
                LoggingClass.LogError(exe.Message, screen, exe.StackTrace);
            }
            //Notification Settings
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }
            return(true);
        }
        public void BindData(MyFavViewCell cell, NSIndexPath indexPath)
        {
            try
            {
                cell.NavigationController = NavigationController;
                //cell.btlImage.SetBackgroundImage(UIImage.FromFile("Wines/wine" + indexPath.Item % 8 + ".png"), UIControlState.Normal);
                cell.parent = this.View;


                int index = (int)indexPath.Item;

                //Data from Model
                //cell.WineName = myData.ItemList[index].Name;
                //cell.AmountLeft.SetProgress(Convert.ToSingle(myData.ItemList[index].AvailableVolume),true);
                double l = Math.Floor(Math.Log10(myData.ItemList[index].Vintage) + 1);
                if (l < 4)
                {
                    cell.lblYear.Text = " ";
                }
                else
                {
                    cell.lblYear.Text = myData.ItemList[index].Vintage.ToString();
                }
                cell.RegPrice      = myData.ItemList[index].SalePrice.ToString();
                cell.averageRating = (decimal)myData.ItemList[index].AverageRating;
                cell.lblName.Text  = myData.ItemList[index].Name;
                //cell.lblYear.Text = myData.ItemList[index].Vintage.ToString();
                cell.lblRegPrice.Text         = myData.ItemList[index].SalePrice.ToString("C", Cultures.UnitedState);
                cell.ratingView.AverageRating = (decimal)myData.ItemList[index].AverageRating;
                cell.myItem      = myData.ItemList[index];
                cell.WineBarcode = myData.ItemList[index].Barcode;
                cell.btnItemname.SetTitle(myData.ItemList[index].Name, UIControlState.Normal);
                if (myData.ItemList[index].IsLike == true)
                {
                    cell.heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                }
                else
                {
                    cell.heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                }
                string url = myData.ItemList[index].SmallImageUrl;
                if (url == null)
                {
                    url = myData.ItemList[index].Barcode + ".jpg";
                }
                //UIImage image = BlobWrapper.GetImageBitmapFromWineId(myData.ItemList[index].WineId.ToString());
                UIImage image = BlobWrapper.GetResizedImage(url, cell.btlImage.Bounds, cell.storeId.ToString());
                if (image != null)
                {
                    cell.btlImage.SetImage(image, UIControlState.Normal);
                }
                else
                {
                    cell.btlImage.SetImage(img, UIControlState.Normal);
                }
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace.ToString());
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Something went wrong. We are on it."
                            //Message = "Coming Soon..."
                };

                alert.AddButton("OK");
                alert.Show();
            }
        }
        public void BindData(APLCollectionViewCell cell, NSIndexPath indexPath, Boolean fav)
        {
            try
            {
                cell.NavigationController = NavigationController;
                //cell.btlImage.SetBackgroundImage(UIImage.FromFile("Wines/wine" + indexPath.Item % 8 + ".png"), UIControlState.Normal);
                cell.parent = this.View;
                //NavigationController.NavigationBar.TopItem.Title = "Locations";

                int index = (int)indexPath.Item;

                //Data from Model
                //cell.WineName = myData.ItemList[index].Name;
                //cell.AmountLeft.SetProgress(Convert.ToSingle(myData.ItemList[index].AvailableVolume),true);
                double l = Math.Floor(Math.Log10(myData.ItemList[index].Vintage) + 1);
                if (l > 4)
                {
                    cell.Vintage = "";
                }
                else
                {
                    cell.Vintage = myData.ItemList[index].Vintage.ToString();
                }
                cell.AmountLeft.Text = "Wine left in bottle: " + myData.ItemList[index].AvailableVolume.ToString() + ".ml";
                cell.RegPrice        = myData.ItemList[index].SalePrice.ToString();
                cell.averageRating   = (decimal)myData.ItemList[index].AverageRating;
                cell.WineBarcode     = myData.ItemList[index].Barcode;
                //cell.btnBuy.TouchUpInside+= delegate {
                //	UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.wineoutlet.com/sku"+myData.ItemList[index].SKU+".html"));
                //};
                cell.Sku = myData.ItemList[index].SKU;
                if (fav == true)
                {
                    cell.storeId           = myData.ItemList[index].PlantFinal.ToString();
                    cell.AmountLeft.Hidden = true;
                }
                else
                {
                    cell.storeId = storeId.ToString();
                }
                cell.lblName.Text = myData.ItemList[index].Name;
                if (myData.ItemList[index].Vintage.ToString().Length < 4)
                {
                    cell.lblYear.Text = " ";
                }
                else
                {
                    cell.lblYear.Text = myData.ItemList[index].Vintage.ToString();
                }
                cell.lblRegPrice.Text         = myData.ItemList[index].RegPrice.ToString("C", Cultures.UnitedState);
                cell.ratingView.AverageRating = (decimal)myData.ItemList[index].AverageRating;
                cell.myItem = myData.ItemList[index];
                //Boolean temp;
                SKULike        like = new SKULike();
                ServiceWrapper sw   = new ServiceWrapper();
                cell.btnItemname.SetTitle(myData.ItemList[index].Name, UIControlState.Normal);
                if (myData.ItemList[index].IsLike == true)
                {
                    cell.heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                    cell.heartImage.Tag = 1;
                    //cell.heartImage.TouchUpInside +=async delegate
                    //{
                    //	if (CurrentUser.RetreiveUserId() != 0)
                    //	{
                    //		cell.heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    //		like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId());
                    //		like.BarCode = cell.WineBarcode;
                    //		like.Liked = false;
                    //		await sw.InsertUpdateLike(like);
                    //	}
                    //	else
                    //	{
                    //		UIAlertView alert = new UIAlertView()
                    //		{
                    //			Title = "This feature is allowed only for VIP Card holders",
                    //			//Message = "Coming Soon..."
                    //		};
                    //		alert.AddButton("OK");
                    //		alert.AddButton("Know more");
                    //		alert.Clicked += (senderalert, buttonArgs) =>
                    //		{
                    //			if (buttonArgs.ButtonIndex == 1)
                    //			{
                    //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                    //			}
                    //		};
                    //		alert.Show();
                    //	}
                    //};
                }
                else
                {
                    cell.heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                    cell.heartImage.Tag = 0;
                    //cell.heartImage.TouchUpInside +=async delegate
                    //{
                    //	if (CurrentUser.RetreiveUserId() != 0)
                    //	{
                    //		cell.heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                    //		like.UserID = Convert.ToInt32(CurrentUser.RetreiveUserId());
                    //		like.BarCode = cell.WineBarcode;
                    //		like.Liked = true;
                    //		await sw.InsertUpdateLike(like);
                    //	}
                    //	else
                    //	{
                    //		UIAlertView alert = new UIAlertView()
                    //		{
                    //			Title = "This feature is allowed only for VIP Card holders",
                    //			//Message = "Coming Soon..."
                    //		};
                    //		alert.AddButton("OK");
                    //		alert.AddButton("Know more");
                    //		alert.Clicked += (senderalert, buttonArgs) =>
                    //		{
                    //			if (buttonArgs.ButtonIndex == 1)
                    //			{
                    //				UIApplication.SharedApplication.OpenUrl(new NSUrl("http://savvyitdev.com/winehangouts/"));
                    //			}
                    //		};
                    //		alert.Show();
                    //	}
                    //};
                }
                //UIImage image = BlobWrapper.GetImageBitmapFromWineId(myData.ItemList[index].WineId.ToString());
                string url = myData.ItemList[index].SmallImageUrl;
                if (url == null)
                {
                    url = myData.ItemList[index].Barcode + ".jpg";
                }
                UIImage image = BlobWrapper.GetResizedImage(url, cell.btlImage.Bounds, cell.storeId.ToString());
                if (image != null)
                {
                    cell.btlImage.SetImage(image, UIControlState.Normal);
                }
                else
                {
                    cell.btlImage.SetImage(img, UIControlState.Normal);
                }
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace.ToString());
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Something went wrong. We are on it."
                            //Message = "Coming Soon..."
                };

                alert.AddButton("OK");
                alert.Show();
            }
        }