/// <summary>
        /// Need to check if the node being requested is a file, if so, return the rules for it, otherwise process as per normal
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="queryStrings"></param>
        /// <returns></returns>
        protected override UmbracoTreeResult GetTreeData(HiveId parentId, FormCollection queryStrings)
        {
            using (var uow = Hive.CreateReadonly())
            {
                var stylesheet = uow.Repositories.Get <File>(parentId);
                if (!stylesheet.IsContainer)
                {
                    var rules = StylesheetHelper.ParseRules(stylesheet);
                    if (rules.Any())
                    {
                        foreach (var rule in rules)
                        {
                            var hiveId = new HiveId(new Uri(HiveUriRouteMatch), string.Empty, new HiveIdValue(parentId.Value + "/" + rule.Name.Replace(" ", "__s__")));
                            var node   = CreateTreeNode(hiveId,
                                                        null,
                                                        rule.Name,
                                                        Url.GetEditorUrl("EditRule", hiveId, EditorControllerId, BackOfficeRequestContext.RegisteredComponents, BackOfficeRequestContext.Application.Settings),
                                                        false,
                                                        "tree-css-item");
                            node.AddEditorMenuItem <Delete>(this, "deleteUrl", "DeleteRule");
                            NodeCollection.Add(node);
                        }
                    }
                    return(UmbracoTree());
                }
            }

            return(base.GetTreeData(parentId, queryStrings));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes an Umbraco stylesheet property
 /// </summary>
 /// <param name="name"></param>
 public void RemoveProperty(string name)
 {
     if (Properties.Any(x => x.Name.InvariantEquals(name)))
     {
         Content = StylesheetHelper.ReplaceRule(Content, name, null);
     }
 }
        /// <summary>
        /// Creates a style sheet from CSS and style rules
        /// </summary>
        /// <param name="data">The style sheet data</param>
        /// <returns>The style sheet combined from the CSS and the rules</returns>
        /// <remarks>
        /// Any "umbraco style rules" in the CSS will be removed and replaced with the rules passed in <see cref="data"/>
        /// </remarks>
        public string PostInterpolateStylesheetRules(StylesheetData data)
        {
            // first remove all existing rules
            var existingRules = data.Content.IsNullOrWhiteSpace()
                ? new Core.Strings.Css.StylesheetRule[0]
                : StylesheetHelper.ParseRules(data.Content).ToArray();

            foreach (var rule in existingRules)
            {
                data.Content = StylesheetHelper.ReplaceRule(data.Content, rule.Name, null);
            }

            data.Content = data.Content.TrimEnd(CharArrays.LineFeedCarriageReturn);

            // now add all the posted rules
            if (data.Rules != null && data.Rules.Any())
            {
                foreach (var rule in data.Rules)
                {
                    data.Content = StylesheetHelper.AppendRule(data.Content, new Core.Strings.Css.StylesheetRule
                    {
                        Name     = rule.Name,
                        Selector = rule.Selector,
                        Styles   = rule.Styles
                    });
                }

                data.Content += Environment.NewLine;
            }

            return(data.Content);
        }
        public void ParseFormattedRules_CanParse()
        {
            // base CSS
            var css = Tabbed(
                @"body {
#font-family:Arial;
}

/**umb_name:Test*/
.test {
#font-color: red;
#margin: 1rem;
}

/**umb_name:Test2*/
.test2 {
#font-color: green;
}");
            var rules = StylesheetHelper.ParseRules(css);

            Assert.AreEqual(2, rules.Count());

            Assert.AreEqual("Test", rules.First().Name);
            Assert.AreEqual(".test", rules.First().Selector);
            Assert.AreEqual(
                @"font-color: red;
margin: 1rem;", rules.First().Styles);

            Assert.AreEqual("Test2", rules.Last().Name);
            Assert.AreEqual(".test2", rules.Last().Selector);
            Assert.AreEqual("font-color: green;", rules.Last().Styles);
        }
        public void Duplicate_Names()
        {
            var css     = @"/** Umb_Name: Test */ p { font-size: 1em; } /** umb_name:  Test */ li {padding:0px;}";
            var results = StylesheetHelper.ParseRules(css);

            Assert.AreEqual(1, results.Count());
        }
Ejemplo n.º 6
0
    private bool Save()
    {
        if (StylesheetHelper.UniqueStylesheetName(nameTextBox.Text, _initialNameValue))
        {
            if (ValidXslt(xslTextBox.Text))
            {
                if (_textChanged)
                {
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    DialogResult = DialogResult.Cancel;
                }

                _textChanged = false;
                return(true);
            }
        }
        else
        {
            nameTextBox.Focus();
        }

        return(false);
    }
Ejemplo n.º 7
0
    private void CheckValues()
    {
        if (_checkValue == GenericHelper.CheckValue.Integer)
        {
            _success = CheckIntegerValue();

            if (_success)
            {
                _newIntegerValue = Convert.ToInt32(newValueTextBox.Text);
            }
        }
        else if (_checkValue == GenericHelper.CheckValue.TaskName)
        {
            _success = TaskHelper.UniqueTaskName(newValueTextBox.Text, _initialNameValue);

            if (_success)
            {
                _newStringValue = newValueTextBox.Text;
            }
        }
        else if (_checkValue == GenericHelper.CheckValue.StylesheetName)
        {
            _success = StylesheetHelper.UniqueStylesheetName(newValueTextBox.Text, _initialNameValue);

            if (_success)
            {
                _newStringValue = newValueTextBox.Text;
            }
        }
    }
        public ActionResult EditRule(HiveId id)
        {
            Mandate.ParameterNotEmpty(id, "id");

            //The rule Id consists of both the stylesheet Id and the rule name
            var idParts      = id.StringParts().ToList();
            var stylesheetId = idParts[0];
            var ruleName     = idParts.Count > 1 ? idParts[1] : "";

            ViewBag.IsNew = string.IsNullOrWhiteSpace(ruleName);

            using (var uow = _hive.Create())
            {
                var stylesheet = uow.Repositories.Get <Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId));
                var rule       = !string.IsNullOrWhiteSpace(ruleName) ?
                                 StylesheetHelper.ParseRules(stylesheet).Single(x => x.Name.Replace(" ", "__s__") == ruleName) :
                                 new StylesheetRule()
                {
                    StylesheetId = id
                };

                var ruleModel = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <StylesheetRuleEditorModel>(rule);

                return(View(ruleModel));
            }
        }
Ejemplo n.º 9
0
        public async Task WriteXhtmlFragmentAsync(StringWriter writer, ContentURI uri,
                                                  string xmlDocToReadPath, DataHelpers.GeneralHelpers.DOC_STATE_NUMBER displayDocType)
        {
            XmlReader oReader = null;

            if (DataHelpers.FileStorageIO.URIAbsoluteExists(uri, xmlDocToReadPath))
            {
                oReader = DataHelpers.FileStorageIO.GetXmlReader(uri, xmlDocToReadPath);
            }
            else
            {
                SetNoXmlDocErrorMsg(uri, displayDocType);
            }
            if (oReader != null)
            {
                using (oReader)
                {
                    if (uri.URIDataManager.ServerSubActionType
                        != DataHelpers.GeneralHelpers.SERVER_SUBACTION_TYPES.respondwithxml &&
                        Path.GetExtension(xmlDocToReadPath).EndsWith(
                            DataAppHelpers.Resources.GENERAL_RESOURCE_TYPES.xml.ToString()))
                    {
                        //write the transformed xml doc (ChangeDisplayParams switched apps so that servicespacks display correctly)
                        StylesheetHelper styleHelper = new StylesheetHelper();
                        await styleHelper.TransformXmlToXhtmlAsync(writer, uri, displayDocType, oReader);
                    }
                    else
                    {
                        oReader.MoveToContent();
                        writer.Write(oReader.ReadOuterXml());
                    }
                    oReader.Close();
                }
            }
        }
Ejemplo n.º 10
0
    private static void LoadStylesheetsFromFile(string stylesheetsFileName)
    {
        string xml = XmlHelper.ReadXmlFromFile(stylesheetsFileName);

        StylesheetHelper.StylesheetCollection                   = StylesheetHelper.XmlToStylesheetCollection(xml);
        StylesheetHelper.StylesheetCollectionFileName           = stylesheetsFileName;
        SessionHelper.EnableLoadLastSessionStylesheetCollection = false;
    }
        public void ParseRules_DoesntParse(string css)
        {
            // Act
            var results = StylesheetHelper.ParseRules(css);

            // Assert
            Assert.IsTrue(results.Count() == 0);
        }
        public void ParseRules_DoesntParse(string css)
        {
            // Act
            IEnumerable <StylesheetRule> results = StylesheetHelper.ParseRules(css);

            // Assert
            Assert.IsTrue(results.Any() == false);
        }
        public ActionResult EditRule(StylesheetRuleEditorModel ruleModel)
        {
            Mandate.ParameterNotNull(ruleModel, "rule");

            if (!TryValidateModel(ruleModel))
            {
                return(View(ruleModel));
            }

            using (var uow = _hive.Create())
            {
                var repo       = uow.Repositories;
                var stylesheet = repo.Get <Umbraco.Framework.Persistence.Model.IO.File>(ruleModel.ParentId);
                var rule       = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <StylesheetRule>(ruleModel);

                if (!ruleModel.Id.IsNullValueOrEmpty())
                {
                    var idParts = ruleModel.Id.StringParts().ToList();
                    if (idParts.Count == 2)
                    {
                        var oldRuleName = idParts[1].Replace("__s__", " ");

                        StylesheetHelper.ReplaceRule(stylesheet, oldRuleName, rule);
                    }
                    else
                    {
                        StylesheetHelper.AppendRule(stylesheet, rule);
                    }
                }
                else
                {
                    StylesheetHelper.AppendRule(stylesheet, rule);
                }

                repo.AddOrUpdate(stylesheet);
                uow.Complete();

                //Always update the Id to be based on the name
                ruleModel.Id = new HiveId(new Uri("storage://stylesheets"), string.Empty, new HiveIdValue(ruleModel.ParentId.Value + "/" + ruleModel.Name.Replace(" ", "__s__")));
            }

            Notifications.Add(new NotificationMessage("Rule saved", NotificationType.Success));

            //add path for entity for SupportsPathGeneration (tree syncing) to work,
            //we need to manually create this path:
            GeneratePathsForCurrentEntity(new EntityPathCollection(ruleModel.Id, new[] { new EntityPath(new[]
                {
                    _hive.GetRootNodeId(),
                    ruleModel.ParentId,
                    ruleModel.Id
                }) }));

            return(RedirectToAction("EditRule", new { id = ruleModel.Id }));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// If the property has changed then we need to update the content
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Property_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var prop = (StylesheetProperty)sender;

            //Ensure we are setting base.Content here so that the properties don't get reset and thus any event handlers would get reset too
            base.Content = StylesheetHelper.ReplaceRule(Content, prop.Name, new StylesheetRule
            {
                Name     = prop.Name,
                Selector = prop.Alias,
                Styles   = prop.Value
            });
        }
        public void ParseRules_Parses(string name, string selector, string styles, string css)
        {
            // Act
            var results = StylesheetHelper.ParseRules(css);

            // Assert
            Assert.AreEqual(1, results.Count());

            //Assert.IsTrue(results.First().RuleId.Value.Value.ToString() == file.Id.Value.Value + "/" + name);
            Assert.AreEqual(name, results.First().Name);
            Assert.AreEqual(selector, results.First().Selector);
            Assert.AreEqual(styles.StripWhitespace(), results.First().Styles.StripWhitespace());
        }
Ejemplo n.º 16
0
        public void StylesheetHelperTests_ParseRules_DoesntParse(string css)
        {
            // Arrange
            var file = new File(new HiveId("styles.css"))
            {
                ContentBytes = Encoding.UTF8.GetBytes(css)
            };

            // Act
            var results = StylesheetHelper.ParseRules(file);

            // Assert
            Assert.IsTrue(results.Count() == 0);
        }
Ejemplo n.º 17
0
        private void InitializeProperties()
        {
            //if the value is already created, we need to be created and update the collection according to
            //what is now in the content
            if (_properties != null && _properties.IsValueCreated)
            {
                //re-parse it so we can check what properties are different and adjust the event handlers
                var parsed   = StylesheetHelper.ParseRules(Content).ToArray();
                var names    = parsed.Select(x => x.Name).ToArray();
                var existing = _properties.Value.Where(x => names.InvariantContains(x.Name)).ToArray();
                //update existing
                foreach (var stylesheetProperty in existing)
                {
                    var updateFrom = parsed.Single(x => x.Name.InvariantEquals(stylesheetProperty.Name));
                    //remove current event handler while we update, we'll reset it after
                    stylesheetProperty.PropertyChanged -= Property_PropertyChanged;
                    stylesheetProperty.Alias            = updateFrom.Selector;
                    stylesheetProperty.Value            = updateFrom.Styles;
                    //re-add
                    stylesheetProperty.PropertyChanged += Property_PropertyChanged;
                }
                //remove no longer existing
                var nonExisting = _properties.Value.Where(x => names.InvariantContains(x.Name) == false).ToArray();
                foreach (var stylesheetProperty in nonExisting)
                {
                    stylesheetProperty.PropertyChanged -= Property_PropertyChanged;
                    _properties.Value.Remove(stylesheetProperty);
                }
                //add new ones
                var newItems = parsed.Where(x => _properties.Value.Select(p => p.Name).InvariantContains(x.Name) == false);
                foreach (var stylesheetRule in newItems)
                {
                    var prop = new StylesheetProperty(stylesheetRule.Name, stylesheetRule.Selector, stylesheetRule.Styles);
                    prop.PropertyChanged += Property_PropertyChanged;
                    _properties.Value.Add(prop);
                }
            }

            //we haven't read the properties yet so create the lazy delegate
            _properties = new Lazy <List <StylesheetProperty> >(() =>
            {
                var parsed = StylesheetHelper.ParseRules(Content);
                return(parsed.Select(statement =>
                {
                    var property = new StylesheetProperty(statement.Name, statement.Selector, statement.Styles);
                    property.PropertyChanged += Property_PropertyChanged;
                    return property;
                }).ToList());
            });
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Extracts "umbraco style rules" from a style sheet
        /// </summary>
        /// <param name="data">The style sheet data</param>
        /// <returns>The style rules</returns>
        public StylesheetRule[] PostExtractStylesheetRules(StylesheetData data)
        {
            if (data.Content.IsNullOrWhiteSpace())
            {
                return(new StylesheetRule[0]);
            }

            return(StylesheetHelper.ParseRules(data.Content)?.Select(rule => new StylesheetRule
            {
                Name = rule.Name,
                Selector = rule.Selector,
                Styles = rule.Styles
            }).ToArray());
        }
        public void Replace_Rule()
        {
            var css     = @"body {font-family:Arial;}/** Umb_Name: Test1 */ p { font-size: 1em; } /** umb_name:  Test2 */ li {padding:0px;} table {margin:0;}";
            var results = StylesheetHelper.ParseRules(css);

            var result = StylesheetHelper.ReplaceRule(css, results.First().Name, new StylesheetRule()
            {
                Name     = "My new rule",
                Selector = "p",
                Styles   = "font-size:1em; color:blue;"
            });

            Assert.AreEqual(@"body {font-family:Arial;}/**umb_name:My new rule*/
p{font-size:1em; color:blue;} /** umb_name:  Test2 */ li {padding:0px;} table {margin:0;}".StripWhitespace(), result.StripWhitespace());
        }
Ejemplo n.º 20
0
    public static void LoadLastSession()
    {
        if (EnableLoadLastSessionTaskCollection)
        {
            TaskHelper.TaskCollectionFileName = RegistryHandler.ReadFromRegistry("TaskCollectionFileName");

            if (TaskHelper.TaskCollectionFileName == "")
            {
                TaskHelper.TaskCollectionFileName = null;
            }
            else
            {
                TaskCollection temporaryTaskCollection = TaskHelper.XmlToTaskCollection(XmlHelper.ReadXmlFromFile(TaskHelper.TaskCollectionFileName));

                if (temporaryTaskCollection == null)
                {
                    TaskHelper.TaskCollectionFileName = null;
                }
                else
                {
                    TaskHelper.TaskCollection = temporaryTaskCollection;
                }
            }
        }

        if (EnableLoadLastSessionStylesheetCollection)
        {
            StylesheetHelper.StylesheetCollectionFileName = RegistryHandler.ReadFromRegistry("StylesheetCollectionFileName");

            if (StylesheetHelper.StylesheetCollectionFileName == "")
            {
                StylesheetHelper.StylesheetCollectionFileName = null;
            }
            else
            {
                StylesheetCollection temporaryStylesheetCollection = StylesheetHelper.XmlToStylesheetCollection(XmlHelper.ReadXmlFromFile(StylesheetHelper.StylesheetCollectionFileName));

                if (StylesheetHelper.StylesheetCollection == null)
                {
                    StylesheetHelper.StylesheetCollectionFileName = null;
                }
                else
                {
                    StylesheetHelper.StylesheetCollection = temporaryStylesheetCollection;
                }
            }
        }
    }
Ejemplo n.º 21
0
        public void Append_Rule()
        {
            var css = @"body {font-family:Arial;}/** Umb_Name: Test1 */ p { font-size: 1em; } /** umb_name:  Test2 */ li {padding:0px;} table {margin:0;}";

            var result = StylesheetHelper.AppendRule(css, new StylesheetRule()
            {
                Name     = "My new rule",
                Selector = "p",
                Styles   = "font-size:1em; color:blue;"
            });

            Assert.AreEqual(@"body {font-family:Arial;}/** Umb_Name: Test1 */ p { font-size: 1em; } /** umb_name:  Test2 */ li {padding:0px;} table {margin:0;}

/**umb_name:My new rule*/
p{font-size:1em; color:blue;}".CrLf(), result);
        }
Ejemplo n.º 22
0
    private bool SaveCollection()
    {
        StylesheetHelper.StylesheetCollection.Description = descriptionTextBox.Text;

        string fileName = GetFileName();

        if (fileName != null)
        {
            StylesheetHelper.SaveStylesheetCollection(fileName);
            CopyStylesheetCollectionToInitialStylesheetCollection();
            SetChangesMade(false);
            return(true);
        }

        return(false);
    }
Ejemplo n.º 23
0
    private bool Import(string xml)
    {
        StylesheetCollection temporaryStylesheetCollection = StylesheetHelper.XmlToStylesheetCollection(xml);

        if (temporaryStylesheetCollection != null)
        {
            StylesheetHelper.StylesheetCollection = temporaryStylesheetCollection;
            FillList();
            SelectFirstItem();

            descriptionTextBox.Text = StylesheetHelper.StylesheetCollection.Description;
            SetChangesMade(false);
            return(true);
        }

        return(false);
    }
Ejemplo n.º 24
0
    public static void SaveSession()
    {
        if (TaskHelper.TaskCollectionFileName == null || TaskHelper.TaskCollectionFileName == GetSessionTaskCollectionFileName())
        {
            TaskHelper.TaskCollectionFileName = GetSessionTaskCollectionFileName();
            TaskHelper.SaveTaskCollection(TaskHelper.TaskCollectionFileName);
        }

        RegistryHandler.SaveToRegistry("TaskCollectionFileName", TaskHelper.TaskCollectionFileName);

        if (StylesheetHelper.StylesheetCollectionFileName == null || StylesheetHelper.StylesheetCollectionFileName == GetSessionStylesheetCollectionFileName())
        {
            StylesheetHelper.StylesheetCollectionFileName = GetSessionStylesheetCollectionFileName();
            StylesheetHelper.SaveStylesheetCollection(StylesheetHelper.StylesheetCollectionFileName);
        }

        RegistryHandler.SaveToRegistry("StylesheetCollectionFileName", StylesheetHelper.StylesheetCollectionFileName);
    }
Ejemplo n.º 25
0
        /// <summary>
        /// Adds an Umbraco stylesheet property for use in the back office
        /// </summary>
        /// <param name="property"></param>
        public void AddProperty(StylesheetProperty property)
        {
            if (Properties.Any(x => x.Name.InvariantEquals(property.Name)))
            {
                throw new DuplicateNameException("The property with the name " + property.Name + " already exists in the collection");
            }

            //now we need to serialize out the new property collection over-top of the string Content.
            Content = StylesheetHelper.AppendRule(Content, new StylesheetRule
            {
                Name     = property.Name,
                Selector = property.Alias,
                Styles   = property.Value
            });

            //re-set lazy collection
            InitializeProperties();
        }
Ejemplo n.º 26
0
        public void StylesheetHelperTests_ParseRules_Parses(string name, string selector, string styles, string css)
        {
            // Arrange
            var file = new File(new HiveId("styles.css"))
            {
                ContentBytes = Encoding.UTF8.GetBytes(css)
            };

            // Act
            var results = StylesheetHelper.ParseRules(file);

            // Assert
            Assert.IsTrue(results.Count() == 1);

            Assert.IsTrue(results.First().RuleId.Value.Value.ToString() == file.Id.Value.Value + "/" + name);
            Assert.IsTrue(results.First().Name == name);
            Assert.IsTrue(results.First().Selector == selector);
            Assert.IsTrue(results.First().Styles == styles);
        }
        protected override void CustomizeFileNode(TreeNode n, FormCollection queryStrings)
        {
            n.AddEditorMenuItem <CreateItem>(this, "createUrl", "EditRule");
            base.CustomizeFileNode(n, queryStrings);
            n.AddMenuItem <Reload>();

            n.Icon = "tree-css";

            using (var uow = Hive.CreateReadonly())
            {
                var stylesheet = uow.Repositories.Get <File>(n.HiveId);
                var rules      = StylesheetHelper.ParseRules(stylesheet);
                n.HasChildren = rules.Count() > 0;
                if (n.HasChildren)
                {
                    n.JsonUrl = Url.GetTreeUrl(GetType(), n.HiveId, queryStrings);
                }
            }
        }
        public void AppendRules_IsFormatted()
        {
            // base CSS
            var css = Tabbed(
                @"body {
#font-family:Arial;
}");
            // add a couple of rules
            var result = StylesheetHelper.AppendRule(css, new StylesheetRule
            {
                Name     = "Test",
                Selector = ".test",
                Styles   = "font-color: red;margin: 1rem;"
            });

            result = StylesheetHelper.AppendRule(result, new StylesheetRule
            {
                Name     = "Test2",
                Selector = ".test2",
                Styles   = "font-color: green;"
            });

            // verify the CSS formatting including the indents
            Assert.AreEqual(Tabbed(
                                @"body {
#font-family:Arial;
}

/**umb_name:Test*/
.test {
#font-color: red;
#margin: 1rem;
}

/**umb_name:Test2*/
.test2 {
#font-color: green;
}"), result
                            );
        }
        public ActionResult DeleteRule(HiveId id)
        {
            Mandate.ParameterNotEmpty(id, "id");

            var idParts      = id.StringParts().ToList();
            var stylesheetId = idParts[0];
            var ruleName     = idParts[1];

            using (var uow = _hive.Create())
            {
                var repo       = uow.Repositories;
                var stylesheet = repo.Get <Umbraco.Framework.Persistence.Model.IO.File>(new HiveId(stylesheetId));

                StylesheetHelper.ReplaceRule(stylesheet, ruleName, null);

                repo.AddOrUpdate(stylesheet);
                uow.Complete();
            }

            //return a successful JSON response
            return(Json(new { message = "Success" }));
        }
    public static void LoadConfig()
    {
        ConnectionString = ConnectionStringSecurity.Decode(RegistryHandler.ReadFromRegistry("ConnectionString"), "ConnectionString");

        if (ConnectionString == "")
        {
            ConnectionString = @"Data Source=SQLServerName\SQLServerInstance;Initial Catalog=master;Integrated Security=True";
        }

        ConnectionStringToSave = ConnectionStringSecurity.Decode(RegistryHandler.ReadFromRegistry("ConnectionString"), "ConnectionString");

        if (ConnectionStringToSave == "")
        {
            ConnectionStringToSave = @"Data Source=SQLServerName\SQLServerInstance;Initial Catalog=master;Integrated Security=True";
        }

        SaveConnectionString = RegistryHandler.ReadFromRegistry("SaveConnectionString");

        if (SaveConnectionString == "")
        {
            SaveConnectionString = "True";
        }

        WordWrap = RegistryHandler.ReadFromRegistry("WordWrap");

        if (WordWrap == "")
        {
            WordWrap = "False";
        }

        if (TraceFileDirectory == null)
        {
            TraceFileDirectory = "";
        }

        EditWindowSize = RegistryHandler.ReadFromRegistry("EditWindowSize");

        if (EditWindowSize == "")
        {
            EditWindowSize = GenericHelper.DefaultWindowSize;
        }

        EditorWindowSize = RegistryHandler.ReadFromRegistry("EditorWindowSize");

        if (EditorWindowSize == "")
        {
            EditorWindowSize = GenericHelper.DefaultWindowSize;
        }

        CommandLineParametersWindowSize = RegistryHandler.ReadFromRegistry("CommandLineParametersWindowSize");

        if (CommandLineParametersWindowSize == "")
        {
            CommandLineParametersWindowSize = GenericHelper.DefaultWindowSize;
        }

        MainWindowSize = RegistryHandler.ReadFromRegistry("MainWindowSize");

        if (MainWindowSize == "")
        {
            MainWindowSize = GenericHelper.DefaultWindowSize;
        }

        ResultsWindowSize = RegistryHandler.ReadFromRegistry("ResultsWindowSize");

        if (ResultsWindowSize == "")
        {
            ResultsWindowSize = GenericHelper.DefaultWindowSize;
        }

        ValueSubstitutorWindowSize = RegistryHandler.ReadFromRegistry("ValueSubstitutorWindowSize");

        if (ValueSubstitutorWindowSize == "")
        {
            ValueSubstitutorWindowSize = GenericHelper.DefaultWindowSize;
        }

        EditorFontFamily = RegistryHandler.ReadFromRegistry("EditorFontFamily");

        if (EditorFontFamily == "")
        {
            EditorFontFamily = "Courier New";
        }

        EditorFontSize = RegistryHandler.ReadFromRegistry("EditorFontSize");

        if (EditorFontSize == "")
        {
            EditorFontSize = "10";
        }

        DefaultStylesheet = RegistryHandler.ReadFromRegistry("DefaultStylesheet");

        if (DefaultStylesheet == "")
        {
            DefaultStylesheet = "Graphs";
        }

        UseExtendedEvents = RegistryHandler.ReadFromRegistry("UseExtendedEvents");

        if (UseExtendedEvents == "")
        {
            UseExtendedEvents = "";
        }

        IgnoreErrors = RegistryHandler.ReadFromRegistry("IgnoreErrors");

        OfflineMode = RegistryHandler.ReadFromRegistry("OfflineMode");

        if (OfflineMode == "")
        {
            OfflineMode = "False";
        }

        OfflineModeToSave = RegistryHandler.ReadFromRegistry("OfflineModeToSave");

        if (OfflineModeToSave == "")
        {
            OfflineModeToSave = "False";
        }

        CheckForUpdatesOnStart = RegistryHandler.ReadFromRegistry("CheckForUpdatesOnStart");

        if (CheckForUpdatesOnStart == "")
        {
            CheckForUpdatesOnStart = "True";
        }

        string installed = RegistryHandler.ReadFromRegistry("Installed", Registry.CurrentUser);

        if (installed == "1")
        {
            SaveConfig();             // To set default values in registry

            if (TaskHelper.TaskCollection.Tasks.Count == 0)
            {
                TaskHelper.TaskCollection.Description = "No Task Collection loaded.\r\nTo load or create a Task Collection choose \"Options\", \"Task Collection Editor...\".";
                TaskHelper.TaskCollection.Connections = 1;
                TaskHelper.TaskCollection.PerformanceCountersSamplingInterval = 0;
                TaskHelper.TaskCollection.TimeBetweenConnections = 0;
            }

            if (StylesheetHelper.StylesheetCollection.Stylesheets.Count == 0)
            {
                StylesheetHelper.StylesheetCollection = StylesheetHelper.XmlToStylesheetCollection(PerformanceTestTool.Properties.Resources.DefaultStylesheets);
            }

            SessionHelper.SaveSession();
            RegistryHandler.SaveToRegistry("Installed", "2", Registry.CurrentUser);
        }

        UpdateServiceUrl = RegistryHandler.ReadFromRegistry("UpdateServiceUrl");

        if (UpdateServiceUrl == "")
        {
            UpdateServiceUrl = "http://virtcore.com/VirtcoreService.asmx";
            RegistryHandler.SaveToRegistry("UpdateServiceUrl", UpdateServiceUrl);
        }
    }