Beispiel #1
0
 public CashButtonControl()
 {
     InitializeComponent();
     DropCoins.Header     = ResourceLoadHelper.GetLocalString("PayGroup");
     DropCurrency.Content = ResourceLoadHelper.GetLocalString("PayCurrency");
     ChangeButton.Content = ResourceLoadHelper.GetLocalString("Change");
 }
        public GoodsButtonControl()
        {
            _template = (ControlTemplate)XamlReader.Parse("<ControlTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' TargetType=\"Button\"><Border Name=\"brdr\" BorderBrush=\"Black\" BorderThickness=\"1\"><Grid><Image x:Name=\"ibtn\" Stretch=\"None\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"><Image.Style><Style TargetType=\"{x:Type Image}\"></Style></Image.Style></Image><Label x:Name=\"tbtn\" VerticalAlignment=\"Top\" HorizontalAlignment=\"Right\" Margin=\"0,-4,-1,0\" /></Grid></Border><ControlTemplate.Triggers><Trigger Property=\"IsMouseOver\" Value=\"true\"><Setter TargetName=\"brdr\" Property=\"BorderThickness\" Value=\"2\" /><Setter TargetName=\"brdr\" Property=\"BorderBrush\" Value=\"Cyan\" /><Setter TargetName=\"tbtn\" Property=\"Margin\" Value=\"0,-5,-2,0\" /></Trigger></ControlTemplate.Triggers></ControlTemplate>");
            DrinksViewModel model = new DrinksViewModel(ResourceLoadHelper.GetLocalString("GoodsDescription")).BindToMainModel();
            int             count = model.Drinks.Count();

            ScrollableWidth = (count > 6 ? Math.Ceiling((double)count / 2) : 3) * 102;
            InitializeComponent();
            Drinks.Header = ResourceLoadHelper.GetLocalString("DrinksGroup");
            DataContext   = model;
            foreach (Product p in model.Drinks)
            {
                Button b = new Button();
                model.SetToolTip(p.id, p.quantity, p.price, ResourceLoadHelper.GetLocalName(p.locals), b);
                model.SetTemplate(p.id, _template);
                model.DrinkButton[p.id].PropertyChanged += Template_PropertyChanged;
                Binding toolTip = new Binding(string.Format("DrinkButton[{0}].ToolTip", p.id));
                toolTip.Source = model;
                toolTip.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.ToolTipProperty, toolTip);
                Binding Visible = new Binding(string.Format("DrinkButton[{0}].Visible", p.id));
                Visible.Source = model;
                Visible.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.VisibilityProperty, Visible);
                Binding Template = new Binding(string.Format("DrinkButton[{0}].Template", p.id));
                Template.Source = model;
                Template.Mode   = BindingMode.OneWay;
                b.SetBinding(Button.TemplateProperty, Template);
                b.CommandParameter = p.id;
                Binding cmd = new Binding();
                cmd.Source = model;
                cmd.Path   = new PropertyPath("PurchaseCommand");
                b.SetBinding(Button.CommandProperty, cmd);
                b.Width  = 100;
                b.Height = 100;
                b.Margin = new Thickness(0, 0, 2, 2);
                Image rimg = ResourceLoadHelper.GetDrinksButtonImage(new Size(96, 96), (Color)ColorConverter.ConvertFromString(p.color), p.type);
                b.AddHandler(LoadedEvent, new RoutedEventHandler((object s, RoutedEventArgs e) => {
                    Button btn = s as Button;
                    if (btn.Template != null)
                    {
                        Label text           = btn.Template.FindName("tbtn", btn) as Label;
                        text.Foreground      = new SolidColorBrush(p.parsedColor.R + p.parsedColor.G + p.parsedColor.B > 381 ? (Color)ColorConverter.ConvertFromString("Black") : (Color)ColorConverter.ConvertFromString("White"));
                        text.FontWeight      = FontWeights.Bold;
                        Binding quantityInfo = new Binding("quantity");
                        quantityInfo.Source  = p;
                        quantityInfo.Mode    = BindingMode.OneWay;
                        text.SetBinding(Label.ContentProperty, quantityInfo);
                        Image img  = btn.Template.FindName("ibtn", btn) as Image;
                        Style simg = new Style(typeof(Image));
                        img.Style.Setters.ToList().ForEach(x => simg.Setters.Add(x));
                        simg.Setters.Add(new Setter(Image.SourceProperty, rimg.Source));
                        img.Style = simg;
                    }
                }));
                DrinksContainer.Children.Add(b);
            }
            model.DisposeRequest += Dispose;
        }
Beispiel #3
0
 private void MessageToCustomer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (!string.IsNullOrEmpty(_model.MessageToCustomer.Text))
     {
         string text = ResourceLoadHelper.GetLocalString(_model.MessageToCustomer.Text);
         if (!string.IsNullOrEmpty(text))
         {
             if (_timer.IsEnabled)
             {
                 _timer.Stop();
             }
             _model.MessageToCustomer.Text = text;
             _timer.Start();
         }
     }
 }
Beispiel #4
0
 public FillingCupProgressBarControl()
 {
     InitializeComponent();
     Queue.Header = ResourceLoadHelper.GetLocalString("Queue");
     DataContext  = new QueueViewModel().BindToMainModel();
 }