Ejemplo n.º 1
0
        public static bool Load(DockPanel dockPanel)
        {
            try
            {
                _dockPanel = dockPanel;

                if (File.Exists(_tempFile))
                {
                    var json = File.ReadAllText(_tempFile);

                    _connections = WEFExtention.JsonDeserialize <List <ConnectionModel> >(json);
                }

                var content = new DeserializeDockContent(GetContentFromPersistString);

                if (File.Exists(_configFile))
                {
                    dockPanel.LoadFromXml(_configFile, content);

                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static void Save(DockPanel dockPanel)
        {
            _dockPanel = dockPanel;

            var contents = dockPanel.Contents;

            if (contents != null && contents.Any())
            {
                List <Connection> connections = new List <Connection>();

                foreach (var content in contents)
                {
                    if (content is SQLForm)
                    {
                        var sqlForm = (SQLForm)content;

                        sqlForm.ConnectionModel.Sql = sqlForm.AutoTextBox.TextBox.Text;

                        connections.Add(sqlForm.ConnectionModel);
                    }
                    if (content is ContentForm)
                    {
                        var contentForm = (ContentForm)content;

                        connections.Add(contentForm.ConnectionModel);
                    }
                }

                var json = WEFExtention.JsonSerialize(connections);

                File.WriteAllText(_tempFile, json, Encoding.UTF8);
            }

            dockPanel.SaveAsXml(_configFile);
        }