Ejemplo n.º 1
0
 private void InitializeComponent()
 {
     this.mPictureBox1 = new Momo.Forms.MPictureBox();
     ((System.ComponentModel.ISupportInitialize)(this.mPictureBox1)).BeginInit();
     this.SuspendLayout();
     //
     // mPictureBox1
     //
     this.mPictureBox1.Dock           = System.Windows.Forms.DockStyle.Fill;
     this.mPictureBox1.Image          = global::Momo.Forms.Properties.Resources.banner;
     this.mPictureBox1.ImageAnimation = Momo.Forms.ImageAnimation.None;
     this.mPictureBox1.Location       = new System.Drawing.Point(0, 0);
     this.mPictureBox1.Name           = "mPictureBox1";
     this.mPictureBox1.Size           = new System.Drawing.Size(600, 300);
     this.mPictureBox1.SizeMode       = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
     this.mPictureBox1.TabIndex       = 0;
     this.mPictureBox1.TabStop        = false;
     this.mPictureBox1.Paint         += new System.Windows.Forms.PaintEventHandler(this.mPictureBox1_Paint);
     this.mPictureBox1.MouseClick    += new System.Windows.Forms.MouseEventHandler(this.mPictureBox1_MouseClick);
     //
     // MBanner
     //
     this.Controls.Add(this.mPictureBox1);
     this.Name = "MBanner";
     this.Size = new System.Drawing.Size(600, 300);
     ((System.ComponentModel.ISupportInitialize)(this.mPictureBox1)).EndInit();
     this.ResumeLayout(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 将第一个控件隐藏,第二个控件显示
        /// </summary>
        /// <param name="toHide"></param>
        /// <param name="toVisible"></param>
        public void Switch(Control toHide, Control toVisible, bool back = false)
        {
            if (toHide.Parent != toVisible.Parent)
            {
                throw new Exception("交换显示状态的控件,必须处于同一个容器中!");
            }

            var hide = new Bitmap(toHide.Width, toHide.Height);

            toHide.DrawToBitmap(hide, toHide.ClientRectangle);
            var visible = new Bitmap(toVisible.Width, toVisible.Height);

            toVisible.DrawToBitmap(visible, toVisible.ClientRectangle);

            hidePic                = new MPictureBox();
            hidePic.Size           = toHide.Size;
            hidePic.Location       = toHide.Location;
            hidePic.ImageAnimation = ImageAnimation.None;
            hidePic.Image          = hide;

            visiblePic                = new MPictureBox();
            visiblePic.Size           = toVisible.Size;
            visiblePic.Location       = StartLocation;
            visiblePic.ImageAnimation = ImageAnimation.None;
            visiblePic.Image          = visible;

            toHide.Visible = false;
            hidePic.Tag    = toHide;
            toHide.Parent.Controls.Add(hidePic);

            toVisible.Visible = false;
            visiblePic.Tag    = toVisible;
            toVisible.Parent.Controls.Add(visiblePic);

            CurrentControl = toVisible;

            if (!back)
            {
                this.queue.Insert(0, toHide);
            }

            this.MoveTo(hidePic, StopLocation, "hide");

            this.MoveTo(visiblePic, VisibleLocation, "visible");
        }