public AtmButtonControl(AtmButton atmButton)
 {
     InitializeComponent();
     ButtonText0   = atmButton.Text0;
     ButtonText1   = atmButton.Text1;
     ButtonText2   = atmButton.Text2;
     ButtonText3   = atmButton.Text3;
     Text0Color    = atmButton.Text0Color.ToString() != "#00000000" ? atmButton.Text0Color : Colors.White;
     Text1Color    = atmButton.Text1Color.ToString() != "#00000000" ? atmButton.Text1Color : Colors.White;
     Text2Color    = atmButton.Text2Color.ToString() != "#00000000" ? atmButton.Text2Color : Colors.White;
     Text3Color    = atmButton.Text3Color.ToString() != "#00000000" ? atmButton.Text3Color : Colors.White;
     MainText.Text = atmButton.MainText;
     ImagePath     = atmButton.ImagePath;
     Name          = atmButton.Name + DateTime.Now.Ticks;
     ButtonImage.SetValue(NameProperty, Name);
     MainText.SetValue(NameProperty, Name);
     Text0.SetValue(NameProperty, Name);
     Text1.SetValue(NameProperty, Name);
     Text2.SetValue(NameProperty, Name);
     Text3.SetValue(NameProperty, Name);
     IsRightButton = atmButton.IsRightButton;
     if (IsRightButton)
     {
         ButtonGrid.HorizontalAlignment = HorizontalAlignment.Right;
     }
 }
Example #2
0
 private void AddComponentToCanvas(bool isPreviewItem)
 {
     if (Components.SelectedItem.GetType() == typeof(AtmButton))
     {
         AtmButton        atmButton        = (AtmButton)Components.SelectedItem;
         AtmButtonControl atmButtonControl = new AtmButtonControl(atmButton);
         if (isPreviewItem)
         {
             atmButtonControl.BorderBrush = new SolidColorBrush(Colors.Black);
             previewItem = atmButtonControl;
         }
         else
         {
             atmButtonControl.BorderBrush = new SolidColorBrush(atmButton.BorderColor);
         }
         SchemerCanvas.Children.Add(atmButtonControl);
         SetComponentPositionOnCanvas(atmButtonControl);
         ComponentsPlacedOnScreen.Add(atmButtonControl, (IListable)Components.SelectedItem);
     }
     else
     {
         BaseComponent selectedComponent = (BaseComponent)Components.SelectedItem;
         Border        border            = new Border()
         {
             Width           = selectedComponent.ScreenWidth,
             Height          = selectedComponent.ScreenHeight,
             BorderThickness = new Thickness(selectedComponent.BorderThickness),
             Background      = new ImageBrush(new BitmapImage(new Uri(selectedComponent.ImagePath, UriKind.Relative))),
             Name            = selectedComponent.Name + DateTime.Now.Ticks
         };
         if (isPreviewItem)
         {
             border.BorderBrush = new SolidColorBrush(Colors.Black);
             previewItem        = border;
         }
         else
         {
             border.BorderBrush = new SolidColorBrush(selectedComponent.BorderColor);
         }
         SchemerCanvas.Children.Add(border);
         SetComponentPositionOnCanvas(border);
         ComponentsPlacedOnScreen.Add(border, (IListable)Components.SelectedItem);
     }
 }