public static CtrlSettings ReadXml(string fileName)
        {
            // Create a TextReader to read the file if it exists. 
            CtrlSettings cs = new CtrlSettings();
            if (fileName != null && fileName != string.Empty)
            {
                try
                {
                    FileStream fs = new FileStream(fileName, FileMode.OpenOrCreate);
                    TextReader reader = new StreamReader(fs);
                    XmlSerializer ser = new XmlSerializer(typeof(CtrlSettings));
                    cs = (CtrlSettings)ser.Deserialize(reader);

                    ser = null;
                    fs.Close();
                    reader.Close();
                    fs.Dispose();
                    reader.Dispose();
                }
                catch (Exception ex)
                {
                    logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
                }
            }
            return cs;
        }
Esempio n. 2
0
        public static CtrlSettings ReadXml(string fileName)
        {
            // Create a TextReader to read the file if it exists.
            CtrlSettings cs = new CtrlSettings();

            if (fileName != null && fileName != string.Empty)
            {
                try
                {
                    FileStream    fs     = new FileStream(fileName, FileMode.OpenOrCreate);
                    TextReader    reader = new StreamReader(fs);
                    XmlSerializer ser    = new XmlSerializer(typeof(CtrlSettings));
                    cs = (CtrlSettings)ser.Deserialize(reader);

                    ser = null;
                    fs.Close();
                    reader.Close();
                    fs.Dispose();
                    reader.Dispose();
                }
                catch (Exception ex)
                {
                    logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
                }
            }
            return(cs);
        }
Esempio n. 3
0
 public static void WriteXml(string fileName, CtrlSettings settings)
 {
     if (fileName != null && fileName != string.Empty && settings != null)
     {
         try
         {
             TextWriter    writer = new StreamWriter(fileName, false);
             XmlSerializer ser    = new XmlSerializer(typeof(CtrlSettings));
             ser.Serialize(writer, settings);
             ser = null;
             writer.Close();
             writer.Dispose();
         }
         catch (Exception ex)
         {
             logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
         }
     }
 }
Esempio n. 4
0
 public static void SetSettings(ref Form form, CtrlSettings cs)
 {
     if (form != null && cs != null && form.GetType().ToString().Equals(cs.Type))
     {
         if (form.Name.Equals(cs.Name))
         {
             if (typeof(Lewis.SST.Gui.Main).IsInstanceOfType(form))
             {
                 ((Lewis.SST.Gui.Main)form).LastDirectory = cs.LastDirectory;
             }
             form.Location = cs.Location;
             form.Size     = cs.Size;
             if (cs.ChildCtrlsToPersist.Length > 0)
             {
                 SetControls(form.Controls, cs);
             }
         }
     }
 }
 public static void WriteXml(string fileName, CtrlSettings settings)
 {
     if (fileName != null && fileName != string.Empty && settings != null)
     {
         try
         {
             TextWriter writer = new StreamWriter(fileName, false);
             XmlSerializer ser = new XmlSerializer(typeof(CtrlSettings));
             ser.Serialize(writer, settings);
             ser = null;
             writer.Close();
             writer.Dispose();
         }
         catch (Exception ex)
         {
             logger.Error(SQLSchemaTool.ERRORFORMAT, ex.Message, ex.Source, ex.StackTrace);
         }
     }
 }
Esempio n. 6
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);
         }
     }
 }
 public CtrlSettings(String name, Point location, Size size, string value, CtrlSettings[] childCtrls)
 {
     _name = name;
     _location = location;
     _size = size;
     _ctrlValue = value;
     _childCtrlsToPersist = childCtrls;
 }
 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);
         }
     }
 }
 public static void SetSettings(ref Form form, CtrlSettings cs)
 {
     if (form != null && cs != null && form.GetType().ToString().Equals(cs.Type))
     {
         if (form.Name.Equals(cs.Name))
         {
             if (typeof(Lewis.SST.Gui.Main).IsInstanceOfType(form))
             {
                 ((Lewis.SST.Gui.Main)form).LastDirectory = cs.LastDirectory;
             }
             form.Location = cs.Location;
             form.Size = cs.Size;
             if (cs.ChildCtrlsToPersist.Length > 0)
             {
                 SetControls(form.Controls, cs);
             }
         }
     }
 }