Exemplo n.º 1
0
        public static void SetBitmapImage(Image image, string fileName, bool isFullImagePath = false)
        {
            BitmapImage bitmapImage = CustomPictureBox.GetBitmapImage(fileName, "", isFullImagePath);

            if (bitmapImage != null)
            {
                bitmapImage.Freeze();
                BlueStacksUIBinding.Bind(image, Image.SourceProperty, fileName);
                if (image is CustomPictureBox)
                {
                    CustomPictureBox customPictureBox = image as CustomPictureBox;
                    customPictureBox.BitmapImage = bitmapImage;
                    if (customPictureBox.IsAlwaysHalfSize)
                    {
                        customPictureBox.maxSize   = new Point(customPictureBox.MaxWidth, customPictureBox.MaxHeight);
                        customPictureBox.MaxWidth  = bitmapImage.Width / 2.0;
                        customPictureBox.MaxHeight = bitmapImage.Height / 2.0;
                    }
                    else if (customPictureBox.maxSize != new Point())
                    {
                        customPictureBox.MaxWidth  = customPictureBox.maxSize.X;
                        customPictureBox.MaxHeight = customPictureBox.maxSize.Y;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public void AddButtonInUI(
     CustomButton button,
     ButtonColors color,
     string text,
     EventHandler handle,
     string image,
     bool ChangeImageAlignment,
     object data,
     bool isEnabled)
 {
     if (button != null)
     {
         if (this.mButton1 == null)
         {
             this.mButton1 = button;
         }
         else
         {
             this.mButton2 = button;
             button.Margin = new Thickness(15.0, 0.0, 0.0, 0.0);
         }
         button.IsEnabled  = isEnabled;
         button.Click     += new RoutedEventHandler(this.Button_Click);
         button.MinWidth   = 100.0;
         button.Visibility = Visibility.Visible;
         BlueStacksUIBinding.Bind((Button)button, text);
         if (image != null)
         {
             button.ImageName   = image;
             button.ImageMargin = new Thickness(0.0, 6.0, 5.0, 6.0);
             if (ChangeImageAlignment)
             {
                 button.ImageOrder  = ButtonImageOrder.AfterText;
                 button.ImageMargin = new Thickness(5.0, 6.0, 0.0, 6.0);
             }
         }
     }
     this.mStackPanel.Children.Add((UIElement)button);
     this.mDictActions.Add((object)button, new Tuple <ButtonColors, EventHandler, object>(color, handle, data));
 }