/// <summary> /// Loads UI layout from XML file and adds controls (panels, toolbars) to this control. /// Adjusts control properties and positions everything according to the XML. /// </summary> /// <param name="xmlFileDefault">XML file containing default panel/toolbar layout.</param> /// <param name="xmlFileCustomized">XML file containing customized panel/toolbar layout. It will be created or updated when saving customizations.</param> /// <param name="controls">Controls. Control Name must match the XML element (panel) name attribute in the XML.</param> public void ZCreate(string xmlFileDefault, string xmlFileCustomized, params Control[] controls) { _initControls = new Dictionary <string, Control>(); foreach (var c in controls) { c.Dock = DockStyle.None; c.Anchor = AnchorStyles.Top | AnchorStyles.Left; _initControls.Add(c.Name, c); } _aSplit = new List <_Split>(); _aTab = new List <_Tab>(); _aPanel = new List <_Panel>(); _paintTools = new _PainTools(this); _toolTip = new ToolTip(); _asmVersion = Assembly.GetCallingAssembly().GetName().Version.ToString(); _xmlFile = xmlFileCustomized; _LoadXmlAndCreateLayout(xmlFileDefault, xmlFileCustomized); SuspendLayout(); this.SetStyle(ControlStyles.ContainerControl | ControlStyles.ResizeRedraw | ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true); //default: UserPaint, AllPaintingInWmPaint; not OptimizedDoubleBuffer, DoubleBuffer, Opaque. Opaque prevents erasing background, which prevents flickering when moving a splitter. //this.SetStyle(ControlStyles.Selectable, false); //no, creates tabstopping problems this.Dock = DockStyle.Fill; foreach (var c in controls) { this.Controls.Add(c); } ResumeLayout(); _initControls = null; }
const int _splitterWidth = 4; //default splitter width. Also used for toolbar caption width. protected override void Dispose(bool disposing) { if (_xmlFile != null) { _SaveLayout(); _xmlFile = null; } //AOutput.Write(disposing, IsHandleCreated); base.Dispose(disposing); _paintTools?.Dispose(); _paintTools = null; _toolTip?.Dispose(); _toolTip = null; //tested: all _Float are automatically closed before destroying this window }