示例#1
0
 private void scrollBar_ValueChanged(object sender, EventArgs e)
 {
     using (ControlTransaction.Layout(this, false))
     {
         var value = this.scrollBar.Value;
         for (var i = 0; i < this.pictureBox.Count; i++)
         {
             this.pictureBox[i].Visible = (i == value);
         }
     }
 }
示例#2
0
        /// <summary>
        /// 表示するサムネイルの数を設定する
        /// </summary>
        /// <param name="count">表示するサムネイルの数</param>
        protected void SetThumbnailCount(int count)
        {
            if (count == 0 && this.pictureBox.Count == 0)
            {
                return;
            }

            using (ControlTransaction.Layout(this.panelPictureBox, false))
            {
                this.panelPictureBox.Controls.Clear();
                foreach (var picbox in this.pictureBox)
                {
                    var memoryImage = picbox.Image;

                    filter.Unregister(picbox);

                    picbox.MouseWheel  -= this.pictureBox_MouseWheel;
                    picbox.DoubleClick -= this.pictureBox_DoubleClick;
                    picbox.Dispose();

                    memoryImage?.Dispose();

                    // メモリリーク対策 (http://stackoverflow.com/questions/2792427#2793714)
                    picbox.ContextMenuStrip = null;
                }
                this.pictureBox.Clear();

                this.scrollBar.Maximum = (count > 0) ? count - 1 : 0;
                this.scrollBar.Value   = 0;

                for (int i = 0; i < count; i++)
                {
                    var picbox = CreatePictureBox("pictureBox" + i);
                    picbox.Visible      = (i == 0);
                    picbox.MouseWheel  += this.pictureBox_MouseWheel;
                    picbox.DoubleClick += this.pictureBox_DoubleClick;

                    filter.Register(picbox);

                    this.panelPictureBox.Controls.Add(picbox);
                    this.pictureBox.Add(picbox);
                }
            }
        }