Example #1
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();
 }
Example #2
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);
 }
Example #3
0
 /// <summary>
 /// 为屏幕增加一个按钮描述子
 /// </summary>
 /// <param name="id">按钮的id</param>
 /// <param name="enable">是否可点击</param>
 /// <param name="X">左上角在画面的X坐标</param>
 /// <param name="Y">左上角在画面的Y坐标</param>
 /// <param name="jumpTarget">按下后要跳转的标签名</param>
 /// <param name="funcCallSign">函数调用签名</param>
 /// <param name="type">按钮存续类型</param>
 /// <param name="normalDesc">正常时的精灵描述子</param>
 /// <param name="overDesc">鼠标悬停时的精灵描述子</param>
 /// <param name="onDesc">鼠标按下时的精灵描述子</param>
 public void AddButton(int id, bool enable, double X, double Y, string jumpTarget, string funcCallSign, string type, SpriteDescriptor normalDesc, SpriteDescriptor overDesc = null, SpriteDescriptor onDesc = null)
 {
     SpriteButtonDescriptor sbd = new SpriteButtonDescriptor()
     {
         Enable = enable,
         X = X,
         Y = Y,
         Z = GlobalDataContainer.GAME_Z_BUTTON + id,
         JumpLabel = jumpTarget,
         InterruptFuncSign = funcCallSign,
         NormalDescriptor = normalDesc,
         OverDescriptor = overDesc,
         OnDescriptor = onDesc,
         Opacity = 1.0,
         Eternal = type == "once" ? false : true
     };
     this.buttonDescVec[id] = sbd;
 }