Files
@ 2f841e844536
Branch filter:
Location: seniordesign-ui/Demo.WindowsForms/BSE.Windows.Forms/XPander/PanelSettingsManager.cs
2f841e844536
9.1 KiB
text/x-csharp
fixed the problem of two forms being created. still need to fix the addToChart()
and addMarker()
and addMarker()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace BSE.Windows.Forms
{
/// <summary>
/// Controls Panel and XPanderPanel rendering.
/// </summary>
/// <example>
/// The following code example creates a <see cref="Panel"/> and sets the panel properties for the forms controls collection,
/// <code>
/// using System;
/// using System.Text;
/// using System.Windows.Forms;
///
/// namespace BSE.Windows.Test
/// {
/// public class Form2 : Form
/// {
/// private BSE.Windows.Forms.Panel panel1;
///
/// public Form2()
/// {
/// // Create and initialize a Panel.
/// this.panel1 = new BSE.Windows.Forms.Panel();
/// this.panel1.Text = "panel1";
/// // Set the panel background.
/// this.panel1.ShowTransparentBackground = false;
/// // Set the panel's DockStyle to DockStyle.Fill
/// this.panel1.Dock = DockStyle.Fill;
/// // Add the panel to the form
/// this.Controls.Add(this.panel1);
///
/// // Create and initialize a ToolStripProfessionalRenderer.
/// ToolStripProfessionalRenderer renderer = new BSE.Windows.Forms.Office2007Renderer();
/// // Add it to the ToolStripManager.Renderer
/// ToolStripManager.Renderer = renderer;
///
/// // Get the ProfessionalColorTable colorTable for the current renderer.
/// BSE.Windows.Forms.ProfessionalColorTable colorTable = renderer.ColorTable as BSE.Windows.Forms.ProfessionalColorTable;
/// if (colorTable != null)
/// {
/// // Get the PanelColors panelColorTable for the current colortable.
/// BSE.Windows.Forms.PanelColors panelColorTable = colorTable.PanelColorTable;
/// if (panelColorTable != null)
/// {
/// // Set the panel properties for the form controls collection
/// BSE.Windows.Forms.PanelSettingsManager.SetPanelProperties(this.Controls, panelColorTable);
/// }
/// }
/// }
/// }
/// }
/// </code>
/// </example>
/// <copyright>Copyright © 2006-2008 Uwe Eichkorn
/// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
/// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
/// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
/// PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER
/// REMAINS UNCHANGED.
/// </copyright>
public static class PanelSettingsManager
{
#region MethodsPublic
/// <summary>
/// Sets the PanelStyle and PanelColors table in the given control collection.
/// </summary>
/// <param name="controls">A collection of child controls.</param>
/// <param name="panelColors">The PanelColors table</param>
public static void SetPanelProperties(Control.ControlCollection controls, PanelColors panelColors)
{
if (panelColors == null)
{
throw new ArgumentNullException("panelColors",
string.Format(System.Globalization.CultureInfo.InvariantCulture,
Demo.WindowsForms.Properties.Resources.IDS_ArgumentException,
"panelColors"));
}
PanelStyle panelStyle = panelColors.PanelStyle;
SetPanelProperties(controls, panelStyle, panelColors);
}
/// <summary>
/// Sets the PanelStyle and PanelColors table in the given control collection.
/// </summary>
/// <param name="controls">A collection of child controls</param>
/// <param name="panelStyle">Style of the panel</param>
/// <param name="panelColors">The PanelColors table</param>
public static void SetPanelProperties(Control.ControlCollection controls, PanelStyle panelStyle, PanelColors panelColors)
{
if (panelColors == null)
{
throw new ArgumentNullException("panelColors",
string.Format(System.Globalization.CultureInfo.InvariantCulture,
Demo.WindowsForms.Properties.Resources.IDS_ArgumentException,
"panelColors"));
}
ArrayList panels = FindPanels(true, controls);
foreach (BasePanel panel in panels)
{
panel.PanelStyle = panelStyle;
panelColors.Panel = panel;
panel.SetPanelProperties(panelColors);
}
ArrayList xpanderPanelLists = FindPanelLists(true, controls);
foreach (XPanderPanelList xpanderPanelList in xpanderPanelLists)
{
xpanderPanelList.PanelStyle = panelStyle;
xpanderPanelList.PanelColors = panelColors;
}
}
/// <summary>
/// Sets the PanelStyle in the given control collection.
/// </summary>
/// <param name="controls">a collection of child controls</param>
/// <param name="panelStyle">Style of the panel</param>
public static void SetPanelProperties(Control.ControlCollection controls, PanelStyle panelStyle)
{
ArrayList panels = FindPanels(true, controls);
if (panels != null)
{
foreach (BasePanel panel in panels)
{
panel.PanelStyle = panelStyle;
}
}
}
/// <summary>
/// Find all controls that derived from BasePanel.
/// </summary>
/// <param name="searchAllChildren">A value indicating whether the FindPanels method loops through all controls.</param>
/// <param name="controlsToLookIn">A collection of child controls.</param>
/// <returns>A arraylist of derived types.</returns>
public static ArrayList FindPanels(bool searchAllChildren, Control.ControlCollection controlsToLookIn)
{
return FindControls(typeof(BasePanel), searchAllChildren, controlsToLookIn, new ArrayList());
}
/// <summary>
/// Find all XPanderPanelLists.
/// </summary>
/// <param name="searchAllChildren">A value indicating whether the FindPanels method loops through all controls.</param>
/// <param name="controlsToLookIn">A collection of child controls.</param>
/// <returns></returns>
public static ArrayList FindPanelLists(bool searchAllChildren, Control.ControlCollection controlsToLookIn)
{
return FindControls(typeof(XPanderPanelList), searchAllChildren, controlsToLookIn, new ArrayList());
}
#endregion
#region MethodsPrivate
private static ArrayList FindControls(Type baseType, bool searchAllChildren, Control.ControlCollection controlsToLookIn, ArrayList foundControls)
{
if ((controlsToLookIn == null) || (foundControls == null))
{
return null;
}
try
{
for (int i = 0; i < controlsToLookIn.Count; i++)
{
if ((controlsToLookIn[i] != null) && baseType.IsAssignableFrom(controlsToLookIn[i].GetType()))
{
foundControls.Add(controlsToLookIn[i]);
}
}
if (searchAllChildren == false)
{
return foundControls;
}
for (int j = 0; j < controlsToLookIn.Count; j++)
{
if (((controlsToLookIn[j] != null) && !(controlsToLookIn[j] is Form)) && ((controlsToLookIn[j].Controls != null) && (controlsToLookIn[j].Controls.Count > 0)))
{
foundControls = FindControls(baseType, searchAllChildren, controlsToLookIn[j].Controls, foundControls);
}
}
}
catch (Exception exception)
{
if (IsCriticalException(exception))
{
throw;
}
}
return foundControls;
}
private static bool IsCriticalException(Exception exception)
{
return (((((exception is NullReferenceException) ||
(exception is StackOverflowException)) ||
((exception is OutOfMemoryException) ||
(exception is System.Threading.ThreadAbortException))) ||
((exception is ExecutionEngineException) ||
(exception is IndexOutOfRangeException))) ||
(exception is AccessViolationException));
}
#endregion
}
}
|