Beispiel #1
0
 /// <summary>
 /// 重绘选择支
 /// </summary>
 /// <param name="id">选择支id</param>
 /// <param name="descriptor">选择支描述子</param>
 private void ReDrawBranchButton(int id, BranchButtonDescriptor descriptor)
 {
     // 不需要重绘的情况
     if (descriptor == null) { return; }
     BranchButton oldButton = this.branchButtonVec[id];
     BranchButton sbutton = new BranchButton(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.branchButtonVec[id] = sbutton;
     // 重绘
     this.RemoveBranchButton(oldButton);
     this.DrawBranchButton(sbutton, descriptor);
 }
Beispiel #2
0
 /// <summary>
 /// 将选择支从画面移除
 /// </summary>
 /// <param name="bbutton">选择支实例</param>
 private void RemoveBranchButton(BranchButton bbutton)
 {
     if (bbutton != null)
     {
         var bbView = bbutton.DisplayBinding;
         if (bbView != null && this.view.BO_MainGrid.Children.Contains(bbView))
         {
             this.view.BO_MainGrid.Children.Remove(bbView);
         }
         bbutton.DisplayBinding = null;
     }
 }
Beispiel #3
0
 /// <summary>
 /// 为主窗体描绘一个选择支
 /// </summary>
 /// <param name="sbutton">按钮实例</param>
 /// <param name="descriptor">按钮描述子</param>
 private void DrawBranchButton(BranchButton bbutton, BranchButtonDescriptor descriptor)
 {
     TextBlock buttonTextView = new TextBlock();
     BitmapImage bmp = bbutton.ImageNormal.SpriteBitmapImage;
     buttonTextView.Width = bmp.PixelWidth;
     buttonTextView.Height = bmp.PixelHeight;
     ImageBrush ib = new ImageBrush(bmp);
     ib.AlignmentX = AlignmentX.Left;
     ib.AlignmentY = AlignmentY.Top;
     ib.TileMode = TileMode.None;
     ib.Stretch = Stretch.Fill;
     buttonTextView.FontSize = GlobalDataContainer.GAME_BRANCH_FONTSIZE;
     buttonTextView.Foreground = new SolidColorBrush(GlobalDataContainer.GAME_BRANCH_FONTCOLOR);
     buttonTextView.FontFamily = new FontFamily(GlobalDataContainer.GAME_BRANCH_FONTNAME);
     buttonTextView.TextAlignment = TextAlignment.Center;
     buttonTextView.Padding = new Thickness(0, GlobalDataContainer.GAME_BRANCH_TOPPAD, 0, 0);
     buttonTextView.Background = ib;
     bbutton.DisplayBinding = buttonTextView;
     bbutton.Eternal = false;
     bbutton.Enable = true;
     bbutton.Text = descriptor.Text;
     bbutton.Ntr = new Interrupt()
     {
         detail = "BranchButtonNTRInterrupt",
         interruptSA = null,
         type = InterruptType.ButtonJump,
         returnTarget = descriptor.JumpTarget,
         exitWait = true
     };
     Canvas.SetLeft(buttonTextView, descriptor.X);
     Canvas.SetTop(buttonTextView, descriptor.Y);
     Canvas.SetZIndex(buttonTextView, descriptor.Z);
     buttonTextView.Visibility = Visibility.Visible;
     buttonTextView.MouseDown += bbutton.MouseOnHandler;
     buttonTextView.MouseEnter += bbutton.MouseEnterHandler;
     buttonTextView.MouseLeave += bbutton.MouseLeaveHandler;
     buttonTextView.MouseUp += bbutton.MouseUpHandler;
     this.view.BO_MainGrid.Children.Add(buttonTextView);
     bbutton.InitAnimationRenderTransform();
 }