Ejemplo n.º 1
0
 /// <summary>
 /// 重绘按钮
 /// </summary>
 /// <param name="id">按钮id</param>
 /// <param name="descriptor">按钮描述子</param>
 private void ReDrawButton(int id, SpriteButtonDescriptor descriptor)
 {
     // 不需要重绘的情况
     if (descriptor == null) { return; }
     SpriteButton oldButton = this.buttonLayerVec[id];
     SpriteButton sbutton = new SpriteButton(id);
     sbutton.ImageNormal = descriptor.NormalDescriptor == null ? null : ResourceManager.GetInstance().GetPicture(descriptor.NormalDescriptor.ResourceName, new Int32Rect(-1, 0, 0, 0));
     sbutton.ImageMouseOver = descriptor.OverDescriptor == null ? null : ResourceManager.GetInstance().GetPicture(descriptor.OverDescriptor.ResourceName, new Int32Rect(-1, 0, 0, 0));
     sbutton.ImageMouseOn = descriptor.OnDescriptor == null ? null : ResourceManager.GetInstance().GetPicture(descriptor.OnDescriptor.ResourceName, new Int32Rect(-1, 0, 0, 0));
     this.buttonLayerVec[id] = sbutton;
     // 重绘
     this.RemoveButton(oldButton);
     this.DrawButton(sbutton, descriptor);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 将按钮从画面移除
 /// </summary>
 /// <param name="sbutton">按钮实例</param>
 private void RemoveButton(SpriteButton sbutton)
 {
     if (sbutton != null)
     {
         Image buttonView = sbutton.DisplayBinding;
         if (buttonView != null && this.view.BO_MainGrid.Children.Contains(buttonView))
         {
             this.view.BO_MainGrid.Children.Remove(buttonView);
             if (sbutton.ImageNormal != null)
             {
                 sbutton.ImageNormal.DisplayBinding = null;
             }
             if (sbutton.ImageMouseOver != null)
             {
                 sbutton.ImageMouseOver.DisplayBinding = null;
             }
             if (sbutton.ImageMouseOn != null)
             {
                 sbutton.ImageMouseOn.DisplayBinding = null;
             }
         }
         sbutton.DisplayBinding = null;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 为主窗体描绘一个按钮
 /// </summary>
 /// <param name="sbutton">按钮实例</param>
 /// <param name="descriptor">按钮描述子</param>
 private void DrawButton(SpriteButton sbutton, SpriteButtonDescriptor descriptor)
 {
     Image buttonImage = new Image();
     BitmapImage bmp = sbutton.ImageNormal.SpriteBitmapImage;
     buttonImage.Width = bmp.PixelWidth;
     buttonImage.Height = bmp.PixelHeight;
     buttonImage.Source = bmp;
     buttonImage.Opacity = descriptor.Opacity;
     sbutton.DisplayBinding = buttonImage;
     sbutton.Eternal = descriptor.Eternal;
     sbutton.Enable = descriptor.Enable;
     sbutton.Ntr = new Interrupt()
     {
         detail = "ButtonNTRInterrupt",
         interruptSA = null,
         type = InterruptType.ButtonJump,
         interruptFuncSign = descriptor.InterruptFuncSign,
         returnTarget = descriptor.JumpLabel,
         pureInterrupt = false,
         exitWait = !descriptor.Eternal
     };
     Canvas.SetLeft(buttonImage, descriptor.X);
     Canvas.SetTop(buttonImage, descriptor.Y);
     Canvas.SetZIndex(buttonImage, descriptor.Z);
     buttonImage.Visibility = Visibility.Visible;
     buttonImage.MouseDown += sbutton.MouseOnHandler;
     buttonImage.MouseEnter += sbutton.MouseEnterHandler;
     buttonImage.MouseLeave += sbutton.MouseLeaveHandler;
     buttonImage.MouseUp += sbutton.MouseUpHandler;
     this.view.BO_MainGrid.Children.Add(buttonImage);
     sbutton.InitAnimationRenderTransform();
 }