コード例 #1
0
        private void OrderBy_Click(object sender, EventArgs e)
        {
            StackPanel s      = new StackPanel();
            var        Picker = new ListPicker();

            Picker.SetValue(ListPicker.ItemCountThresholdProperty, 6);
            var PickerItems = new string[] { ProductSortingEnum.CreatedOn.ToString(), ProductSortingEnum.NameAsc.ToString(),
                ProductSortingEnum.NameDesc.ToString(), ProductSortingEnum.Position.ToString(), ProductSortingEnum.PriceAsc.ToString(), ProductSortingEnum.PriceDesc.ToString() };

            Picker.ItemsSource = PickerItems;
            s.Children.Add(Picker);
            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption            = "Order By",
                Message            = "Select the order you want the products to be displayed",
                LeftButtonContent  = "Submit",
                Content            = s,
                RightButtonContent = "Cancel"
            };

            messageBox.Show();
            messageBox.Dismissed += async(s1, e1) => {
                ProductSortingEnum Result = ProductSortingEnum.Position;
                if (e1.Result.Equals(CustomMessageBoxResult.LeftButton))
                {
                    foreach (ProductSortingEnum pse in Enum.GetValues(typeof(ProductSortingEnum)))
                    {
                        if (pse.ToString().Equals(Picker.SelectedItem.ToString()))
                        {
                            Result = pse;
                            break;
                        }
                    }
                    var Count = 0;
                    foreach (PivotItem pivot in CategoryPivot.Items)
                    {
                        var Listbox = Helper.FindFirstElementInVisualTree <ListBox>(pivot);
                        Listbox.Items.Clear();
                        if (Listbox.ItemTemplate.Equals(Application.Current.Resources["ProductCategoryTemplate"] as DataTemplate))
                        {
                            var Prods = await api.CategoryProductsSortedFiltered(Categories[Count].Id, true, false, Result, 0, 0);

                            foreach (ProductDTO p in Prods)
                            {
                                Listbox.Items.Add(new MainPage.ProductData {
                                    Id = p.Id, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), ProductName = p.Name, Value = p.Price.ToString("0.0#") + " " + Currency
                                });
                            }
                        }
                        Count++;
                    }
                }
            };
        }
コード例 #2
0
        private void ChangeStatus_Click(object sender, RoutedEventArgs e)
        {
            StackPanel sp           = new StackPanel();
            ListPicker ShippingDrop = new ListPicker();
            ListPicker PaymentDrop  = new ListPicker();

            PaymentDrop.SetValue(Microsoft.Phone.Controls.ListPicker.ItemCountThresholdProperty, 6);
            ListPicker OrderDrop     = new ListPicker();
            var        OrderIndex    = Array.IndexOf(OrderStatusValues, Order.OrderStatus.ToString());
            var        ShippingIndex = 0;

            switch (Order.ShippingStatus)
            {
            case ShippingStatus.NotYetShipped:
                ShippingIndex = 1;
                break;

            case ShippingStatus.PartiallyShipped:
                ShippingIndex = 2;
                break;

            case ShippingStatus.ShippingNotRequired:
                ShippingIndex = 4;
                break;

            default:
                ShippingIndex = Array.IndexOf(ShippingStatusValues, Order.ShippingStatus.ToString());
                break;
            }
            var PaymentIndex = 0;

            switch (Order.PayStatus)
            {
            case PaymentStatus.PartiallyRefunded:
                PaymentIndex = 2;
                break;

            default:
                PaymentIndex = Array.IndexOf(PayStatusValues, Order.PayStatus.ToString());
                break;
            }



            ShippingDrop.ItemsSource = ShippingStatusValues;
            PaymentDrop.ItemsSource  = PayStatusValues;
            OrderDrop.ItemsSource    = this.OrderStatusValues;

            ShippingDrop.SelectedIndex = ShippingIndex;
            OrderDrop.SelectedIndex    = OrderIndex;
            PaymentDrop.SelectedIndex  = PaymentIndex;

            ShippingDrop.SelectionChanged += (se, ev) => {
                ShippingIndex = ShippingDrop.SelectedIndex;
            };
            OrderDrop.SelectionChanged += (se, ev) => {
                OrderIndex = OrderDrop.SelectedIndex;
            };
            PaymentDrop.SelectionChanged += (se, ev) => {
                PaymentIndex = PaymentDrop.SelectedIndex;
            };

            sp.Children.Add(ShippingDrop);
            sp.Children.Add(PaymentDrop);
            sp.Children.Add(OrderDrop);

            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Caption            = "Change Order Status",
                Message            = "Change the status accordingly",
                Content            = sp,
                LeftButtonContent  = "Submit",
                RightButtonContent = "Cancel"
            };

            messageBox.Dismissed += async(s1, e1) => {
                switch (e1.Result)
                {
                case CustomMessageBoxResult.LeftButton:
                    await api.ChangeOrderStatus(Order.OrderID, OrderStatusValues[OrderIndex]);

                    var PayS = new PaymentStatus[] { PaymentStatus.Paid, PaymentStatus.Authorized, PaymentStatus.PartiallyRefunded, PaymentStatus.Pending, PaymentStatus.Refunded, PaymentStatus.Voided };
                    await api.ChangePaymentStatus(Order.OrderID, PayS[PaymentIndex]);

                    var ShipS = new ShippingStatus[] { ShippingStatus.Delivered, ShippingStatus.NotYetShipped, ShippingStatus.PartiallyShipped, ShippingStatus.Shipped, ShippingStatus.ShippingNotRequired };
                    await api.ChangeShippingStatus(Order.OrderID, ShipS[ShippingIndex]);

                    MessageBox.Show("Status changed sucessfuly");
                    InitializeOrder();
                    break;
                }
            };

            messageBox.Show();
        }
コード例 #3
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Check for root
            if (WP7RootToolsSDK.Environment.HasRootAccess())
            {
                // Add the quick toggles defined in Tweaks
                foreach (Tweak tweak in Tweaks.tweaks)
                {
                    if (tweak.type == Tweak.controlType.toggle)
                    {
                        ToggleSwitch control = new ToggleSwitch();

                        control.Header = tweak.title;
                        if (tweak.description != "")
                        {
                            control.Content = tweak.description;
                        }

                        control.FontSize = 22;

                        //get valuelolo
                        if (tweak.keyType == Tweak.tweakType.dword)
                        {
                            var val = 0;
                            try
                            {
                                val = (int)WP7RootToolsSDK.Registry.GetDWordValue(tweak.getHyve(), tweak.getKeyName(), tweak.getValueName());
                            }
                            catch
                            {
                            }
                            control.IsChecked = (val == tweak.onValue);
                        }
                        if (tweak.keyType == Tweak.tweakType.str)
                        {
                            var val = "";
                            try
                            {
                                val = WP7RootToolsSDK.Registry.GetStringValue(tweak.getHyve(), tweak.getKeyName(), tweak.getValueName());
                            }
                            catch
                            {
                            }
                            control.IsChecked = (val == tweak.strOnValue);
                        }

                        control.Checked   += new EventHandler <RoutedEventArgs>(control_Checked);
                        control.Unchecked += new EventHandler <RoutedEventArgs>(control_Checked);

                        controlsPanel.Children.Add(control);
                    }
                    if (tweak.type == Tweak.controlType.selector)
                    {
                        ListPicker lp = new ListPicker();
                        lp.Header      = tweak.title;
                        lp.ItemsSource = tweak.options;
                        lp.SetValue(ListPicker.ItemCountThresholdProperty, 10);
                        lp.SelectionChanged += new SelectionChangedEventHandler(lp_SelectionChanged);
                        lp.Tap += new EventHandler <System.Windows.Input.GestureEventArgs>(lp_Tap);
                        controlsPanel.Children.Add(lp);
                    }
                    if (tweak.type == Tweak.controlType.title)
                    {
                        addCategory(tweak.title);
                    }
                }
            }
            else
            {
                LayoutRoot.Visibility = System.Windows.Visibility.Collapsed;
            }
        }