Пример #1
0
        public InvoiceLineCell() : base(Key)
        {
            AutoAddSubview(Description = new UILabel {
                Text = "Description",
            }, 4
                           );

            AutoAddSubview(Price = new UILabel {
                Text = "Price", TextAlignment = UITextAlignment.Center
            }, 2);
            AutoAddSubview(Discount = new UIBorderedButton()
            {
                Title  = "0",
                Tapped = (b) => {
                    if (popup != null)
                    {
                        popup.Dispose();
                    }

                    var d = new DiscountViewController(line.Price)
                    {
                        DollarChanged = (dollar) => {
                            popup.Dismiss(true);
                            Line.Discount = dollar;
                        }
                    };

                    popup             = new UIPopoverController(d);
                    popup.DidDismiss += (object sender, EventArgs e) => {
                        line.Discount = 0;
                        d.Dispose();
                        popup.Dispose();
                        popup = null;
                    };
                    popup.PresentFromRect(Discount.Bounds, Discount, UIPopoverArrowDirection.Any, true);
                }
            }, 2);

            AutoAddSubview(TransTypeButton = new UIBorderedButton {
                Title = "S", TintColor = Color.LightBlue
            });
            TransTypeButton.TouchUpInside += (sender, e) => {
                var sheet = new SimpleActionSheet();
                var types = Database.Main.Table <TransactionType>().ToList();
                types.ForEach(x => sheet.Add(x.Description, Color.LightBlue, () => Line.TransType = x));
                sheet.ShowFrom(TransTypeButton.Bounds, TransTypeButton, true);
            };
            AddSubview(Total = new UILabel {
                Text = "Total", TextAlignment = UITextAlignment.Center
            }, 9, columnspan: 2);
        }
Пример #2
0
        public RootViewController()
        {
            var downloadButton =
                View = stackPanel = new StackPanel()
            {
                new SimpleButton {
                    Title           = "Simple ActionSheet",
                    BackgroundColor = UIColor.Gray,
                    Tapped          = (btn) => {
                        var popup = new SimpleActionSheet()
                        {
                            { "Red", UIColor.Red, () => Console.WriteLine("red") },
                            { "Blue", UIColor.Blue, () => Console.WriteLine("Blue") },
                            { "Black", UIColor.Black, () => Console.WriteLine("Black") },
                            { "Green", UIColor.Green, () => Console.WriteLine("Green") },
                            { "Cancel", () => Console.WriteLine("Cancel") }
                        };
                        popup.ShowInView(View);
                    }
                },
                new SimpleButton {
                    Title           = "I move on tilt",
                    BackgroundColor = UIColor.Gray,
                }.AddMotion(-100, 100),
                new SimpleButton {
                    Title           = "Click to download",
                    BackgroundColor = UIColor.Gray,
                    Tapped          = async(btn) => {
                        btn.Enabled = false;
                        var endPath = Path.Combine(DocumentsFolder, "test.zip");
                        if (File.Exists(endPath))
                        {
                            File.Delete(endPath);
                        }
                        var downloader = new BackgroundDownload();
                        downloader.ProgressChanged += (float obj) => Device.EnsureInvokedOnMainThread(() => btn.Title = obj.ToString());
                        await downloader.DownloadFileAsync(new Uri("http://ipv4.download.thinkbroadband.com/5MB.zip"), endPath);

                        btn.Title   = "Click to download";
                        btn.Enabled = true;
                    }
                },
                new UIImageView(UIImage.FromBundle("monkey").Blur(30))
                {
                    ContentMode = UIViewContentMode.ScaleAspectFill
                },
            };
        }
Пример #3
0
        public SettingsViewController() : base(UITableViewStyle.Grouped, null)
        {
            var testButton = new SimpleButton {
                Title      = "Test Connection",
                TitleColor = UIColor.Black,
                Tapped     = async(t) => {
                    View.DismissKeyboard();
                    var f = t.Frame;
                    t.Title = "Testing...";
                    t.Title = string.Format("Test Connection: {0}", await WebService.Main.Test());
                    t.Frame = f;
                }
            };

            this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => save());
            Root = new RootElement("Settings")
            {
                new Section("Server Settings")
                {
                    new EntryElement("Server", "http://10.0.1.2/api/", Settings.Shared.ServerUrl)
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            Settings.Shared.ServerUrl = v;
                        },
                    },
                    new EntryElement("Test Server", "http://10.0.1.2/api/", Settings.Shared.TestServerUrl)
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            Settings.Shared.TestServerUrl = v;
                        },
                    },
                    new UIViewElement("", testButton, false),
                },
                new Section("iPad Settings")
                {
                    new BooleanElement("Test Mode", Settings.Shared.TestMode)
                    {
                        ValueUpdated = (v) => {
                            Settings.Shared.TestMode = v;
                        }
                    },
                    new EntryElement("Register Id", "1", Settings.Shared.RegisterId.ToString())
                    {
                        ShouldAutoCorrect = false,
                        ValueUpdated      = (v) => {
                            try {
                                Settings.Shared.RegisterId = int.Parse(v);
                            } catch (Exception ex) {
                                Console.WriteLine(ex);
                                new SimpleAlertView("Invalid Register ID", "The Register ID must be a number").Show();
                            }
                        },
                    },
                },
                new Section("Payment Settings")
                {
                    (processorType = new StringElement("Credit Card Processor", Settings.Shared.CreditCardProcessor.ToString(), () => {
                        //
                        var sheet = new SimpleActionSheet();
                        Enum.GetValues(typeof(CreditCardProcessorType)).Cast <CreditCardProcessorType>().ToList().ForEach(x => sheet.Add(x.ToString(), Color.LightBlue, () => {
                            if (x == CreditCardProcessorType.Paypal)
                            {
                                //check if paypal is installed
                            }
                            processorType.Value = x.ToString();
                            Settings.Shared.CreditCardProcessor = x;
                            processorType.Reload();
                            UpdatePaymentDetails();
                        }));
                        sheet.ShowFrom(processorType.GetActiveCell().Bounds, processorType.GetActiveCell(), true);
                    })),
                },
                new Section()
                {
                    new StringElement("Version", NSBundle.MainBundle.InfoDictionary["CFBundleVersion"].ToString()),
                    new StringElement("Check for updates", () => Updater.Shared.Update()),
                }
            };
            UpdatePaymentDetails();
        }
Пример #4
0
        public InvoiceViewController()
        {
            SetTitle();
            Settings.Shared.SubscribeToProperty("TestMode", SetTitle);
            var searchBar = new ItemSearchView {
                Frame = new System.Drawing.RectangleF(0, 0, 200, 30)
            };

            searchBar.ItemSelected += (Item obj) => {
                Invoice.AddItem(obj);
            };
            NavigationItem.RightBarButtonItem = new UIBarButtonItem(searchBar);
            NavigationItem.LeftBarButtonItem  = new UIBarButtonItem(UIImage.FromBundle("menu").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, (s, e) => {
                //Show simple actionsheet
                if (sheet != null)
                {
                    sheet.DismissWithClickedButtonIndex(-1, true);
                    return;
                }
                sheet = new SimpleActionSheet {
                    { "New Invoice", async() => {
                          if (await AskSave())
                          {
                              NewInvoice();
                          }
                      } },
                    { "Load Invoice", () => {
                          if (popover != null)
                          {
                              popover.Dismiss(true);
                          }
                          popover = new UIPopoverController(new UINavigationController(new LoadInvoiceViewController()
                            {
                                InvoiceSelected = async(i) => {
                                    popover.Dismiss(true);
                                    try{
                                        BigTed.BTProgressHUD.ShowContinuousProgress();
                                        if (Invoice != null && Invoice.Id != i.Id)
                                        {
                                            if (!await AskSave())
                                            {
                                                return;
                                            }
                                        }
                                        Invoice.DeleteLocal();
                                        Invoice = await WebService.Main.GetInvoice(i.Id);
                                        Invoice.Save(true);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex);
                                    }
                                    finally{
                                        BigTed.BTProgressHUD.Dismiss();
                                    }
                                },
                            }));
                          popover.DidDismiss += (sender, evt) => {
                              popover.Dispose();
                          };
                          popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any, true);
                      } },
                    { "Payout Buy", () => {
                          if (popover != null)
                          {
                              popover.Dismiss(true);
                          }
                          popover = new UIPopoverController(new UINavigationController(new LoadBuyPayoutViewController()
                            {
                                InvoiceSelected = async(i) => {
                                    popover.Dismiss(true);
                                    try{
                                        BigTed.BTProgressHUD.ShowContinuousProgress();
                                        if (Invoice != null && Invoice.Id != i.Id)
                                        {
                                            if (!await AskSave())
                                            {
                                                return;
                                            }
                                        }
                                        Invoice.DeleteLocal();
                                        Invoice = await WebService.Main.GetInvoice(i.Id);
                                        //Setup payments
                                        Database.Main.Table <PaymentType> ().Where(x => x.IsActive)
                                        .OrderBy(X => X.SortOrder).ToList().ForEach(x => Invoice.Payments.Add(new Payment {
                                            PaymentType = x
                                        }));
                                        Invoice.Save(true);
                                        if ((i as BuyInvoice).IsOnAccount)
                                        {
                                            Invoice.OnAccountPayment.Amount = Invoice.Total;
                                        }
                                        else
                                        {
                                            Invoice.CashPayment.Amount = Invoice.Total;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex);
                                    }
                                    finally{
                                        BigTed.BTProgressHUD.Dismiss();
                                    }
                                },
                            }));
                          popover.DidDismiss += (sender, evt) => {
                              popover.Dispose();
                          };
                          popover.PresentFromBarButtonItem(NavigationItem.LeftBarButtonItem, UIPopoverArrowDirection.Any, true);
                      } },
                    { "Settings", () => this.PresentViewControllerAsync(new UINavigationController(new SettingsViewController()), true) },
                };
                sheet.Dismissed += (object sender, UIButtonEventArgs e2) => {
                    sheet.Dispose();
                    sheet = null;
                };
                sheet.ShowFrom(s as UIBarButtonItem, true);
            });

            //this.AutomaticallyAdjustsScrollViewInsets = false;
        }