public APLCollectionViewCell(CGRect frame) : base(frame)
        {
            try
            {
                //BTProgressHUD.Show("Please wait...");
                CGRect box = new CGRect(Bounds.Location, Bounds.Size);
                box.X           = 0;
                box.Y           = 0;
                box.Height      = box.Height - 140;
                BackgroundColor = UIColor.White;

                btnBack = new UIButton();
                btnBack.BackgroundColor        = UIColor.Black;
                btnBack.Frame                  = new CGRect(2, 2, Bounds.Width + 1, box.Height - 139);
                btnBack.UserInteractionEnabled = false;

                ImageView = new UIButton(box);
                ImageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                ImageView.ContentMode      = UIViewContentMode.ScaleAspectFill;
                //ImageView.Layer.BorderWidth = 3.0f;
                ImageView.ClipsToBounds              = true;
                ImageView.Layer.BorderColor          = UIColor.White.CGColor;
                ImageView.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;

                box.Y    = 3;
                btlImage = new UIButton(box);
                btlImage.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                //btlImage.ContentMode = UIViewContentMode.ScaleAspectFill;
                btlImage.ClipsToBounds              = true;
                btlImage.Layer.BorderColor          = UIColor.White.CGColor;
                btlImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;

                //btlImage.TouchDown += (sender, e) =>
                //{
                //		BTProgressHUD.Show("Loading..."); //show spinner + text
                //};

                btlImage.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show("Loading...");
                    //BTProgressHUD.Dismiss();
                    NavigationController.PushViewController(new DetailViewController(WineBarcode, storeId, false, false), false);
                    LoggingClass.LogInfo("Clicked on " + WineBarcode + " to enter into Details", screen);
                };

                box.Height = 25;
                box.Width  = 25;
                box.X      = (Bounds.Width - 30);
                box.Y      = 5;
                heartImage = new UIButton(box);
                heartImage.ClipsToBounds              = true;
                heartImage.Layer.BorderColor          = UIColor.White.CGColor;
                heartImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                heartImage.Tag            = 0;
                heartImage.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    //Do some actionn
                    if (CurrentUser.RetreiveUserId() != 0)
                    {
                        UIButton temp = (UIButton)sender;
                        if (temp.Tag == 0)
                        {
                            heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                            temp.Tag      = 1;
                            myItem.IsLike = true;
                            LoggingClass.LogInfo("Liked Wine " + WineBarcode, screen);
                        }
                        else
                        {
                            heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                            temp.Tag      = 0;
                            myItem.IsLike = false;
                            LoggingClass.LogInfo("Unliked Wine " + WineBarcode, screen);
                        }
                        //NavigationController.PushViewController(new DetailViewController(), false);
                        SKULike like = new SKULike();
                        like.UserID  = Convert.ToInt32(CurrentUser.RetreiveUserId());
                        like.BarCode = WineBarcode;
                        like.Liked   = Convert.ToBoolean(temp.Tag);
                        ServiceWrapper sw = new ServiceWrapper();
                        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("https://hangoutz.azurewebsites.net/index.html"));
                            }
                        };
                        //alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;

                        alert.Show();
                    }
                };

                //for buy button
                box.Height                        = 35;
                box.Width                         = 35;
                box.X                             = (Bounds.Width - 40);
                box.Y                             = 40;
                btnBuy                            = new UIButton(box);
                btnBuy.ClipsToBounds              = true;
                btnBuy.Layer.BorderColor          = UIColor.White.CGColor;
                btnBuy.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                btnBuy.SetImage(UIImage.FromFile("buy.png"), UIControlState.Normal);
                btnBuy.TouchUpInside += delegate {
                    NavigationController.PushViewController(new ExploreViewController("http://www.wineoutlet.com/sku" + Sku + ".html"), false);
                    //UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.wineoutlet.com/sku"+Sku+".html"));
                };

                CGRect lower = new CGRect(Bounds.Location, Bounds.Size);
                lower.Y     = 50;             //lower.Y + (ratio)*(Bounds.Height);
                btnItemname = new UIButton(lower);
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                btnItemname.Font           = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode  = UILineBreakMode.WordWrap;
                btnItemname.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show("Loading...");
                    //BTProgressHUD.Dismiss();
                    NavigationController.PushViewController(new DetailViewController(WineBarcode, storeId, false, false), false);
                    LoggingClass.LogInfo("Clicked on " + WineBarcode + " to enter into Details", screen);
                };
                lblName               = new UILabel(lower);
                lblName.Font          = UIFont.FromName("Verdana-Bold", 13f);
                lblName.TextColor     = UIColor.Purple;
                lblName.Text          = WineName;
                lblName.TextAlignment = UITextAlignment.Center;
                lblName.LineBreakMode = UILineBreakMode.WordWrap;
                lblName.Lines         = 0;


                lower.Y      = 245;
                lower.Height = 1;
                lower.Width  = lower.Width - 20;
                lower.X      = lower.X + 10;

                Separator = new UIImageView(lower);
                Separator.AutoresizingMask  = UIViewAutoresizing.FlexibleWidth;
                Separator.Image             = UIImage.FromFile("separator.png");
                Separator.ContentMode       = UIViewContentMode.ScaleAspectFill;
                Separator.ClipsToBounds     = true;
                Separator.Layer.BorderColor = UIColor.White.CGColor;
                Separator.BackgroundColor   = UIColor.LightGray;

                CGRect year = new CGRect(Bounds.Location, Bounds.Size);
                year.Y                  = lower.Y - 15;
                year.X                  = year.Width / 2 - 25;
                year.Height             = 30;
                year.Width              = 50;
                lblYear                 = new UILabel(year);
                lblYear.Font            = UIFont.FromName("Verdana", 12f);
                lblYear.Text            = Vintage;
                lblYear.TextAlignment   = UITextAlignment.Center;
                lblYear.BackgroundColor = UIColor.White;


                lblRegPrice      = new UILabel(new CGRect(0, Bounds.Height - 60, Bounds.Width, 12f));
                lblRegPrice.Text = RegPrice;

                lblRegPrice.Font = UIFont.FromName("Verdana", 13f);

                lblRegPrice.TextAlignment = UITextAlignment.Center;

                var ratingConfig = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"),
                                                    filledImage: UIImage.FromBundle("Stars/star.png"),
                                                    chosenImage: UIImage.FromBundle("Stars/star.png"));
                //decimal averageRating = 3.25m;

                ratingView = new PDRatingView(new CGRect(Bounds.Width * 1 / 4, Bounds.Height - 40, Bounds.Width / 2, 14f), ratingConfig, averageRating);
                ratingView.UserInteractionEnabled = false;
                //ratingView.BackgroundColor = UIColor.White;
                //Console.WriteLine(Sku);
                //if (Sku != null)
                //{
                //ContentView.AddSubview(btnBuy);
                //}

                AmountLeft = new UITextView(new CGRect(0, Bounds.Height - 30, Bounds.Width, 20));
                AmountLeft.TextAlignment = UITextAlignment.Center;
                AmountLeft.Editable      = false;
                //AmountLeft.ProgressTintColor = UIColor.Blue;
                //AmountLeft.SetProgress(1, true);
                //AmountLeft.Progress = 30f;
                //ContentView.AddSubview(btnBack);
                ContentView.AddSubview(ImageView);
                ContentView.InsertSubviewAbove(btlImage, ImageView);
                ContentView.AddSubview(AmountLeft);
                ContentView.AddSubview(heartImage);
                //ContentView.AddSubview(lblName);
                ContentView.AddSubview(btnItemname);
                ContentView.AddSubview(Separator);
                ContentView.AddSubview(lblYear);
                ContentView.AddSubview(lblRegPrice);
                ContentView.AddSubview(ratingView);
                ContentView.AddSubview(btnBuy);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screen, ex.StackTrace);
            }
        }
        public MyReviewCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            try
            {
                btnBack = new UIButton();
                btnBack.BackgroundColor        = UIColor.FromRGB(63, 63, 63);
                btnBack.UserInteractionEnabled = false;
                SelectionStyle             = UITableViewCellSelectionStyle.Gray;
                imageView                  = new UIButton();
                imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                imageView.ContentMode      = UIViewContentMode.Center;
                imageView.ClipsToBounds    = true;
                //imageView.TouchDown += (object sender, EventArgs e) =>
                //{
                //	BTProgressHUD.Show("Loading...");
                //};
                imageView.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show(LoggingClass.txtloading);
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                Review review = new Review();
                separator = new UIImageView();

                btnItemname = new UIButton();
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal);
                btnItemname.Font                = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode       = UILineBreakMode.WordWrap;
                btnItemname.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                btnItemname.TouchUpInside      += delegate
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                ReviewDate = new UILabel()
                {
                    Font      = UIFont.FromName("AmericanTypewriter", 10f),
                    TextColor = UIColor.FromRGB(38, 127, 200),
                    //TextAlignment = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                Comments = new UITextView()
                {
                    Font          = UIFont.FromName("AmericanTypewriter", 14f),
                    TextColor     = UIColor.FromRGB(55, 127, 0),
                    TextAlignment = UITextAlignment.Justified,
                    //TextAlignment = UITextAlignment.Natural,
                    BackgroundColor = UIColor.Clear,
                    //LineBreakMode = UILineBreakMode.WordWrap
                    Editable   = false,
                    Selectable = false
                };
                ReadMore = new UIButton()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    BackgroundColor = UIColor.White
                };
                Vintage = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                decimal averageRating = 0.0m;
                var     ratingConfig  = new RatingConfig(emptyImage: UIImage.FromBundle("Stars/star-silver2.png"),
                                                         filledImage: UIImage.FromBundle("Stars/star.png"),
                                                         chosenImage: UIImage.FromBundle("Stars/star.png"));
                stars   = new PDRatingView(new CGRect(110, 60, 60, 20), ratingConfig, averageRating);
                btnEdit = new UIButton();
                btnEdit.SetImage(UIImage.FromFile("edit.png"), UIControlState.Normal);
                btnEdit.TouchUpInside += (sender, e) =>
                {
                    PopupView yourController = new PopupView(WineIdLabel.Text, storeid);
                    yourController.NavController  = NavController;
                    yourController.parent         = Parent;
                    yourController.StartsSelected = stars.AverageRating;
                    yourController.Comments       = Comments.Text;
                    LoggingClass.LogInfo("Edited the review of " + wineId, screenid);


                    //yourController.WineId = Convert.ToInt32(WineIdLabel.Text);
                    yourController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    //this.PresentViewController(yourController, true, null);
                    Parent.PresentModalViewController(yourController, false);
                };
                btnDelete = new UIButton();
                btnDelete.SetImage(UIImage.FromFile("delete.png"), UIControlState.Normal);
                btnDelete.TouchUpInside += (sender, e) =>
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Delete Review ",
                        Message = LoggingClass.txtdeletereview,
                    };
                    alert.AddButton("Yes");
                    alert.AddButton("No");

                    alert.Clicked += async(senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 0)
                        {
                            review.Barcode      = WineIdLabel.Text;
                            review.ReviewUserId = Convert.ToInt32(CurrentUser.RetreiveUserId());
                            BTProgressHUD.Show("Deleting review");
                            await sw.DeleteReview(review);

                            LoggingClass.LogInfo("Deleting the review of " + wineId, screenid);
                            BTProgressHUD.ShowSuccessWithStatus("Done");
                            ((IPopupParent)Parent).RefreshParent();
                        }
                    };

                    alert.Show();
                };
                btnLike = new UIButton();
                btnLike.ClipsToBounds              = true;
                btnLike.Layer.BorderColor          = UIColor.White.CGColor;
                btnLike.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                btnLike.Tag = 0;
                //myItem = new Item();
                //bool count =Convert.ToBoolean( myItem.IsLike);
                //if (count == true)
                //{
                //btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);}
                //else
                //{
                //	btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                //}
                btnLike.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    try
                    {
                        UIButton temp = (UIButton)sender;
                        if (temp.Tag == 0)
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                            temp.Tag   = 1;
                            Data.Liked = 1;
                            //btnLike.Tag = 1;
                            LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screenid);
                        }
                        else
                        {
                            btnLike.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                            temp.Tag   = 0;
                            Data.Liked = 0;

                            LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screenid);
                        }
                        SKULike like = new SKULike();
                        like.UserID  = Convert.ToInt32(CurrentUser.RetreiveUserId());
                        like.BarCode = WineIdLabel.Text;
                        like.Liked   = Convert.ToBoolean(temp.Tag);

                        Data.Liked = Convert.ToInt32(temp.Tag);
                        await sw.InsertUpdateLike(like);
                    }
                    catch (Exception ex)
                    {
                        LoggingClass.LogError(ex.Message, screenid, ex.StackTrace);
                    }
                };
                WineIdLabel = new UILabel();
                ContentView.AddSubviews(new UIView[] { btnBack, btnItemname, ReadMore, ReviewDate, Comments, stars, imageView, Vintage, separator, btnEdit, btnDelete, btnLike });
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
Ejemplo n.º 3
0
        public MyTastingCellView(NSString cellId) : base(UITableViewCellStyle.Default, cellId)
        {
            try
            {
                SelectionStyle = UITableViewCellSelectionStyle.Gray;
                LoggingClass.LogInfo("Entered Into Tasting View", screen);
                imageView = new UIButton();
                imageView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
                imageView.ContentMode      = UIViewContentMode.Center;
                imageView.ClipsToBounds    = true;

                imageView.TouchUpInside += (object sender, EventArgs e) =>
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                separator   = new UIImageView();
                btnItemname = new UIButton();
                btnItemname.SetTitle("", UIControlState.Normal);
                btnItemname.SetTitleColor(UIColor.FromRGB(127, 51, 0), UIControlState.Normal);
                btnItemname.Font           = UIFont.FromName("Verdana-Bold", 13f);
                btnItemname.LineBreakMode  = UILineBreakMode.WordWrap;
                btnItemname.TouchUpInside += delegate
                {
                    BTProgressHUD.Show("Loading...");
                    NavController.PushViewController(new DetailViewController(WineIdLabel.Text, storeid.ToString(), false, true), false);
                };
                WineName = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 14f),
                    TextColor       = UIColor.FromRGB(127, 51, 0),
                    BackgroundColor = UIColor.Clear,
                };
                ReviewDate = new UILabel()
                {
                    Font      = UIFont.FromName("AmericanTypewriter", 10f),
                    TextColor = UIColor.FromRGB(38, 127, 200),
                    //TextAlignment = UITextAlignment.Center,
                    BackgroundColor = UIColor.Clear
                };
                Vintage = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                location = new UILabel()
                {
                    Font            = UIFont.FromName("Verdana", 10f),
                    TextColor       = UIColor.FromRGB(127, 51, 100),
                    BackgroundColor = UIColor.Clear
                };
                heartImage = new UIButton();
                heartImage.ClipsToBounds              = true;
                heartImage.Layer.BorderColor          = UIColor.White.CGColor;
                heartImage.Layer.EdgeAntialiasingMask = CAEdgeAntialiasingMask.LeftEdge | CAEdgeAntialiasingMask.RightEdge | CAEdgeAntialiasingMask.BottomEdge | CAEdgeAntialiasingMask.TopEdge;
                heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                heartImage.Tag = 0;
                myItem         = new Item();
                bool count = Convert.ToBoolean(myItem.IsLike);
                if (count == true)
                {
                    heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                }
                else
                {
                    heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                }
                heartImage.TouchUpInside += async(object sender, EventArgs e) =>
                {
                    try
                    {
                        //Do some actionn
                        if (CurrentUser.RetreiveUserId() != 0)
                        {
                            UIButton temp = (UIButton)sender;
                            if (temp.Tag == 0)
                            {
                                heartImage.SetImage(UIImage.FromFile("heart_full.png"), UIControlState.Normal);
                                temp.Tag      = 1;
                                myItem.IsLike = true;
                                taste.IsLike  = true;
                                LoggingClass.LogInfo("Liked Wine " + WineIdLabel.Text, screen);
                            }
                            else
                            {
                                heartImage.SetImage(UIImage.FromFile("heart_empty.png"), UIControlState.Normal);
                                temp.Tag      = 0;
                                myItem.IsLike = false;
                                taste.IsLike  = false;
                                LoggingClass.LogInfo("Unliked Wine " + WineIdLabel.Text, screen);
                            }
                            //NavigationController.PushViewController(new DetailViewController(), false);
                            SKULike like = new SKULike();
                            like.UserID   = Convert.ToInt32(CurrentUser.RetreiveUserId());
                            like.BarCode  = WineIdLabel.Text;
                            like.Liked    = Convert.ToBoolean(temp.Tag);
                            myItem.IsLike = Convert.ToBoolean(temp.Tag);
                            ServiceWrapper sw = new ServiceWrapper();
                            await sw.InsertUpdateLike(like);
                        }
                    }
                    catch (Exception ex)
                    {
                        LoggingClass.LogError(ex.Message, screen, ex.StackTrace);
                    }
                };
                WineIdLabel = new UILabel();
                ContentView.AddSubviews(new UIView[] { btnItemname, ReviewDate, imageView, Vintage, separator, heartImage, location });
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.Message, screen, ex.StackTrace);
            }
        }