Пример #1
0
 /// <summary>
 /// Create image button
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="normalimgpath"></param>
 /// <param name="focusimgpath"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public static ImageButton CreateImageButton(
   Panel parent,
   string normalimgpath,
   string focusimgpath,
   double x,
   double y)
 {
   var btn = new ImageButton();
   btn.Create(BUTTON_IMAGE_WIDTH,
              BUTTON_IMAGE_HEIGHT,
              normalimgpath,
              focusimgpath);
   btn.SetXYWithMargin(x, y);
   parent.Children.Add(btn);
   btn.Hide();
   return btn;
 }
Пример #2
0
    /// <summary>
    /// Add menu item
    /// </summary>
    /// <param name="itemid"></param>
    /// <param name="marginx"></param>
    /// <param name="marginy"></param>
    /// <param name="normalbmpid"></param>
    /// <param name="focusbmpid"></param>
    public void AddMenuItem(
                    int itemid,
                    int marginx,
                    int marginy,
                    BitmapSource normalbmp,
                    BitmapSource focusbmp)
    {
      var imgbutton = new ImageButton();

      Debug.Assert(normalbmp != null);
      Debug.Assert(focusbmp != null);

      imgbutton.Create(normalbmp, focusbmp);
      imgbutton.Tag = itemid;

      var pt = ComputeNextItemPoint();
      imgbutton.SetXY(pt.X + marginx, pt.Y + marginy);
      imgbutton.Clicked += new EventHandler(OnImageButtonClicked);

      _menucontent.Children.Add(imgbutton);
      _items.Add(imgbutton);
    }