Пример #1
0
        public KeyboardForm(TextBox edOriginal = null)
        {
            InitializeComponent();
            m_edOriginal = edOriginal;
            m_keyboard   = new MyKeyboard();

            h_FillForm();
        }
Пример #2
0
        public Vector2 updateVelWithInput(Player player, MyKeyboard keyboard)
        {
            Vector2 newVelocity = new Vector2(player.velocity.X, player.velocity.Y);

            if (keyboard.GetPress("W") && !isInAir)
            {
                newVelocity.Y  = -12;
                player.isInAir = true;
            }
            if (keyboard.GetPress("S"))
            {
                newVelocity.Y = 12;
            }
            if (keyboard.GetPress("A"))
            {
                newVelocity.X = -4;
            }
            if (keyboard.GetPress("D"))
            {
                newVelocity.X = 4;
            }

            return(newVelocity);
        }
Пример #3
0
        public AddFreeProducts(SaleOrder SaleOrder, OrderPreviewForm OrderPreviewForm)
        {
            InitializeComponent();

            this.SaleOrder        = SaleOrder;
            this.OrderPreviewForm = OrderPreviewForm;

            ArticlesList.HasUnevenRows  = true;
            ArticlesList.SeparatorColor = Color.FromHex("A5ABB7");
            ArticlesList.ItemSelected  += ArticlesList_ItemSelected;
            CustomFreeProductStuffListCell.UnitNameTapEventHandler = (s, e) => {
                var StuffId = (Guid)((TappedEventArgs)e).Parameter;
                UnitNameClicked(StuffId);
            };
            CustomFreeProductStuffListCell.QuantityPlusTapEventHandler = (s, e) => {
                var StuffId = (Guid)((TappedEventArgs)e).Parameter;
                QuantityPlusClicked(StuffId);
            };
            CustomFreeProductStuffListCell.QuantityMinusTapEventHandler = (s, e) => {
                var StuffId = (Guid)((TappedEventArgs)e).Parameter;
                QuantityMinusClicked(StuffId);
            };
            CustomFreeProductStuffListCell.AddedQuantityTextBoxTapEventHandler = async(s, e) =>
            {
                var StuffId = (Guid)((TappedEventArgs)e).Parameter;
                FocusedAddedQuantityTextBoxStuffId = StuffId;
                var ArticleRow = ArticlesData.SingleOrDefault(a => a.StuffId == StuffId);
                if (ArticleRow != null)
                {
                    await Task.Delay(200);

                    ArticlesList.ScrollTo(ArticleRow, ScrollToPosition.Start, true);
                }
            };
            ArticlesList.ItemTemplate = new DataTemplate(typeof(CustomFreeProductStuffListCell));
            ArticlesListHeader.Children.Add(new CustomFreeProductStuffListCell().GetView(false));

            ToolbarItem_SearchBar            = new ToolbarItem();
            ToolbarItem_SearchBar.Text       = "جستجو";
            ToolbarItem_SearchBar.Icon       = "Search.png";
            ToolbarItem_SearchBar.Activated += ToolbarItem_SearchBar_Activated;
            ToolbarItem_SearchBar.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_SearchBar.Priority   = 10;
            if (!this.ToolbarItems.Contains(ToolbarItem_SearchBar) && !StuffsSearchBar.IsVisible)
            {
                this.ToolbarItems.Add(ToolbarItem_SearchBar);
            }

            StuffsSearchBar.TextChanged += async(sender, args) => {
                var thisTextSearchId = Guid.NewGuid();
                LastSearchWhenTypingId = thisTextSearchId;
                await Task.Delay(1000);

                if (LastSearchWhenTypingId == thisTextSearchId)
                {
                    await FillArticlesData(args.NewTextValue);
                }
            };
            StuffsSearchBar.SearchButtonPressed += async(sender, args) =>
            {
                await StuffsSearchBar.FadeTo(0, 350);

                StuffsSearchBar.IsVisible  = false;
                ToolbarItem_SearchBar.Icon = "Search.png";
            };

            ShowingOrder = false;

            FillArticlesData("");

            RowAddedQuantityKeyboard = new MyKeyboard <AddedQuantityEditingArticleModel, decimal>
                                       (
                RowAddedQuantityKeyboardHolder,
                new Command((parameter) => {        //OnOK
                FocusedAddedQuantityTextBoxStuffId = null;
                CalculateTotalAddedDiscount();
            }),
                new Command((parameter) => {        //OnChange
                CalculateTotalAddedDiscount();
            })
                                       );

            CalculateTotalAddedDiscount();
        }
Пример #4
0
        //Dictionary<Guid, decimal> PackagesQuantity;

        public OrderBeforePreviewForm
        (
            List <DBRepository.StuffListModel> AllStuffsData,
            Partner Partner,
            SaleOrder SaleOrder,
            PartnerListForm PartnerListForm,
            InsertedInformations_Orders OrdersForm,
            Guid?_SettlementTypeId,
            string Description,
            OrderInsertForm OrderInsertForm,
            bool CanChangePartner,
            Guid?WarehouseId
        )
        {
            InitializeComponent();

            this.WarehouseId = WarehouseId;

            this.OrderInsertForm = OrderInsertForm;

            EditingSaleOrderId = SaleOrder != null ? SaleOrder.Id : new Nullable <Guid>();

            this.AllStuffsData = AllStuffsData;

            this.PartnerListForm = PartnerListForm;
            this.OrdersForm      = OrdersForm;

            CustomStuffListCell.UnitNameTapEventHandler = (s, e) => {
                var Ids           = ((string)((TappedEventArgs)e).Parameter).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                var StuffId       = new Guid(Ids[0]);
                var BatchNumberId = Ids.Length == 2 ? new Guid(Ids[1]) : new Nullable <Guid>();
                UnitNameClicked(StuffId);
            };
            CustomStuffListCell.QuantityTextBoxTapEventHandler = (s, e) => {
                var Ids           = ((string)((TappedEventArgs)e).Parameter).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                var StuffId       = new Guid(Ids[0]);
                var BatchNumberId = Ids.Length == 2 ? new Guid(Ids[1]) : new Nullable <Guid>();
                FocusedQuantityTextBoxId = BatchNumberId.HasValue ? new Guid[] { StuffId, BatchNumberId.Value } : new Guid[] { StuffId };
            };
            CustomStuffListCell.QuantityPlusTapEventHandler = (s, e) => {
                var Ids           = ((string)((TappedEventArgs)e).Parameter).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                var StuffId       = new Guid(Ids[0]);
                var BatchNumberId = Ids.Length == 2 ? new Guid(Ids[1]) : new Nullable <Guid>();
                QuantityPlusClicked(StuffId, BatchNumberId);
            };
            CustomStuffListCell.QuantityMinusTapEventHandler = (s, e) => {
                var Ids           = ((string)((TappedEventArgs)e).Parameter).Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                var StuffId       = new Guid(Ids[0]);
                var BatchNumberId = Ids.Length == 2 ? new Guid(Ids[1]) : new Nullable <Guid>();
                QuantityMinusClicked(StuffId, BatchNumberId);
            };
            StuffItems.ItemTemplate = new DataTemplate(typeof(CustomStuffListCell));

            SelectedPartner = Partner != null ? Partner : SaleOrder != null ? SaleOrder.Partner : null;
            if (CanChangePartner)
            {
                PartnerChangeButton.IsEnabled = true;
            }
            else
            {
                PartnerChangeButton.IsEnabled = false;
            }
            PartnerLabel.FontSize *= 1.5;

            var PartnerChangeButtonTapGestureRecognizer = new TapGestureRecognizer();

            PartnerChangeButtonTapGestureRecognizer.Tapped += (sender, e) => {
                if (PartnerChangeButton.IsEnabled)
                {
                    FocusedQuantityTextBoxId = null;
                    var PartnerListForm1 = new PartnerListForm();
                    PartnerListForm1.OrderBeforePreviewForm = this;
                    Navigation.PushAsync(PartnerListForm1);
                }
            };
            PartnerChangeButtonTapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandParameterProperty, "Id");
            PartnerChangeButton.GestureRecognizers.Add(PartnerChangeButtonTapGestureRecognizer);
            PartnerChangeButton.WidthRequest = 150;

            StuffItems.HasUnevenRows       = true;
            StuffItems.SeparatorVisibility = SeparatorVisibility.None;
            StuffItems.ItemSelected       += StuffItems_ItemSelected;

            ToolbarItem_OrderPreviewForm            = new ToolbarItem();
            ToolbarItem_OrderPreviewForm.Text       = "پیش نمایش سفارش";
            ToolbarItem_OrderPreviewForm.Icon       = "ShowInvoice.png";
            ToolbarItem_OrderPreviewForm.Activated += ToolbarItem_OrderPreviewForm_Activated;
            ToolbarItem_OrderPreviewForm.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_OrderPreviewForm.Priority   = 2;
            if (!this.ToolbarItems.Contains(ToolbarItem_OrderPreviewForm))
            {
                this.ToolbarItems.Add(ToolbarItem_OrderPreviewForm);
            }

            SettlementTypes = App.SettlementTypes.Where(a => a.Enabled).ToArray();
            foreach (var SettlementType in SettlementTypes)
            {
                SettlementTypePicker.Items.Add(SettlementType.Name);
            }

            if (SaleOrder != null)
            {
                _SettlementTypeId = SaleOrder.SettlementTypeId;
            }
            if (_SettlementTypeId.HasValue)
            {
                SettlementTypePicker.SelectedIndex = SettlementTypes.Select((a, index) => new { a, index }).Single(a => a.a.Id == _SettlementTypeId).index;
                SettlementTypeLabel.Text           = SettlementTypes[SettlementTypePicker.SelectedIndex].Name;
            }
            SettlementTypeId = _SettlementTypeId;

            SettlementTypePicker.SelectedIndexChanged += (sender, e) => {
                FocusedQuantityTextBoxId = null;

                SettlementTypeLabel.Text = SettlementTypes[SettlementTypePicker.SelectedIndex].Name;

                var SettlementType = SettlementTypePicker.SelectedIndex == -1 ? null : SettlementTypes[SettlementTypePicker.SelectedIndex];
                this.SettlementTypeId            = SettlementType == null ? new Nullable <Guid>() : SettlementType.Id;
                OrderInsertForm.SettlementTypeId = SettlementTypeId;
            };

            var _Description = SaleOrder != null ? SaleOrder.Description : Description;

            DescriptionEditor.Text = !string.IsNullOrEmpty(_Description) ? _Description : "";

            QuantityKeyboard = new MyKeyboard <QuantityEditingStuffModel, decimal>
                               (
                QuantityKeyboardHolder,
                new Command((parameter) => {        //OnOK
                FocusedQuantityTextBoxId = null;
                CheckToBackToOrderInsertFormIfStuffsEmpty();
            }),
                new Command((parameter) => {        //OnChange
                CheckToBackToOrderInsertFormIfStuffsEmpty();
            })
                //new Command((parameter) => {        //OnOK
                //    var Value = (decimal)parameter;
                //    //var StuffModel3 = OrderInsertForm.StuffsList.SingleOrDefault(a => a.StuffId == FocusedQuantityTextBoxId);
                //    var StuffModel4 = OrderInsertForm.AllStuffsData.Where(a => a.StuffId == FocusedQuantityTextBoxId).ToArray();
                //    //if (StuffModel3 != null)
                //    //    StuffModel3.Quantity = Value;
                //    foreach (var item in StuffModel4)
                //        item.Quantity = Value;
                //    FocusedQuantityTextBoxId = null;
                //    CheckToBackToOrderInsertFormIfStuffsEmpty();
                //}),
                //new Command((parameter) => {        //OnChange
                //    var Value = (decimal)parameter;
                //    //var StuffModel3 = OrderInsertForm.StuffsList.SingleOrDefault(a => a.StuffId == FocusedQuantityTextBoxId);
                //    var StuffModel4 = OrderInsertForm.AllStuffsData.Where(a => a.StuffId == FocusedQuantityTextBoxId).ToArray();
                //    //if (StuffModel3 != null)
                //    //    StuffModel3.Quantity = Value;
                //    foreach (var item in StuffModel4)
                //        item.Quantity = Value;
                //    CheckToBackToOrderInsertFormIfStuffsEmpty();
                //})
                               );
        }
Пример #5
0
        public AddDiscounts(SaleOrder saleOrder, OrderPreviewForm OrderPreviewForm)
        {
            InitializeComponent();

            SaleOrder = new SaleOrderAddedDiscountModel()
            {
                SaleOrder = saleOrder
            };
            OrderAddedDiscountPercent.BindingContext = SaleOrder;
            OrderAddedDiscountPercent.SetBinding(Label.TextProperty, new Binding()
            {
                Mode = BindingMode.OneWay, Path = "AddedDiscountPercentLabel"
            });

            this.OrderPreviewForm = OrderPreviewForm;

            ArticlesList.HasUnevenRows  = true;
            ArticlesList.SeparatorColor = Color.FromHex("A5ABB7");
            ArticlesList.ItemSelected  += ArticlesList_ItemSelected;
            CustomArticleListCell.AddedDiscountPercentPlusTapEventHandler = (s, e) => {
                var ArticleId = (Guid)((TappedEventArgs)e).Parameter;
                AddedDiscountPercentPlusClicked(ArticleId);
            };
            CustomArticleListCell.AddedDiscountPercentMinusTapEventHandler = (s, e) => {
                var ArticleId = (Guid)((TappedEventArgs)e).Parameter;
                AddedDiscountPercentMinusClicked(ArticleId);
            };
            CustomArticleListCell.AddedDiscountPercentTextBoxTapEventHandler = async(s, e) =>
            {
                var ArticleId = (Guid)((TappedEventArgs)e).Parameter;
                FocusedAddedDiscountPercentTextBoxArticleId = ArticleId;
                var ArticleRow = ArticlesData.SingleOrDefault(a => a.ArtcileData.Id == ArticleId);
                if (ArticleRow != null)
                {
                    await Task.Delay(200);

                    ArticlesList.ScrollTo(ArticleRow, ScrollToPosition.Start, true);
                }
            };
            ArticlesList.ItemTemplate = new DataTemplate(typeof(CustomArticleListCell));
            ArticlesListHeader.Children.Add(new CustomArticleListCell().GetView(false));

            ShowingOrder = false;

            FillArticlesData();

            CalculateTotalAddedDiscount();

            var OrderAddedDiscountPercentPlusTapGestureRecognizer = new TapGestureRecognizer();

            OrderAddedDiscountPercentPlusTapGestureRecognizer.Tapped += (s, e) => {
                var NewDiscountPercent      = SaleOrder.SaleOrder.DiscountPercent + 1;
                var NewAddedDiscountPercent = SaleOrder.AddedDiscountPercent + 1;
                var Correction = NewDiscountPercent > 100 ? 100 - NewDiscountPercent : NewAddedDiscountPercent < 0 ? -NewAddedDiscountPercent : 0;
                NewDiscountPercent      += Correction;
                NewAddedDiscountPercent += Correction;

                //SaleOrder.SaleOrder.DiscountPercent = NewDiscountPercent;
                SaleOrder.AddedDiscountPercent = NewAddedDiscountPercent;

                CalculateTotalAddedDiscount();
            };
            OrderAddedDiscountPercentPlusLabel.GestureRecognizers.Add(OrderAddedDiscountPercentPlusTapGestureRecognizer);

            var OrderAddedDiscountPercentMinusTapGestureRecognizer = new TapGestureRecognizer();

            OrderAddedDiscountPercentMinusTapGestureRecognizer.Tapped += (s, e) => {
                var NewDiscountPercent      = SaleOrder.SaleOrder.DiscountPercent - 1;
                var NewAddedDiscountPercent = SaleOrder.AddedDiscountPercent - 1;
                var Correction = NewDiscountPercent > 100 ? 100 - NewDiscountPercent : NewAddedDiscountPercent < 0 ? -NewAddedDiscountPercent : 0;
                NewDiscountPercent      += Correction;
                NewAddedDiscountPercent += Correction;

                //SaleOrder.SaleOrder.DiscountPercent = NewDiscountPercent;
                SaleOrder.AddedDiscountPercent = NewAddedDiscountPercent;

                CalculateTotalAddedDiscount();
            };
            OrderAddedDiscountPercentMinusLabel.GestureRecognizers.Add(OrderAddedDiscountPercentMinusTapGestureRecognizer);

            var OrderAddedDiscountPercentTapGestureRecognizer = new TapGestureRecognizer();

            OrderAddedDiscountPercentTapGestureRecognizer.Tapped += (s, e) => {
                SaleOrder.AddedDiscountPercentFocused = true;

                OrderKeyboardObject = new AddedDiscountPercentEditingOrderModel(SaleOrder, SaleOrder != null ? SaleOrder.AddedDiscountPercent : 0);
                OrderAddedDiscountPercentKeyboard.SetObject(OrderKeyboardObject, a => a.AddedDiscountPercent);
                OrderAddedDiscountPercentKeyboard.Show();

                FocusedAddedDiscountPercentTextBoxArticleId = null;
            };
            OrderAddedDiscountPercent.GestureRecognizers.Add(OrderAddedDiscountPercentTapGestureRecognizer);

            RowAddedDiscountPercentKeyboard = new MyKeyboard <AddedDiscountPercentEditingArticleModel, decimal>
                                              (
                RowAddedDiscountPercentKeyboardHolder,
                new Command((parameter) => {        //OnOK
                FocusedAddedDiscountPercentTextBoxArticleId = null;
                CalculateTotalAddedDiscount();
            }),
                new Command((parameter) => {        //OnChange
                CalculateTotalAddedDiscount();
            })
                                              );

            OrderAddedDiscountPercentKeyboard = new MyKeyboard <AddedDiscountPercentEditingOrderModel, decimal>
                                                (
                OrderAddedDiscountPercentKeyboardHolder,
                new Command((parameter) => {        //OnOK
                SaleOrder.AddedDiscountPercentFocused = false;
                OrderAddedDiscountPercentKeyboard.Hide();
                CalculateTotalAddedDiscount();
            }),
                new Command((parameter) => {        //OnChange
                CalculateTotalAddedDiscount();
            })
                                                );
        }
Пример #6
0
 public void updateVelocity(Player player, MyKeyboard keyboard)
 {
     player.velocity = updateVelWithFriction(player);
     player.velocity = updateVelWithInput(player, keyboard);
 }
Пример #7
0
 void Awake()
 {
     Instance = this;
 }