public CockpitPanel(CockpitForm form, ControlManager manager, IImageCache imageCache, CockpitXML.CockpitLayoutPanel layout) { this.name = layout.Name; this.form = form; if (layout.ControlLayout != null) { // Now construct the list of controls that are actually used in the layout foreach (CockpitXML.CockpitLayoutPanelControlLayout controlLayout in layout.ControlLayout) { if (manager.HasControl(controlLayout.ControlName)) { ICockpitControl control = manager.GetControl(controlLayout.ControlName); CockpitControlInstance formItem = new CockpitControlInstance(this, control, new Point(controlLayout.X, controlLayout.Y)); controlInstances.Add(formItem); control.AddInstance(formItem); } } } this.Location = new Point(layout.X, layout.Y); this.Size = new Size(layout.Width, layout.Height); this.backgroundImage = imageCache.getImage(layout.BackgroundImage); if (layout.VisibleSpecified) { this.Visible = layout.Visible; } else { this.Visible = true; } }
public void RemoveInstance(CockpitControlInstance instance) { if (instances.Contains(instance)) { instances.Remove(instance); } }
public void AddInstance(CockpitControlInstance instance) { if (!instances.Contains(instance)) { instances.Add(instance); } }
private void CockpitForm_MouseUp(object sender, MouseEventArgs e) { if (pushedItem != null) { pushedItem.Control.Released(); pushedItem = null; } }
public CockpitControlInstance InstanceAt(Point location) { location.Offset(-Location.X, -Location.Y); // Loop through controls in reverse order check if click is within that button then execute action if so for (int i = controlInstances.Count() - 1; i >= 0; i--) { CockpitControlInstance item = controlInstances[i]; if (item.Rectangle.Contains(location)) { return(item); } } return(null); }
private void CockpitForm_MouseDown(object sender, MouseEventArgs e) { // Loop through controls in reverse order check if click is within that button then execute action if so for (int i = controlPanels.Count() - 1; i >= 0; i--) { if (controlPanels[i].Visible && controlPanels[i].Rectangle.Contains(e.Location)) { CockpitControlInstance item = controlPanels[i].InstanceAt(e.Location); if (item != null) { pushedItem = item; pushedItem.Control.Pushed(); i = -1; } } } }