示例#1
0
        private void BuildImagePictures(bool create = true)
        {
            var maxWidth = this.PicPanel.Size.Width;
            var y        = 3;
            var x        = 3;

            this.PicPanel.VerticalScroll.Value = this.PicPanel.VerticalScroll.Minimum;
            foreach (var img in Recursos.GetAllImages())
            {
                PictureBox pic;
                if (create)
                {
                    pic = new PictureBox();
                    this.PicPanel.Controls.Add(pic);
                    pic.Size     = new System.Drawing.Size(32, 32);
                    pic.SizeMode = PictureBoxSizeMode.Zoom;
                    pic.Image    = img.Value;
                    pic.Tag      = img.Key;
                    pic.Click   += (sender, e) => SetSelectedPicture(sender.GetTag <string>());
                }
                else
                {
                    pic = this.PicPanel.Controls.OfType <PictureBox>().Single(p => p.GetTag <string>() == img.Key);
                }
                pic.Location = new System.Drawing.Point(x, y);

                x += 32 + 3;
                if (x + 32 > maxWidth)
                {
                    y += 32 + 3;
                    x  = 3;
                }
            }
        }
示例#2
0
        public ConfigLinksHelper(Forms.Configuration form, Control container) : base(form, container)
        {
            // form event
            form.ResizeEnd += (sender, e) => BuildImagePictures(false);

            // events
            bEditPathFind.Click  += (sender, e) => OpenDialog("path");
            bImgCustomFind.Click += (sender, e) => OpenDialog("img");

            cbShowFolderContent.CheckedChanged += (sender, e) => UpdateChecksStatus();
            cbShowSubFolders.CheckedChanged    += (sender, e) => UpdateChecksStatus();
            tvLinks.AfterSelect += (sender, e) => SelectNode(e.Node);
            bSave.Click         += (sender, e) => Save();


            // TreeList
            tvLinks.ImageList = new ImageList();
            foreach (var img in Recursos.GetAllImages())
            {
                tvLinks.ImageList.Images.Add(img.Key, img.Value);
            }

            BuildImagePictures();
            ReLoadData();
            tvLinks.TopNode.ExpandAll();
            SelectNode(tvLinks.TopNode);
        }