private void RemoveButton(OwnerDrawPictureButton but) { if (flowLayoutPanel1.InvokeRequired) { flowLayoutPanel1.Invoke(new UpdatePicture(this.RemoveHelper), new object[] { but }); } else { this.flowLayoutPanel1.Controls.Remove(but); } }
private void ShowHideButtonHelper(OwnerDrawPictureButton button, bool hide) { if (hide) { button.Hide(); button.Visible = false; button.IsVisible = false; } else { button.Show(); button.Visible = true; button.IsVisible = true; } }
private void pictureButton_Click(object sender, EventArgs e) { OwnerDrawPictureButton picture = (OwnerDrawPictureButton)sender; int id = buttonsToId[picture]; bool b = isBuilding[id]; if (b) { OnBuildChosen(id); } else { OnUnitChosen(id, ((OwnerDrawPictureButton)sender).Name); } }
/* * public void Add(short id, string name, bool building, OwnerDrawPictureButton pictureButton) { * InfoLog.WriteInfo("Add", EPrefix.Stripe); * if (buttons.ContainsKey(id)) return; * Insert(id, name, building, pictureButton); * * }*/ public void Remove(int id) { OwnerDrawPictureButton but = buttons[id]; SuspendFlowLayout(); if (but != null) { //this.flowLayoutPanel1.Controls.Remove(but); RemoveButton(but); this.isBuilding.Remove(id); this.buttons.Remove(id); this.buttonsToId.Remove(but); ids.Remove(id); } InfoLog.WriteInfo("Remove", EPrefix.Stripe); num--; UpdateFlowLayoutPanelSize(); ResumeFlowLayout(); }
/* * public void Insert(short id, String name, String pictureName, bool building) { * OwnerDrawPictureButton pictureButton = new OwnerDrawPictureButton(ResourceFactory.GetPicture(name), ResourceFactory.GetPicture(name)); * isBuilding[id] = building; * buttons[id] = pictureButton; * buttonsToId[pictureButton] = id; * ids.Add(id); * pictureButton.Text = name; * pictureButton.Name = name; * pictureButton.Tag = building; * pictureButton.Size = new Size(WIDTH, HEIGHT); * * pictureButton.Margin = new Padding(0, 0, 0, 0); * pictureButton.UseVisualStyleBackColor = true; * pictureButton.Click += new EventHandler(pictureButton_Click); * num++; * //TODO: check? * //this.flowLayoutPanel1.Controls.Add(pictureButton); * if (flowLayoutPanel1.InvokeRequired) { * flowLayoutPanel1.Invoke(new UpdatePicture(this.AddHelper), new object[] { pictureButton }); * scrollingPanel.Invoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { scrollingPanel, new Size(WIDTH, num * HEIGHT) }); * flowLayoutPanel1.Invoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { flowLayoutPanel1, new Size(WIDTH, num * HEIGHT) }); * } * else { * this.flowLayoutPanel1.Controls.Add(pictureButton); * this.scrollingPanel.Size = new Size(WIDTH, num * HEIGHT); * this.flowLayoutPanel1.Size = new Size(WIDTH, num * HEIGHT); * } * * * InfoLog.WriteInfo("Insert: size: " + num * HEIGHT, EPrefix.Stripe); * * }*/ /* * public void Insert(short id, String name, bool building, OwnerDrawPictureButton pictureButton) { * //OwnerDrawPictureButton pictureButton = new OwnerDrawPictureButton(ResourceFactory.GetPicture(name), ResourceFactory.GetPicture(name)); * isBuilding[id] = building; * buttons[id] = pictureButton; * buttonsToId[pictureButton] = id; * ids.Add(id); * pictureButton.Text = name; * pictureButton.Name = name; * pictureButton.Tag = building; * pictureButton.Size = new Size(WIDTH, HEIGHT); * * pictureButton.Margin = new Padding(0, 0, 0, 0); * pictureButton.UseVisualStyleBackColor = true; * pictureButton.Click += new EventHandler(pictureButton_Click); * num++; * //TODO: check? * //this.flowLayoutPanel1.Controls.Add(pictureButton); * UpdateFlowLayout(pictureButton); * * * InfoLog.WriteInfo("Insert: size: " + num * HEIGHT, EPrefix.Stripe); * * }*/ private void UpdateFlowLayout(OwnerDrawPictureButton pictureButton) { if (flowLayoutPanel1.InvokeRequired) { flowLayoutPanel1.BeginInvoke(new UpdatePicture(this.AddHelper), new object[] { pictureButton }); scrollingPanel.BeginInvoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { scrollingPanel, new Size(WIDTH, num * HEIGHT) }); flowLayoutPanel1.BeginInvoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { flowLayoutPanel1, new Size(WIDTH, num * HEIGHT) }); //flowLayoutPanel1.Invoke(new PerformLayoutCallBack(this.PerformLayoutHelper), new object[] { flowLayoutPanel1 }); flowLayoutPanel1.BeginInvoke(new RefreshCallback(this.RefreshHelper), new object[] { flowLayoutPanel1 }); } else { this.flowLayoutPanel1.Controls.Add(pictureButton); this.scrollingPanel.Size = new Size(WIDTH, num * HEIGHT); this.flowLayoutPanel1.Size = new Size(WIDTH, num * HEIGHT); //this.flowLayoutPanel1.PerformLayout(); this.flowLayoutPanel1.Refresh(); } }
public void Insert(int id, String name, String pictureName, bool building) { OwnerDrawPictureButton pictureButton = new OwnerDrawPictureButton(ResourceFactory.GetPicture(name), ResourceFactory.GetPicture(name)); isBuilding[id] = building; buttons[id] = pictureButton; pictureButton.Id = id; buttonsToId[pictureButton] = id; ids.Add(id); pictureButton.Text = name; pictureButton.Name = name; pictureButton.Tag = building; pictureButton.Size = new Size(WIDTH, HEIGHT); pictureButton.IsVisible = true; pictureButton.Margin = new Padding(0, 0, 0, 0); pictureButton.UseVisualStyleBackColor = true; pictureButton.Click += new EventHandler(pictureButton_Click); num++; //TODO: check? //this.flowLayoutPanel1.Controls.Add(pictureButton); if (flowLayoutPanel1.InvokeRequired) { flowLayoutPanel1.BeginInvoke(new UpdatePicture(this.AddHelper), new object[] { pictureButton }); scrollingPanel.BeginInvoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { scrollingPanel, new Size(WIDTH, num * HEIGHT) }); flowLayoutPanel1.BeginInvoke(new UpdateControlSize(this.UpdateControlSizeHelper), new object[] { flowLayoutPanel1, new Size(WIDTH, num * HEIGHT) }); } else { this.flowLayoutPanel1.Controls.Add(pictureButton); this.scrollingPanel.Size = new Size(WIDTH, num * HEIGHT); this.flowLayoutPanel1.Size = new Size(WIDTH, num * HEIGHT); } InfoLog.WriteInfo("Insert: size: " + num * HEIGHT, EPrefix.Stripe); }
private void RemoveHelper(OwnerDrawPictureButton odpb) { this.flowLayoutPanel1.Controls.Remove(odpb); }
private void AddHelper(OwnerDrawPictureButton odpb) { this.flowLayoutPanel1.Controls.Add(odpb); }