public void UpdateParentDesign(Form frmParent) { if (configParser == null) { return; } FormDesign formDesign = configParser.GetFormDesign(); frmParent.PerformSafely(() => { double scalingFactor = frmParent.CreateGraphics().DpiX / 96.0; if (formDesign.Height > 0) { frmParent.Height = (int)Math.Round(formDesign.Height * scalingFactor); } if (formDesign.Width > 0) { frmParent.Width = (int)Math.Round(formDesign.Width * scalingFactor); } if (formDesign.ClientWidth > 0 && formDesign.ClientHeight > 0) { frmParent.ClientSize = new Size((int)Math.Round(formDesign.ClientWidth * scalingFactor), (int)Math.Round(formDesign.ClientHeight * scalingFactor)); } frmParent.BackColor = formDesign.BackgroundColor; if (formDesign.FormName != "") { frmParent.Text = formDesign.FormName; } }); }
private void SetFormDesign() { formDesign = new FormDesign(); XmlNode formDesignNode = xmlDoc.SelectSingleNode("//FormDesign"); #if DEBUG Logger.GetLogger().Info("Read config file - Form Design:", Logger.Level.MEDIUM_DEBUG_LEVEL); #endif if (formDesignNode == null) { return; } formDesign.Height = XmlParser.GetIntValue(formDesignNode, "Height"); formDesign.Width = XmlParser.GetIntValue(formDesignNode, "Width"); formDesign.ClientHeight = XmlParser.GetIntValue(formDesignNode, "ClientHeight"); formDesign.ClientWidth = XmlParser.GetIntValue(formDesignNode, "ClientWidth"); formDesign.BackgroundColor = XmlParser.GetColorValue(formDesignNode, "BackgroundColor"); formDesign.FormName = XmlParser.GetStringValue(formDesignNode, "FormName"); formDesign.DefaultControlDesign = XmlParser.GetXpathRefAttributes(formDesignNode.SelectSingleNode("DefaultControlDesign")); }