Exemplo n.º 1
0
 private static void SetControls(Control.ControlCollection cc, CtrlSettings cs)
 {
     if (cc != null && cs != null)
     {
         foreach (Control c1 in cc)
         {
             foreach (CtrlSettings c in cs.ChildCtrlsToPersist)
             {
                 if (typeof(ToolStripPanel).IsInstanceOfType(c1))
                 {
                     ToolStripPanel ts = (ToolStripPanel)c1;
                     foreach (Control c2 in ts.Controls)
                     {
                         if (c2.GetType().ToString().Equals(c.Type))
                         {
                             if (c2.Name.Equals(c.Name))
                             {
                                 if (ts.Dock.ToString().Equals(c.CtrlValue))
                                 {
                                     c2.Location = c.Location;
                                     c2.Size     = c.Size;
                                 }
                                 else
                                 {
                                     foreach (Control c3 in ts.Parent.Controls)
                                     {
                                         if (typeof(ToolStripPanel).IsInstanceOfType(c3))
                                         {
                                             ToolStripPanel ts2 = (ToolStripPanel)c3;
                                             if (!ts2.Equals(ts))
                                             {
                                                 if (ts2.Dock.ToString().Equals(c.CtrlValue))
                                                 {
                                                     ts.Controls.Remove(c2);
                                                     c2.Location = c.Location;
                                                     c2.Size     = c.Size;
                                                     ts2.Controls.Add(c2);
                                                     break;
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 break;
                             }
                         }
                     }
                 }
             }
             if (typeof(SQLServerExplorer).IsInstanceOfType(c1))
             {
                 SQLServerExplorer sse = (SQLServerExplorer)c1;
                 foreach (CtrlSettings c in cs.ChildCtrlsToPersist)
                 {
                     if (typeof(SQLConnection).ToString().Equals(c.Type))
                     {
                         string[] ss      = c.CtrlValue.Split(new char[] { '\\' });
                         bool     savePWD = false;
                         if (ss.Length > 1)
                         {
                             savePWD = Convert.ToBoolean(ss[1]);
                         }
                         sse.SQLConnections.AddEncrypted(ss[0], "LLEWIS55", savePWD);
                     }
                 }
             }
             SetControls(c1.Controls, cs);
         }
     }
 }