Exemplo n.º 1
0
 public void Initialize()
 {
     _config = new StyleConfig();
     _config.LeftIdentationCssClassSuffix = ".numbering-container";
     _instance          = new IndentationCssProperty(_config);
     _instance.Selector = ".test";
 }
Exemplo n.º 2
0
 public void Initialize()
 {
     _cssRegistrator = Substitute.For <ICssRegistrator>();
     _styleConveter  = Substitute.For <IStyleConverter>();
     _styleConveter.BuildRegistrator().Returns(_cssRegistrator);
     _config   = new StyleConfig();
     _instance = new StylePlugin(_styleConveter, _config);
     _css      = new StringBuilder();
     _state    = Substitute.For <IProcessingState>();
     _state.Css.Returns(_css);
     _state.Elements.Returns(_ => new ElementProcessingState[0]);
     _state.GetContext(out ICssRegistrator _)
     .Returns(x =>
     {
         x[0] = _cssRegistrator;
         return(true);
     });
     _parentVNode  = new VNode();
     _currentVNode = new VNode();
     _elemState    = Substitute.For <IElementProcessingState>();
     _elemState.ProcessingState.Returns(_state);
     _elemState
     .GetContext(out ParagraphContext _)
     .Returns(x =>
     {
         x[0] = new ParagraphContext {
             Parent = _parentVNode
         };
         return(true);
     });
     _elemState.CurrentVNode.Returns(_ => _currentVNode);
 }
        public static XWPFParagraph CreateParagraph(this XWPFDocument doc, StyleConfig styles)
        {
            XWPFParagraph para = doc.CreateParagraph();

            para.Alignment = (styles.isAlignRight ? ParagraphAlignment.RIGHT : ParagraphAlignment.LEFT);
            return(para);
        }
        public static IXLCell SetStyle(this IXLCell cell, StyleConfig styleConfig)
        {
            if (styleConfig.Bold.HasValue)
            {
                cell.Style.Font.SetBold(styleConfig.Bold.Value);
            }

            if (styleConfig.FontColor != null)
            {
                cell.Style.Font.SetFontColor(styleConfig.FontColor);
            }

            if (styleConfig.BackgroundColor != null)
            {
                cell.Style.Fill.SetBackgroundColor(styleConfig.BackgroundColor);
            }

            if (styleConfig.HorizontalAlignment.HasValue)
            {
                cell.Style.Alignment.SetHorizontal(styleConfig.HorizontalAlignment.Value);
            }

            if (styleConfig.OutsideBorder.HasValue)
            {
                cell.Style.Border.SetOutsideBorder(styleConfig.OutsideBorder.Value ? XLBorderStyleValues.Thick : XLBorderStyleValues.None);
            }

            if (styleConfig.InsideBorder.HasValue)
            {
                cell.Style.Border.SetInsideBorder(styleConfig.InsideBorder.Value ? XLBorderStyleValues.Thin : XLBorderStyleValues.None);
            }

            return(cell);
        }
            public void InsideBorderBorderSetting()
            {
                var config = new StyleConfig()
                {
                    InsideBorder = null
                };

                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockBorder.Verify(b => b.SetInsideBorder(It.IsAny <XLBorderStyleValues>()), Times.Never);

                mockBorder.Setup(c => c.SetInsideBorder(It.IsAny <XLBorderStyleValues>())).Returns(mockStyle.Object);

                config = new StyleConfig()
                {
                    InsideBorder = false
                };
                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockBorder.Verify(b => b.SetInsideBorder(It.Is <XLBorderStyleValues>(x => x == XLBorderStyleValues.None)), Times.Once);

                config = new StyleConfig()
                {
                    InsideBorder = true
                };
                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockBorder.Verify(b => b.SetInsideBorder(It.Is <XLBorderStyleValues>(x => x == XLBorderStyleValues.Thin)), Times.Once);
            }
Exemplo n.º 6
0
        public static void AddConfig(StyleConfig ur)
        {
            SQLiteConnection conn = new SQLiteConnection(connStr);

            try
            {
                conn.Open();
                using (SQLiteCommand cmd = new SQLiteCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = "INSERT INTO StyleConfig(userid,color,size,fontFamily,fontStyle)VALUES(@userid,@color,@size,@fontFamily,@fontStyle)";
                    cmd.Parameters.AddWithValue("@userid", ur.UserId);
                    cmd.Parameters.AddWithValue("@color", ur.Color);
                    cmd.Parameters.AddWithValue("@size", ur.Size);
                    cmd.Parameters.AddWithValue("@fontFamily", ur.FontFamily);
                    cmd.Parameters.AddWithValue("@fontStyle", ur.FontStyle);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogManager.LOGERROR, "AddConfig:" + ex.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
            public void BoldSetting()
            {
                var config = new StyleConfig()
                {
                    Bold = null
                };

                ExcelStyleExtensions.SetStyle(mockCell.Object, config);
                mockFont.Verify(f => f.SetBold(It.IsAny <bool>()), Times.Never);

                mockFont.Setup(c => c.SetBold(It.IsAny <bool>())).Returns(mockStyle.Object);

                config = new StyleConfig()
                {
                    Bold = false
                };
                ExcelStyleExtensions.SetStyle(mockCell.Object, config);
                mockFont.Verify(f => f.SetBold(It.Is <bool>(x => x == false)), Times.Once);

                config = new StyleConfig()
                {
                    Bold = true
                };
                ExcelStyleExtensions.SetStyle(mockCell.Object, config);
                mockFont.Verify(f => f.SetBold(It.Is <bool>(x => x == true)), Times.Once);
            }
        public void loadStyle(StyleConfig styleConfig)
        {
            this.InterruptList.BorderStyle = styleConfig.DisplayBorderStyle;

            this.InterruptForm_Resize(null, null);
            this.Refresh();
        }
        public static XWPFParagraph AddParagraph(this XWPFTableCell cell, StyleConfig styles)
        {
            XWPFParagraph para = cell.AddParagraph();

            para.Alignment = (styles.isAlignRight ? ParagraphAlignment.RIGHT : ParagraphAlignment.LEFT);
            return(para);
        }
        public static XWPFParagraph CreateParagraph(this XWPFDocument doc, StyleConfig styles, DocxConfig config)
        {
            XWPFParagraph para = doc.CreateParagraph(styles);

            para.IndentationLeft  = config.marginLeft * UnitValue.TWIP_PER_CM;
            para.IndentationRight = config.marginRight * UnitValue.TWIP_PER_CM;
            return(para);
        }
Exemplo n.º 11
0
        internal void define_style(string name, GUIStyle inherits_from, StyleConfig config)
        {
            GUIStyle style = new GUIStyle(inherits_from);

            style.name = name;
            custom_styles.Add(name, style);
            config(style);
        }
Exemplo n.º 12
0
        public void StyleConfiguration_Test()
        {
            var a = new StyleConfig();

            Assert.AreEqual("div.container", a.ContainerCssClassPrefix);
            Assert.AreEqual("span", a.RunCssClassPrefix);
            Assert.AreEqual(".leftspacer", a.LeftIdentationCssClassSuffix);
        }
Exemplo n.º 13
0
        public void define_style(string name, string inherits_from_name, StyleConfig config)
        {
            GUIStyle style = new GUIStyle(custom_styles[inherits_from_name]);

            style.name = name;
            custom_styles.Add(name, style);
            config(style);
        }
Exemplo n.º 14
0
        public CssStyle GetStyleFromRunProperties(RunProperties r, StyleConfig config = null)
        {
            CssStyle style = new CssStyle(null);
            var      rPr   = r;

            if (rPr != null)
            {
                if (rPr.RunFonts != null)
                {
                    if (config != null)
                    {
                        if (config.Charset == "Ascii")
                        {
                            if (rPr.RunFonts.Ascii != null || rPr.RunFonts.HighAnsi != null)
                            {
                                var fs = (rPr.RunFonts.Ascii != null ? rPr.RunFonts.Ascii.Value : "nofont")
                                         + "," + (rPr.RunFonts.HighAnsi != null ? rPr.RunFonts.HighAnsi.Value : "nofont");
                                style.AddStyle("font-family", fs);
                            }
                        }
                        if (config.Charset == "EastAsia")
                        {
                            if (rPr.RunFonts.EastAsia != null)
                            {
                                var fs = (rPr.RunFonts.EastAsia != null ? rPr.RunFonts.EastAsia.Value : "nofont");
                                style.AddStyle("font-family", fs);
                            }
                        }
                    }
                    else
                    {
                        var fs = (rPr.RunFonts.Ascii != null ? rPr.RunFonts.Ascii.Value : "nofont")
                                 + "," + (rPr.RunFonts.HighAnsi != null ? rPr.RunFonts.HighAnsi.Value : "nofont")
                                 + "," + (rPr.RunFonts.EastAsia != null ? rPr.RunFonts.EastAsia.Value : "nofont");
                        style.AddStyle("font-family", fs);
                    }
                }
                if (rPr.FontSize != null && rPr.FontSize.Val != null)
                {
                    style.AddStyle("font-size", rPr.FontSize.Val + "px");
                }
                if (rPr.Bold != null)
                {
                    if (rPr.Bold.Val != null && rPr.Bold.Val.Value)
                    {
                        style.AddStyle("font-weight", "bold");
                    }
                }
                if (rPr.Color != null)
                {
                    style.AddStyle("color", "#" + rPr.Color.Val);
                }
            }

            return(style);
        }
        public static XWPFRun CreateRun(this XWPFParagraph para, StyleConfig styles)
        {
            XWPFRun run = para.CreateRun();

            run.IsBold      = styles.isBold;
            run.IsItalic    = styles.isItalics;
            run.FontSize    = styles.fontSize;
            run.IsSmallCaps = styles.isSmallCaps;
            return(run);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initialises the window with the provided options.
        /// </summary>
        protected SelectionWindow(SelectionWindowConfiguration configuration)
        {
            TimerHelper.Current.TakeSnapshot("mainwnd-creating");
            styleConfig    = ConfigManager.Config.Interface.Style;
            scrollBoundary = ConfigManager.Config.Interface.Style.ScrollBoundary;

            // Position and size the window according to user configuration.
            Matrix fromDevice;

            using (var source = new HwndSource(new HwndSourceParameters()))
            {
                if (source.CompositionTarget == null)
                {
                    // I doubt this path is ever triggered, but we'll handle it just in case.
                    Log.Send("Could not determine the composition target. Window may not be positioned and sized correctly.", LogLevel.Warning);
                    // We'll just use the identity matrix here.
                    // This works fine as long as the screen's DPI scaling is set to 100%.
                    fromDevice = Matrix.Identity;
                }
                else
                {
                    fromDevice = source.CompositionTarget.TransformFromDevice;
                }
            }

            var position = fromDevice.Transform(configuration.Position);

            Left = position.X;
            Top  = position.Y;

            var dimensions = fromDevice.Transform(configuration.Dimensions);

            Width     = dimensions.X;
            MaxHeight = dimensions.Y;

            InitializeComponent();

            InitialiseLabels(configuration.Orientation);

            SearchBox.BorderBrush     = styleConfig.Search.BorderColour;
            SearchBox.CaretBrush      = styleConfig.CaretColour;
            SearchBox.Background      = styleConfig.Search.BackgroundColour;
            SearchBox.Foreground      = styleConfig.Search.TextColour;
            SearchBox.Margin          = styleConfig.Search.Margin;
            SearchBox.BorderThickness = styleConfig.Search.BorderWidth;
            SearchBox.FontSize        = styleConfig.FontSize;
            SearchBox.FontFamily      = new FontFamily(styleConfig.FontFamily);

            Background      = styleConfig.BackgroundColour;
            BorderBrush     = styleConfig.BorderColour;
            BorderThickness = styleConfig.BorderWidth;

            TimerHelper.Current.TakeSnapshot("mainwnd-created");
        }
Exemplo n.º 17
0
 public void loadStyle(StyleConfig styleConfig)
 {
     createNoPictureImage();
     LinearGlobal.MainForm.loadStyle(styleConfig);
     LinearGlobal.MainForm.ListForm.loadStyle(styleConfig);
     //LinearGlobal.MainForm.ListForm.InterruptForm.loadStyle(styleConfig);
     LinearAudioPlayer.GridController.loadStyle();
     LinearAudioPlayer.FilteringGridController.loadStyle();
     LinearAudioPlayer.GroupGridController.loadStyle();
     LinearAudioPlayer.LinkGridController.loadStyle();
 }
Exemplo n.º 18
0
        private void DefaultsButton_Click(object sender, EventArgs e)
        {
            AppConfig        = AppConfig.LoadFromRegistry(null);
            TextEditorConfig = TextEditorConfig.LoadFromRegistry(null);
            StyleConfig      = StyleConfig.LoadFromRegistry(null);

            PopulateThemeUI(AppConfig);
            PopulateTextEditorConfigUI(TextEditorConfig);
            PopulateColorEditorUI(StyleConfig);
            PopulateFontUI(TextEditorConfig);
        }
Exemplo n.º 19
0
        public CssStyle GetStyle(Style s, StyleConfig config = null)
        {
            CssStyle cs = new CssStyle();

            if (s == null)
            {
                return(cs);
            }
            var id   = s.StyleId;
            var type = s.Type.ToString();

            if (type == "paragraph")
            {
                if (s.StyleParagraphProperties != null)
                {
                    CssStyle cS = this.GetStyleFromParagraphProperties(new ParagraphProperties(s.StyleParagraphProperties.OuterXml), config);
                    cS.Selector = ".Inner_P_" + id;
                    if (s.StyleRunProperties != null)
                    {
                        CssStyle cSs = this.GetStyleFromRunProperties(new RunProperties(s.StyleRunProperties.OuterXml), config);
                        cS.CombineStyles(cSs);
                    }
                    return(cS);
                }
            }
            else if (type == "character")
            {
                if (s.StyleRunProperties != null)
                {
                    CssStyle cS = this.GetStyleFromRunProperties(new RunProperties(s.StyleRunProperties.OuterXml), config);
                    cS.Selector = ".Inner_R_" + id;
                    return(cS);
                }
            }
            else if (type == "table")
            {
                if (s.StyleTableProperties != null)
                {
                    CssStyle cS = this.GetStyleFromTableProperties(new TableProperties(s.StyleTableProperties.OuterXml), config);
                    cS.Selector = ".Inner_T_" + id;
                    return(cS);
                }
            }
            else if (type == "numbering")
            {
            }
            else if (type == "direct")
            {
            }
            return(cs);
        }
Exemplo n.º 20
0
        private void PopulateColorEditorUI(StyleConfig styleConfig)
        {
            StyleKind[] styleKinds = Enum.GetValues(typeof(StyleKind)).Cast <StyleKind>().ToArray();
            Dictionary <StyleKind, Style> styleLookup = styleConfig.ToDictionary(p => p.StyleKind);
            ToolTip tooltip = new ToolTip();

            EditorColorsPanel.SuspendLayout();
            EditorColorsPanel.Controls.Clear();

            int    yOffset      = 8;
            string lastCategory = null;

            foreach (StyleKind styleKind in styleKinds)
            {
                Style?style = styleLookup.TryGetValue(styleKind, out Style trueStyle)
                                        ? (Style?)trueStyle : null;

                // First, figure out what the category and name are for this color option.
                string category, name;
                ColorEditRow.SplitStyleKindIntoCategoryAndName(styleKind, out category, out name);

                // If we switched categories, generate a header row.
                if (category != lastCategory)
                {
                    yOffset += 10;

                    Label headerLabel = new Label();
                    headerLabel.Text     = category;
                    headerLabel.Location = new Point(0, yOffset);
                    headerLabel.Font     = _colorEditorHeaderFont;
                    headerLabel.AutoSize = true;
                    EditorColorsPanel.Controls.Add(headerLabel);
                    yOffset += 30;

                    lastCategory = category;
                }

                ColorEditRow colorEditRow = new ColorEditRow(styleKind, style, GetDefaultStyle);
                colorEditRow.Location      = new Point(0, yOffset);
                colorEditRow.Size          = new Size(EditorColorsPanel.Width, 25);
                colorEditRow.Anchor        = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                colorEditRow.StyleChanged += ColorEditRow_StyleChanged;
                EditorColorsPanel.Controls.Add(colorEditRow);

                yOffset += 25;
            }

            EditorColorsPanel.ResumeLayout();
        }
Exemplo n.º 21
0
        public void Clone_Test()
        {
            var a = new StyleConfig
            {
                ContainerCssClassPrefix      = "a",
                RunCssClassPrefix            = "b",
                LeftIdentationCssClassSuffix = "c",
            };

            var b = a.Clone();

            Assert.AreEqual(a.ContainerCssClassPrefix, b.ContainerCssClassPrefix);
            Assert.AreEqual(a.RunCssClassPrefix, b.RunCssClassPrefix);
            Assert.AreEqual(a.LeftIdentationCssClassSuffix, b.LeftIdentationCssClassSuffix);
        }
Exemplo n.º 22
0
 public ParagraphClassFactory(
     StyleConfig config,
     ClsNameGenerator clsNameGenerator,
     IDefaultsProvider defaultsProvider,
     IStylePropsCache stylePropsCache,
     INumberingPropsCache numPropsCache,
     Func <CssPropertySource, ICssPropertiesFactory> _facBuiler)
 {
     _config           = config;
     _clsNameGenerator = clsNameGenerator;
     _propsFac         = _facBuiler(CssPropertySource.Paragraph);
     _stylePropsCache  = stylePropsCache;
     _numPropsCache    = numPropsCache;
     _defaultsProvider = defaultsProvider;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Initialises the window with the provided options.
        /// </summary>
        protected MainWindow(MainWindowConfiguration configuration)
        {
            this.configuration = configuration;
            StyleConfig        = ConfigManager.Config.Interface.Style;
            InitializeComponent();

            if (configuration.Orientation == Orientation.Vertical)
            {
                WrapPanel.Orientation = Orientation.Vertical;
                // In order to prevent its content from wrapping, the WrapPanel should be added to a ScrollViewer.
                var scrollViewer = new ScrollViewer
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
                    Content = WrapPanel,
                    Margin  = new Thickness
                    {
                        Top    = 25,
                        Right  = WrapPanel.Margin.Right,
                        Bottom = WrapPanel.Margin.Bottom,
                        Left   = WrapPanel.Margin.Left
                    }
                };
                // The WrapPanel must be removed from the grid before its ScrollViewer can be added.
                Grid.Children.Remove(WrapPanel);
                Grid.Children.Add(scrollViewer);

                // Reorient the searchbox so its margins match those of the WrapPanel.
                SearchBox.Margin = new Thickness(5, 5, 5, 5);
            }
            else
            {
                Grid.Children.Remove(SearchBox);
                WrapPanel.Children.Add(SearchBox);
            }

            SearchBox.CaretBrush      = BrushFromColourString(StyleConfig.CaretColour);
            SearchBox.Background      = BrushFromColourString(StyleConfig.Search.BackgroundColour);
            SearchBox.Foreground      = BrushFromColourString(StyleConfig.Search.TextColour);
            SearchBox.BorderThickness = new Thickness(StyleConfig.Search.BorderWidth);
            SearchBox.BorderBrush     = BrushFromColourString(StyleConfig.Search.BorderColour);
            SearchBox.FontSize        = StyleConfig.FontSize;
            SearchBox.FontFamily      = new FontFamily(StyleConfig.FontFamily);

            Background = BrushFromColourString(StyleConfig.BackgroundColour);

            BorderBrush     = BrushFromColourString(StyleConfig.BorderColour);
            BorderThickness = new Thickness(1);
        }
Exemplo n.º 24
0
 private void DarkThemeButton_Click(object sender, EventArgs e)
 {
     if (BetterMessageBox.Owner(this)
         .Message("You are about to replace all of your current text\r\n"
                  + "styles with the default \"dark\" color scheme.\r\n"
                  + "Are you sure you want to do this?\r\n")
         .Button("OK", DialogResult.OK, true)
         .Button("Cancel", DialogResult.Cancel)
         .Caption("Warning")
         .StandardImage(StandardImageKind.Warning)
         .Show() == DialogResult.OK)
     {
         StyleConfig = new StyleConfig(DefaultStyles.DarkTheme);
         PopulateColorEditorUI(StyleConfig);
     }
 }
Exemplo n.º 25
0
        public OptionsDialog(Configurator configurator, Dispatcher dispatcher)
        {
            InitializeComponent();

            Configurator = configurator;
            Dispatcher   = dispatcher;

            AppConfig        = configurator.AppConfig;
            TextEditorConfig = configurator.TextEditorConfig;
            StyleConfig      = configurator.StyleConfig;

            PopulateThemeUI(AppConfig);
            PopulateTextEditorConfigUI(TextEditorConfig);
            PopulateColorEditorUI(StyleConfig);
            PopulateFontUI(TextEditorConfig);
        }
Exemplo n.º 26
0
 public RunClassFactory(
     StyleConfig config,
     ClsNameGenerator clsNameGenerator,
     IDefaultsProvider defaults,
     IStylePropsCache pStylePropsCache,
     INumberingPropsCache numPropsCache,
     IStylePropsCache rStylePropsCache,
     Func <CssPropertySource, ICssPropertiesFactory> factoryBuilder)
 {
     _config           = config;
     _clsNameGenerator = clsNameGenerator;
     _defaults         = defaults;
     _pStylePropsCache = pStylePropsCache;
     _numPropsCache    = numPropsCache;
     _rStylePropsCache = rStylePropsCache;
     _propsFac         = factoryBuilder(CssPropertySource.Run);
 }
            public void BackgroundColorSetting()
            {
                var config = new StyleConfig()
                {
                    BackgroundColor = null
                };

                ExcelStyleExtensions.SetStyle(mockCell.Object, config);
                mockFill.Verify(f => f.SetBackgroundColor(It.IsAny <XLColor>()), Times.Never);

                mockFill.Setup(f => f.SetBackgroundColor(It.IsAny <XLColor>())).Returns(mockStyle.Object);
                config = new StyleConfig()
                {
                    BackgroundColor = XLColor.DarkBlue
                };
                ExcelStyleExtensions.SetStyle(mockCell.Object, config);
                mockFill.Verify(f => f.SetBackgroundColor(It.Is <XLColor>(x => x == XLColor.DarkBlue)), Times.Once);
            }
            public void HorizontalAlignmentSetting()
            {
                var config = new StyleConfig()
                {
                    HorizontalAlignment = null
                };

                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockAlignment.Verify(a => a.SetHorizontal(It.IsAny <XLAlignmentHorizontalValues>()), Times.Never);

                mockAlignment.Setup(c => c.SetHorizontal(It.IsAny <XLAlignmentHorizontalValues>())).Returns(mockStyle.Object);
                config = new StyleConfig()
                {
                    HorizontalAlignment = XLAlignmentHorizontalValues.Center
                };
                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockAlignment.Verify(a => a.SetHorizontal(It.Is <XLAlignmentHorizontalValues>(x => x == XLAlignmentHorizontalValues.Center)), Times.Once);
            }
            public void FontColorSetting()
            {
                var config = new StyleConfig()
                {
                    FontColor = null
                };

                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockFont.Verify(f => f.SetFontColor(It.IsAny <XLColor>()), Times.Never);

                mockFont.Setup(c => c.SetFontColor(It.IsAny <XLColor>())).Returns(mockStyle.Object);
                config = new StyleConfig()
                {
                    FontColor = XLColor.DarkBlue
                };
                ExcelStyleExtensions.SetStyle(mockRange.Object, config);
                mockFont.Verify(f => f.SetFontColor(It.Is <XLColor>(x => x == XLColor.DarkBlue)), Times.Once);
            }
Exemplo n.º 30
0
        private void ColorEditRow_StyleChanged(object sender, StyleChangedEventArgs e)
        {
            if (e.Style.HasValue)
            {
                StyleConfig = StyleConfig.WithStyles(e.Style.Value);
            }
            else
            {
                StyleConfig = StyleConfig.WithoutStyleKinds(e.StyleKind);
            }

            if (e.StyleKind == StyleKind.Default)
            {
                foreach (Control control in EditorColorsPanel.Controls)
                {
                    control.Invalidate();
                }
            }
        }
Exemplo n.º 31
0
        internal void Configure(List<Configuration> configList)
        {
            //	So here is the general pattern: We go through each of
            //	the configurations in the list (which has been ordered
            //	by priority). If the configuration has a value we're
            //	looking for it overwrites whatever was before it.
            //	In the end if the value isn't null, we set the
            //	corresponding Scintilla Value to this.
            bool? b = null;
            int? i = null;
            Color co = Color.Empty;
            char? ch = null;
            string s = null;

            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_AutoHide.HasValue)
                    b = c.AutoComplete_AutoHide;
            }
            if (b.HasValue)
                Scintilla.AutoComplete.AutoHide = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_AutomaticLengthEntered.HasValue)
                    b = c.AutoComplete_AutomaticLengthEntered;
            }
            if (b.HasValue)
                Scintilla.AutoComplete.AutomaticLengthEntered = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_CancelAtStart.HasValue)
                    b = c.AutoComplete_CancelAtStart;
            }
            if (b.HasValue)
                Scintilla.AutoComplete.CancelAtStart = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_DropRestOfWord.HasValue)
                    b = c.AutoComplete_DropRestOfWord;
            }
            if (b.HasValue)
                Scintilla.AutoComplete.DropRestOfWord = b.Value;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_FillUpCharacters != null)
                    s = c.AutoComplete_FillUpCharacters;
            }
            if (s != null)
                Scintilla.AutoComplete.FillUpCharacters = s;

            ch = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_ImageSeperator != null)
                    ch = c.AutoComplete_ImageSeperator;
            }
            if (ch != null)
                Scintilla.AutoComplete.ImageSeparator = ch.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_IsCaseSensitive.HasValue)
                    b = c.AutoComplete_IsCaseSensitive;

            }
            if (b.HasValue)
                Scintilla.AutoComplete.IsCaseSensitive = b.Value;

            ch = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_ListSeperator.HasValue)
                    ch = c.AutoComplete_ListSeperator;

            }
            if (ch.HasValue)
                Scintilla.AutoComplete.ListSeparator = ch.Value;

            string seperator = Scintilla.AutoComplete.ListSeparator.ToString();
            s = null;
            foreach (Configuration c in configList)
            {
                //	Lists tend to have an extra config property of "inherits".
                //	It this flag set to false, the list is cleared before setting
                //	the current config's list. Otherwise the current config adds
                //	to the previous configs'.
                if (c.AutoComplete_List != null)
                {
                    if (!(c.AutoComplete_ListInherits.HasValue && !c.AutoComplete_ListInherits.Value) || string.IsNullOrEmpty(s))
                        s = c.AutoComplete_List;
                    else
                        s += seperator + c.AutoComplete_List;
                }
            }
            if (s != null)
                Scintilla.AutoComplete.ListString = s;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_MaxHeight.HasValue)
                    i = c.AutoComplete_MaxHeight;

            }
            if (i.HasValue)
                Scintilla.AutoComplete.MaxHeight = i.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_MaxWidth.HasValue)
                    i = c.AutoComplete_MaxWidth;
            }
            if (i.HasValue)
                Scintilla.AutoComplete.MaxWidth = i.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_SingleLineAccept.HasValue)
                    b = c.AutoComplete_SingleLineAccept;

            }
            if (b.HasValue)
                Scintilla.AutoComplete.SingleLineAccept = b.Value;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.AutoComplete_StopCharacters != null)
                    s = c.AutoComplete_StopCharacters;
            }
            if (s != null)
                Scintilla.AutoComplete.StopCharacters = s;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.CallTip_BackColor != Color.Empty)
                    co = c.CallTip_BackColor;

            }
            if (co != Color.Empty)
                Scintilla.CallTip.BackColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.CallTip_ForeColor != Color.Empty)
                    co = c.CallTip_ForeColor;

            }
            if (co != Color.Empty)
                Scintilla.CallTip.ForeColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.CallTip_HighlightTextColor != Color.Empty)
                    co = c.CallTip_HighlightTextColor;

            }
            if (co != Color.Empty)
                Scintilla.CallTip.HighlightTextColor = co;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_BlinkRate.HasValue)
                    i = c.Caret_BlinkRate;
            }
            if (i.HasValue)
                Scintilla.Caret.BlinkRate = i.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Caret_Color != Color.Empty)
                    co = c.Caret_Color;

            }
            if (co != Color.Empty)
                Scintilla.Caret.Color = co;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_CurrentLineBackgroundAlpha.HasValue)
                    i = c.Caret_CurrentLineBackgroundAlpha;
            }
            if (i.HasValue)
                Scintilla.Caret.CurrentLineBackgroundAlpha = i.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Caret_CurrentLineBackgroundColor != Color.Empty)
                    co = c.Caret_CurrentLineBackgroundColor;

            }
            if (co != Color.Empty)
                Scintilla.Caret.CurrentLineBackgroundColor = co;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_HighlightCurrentLine.HasValue)
                    b = c.Caret_HighlightCurrentLine;

            }
            if (b.HasValue)
                Scintilla.Caret.HighlightCurrentLine = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_IsSticky.HasValue)
                    b = c.Caret_IsSticky;

            }
            if (b.HasValue)
                Scintilla.Caret.IsSticky = b.Value;

            CaretStyle? caretStyle = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_Style.HasValue)
                    caretStyle = c.Caret_Style;
            }
            if (caretStyle.HasValue)
                Scintilla.Caret.Style = caretStyle.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Caret_Width.HasValue)
                    i = c.Caret_Width;
            }
            if (i.HasValue)
                Scintilla.Caret.Width = i.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Clipboard_ConvertEndOfLineOnPaste.HasValue)
                    b = c.Clipboard_ConvertEndOfLineOnPaste;
            }
            if (b.HasValue)
                Scintilla.Clipboard.ConvertEndOfLineOnPaste = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Commands_KeyBindingList.AllowDuplicateBindings.HasValue)
                    b = c.Commands_KeyBindingList.AllowDuplicateBindings;
            }
            if (b.HasValue)
                Scintilla.Commands.AllowDuplicateBindings = b.Value;

            if (_clearKeyBindings)
                Scintilla.Commands.RemoveAllBindings();

            CommandBindingConfigList cbcl = new CommandBindingConfigList();
            foreach (Configuration c in configList)
            {
                if (c.Commands_KeyBindingList.Inherit.HasValue && !c.Commands_KeyBindingList.Inherit.Value)
                    cbcl.Clear();

                foreach (CommandBindingConfig cbc in c.Commands_KeyBindingList)
                    cbcl.Add(cbc);
            }

            foreach (CommandBindingConfig cbc in cbcl)
            {
                //	This indicates that we should clear out any
                //	existing commands bound to this key combination
                if (cbc.ReplaceCurrent.HasValue && cbc.ReplaceCurrent.Value)
                    Scintilla.Commands.RemoveBinding(cbc.KeyBinding.KeyCode, cbc.KeyBinding.Modifiers);

                Scintilla.Commands.AddBinding(cbc.KeyBinding.KeyCode, cbc.KeyBinding.Modifiers, cbc.BindableCommand);
            }

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.DropMarkers_SharedStackName != null)
                    s = c.DropMarkers_SharedStackName;
            }
            if (s != null)
                Scintilla.DropMarkers.SharedStackName = s;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.EndOfLine_ConvertOnPaste.HasValue)
                    b = c.EndOfLine_ConvertOnPaste;
            }
            if (b.HasValue)
                Scintilla.EndOfLine.ConvertOnPaste = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.EndOfLine_IsVisisble.HasValue)
                    b = c.EndOfLine_IsVisisble;
            }
            if (b.HasValue)
                Scintilla.EndOfLine.IsVisible = b.Value;

            EndOfLineMode? endOfLineMode = null;
            foreach (Configuration c in configList)
            {
                if (c.EndOfLine_Mode.HasValue)
                    endOfLineMode = c.EndOfLine_Mode;
            }
            if (endOfLineMode.HasValue)
                Scintilla.EndOfLine.Mode = endOfLineMode.Value;

            FoldFlag? ff = null;
            foreach (Configuration c in configList)
            {
                if (c.Folding_Flags.HasValue)
                    ff = c.Folding_Flags;
            }
            if (ff.HasValue)
                Scintilla.Folding.Flags = ff.Value;

            //	FoldMarkerScheme moved to Markers section
            //	becuase Markers need to come first as the
            //	FoldMarkerScheme really just manipulates
            //	Markers.

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Folding_IsEnabled.HasValue)
                    b = c.Folding_IsEnabled;
            }
            if (b.HasValue)
                Scintilla.Folding.IsEnabled = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Folding_UseCompactFolding.HasValue)
                    b = c.Folding_UseCompactFolding;
            }
            if (b.HasValue)
                Scintilla.Folding.UseCompactFolding = b.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_ActiveBackColor != Color.Empty)
                    co = c.Hotspot_ActiveBackColor;

            }
            if (co != Color.Empty)
                Scintilla.HotspotStyle.ActiveBackColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_ActiveForeColor != Color.Empty)
                    co = c.Hotspot_ActiveForeColor;

            }
            if (co != Color.Empty)
                Scintilla.HotspotStyle.ActiveForeColor = co;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_ActiveUnderline.HasValue)
                    b = c.Hotspot_ActiveUnderline;
            }
            if (b.HasValue)
                Scintilla.HotspotStyle.ActiveUnderline = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_SingleLine.HasValue)
                    b = c.Hotspot_SingleLine;
            }
            if (b.HasValue)
                Scintilla.HotspotStyle.SingleLine = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_UseActiveBackColor.HasValue)
                    b = c.Hotspot_UseActiveBackColor;
            }
            if (b.HasValue)
                Scintilla.HotspotStyle.UseActiveBackColor = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Hotspot_UseActiveForeColor.HasValue)
                    b = c.Hotspot_UseActiveForeColor;
            }
            if (b.HasValue)
                Scintilla.HotspotStyle.UseActiveForeColor = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_BackspaceUnindents.HasValue)
                    b = c.Indentation_BackspaceUnindents;
            }
            if (b.HasValue)
                Scintilla.Indentation.BackspaceUnindents = b.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_IndentWidth.HasValue)
                    i = c.Indentation_IndentWidth;
            }
            if (i.HasValue)
                Scintilla.Indentation.IndentWidth = i.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_ShowGuides.HasValue)
                    b = c.Indentation_ShowGuides;
            }
            if (b.HasValue)
                Scintilla.Indentation.ShowGuides = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_TabIndents.HasValue)
                    b = c.Indentation_TabIndents;
            }
            if (b.HasValue)
                Scintilla.Indentation.TabIndents = b.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_TabWidth.HasValue)
                    i = c.Indentation_TabWidth;
            }
            if (i.HasValue)
                Scintilla.Indentation.TabWidth = i.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_UseTabs.HasValue)
                    b = c.Indentation_UseTabs;
            }
            if (b.HasValue)
                Scintilla.Indentation.UseTabs = b.Value;

            SmartIndent? si = null;
            foreach (Configuration c in configList)
            {
                if (c.Indentation_SmartIndentType.HasValue)
                    si = c.Indentation_SmartIndentType;
            }
            if (si.HasValue)
                Scintilla.Indentation.SmartIndentType = si.Value;

            if (_clearIndicators)
                Scintilla.Indicators.Reset();

            IndicatorConfigList resolvedIndicators = new IndicatorConfigList();
            foreach (Configuration c in configList)
            {
                if (c.Indicator_List.Inherit.HasValue && !c.Indicator_List.Inherit.Value)
                    resolvedIndicators.Clear();

                foreach (IndicatorConfig ic in c.Indicator_List)
                {
                    if (!resolvedIndicators.Contains(ic.Number) || !(ic.Inherit.HasValue && ic.Inherit.Value))
                    {
                        resolvedIndicators.Remove(ic.Number);
                        resolvedIndicators.Add(ic);
                    }
                    else
                    {
                        IndicatorConfig rc = resolvedIndicators[ic.Number];
                        if (ic.Color != Color.Empty)
                            rc.Color = ic.Color;

                        if (ic.Style.HasValue)
                            rc.Style = ic.Style;

                        if (ic.IsDrawnUnder.HasValue)
                            rc.IsDrawnUnder = ic.IsDrawnUnder;
                    }
                }
            }

            foreach (IndicatorConfig ic in resolvedIndicators)
            {
                Indicator ind = Scintilla.Indicators[ic.Number];
                if (ic.Color != Color.Empty)
                    ind.Color = ic.Color;

                if (ic.IsDrawnUnder.HasValue)
                    ind.IsDrawnUnder = ic.IsDrawnUnder.Value;

                if (ic.Style.HasValue)
                    ind.Style = ic.Style.Value;
            }

            foreach(Configuration c in configList)
            {
                foreach (KeyWordConfig kwc in c.Lexing_Keywords)
                {
                    if (kwc.Inherit.HasValue && kwc.Inherit.Value)
                        Scintilla.Lexing.Keywords[kwc.List] += kwc.Value;
                    else
                        Scintilla.Lexing.Keywords[kwc.List] = kwc.Value;
                }
            }

            //	Hrm... unfortunately there's no way to clear
            //	Scintilla's Lexing Properties. Guess we'll just
            //	have to live with adding to the existing list
            //	and/or just overriding with new values. This
            //	means that the "Inherit" attribute is really
            //	meaningless. Nevertheless I'm leaving it in
            //	just in case it ever becomes useful.
            foreach (Configuration c in configList)
            {
                foreach (KeyValuePair<string,string> item in c.Lexing_Properties)
                {
                    Scintilla.Lexing.SetProperty(item.Key, item.Value);
                }
            }

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_WhitespaceChars != null)
                    s = c.Lexing_WhitespaceChars;
            }
            if (s != null)
                Scintilla.Lexing.WhitespaceChars = s;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_WordChars != null)
                    s = c.Lexing_WordChars;
            }
            if (s != null)
                Scintilla.Lexing.WordChars = s;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_LineCommentPrefix != null)
                    s = c.Lexing_LineCommentPrefix;
            }
            if (s != null)
                Scintilla.Lexing.LineCommentPrefix = s;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_StreamCommentPrefix != null)
                    s = c.Lexing_StreamCommentPrefix;
            }
            if (s != null)
                Scintilla.Lexing.StreamCommentPrefix = s;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_StreamCommentSuffix != null)
                    s = c.Lexing_StreamCommentSuffix;
            }
            if (s != null)
                Scintilla.Lexing.StreamCommentSufix = s;

            s = null;
            foreach (Configuration c in configList)
            {
                if (c.Lexing_Language != null)
                    s = c.Lexing_Language;
            }

            if (s == null)
            {
                //	None of the configs specified a lexer. First let's see if
                //	we have a Language-Lexer map defined:
                if (Scintilla.Lexing.LexerLanguageMap.ContainsKey(_language))
                {
                    s = Scintilla.Lexing.LexerLanguageMap[_language];
                }
                else
                {
                    try
                    {
                        Enum.Parse(typeof(Lexer), _language, true);

                        //	If we made it here, the language matches one of
                        //	the lexer names, just use that.
                        s = _language;
                    }
                    catch (ArgumentException)
                    {
                        //	No match, oh well. Don't set the lexer.
                    }
                }
            }
            Scintilla.Lexing.LexerName = s;

            LineCache? lc = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_LayoutCache.HasValue)
                    lc = c.LineWrap_LayoutCache;
            }
            if (lc.HasValue)
                Scintilla.LineWrap.LayoutCache = lc.Value;

            WrapMode? wm = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_Mode.HasValue)
                    wm = c.LineWrap_Mode;
            }
            if (wm.HasValue)
                Scintilla.LineWrap.Mode = wm.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_PositionCacheSize.HasValue)
                    i = c.LineWrap_PositionCacheSize;
            }
            if (i.HasValue)
                Scintilla.LineWrap.PositionCacheSize = i.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_StartIndent.HasValue)
                    i = c.LineWrap_StartIndent;
            }
            if (i.HasValue)
                Scintilla.LineWrap.StartIndent = i.Value;

            WrapVisualFlag? wvf = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_VisualFlags.HasValue)
                    wvf = c.LineWrap_VisualFlags;
            }
            if (wvf.HasValue)
                Scintilla.LineWrap.VisualFlags = wvf.Value;

            WrapVisualLocation? wvl = null;
            foreach (Configuration c in configList)
            {
                if (c.LineWrap_VisualFlagsLocation.HasValue)
                    wvl = c.LineWrap_VisualFlagsLocation;
            }
            if (wvl.HasValue)
                Scintilla.LineWrap.VisualFlagsLocation = wvl.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.LongLines_EdgeColor != Color.Empty)
                    co = c.LongLines_EdgeColor;

            }
            if (co != Color.Empty)
                Scintilla.LongLines.EdgeColor = co;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.LongLines_EdgeColumn.HasValue)
                    i = c.LongLines_EdgeColumn;
            }
            if (i.HasValue)
                Scintilla.LongLines.EdgeColumn = i.Value;

            EdgeMode? em = null;
            foreach (Configuration c in configList)
            {
                if (c.LongLines_EdgeMode.HasValue)
                    em = c.LongLines_EdgeMode;

            }
            if (em.HasValue)
                Scintilla.LongLines.EdgeMode = em.Value;

            if (_clearMargins)
                Scintilla.Margins.Reset();

            Dictionary<int, MarginConfig> margins = new Dictionary<int, MarginConfig>();
            foreach (Configuration c in configList)
            {
                if (c.Margin_List.Inherit.HasValue && !c.Margin_List.Inherit.Value)
                    margins.Clear();

                foreach (MarginConfig mc in c.Margin_List)
                {

                    if (!margins.ContainsKey(mc.Number) || (mc.Inherit.HasValue && !mc.Inherit.Value))
                    {
                        margins.Remove(mc.Number);
                        margins.Add(mc.Number, mc);
                    }
                    else
                    {
                        MarginConfig m = margins[mc.Number];

                        if (mc.AutoToggleMarkerNumber.HasValue)
                            m.AutoToggleMarkerNumber = mc.AutoToggleMarkerNumber.Value;

                        if (mc.IsClickable.HasValue)
                            m.IsClickable = mc.IsClickable.Value;

                        if (mc.IsFoldMargin.HasValue)
                            m.IsFoldMargin = mc.IsFoldMargin.Value;

                        if (mc.IsMarkerMargin.HasValue)
                            m.IsMarkerMargin = mc.IsMarkerMargin.Value;

                        if (mc.Type.HasValue)
                            m.Type = mc.Type.Value;

                        if (mc.Width.HasValue)
                            m.Width = mc.Width.Value;
                    }
                }
            }

            foreach (MarginConfig mc in margins.Values)
            {
                Margin m = Scintilla.Margins[mc.Number];

                if (mc.AutoToggleMarkerNumber.HasValue)
                    m.AutoToggleMarkerNumber = mc.AutoToggleMarkerNumber.Value;

                if (mc.IsClickable.HasValue)
                    m.IsClickable = mc.IsClickable.Value;

                if (mc.IsFoldMargin.HasValue)
                    m.IsFoldMargin = mc.IsFoldMargin.Value;

                if (mc.IsMarkerMargin.HasValue)
                    m.IsMarkerMargin = mc.IsMarkerMargin.Value;

                if (mc.Type.HasValue)
                    m.Type = mc.Type.Value;

                if (mc.Width.HasValue)
                    m.Width = mc.Width.Value;
            }

            if (_clearMarkers)
                Scintilla.Markers.Reset();

            MarkersConfigList resolvedMarkers = new MarkersConfigList();
            foreach (Configuration c in configList)
            {
                if (c.Markers_List.Inherit.HasValue && !c.Markers_List.Inherit.Value)
                    resolvedMarkers.Clear();

                foreach (MarkersConfig mc in c.Markers_List)
                {
                    if (!resolvedMarkers.Contains(mc.Number.Value) || (mc.Inherit.HasValue && !mc.Inherit.Value))
                    {
                        resolvedMarkers.Remove(mc.Number.Value);
                        resolvedMarkers.Add(mc);
                    }
                    else
                    {
                        if (!mc.Number.HasValue)
                            mc.Number = (int)(MarkerOutline)Enum.Parse(typeof(MarkerOutline), mc.Name, true);

                        MarkersConfig m = resolvedMarkers[mc.Number.Value];
                        if (mc.Alpha.HasValue)
                            m.Alpha = mc.Alpha;

                        if (mc.BackColor != Color.Empty)
                            m.BackColor = mc.BackColor;

                        if (mc.ForeColor != Color.Empty)
                            m.ForeColor = mc.ForeColor;

                        if (mc.Symbol.HasValue)
                            m.Symbol = mc.Symbol;
                    }
                }
            }

            foreach (MarkersConfig mc in resolvedMarkers)
            {
                Marker m = Scintilla.Markers[mc.Number.Value];

                if (mc.Alpha.HasValue)
                    m.Alpha = mc.Alpha.Value;

                if (mc.BackColor != Color.Empty)
                    m.BackColor = mc.BackColor;

                if (mc.ForeColor != Color.Empty)
                    m.ForeColor = mc.ForeColor;

                if (mc.Symbol.HasValue)
                    m.Symbol = mc.Symbol.Value;
            }

            FoldMarkerScheme? fms = null;
            foreach (Configuration c in configList)
            {
                if (c.Folding_MarkerScheme.HasValue)
                    fms = c.Folding_MarkerScheme;
            }
            if (fms.HasValue)
                Scintilla.Folding.MarkerScheme = fms.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Scrolling_EndAtLastLine.HasValue)
                    b = c.Scrolling_EndAtLastLine;
            }
            if (b.HasValue)
                Scintilla.Scrolling.EndAtLastLine = b.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Scrolling_HorizontalWidth.HasValue)
                    i = c.Scrolling_HorizontalWidth;
            }
            if (i.HasValue)
                Scintilla.Scrolling.HorizontalWidth = i.Value;

            ScrollBars? sb = null;
            foreach (Configuration c in configList)
            {
                if (c.Scrolling_ScrollBars.HasValue)
                    sb = c.Scrolling_ScrollBars;
            }
            if (sb.HasValue)
                Scintilla.Scrolling.ScrollBars = sb.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Scrolling_XOffset.HasValue)
                    i = c.Scrolling_XOffset;
            }
            if (i.HasValue)
                Scintilla.Scrolling.XOffset = i.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Selection_BackColor != Color.Empty)
                    co = c.Selection_BackColor;

            }
            if (co != Color.Empty)
                Scintilla.Selection.BackColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Selection_BackColorUnfocused != Color.Empty)
                    co = c.Selection_BackColorUnfocused;

            }
            if (co != Color.Empty)
                Scintilla.Selection.BackColorUnfocused = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Selection_ForeColor != Color.Empty)
                    co = c.Selection_ForeColor;

            }
            if (co != Color.Empty)
                Scintilla.Selection.ForeColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Selection_ForeColorUnfocused != Color.Empty)
                    co = c.Selection_ForeColorUnfocused;

            }
            if (co != Color.Empty)
                Scintilla.Selection.ForeColorUnfocused = co;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Selection_Hidden.HasValue)
                    b = c.Selection_Hidden;
            }
            if (b.HasValue)
                Scintilla.Selection.Hidden = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.Selection_HideSelection.HasValue)
                    b = c.Selection_HideSelection;
            }
            if (b.HasValue)
                Scintilla.Selection.HideSelection = b.Value;

            SelectionMode? selectionMode = null;
            foreach (Configuration c in configList)
            {
                if (c.Selection_Mode.HasValue)
                    selectionMode = c.Selection_Mode;
            }
            if (selectionMode.HasValue)
                Scintilla.Selection.Mode = selectionMode.Value;

            if (_clearSnippets)
                Scintilla.Snippets.List.Clear();

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.IsEnabled.HasValue)
                    b = c.SnippetsConfigList.IsEnabled;
            }
            if (b.HasValue)
                Scintilla.Snippets.IsEnabled = b.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.IsOneKeySelectionEmbedEnabled.HasValue)
                    b = c.SnippetsConfigList.IsOneKeySelectionEmbedEnabled;
            }
            if (b.HasValue)
                Scintilla.Snippets.IsOneKeySelectionEmbedEnabled = b.Value;

            char? defaultDelimeter = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.DefaultDelimeter.HasValue)
                    defaultDelimeter = c.SnippetsConfigList.DefaultDelimeter;

            }
            if (!ch.HasValue)
                Scintilla.Snippets.DefaultDelimeter = '$';

            SnippetList snips = new SnippetList(null);
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.Inherit.HasValue && !c.SnippetsConfigList.Inherit.Value)
                    snips.Clear();

                foreach (SnippetsConfig sc in c.SnippetsConfigList)
                {
                    if (snips.Contains(sc.Shortcut))
                        snips.Remove(sc.Shortcut);

                    Snippet snip;
                    if (sc.Delimeter.HasValue)
                        snip = snips.Add(sc.Shortcut, sc.Code, sc.Delimeter.Value);
                    else
                        snip = snips.Add(sc.Shortcut, sc.Code, Scintilla.Snippets.DefaultDelimeter);

                    if (sc.IsSurroundsWith.HasValue)
                        snip.IsSurroundsWith = sc.IsSurroundsWith.Value;
                }
            }

            SnippetList sl = Scintilla.Snippets.List;
            foreach (Snippet sc in snips)
            {
                if (sl.Contains(sc.Shortcut))
                    sl.Remove(sc.Shortcut);

                sl.Add(sc.Shortcut, sc.Code, Scintilla.Snippets.DefaultDelimeter, sc.IsSurroundsWith);
            }

            sl.Sort();

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.ActiveSnippetColor != Color.Empty)
                    co = c.SnippetsConfigList.ActiveSnippetColor;
            }
            if (co != Color.Empty)
                Scintilla.Snippets.ActiveSnippetColor = co;

            IndicatorStyle? indicatorStyle = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.ActiveSnippetIndicatorStyle.HasValue)
                    indicatorStyle = c.SnippetsConfigList.ActiveSnippetIndicatorStyle;
            }
            if (indicatorStyle.HasValue)
                Scintilla.Snippets.ActiveSnippetIndicatorStyle = indicatorStyle.Value;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.ActiveSnippetIndicator.HasValue)
                    i = c.SnippetsConfigList.ActiveSnippetIndicator;
            }
            if (i.HasValue)
                Scintilla.Snippets.ActiveSnippetIndicator = i.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.InactiveSnippetColor != Color.Empty)
                    co = c.SnippetsConfigList.InactiveSnippetColor;

            }
            if (co != Color.Empty)
                Scintilla.Snippets.InactiveSnippetColor = co;

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.InactiveSnippetIndicator.HasValue)
                    i = c.SnippetsConfigList.InactiveSnippetIndicator;
            }
            if (i.HasValue)
                Scintilla.Snippets.InactiveSnippetIndicator = i.Value;

            IndicatorStyle? ics = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.ActiveSnippetIndicatorStyle.HasValue)
                    ics = c.SnippetsConfigList.ActiveSnippetIndicatorStyle;
            }
            if (ics.HasValue)
                Scintilla.Snippets.ActiveSnippetIndicatorStyle = ics.Value;

            indicatorStyle = null;
            foreach (Configuration c in configList)
            {
                if (c.SnippetsConfigList.InactiveSnippetIndicatorStyle.HasValue)
                    indicatorStyle = c.SnippetsConfigList.InactiveSnippetIndicatorStyle;
            }
            if (indicatorStyle.HasValue)
                Scintilla.Snippets.InactiveSnippetIndicatorStyle = indicatorStyle.Value;

            b = null;
            foreach (Configuration c in configList)
            {
                if (c.UndoRedoIsUndoEnabled.HasValue)
                    b = c.UndoRedoIsUndoEnabled;
            }
            if (b.HasValue)
                Scintilla.UndoRedo.IsUndoEnabled = b.Value;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Whitespace_BackColor != Color.Empty)
                    co = c.Whitespace_BackColor;

            }
            if (co != Color.Empty)
                Scintilla.Whitespace.BackColor = co;

            co = Color.Empty;
            foreach (Configuration c in configList)
            {
                if (c.Whitespace_ForeColor != Color.Empty)
                    co = c.Whitespace_ForeColor;
            }
            if (co != Color.Empty)
                Scintilla.Whitespace.ForeColor = co;

            WhitespaceMode? wsm = null;
            foreach (Configuration c in configList)
            {
                if (c.Whitespace_Mode.HasValue)
                    wsm = c.Whitespace_Mode;
            }
            if (wsm.HasValue)
                Scintilla.Whitespace.Mode = wsm.Value;

            //	OK so we saved the best for last instead of going in
            //	strict lexical order. Styles! This is really the section
            //	that people care about most in the config, and is also
            //	the most complex.
            if (_clearStyles)
                Scintilla.Styles.Reset();

            i = null;
            foreach (Configuration c in configList)
            {
                if (c.Styles.Bits.HasValue)
                    i = c.Styles.Bits;
            }

            #pragma warning disable 618
            if (i.HasValue)
                Scintilla.Styles.Bits = i.Value;
            #pragma warning restore 618

            Dictionary<string, int> styleNameMap =  Scintilla.Lexing.StyleNameMap;
            ResolvedStyleList resolvedStyles = new ResolvedStyleList();

            int _unmappedStyleNumber = -1;
            Dictionary<string, int> _unmappedStyleMap = new Dictionary<string,int>();
            foreach (Configuration c in configList)
            {
                if (c.Styles.Inherit.HasValue && !c.Styles.Inherit.Value)
                    resolvedStyles.Clear();

                foreach (StyleConfig sc in c.Styles)
                {
                    i = sc.Number;

                    if (!i.HasValue)
                    {
                        if (!styleNameMap.ContainsKey(sc.Name))
                        {
                            if (_unmappedStyleMap.ContainsKey(sc.Name))
                            {
                                i = _unmappedStyleMap[sc.Name];
                                sc.Number = i;
                            }
                            else
                            {
                                i = _unmappedStyleNumber--;
                                sc.Number = i;

                                _unmappedStyleMap[sc.Name] = sc.Number.Value;
                            }
                        }
                        else
                        {
                            i = styleNameMap[sc.Name];
                            sc.Number = i;
                        }
                    }

                    StyleConfig baseStyleConfig = null;
                    if (!string.IsNullOrEmpty(sc.Name) && sc.Name.Contains("."))
                    {
                        baseStyleConfig = resolvedStyles.FindByName(sc.Name.Substring(sc.Name.IndexOf(".") + 1));
                    }

                    if (!resolvedStyles.ContainsKey(i.Value) || (sc.Inherit.HasValue && !sc.Inherit.Value))
                    {
                        resolvedStyles.Remove(i.Value);
                        resolvedStyles.Add(i.Value, sc);
                    }

                    StyleConfig rs = resolvedStyles[i.Value];

                    if (sc.BackColor != Color.Empty)
                        rs.BackColor = sc.BackColor;
                    else if (baseStyleConfig != null && baseStyleConfig.BackColor != Color.Empty)
                        rs.BackColor = baseStyleConfig.BackColor;

                    if (sc.Bold.HasValue)
                        rs.Bold = sc.Bold.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.Bold.HasValue)
                        rs.Bold = baseStyleConfig.Bold.Value;

                    if (sc.Case.HasValue)
                        rs.Case = sc.Case.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.Case.HasValue)
                        rs.Case = baseStyleConfig.Case.Value;

                    if (sc.CharacterSet.HasValue)
                        rs.CharacterSet = sc.CharacterSet.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.CharacterSet.HasValue)
                        rs.CharacterSet = baseStyleConfig.CharacterSet.Value;

                    if (sc.FontName != null)
                        rs.FontName = sc.FontName;
                    else if (baseStyleConfig != null && baseStyleConfig.FontName != null)
                        rs.FontName = baseStyleConfig.FontName;

                    if (sc.ForeColor != Color.Empty)
                        rs.ForeColor = sc.ForeColor;
                    else if (baseStyleConfig != null && baseStyleConfig.ForeColor != Color.Empty)
                        rs.ForeColor = baseStyleConfig.ForeColor;

                    if (sc.IsChangeable.HasValue)
                        rs.IsChangeable = sc.IsChangeable.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.IsChangeable.HasValue)
                        rs.IsChangeable = baseStyleConfig.IsChangeable.Value;

                    if (sc.IsHotspot.HasValue)
                        rs.IsHotspot = sc.IsHotspot.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.IsHotspot.HasValue)
                        rs.IsHotspot = baseStyleConfig.IsHotspot.Value;

                    if (sc.IsSelectionEolFilled.HasValue)
                        rs.IsSelectionEolFilled = sc.IsSelectionEolFilled.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.IsSelectionEolFilled.HasValue)
                        rs.IsSelectionEolFilled = baseStyleConfig.IsSelectionEolFilled.Value;

                    if (sc.IsVisible.HasValue)
                        rs.IsVisible = sc.IsVisible.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.IsVisible.HasValue)
                        rs.IsVisible = baseStyleConfig.IsVisible.Value;

                    if (sc.Italic.HasValue)
                        rs.Italic = sc.Italic.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.Italic.HasValue)
                        rs.Italic = baseStyleConfig.Italic.Value;

                    if (sc.Size.HasValue)
                        rs.Size = sc.Size.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.Size.HasValue)
                        rs.Size = baseStyleConfig.Size.Value;

                    if (sc.Underline.HasValue)
                        rs.Underline = sc.Underline.Value;
                    else if (baseStyleConfig != null && baseStyleConfig.Underline.HasValue)
                        rs.Underline = baseStyleConfig.Underline.Value;
                }

            }
            //	If a Default styles exist we want them at the top of the list because
            //	it needs to be applied first, then StyleClearAll() called so that all
            //	other styles will "inherit" this style. Then the other styles will
            //	override the default with any defined properties.
            StyleConfig[] arr = new StyleConfig[resolvedStyles.Count];
            resolvedStyles.Values.CopyTo(arr, 0);
            Array.Sort<StyleConfig>(arr, new Comparison<StyleConfig>(delegate(StyleConfig sc1, StyleConfig sc2)
            {
                int v1 = sc1.Number.Value == Constants.STYLE_DEFAULT ? -1 : sc1.Number.Value;
                int v2 = sc2.Number.Value == Constants.STYLE_DEFAULT ? -1 : sc2.Number.Value;

                if (v1 < v2)
                    return -1;
                else if (v2 < v1)
                    return 1;

                return 0;
            }));

            foreach (StyleConfig sc in arr)
            {
                if (sc.Number < 0)
                    continue;

                Style style = Scintilla.Styles[sc.Number.Value];

                if (sc.BackColor != Color.Empty)
                    style.BackColor = sc.BackColor;

                if (sc.Bold.HasValue)
                    style.Bold = sc.Bold.Value;

                if (sc.Case.HasValue)
                    style.Case = sc.Case.Value;

                if (sc.CharacterSet.HasValue)
                    style.CharacterSet = sc.CharacterSet.Value;

                if (sc.FontName != null)
                    style.FontName = sc.FontName;

                if (sc.ForeColor != Color.Empty)
                    style.ForeColor = sc.ForeColor;

                if (sc.IsChangeable.HasValue)
                    style.IsChangeable = sc.IsChangeable.Value;

                if (sc.IsHotspot.HasValue)
                    style.IsHotspot = sc.IsHotspot.Value;

                if (sc.IsSelectionEolFilled.HasValue)
                    style.IsSelectionEolFilled = sc.IsSelectionEolFilled.Value;

                if (sc.IsVisible.HasValue)
                    style.IsVisible = sc.IsVisible.Value;

                if (sc.Italic.HasValue)
                    style.Italic = sc.Italic.Value;

                if (sc.Size.HasValue)
                    style.Size = sc.Size.Value;

                if (sc.Underline.HasValue)
                    style.Underline = sc.Underline.Value;

                if (sc.Number == Constants.STYLE_DEFAULT)
                    Scintilla.Styles.ClearAll();
            }

            //	These values should always override any config values
            //	We need to reset these if their UseXXX is true
            if (Scintilla.UseFont)
                Scintilla.Font = Scintilla.Font;

            if (Scintilla.UseForeColor)
                Scintilla.UseForeColor = Scintilla.UseForeColor;

            if (Scintilla.UseBackColor)
                Scintilla.UseBackColor = Scintilla.UseBackColor;
        }
Exemplo n.º 32
0
		private StyleConfig getStyleConfigFromElement(XmlReader reader)
		{
			StyleConfig sc = new StyleConfig();
			if (reader.HasAttributes)
			{
				while (reader.MoveToNextAttribute())
				{
					string attrName = reader.Name.ToLower();
					switch (attrName)
					{
						case "name":
							sc.Name = reader.Value;
							break;
						case "number":
							sc.Number = getInt(reader.Value);
							break;
						case "backcolor":
							sc.BackColor = getColor(reader.Value);
							break;
						case "bold":
							sc.Bold = getBool(reader.Value);
							break;
						case "case":
							sc.Case = (StyleCase)Enum.Parse(typeof(StyleCase), reader.Value, true);
							break;
						case "characterset":
							sc.CharacterSet = (CharacterSet)Enum.Parse(typeof(CharacterSet), reader.Value, true);
							break;
						case "fontname":
							sc.FontName = reader.Value;
							break;
						case "forecolor":
							sc.ForeColor = getColor(reader.Value);
							break;
						case "ischangeable":
							sc.IsChangeable = getBool(reader.Value);
							break;
						case "ishotspot":
							sc.IsHotspot = getBool(reader.Value);
							break;
						case "isselectioneolfilled":
							sc.IsSelectionEolFilled = getBool(reader.Value);
							break;
						case "isvisible":
							sc.IsVisible = getBool(reader.Value);
							break;
						case "italic":
							sc.Italic = getBool(reader.Value);
							break;
						case "size":
							sc.Size = getInt(reader.Value);
							break;
						case "underline":
							sc.Underline = getBool(reader.Value);
							break;
						case "inherit":
							sc.Inherit = getBool(reader.Value);
							break;
					}
				}
				reader.MoveToElement();
			}

			return sc;
        }
Exemplo n.º 33
0
		public void Load(XmlDocument configDocument)
		{
			
			XmlNode langNode = configDocument.DocumentElement.SelectSingleNode("./Language[@Name='" + _language + "']");
			if (langNode == null)
				return;

			XmlElement callTipNode = langNode.SelectSingleNode("CallTip") as XmlElement;
			if (callTipNode != null)
			{
				_callTip_BackColor = getColor(callTipNode.GetAttribute("BackColor"));
				_callTip_ForeColor = getColor(callTipNode.GetAttribute("ForeColor"));
				_callTip_HighlightTextColor = getColor(callTipNode.GetAttribute("HighlightTextColor"));
			}
			callTipNode = null;

			XmlElement caretNode = langNode.SelectSingleNode("Caret") as XmlElement;
			if (caretNode != null)
			{
				//	This guy is a bit of an oddball becuase null means "I don't Care"
				//	and we need some way of using the OS value.
				string blinkRate = caretNode.GetAttribute("BlinkRate");
				if (blinkRate.ToLower() == "system")
					_caret_BlinkRate = SystemInformation.CaretBlinkTime;
				else
					_caret_BlinkRate = getInt(blinkRate);

				_caret_Color = getColor(caretNode.GetAttribute("Color"));
				_caret_CurrentLineBackgroundAlpha = getInt(caretNode.GetAttribute("CurrentLineBackgroundAlpha"));
				_caret_CurrentLineBackgroundColor = getColor(caretNode.GetAttribute("CurrentLineBackgroundColor"));
				_caret_HighlightCurrentLine = getBool(caretNode.GetAttribute("HighlightCurrentLine"));
				_caret_IsSticky = getBool(caretNode.GetAttribute("IsSticky"));
				try
				{
					_caret_Style = (CaretStyle)Enum.Parse(typeof(CaretStyle), caretNode.GetAttribute("Style"), true);
				}
				catch (ArgumentException) { }
				_caret_Width = getInt(caretNode.GetAttribute("Width"));
			}
			caretNode = null;

			XmlElement clipboardNode = langNode.SelectSingleNode("Clipboard") as XmlElement;
			if (clipboardNode != null)
			{
				_clipboard_ConvertEndOfLineOnPaste = getBool(clipboardNode.GetAttribute("ConvertEndOfLineOnPaste"));
			}
			clipboardNode = null;

			_commands_KeyBindingList = new CommandBindingConfigList();
			XmlElement commandsNode = langNode.SelectSingleNode("Commands") as XmlElement;
			if (commandsNode != null)
			{
				_commands_KeyBindingList.Inherit = getBool(commandsNode.GetAttribute("Inherit"));
				_commands_KeyBindingList.AllowDuplicateBindings = getBool(commandsNode.GetAttribute("AllowDuplicateBindings"));
				foreach (XmlElement el in commandsNode.SelectNodes("./Binding"))
				{
					KeyBinding kb = new KeyBinding();
					kb.KeyCode = Utilities.GetKeys(el.GetAttribute("Key"));

					string modifiers = el.GetAttribute("Modifier");
					if (modifiers != string.Empty)
					{
						foreach (string modifier in modifiers.Split(' '))
							kb.Modifiers |= (Keys)Enum.Parse(typeof(Keys), modifier.Trim(), true);
					}

					BindableCommand cmd = (BindableCommand)Enum.Parse(typeof(BindableCommand), el.GetAttribute("Command"), true);
					CommandBindingConfig cfg = new CommandBindingConfig(kb, getBool(el.GetAttribute("ReplaceCurrent")), cmd);
					_commands_KeyBindingList.Add(cfg);
				}
			}
			commandsNode = null;

			XmlElement endOfLineNode = langNode.SelectSingleNode("EndOfLine") as XmlElement;
			if (endOfLineNode != null)
			{
				_endOfLine_ConvertOnPaste = getBool(endOfLineNode.GetAttribute("ConvertOnPaste"));
				_endOfLine_IsVisisble = getBool(endOfLineNode.GetAttribute("IsVisible"));

				try
				{
					_endOfLine_Mode = (EndOfLineMode)Enum.Parse(typeof(EndOfLineMode), endOfLineNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }
			}
			endOfLineNode = null;

			XmlElement hotSpotNode = langNode.SelectSingleNode("HotSpot") as XmlElement;
			if (hotSpotNode != null)
			{
				_hotspot_ActiveBackColor = getColor(hotSpotNode.GetAttribute("ActiveBackColor"));
				_hotspot_ActiveForeColor = getColor(hotSpotNode.GetAttribute("ActiveForeColor"));
				_hotspot_ActiveUnderline = getBool(hotSpotNode.GetAttribute("ActiveUnderline"));
				_hotspot_SingleLine = getBool(hotSpotNode.GetAttribute("SingleLine"));
				_hotspot_UseActiveBackColor = getBool(hotSpotNode.GetAttribute("UseActiveBackColor"));
				_hotspot_UseActiveForeColor = getBool(hotSpotNode.GetAttribute("UseActiveForeColor"));
			}
			hotSpotNode = null;

			XmlElement indentationNode = langNode.SelectSingleNode("Indentation") as XmlElement;
			if (indentationNode != null)
			{
				_indentation_BackspaceUnindents = getBool(indentationNode.GetAttribute("BackspaceUnindents"));
				_indentation_IndentWidth = getInt(indentationNode.GetAttribute("IndentWidth"));
				_indentation_ShowGuides = getBool(indentationNode.GetAttribute("ShowGuides"));
				_indentation_TabIndents = getBool(indentationNode.GetAttribute("TabIndents"));
				_indentation_TabWidth = getInt(indentationNode.GetAttribute("TabWidth"));
				_indentation_UseTabs = getBool(indentationNode.GetAttribute("UseTabs"));

				try
				{
					_indentation_SmartIndentType = (SmartIndent)Enum.Parse(typeof(SmartIndent), indentationNode.GetAttribute("SmartIndentType"), true);
				}
				catch (ArgumentException) { }

			}
			indentationNode = null;

			XmlElement indicatorNode = langNode.SelectSingleNode("Indicators") as XmlElement;
			if (indicatorNode != null)
			{
				_indicator_List.Inherit = getBool(indicatorNode.GetAttribute("Inherit"));
				foreach (XmlElement el in indicatorNode.SelectNodes("Indicator"))
				{
					IndicatorConfig ic = new IndicatorConfig();
					ic.Number = int.Parse(el.GetAttribute("Number"));
					ic.Color = getColor(el.GetAttribute("Color"));
					ic.Inherit = getBool(el.GetAttribute("Inherit"));
					ic.IsDrawnUnder = getBool(el.GetAttribute("IsDrawnUnder"));
					try
					{
						ic.Style = (IndicatorStyle)Enum.Parse(typeof(IndicatorStyle), el.GetAttribute("Style"), true);
					}
					catch (ArgumentException) { }

					_indicator_List.Add(ic);
				}
			}

			_lexing_Properties = new LexerPropertiesConfig();
			_lexing_Keywords = new KeyWordConfigList();
			XmlElement lexerNode = langNode.SelectSingleNode("Lexer") as XmlElement;
			if (lexerNode != null)
			{
				_lexing_WhiteSpaceChars = getString(lexerNode.GetAttributeNode("WhiteSpaceChars"));
				_lexing_WordChars = getString(lexerNode.GetAttributeNode("WordChars"));
				_lexing_Language = getString(lexerNode.GetAttributeNode("LexerName"));
				_lexing_LineCommentPrefix = getString(lexerNode.GetAttributeNode("LineCommentPrefix"));
				_lexing_StreamCommentPrefix = getString(lexerNode.GetAttributeNode("StreamCommentPrefix"));
				_lexing_StreamCommentSuffix = getString(lexerNode.GetAttributeNode("StreamCommentSuffix"));

				XmlElement propNode = lexerNode.SelectSingleNode("Properties") as XmlElement;
				if (propNode != null)
				{
					_lexing_Properties.Inherit = getBool(propNode.GetAttribute("Inherit"));

					foreach (XmlElement el in propNode.SelectNodes("Property"))
						_lexing_Properties.Add(el.GetAttribute("Name"), el.GetAttribute("Value"));
				}

				foreach (XmlElement el in lexerNode.SelectNodes("Keywords"))
					_lexing_Keywords.Add(new KeyWordConfig(getInt(el.GetAttribute("List")).Value, el.InnerText.Trim(), getBool(el.GetAttribute("Inherit"))));

			}
			lexerNode = null;

			XmlElement lineWrapNode = langNode.SelectSingleNode("LineWrap") as XmlElement;
			if (lineWrapNode != null)
			{
				try
				{
					_lineWrap_LayoutCache = (LineCache)Enum.Parse(typeof(LineCache), lineWrapNode.GetAttribute("LayoutCache"), true);
				}
				catch (ArgumentException) { }

				try
				{
					_lineWrap_Mode = (WrapMode)Enum.Parse(typeof(WrapMode), lineWrapNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }

				_lineWrap_PositionCacheSize = getInt(lineWrapNode.GetAttribute("PositionCacheSize"));
				_lineWrap_StartIndent = getInt(lineWrapNode.GetAttribute("StartIndent"));

				string flags = lineWrapNode.GetAttribute("VisualFlags").Trim();
				if (flags != string.Empty)
				{
					WrapVisualFlag? wvf = null;
					foreach (string flag in flags.Split(' '))
						wvf |= (WrapVisualFlag)Enum.Parse(typeof(WrapVisualFlag), flag.Trim(), true);

					if (wvf.HasValue)
						_lineWrap_VisualFlags = wvf;
				}

				try
				{
					_lineWrap_VisualFlagsLocation = (WrapVisualLocation)Enum.Parse(typeof(WrapVisualLocation), lineWrapNode.GetAttribute("VisualFlagsLocation"), true);
				}
				catch (ArgumentException) { }
			}
			lineWrapNode = null;

			XmlElement longLinesNode = langNode.SelectSingleNode("LongLines") as XmlElement;
			if (longLinesNode != null)
			{
				_longLines_EdgeColor = getColor(longLinesNode.GetAttribute("EdgeColor"));
				_longLines_EdgeColumn = getInt(longLinesNode.GetAttribute("EdgeColumn"));
				try
				{
					_longLines_EdgeMode = (EdgeMode)Enum.Parse(typeof(EdgeMode), longLinesNode.GetAttribute("EdgeMode"), true);
				}
				catch (ArgumentException) { }
			}
			longLinesNode = null;

			_margin_List = new MarginConfigList();
			XmlElement marginNode = langNode.SelectSingleNode("Margins") as XmlElement;
			if (marginNode != null)
			{
				_margin_List.FoldMarginColor = getColor(marginNode.GetAttribute("FoldMarginColor"));
				_margin_List.FoldMarginHighlightColor = getColor(marginNode.GetAttribute("FoldMarginHighlightColor"));
				_margin_List.Left = getInt(marginNode.GetAttribute("Left"));
				_margin_List.Right = getInt(marginNode.GetAttribute("Right"));
				_margin_List.Inherit = getBool(marginNode.GetAttribute("Inherit"));

				foreach (XmlElement el in marginNode.SelectNodes("./Margin"))
				{
					MarginConfig mc = new MarginConfig();
					mc.Number = int.Parse(el.GetAttribute("Number"));
					mc.Inherit = getBool(el.GetAttribute("Inherit"));
					mc.AutoToggleMarkerNumber = getInt(el.GetAttribute("AutoToggleMarkerNumber"));
					mc.IsClickable = getBool(el.GetAttribute("IsClickable"));
					mc.IsFoldMargin = getBool(el.GetAttribute("IsFoldMargin"));
					mc.IsMarkerMargin = getBool(el.GetAttribute("IsMarkerMargin"));
					try
					{
						mc.Type = (MarginType)Enum.Parse(typeof(MarginType), el.GetAttribute("Type"), true);
					}
					catch (ArgumentException) { }

					mc.Width = getInt(el.GetAttribute("Width"));

					_margin_List.Add(mc);
				}
			}
			marginNode = null;

			XmlElement markersNode = langNode.SelectSingleNode("Markers") as XmlElement;
			_markers_List = new MarkersConfigList();
			if (markersNode != null)
			{
				_markers_List.Inherit = getBool(markersNode.GetAttribute("Inherit"));

				foreach (XmlElement el in markersNode.SelectNodes("Marker"))
				{
					MarkersConfig mc = new MarkersConfig();
					mc.Alpha = getInt(el.GetAttribute("Alpha"));
					mc.BackColor = getColor(el.GetAttribute("BackColor"));
					mc.ForeColor = getColor(el.GetAttribute("ForeColor"));
					mc.Name = getString(el.GetAttributeNode("Name"));
					mc.Number = getInt(el.GetAttribute("Number"));
					mc.Inherit = getBool(el.GetAttribute("Inherit"));
					try
					{
						mc.Symbol = (MarkerSymbol)Enum.Parse(typeof(MarkerSymbol), el.GetAttribute("Symbol"), true);
					}
					catch (ArgumentException) { }
					_markers_List.Add(mc);
				}
			}

			XmlElement scrollingNode = langNode.SelectSingleNode("Scrolling") as XmlElement;
			if (scrollingNode != null)
			{
				_scrolling_EndAtLastLine = getBool(scrollingNode.GetAttribute("EndAtLastLine"));
				_scrolling_HorizontalWidth = getInt(scrollingNode.GetAttribute("HorizontalWidth"));

				string flags = scrollingNode.GetAttribute("ScrollBars").Trim();
				if (flags != string.Empty)
				{
					ScrollBars? sb = null;
					foreach (string flag in flags.Split(' '))
						sb |= (ScrollBars)Enum.Parse(typeof(ScrollBars), flag.Trim(), true);

					if (sb.HasValue)
						_scrolling_ScrollBars = sb;
				}

				_scrolling_XOffset = getInt(scrollingNode.GetAttribute("XOffset"));
			}
			scrollingNode = null;


			XmlElement selectionNode = langNode.SelectSingleNode("Selection") as XmlElement;
			if (selectionNode != null)
			{
				_selection_BackColor = getColor(selectionNode.GetAttribute("BackColor"));
				_selection_BackColorUnfocused = getColor(selectionNode.GetAttribute("BackColorUnfocused"));
				_selection_ForeColor = getColor(selectionNode.GetAttribute("ForeColor"));
				_selection_ForeColorUnfocused = getColor(selectionNode.GetAttribute("ForeColorUnfocused"));
				_selection_Hidden = getBool(selectionNode.GetAttribute("Hidden"));
				_selection_HideSelection = getBool(selectionNode.GetAttribute("HideSelection"));
				try
				{
					_selection_Mode = (SelectionMode)Enum.Parse(typeof(SelectionMode), selectionNode.GetAttribute("Mode"), true);
				}
				catch (ArgumentException) { }
			}
			selectionNode = null;

			_styles = new StyleConfigList();
			XmlElement stylesNode = langNode.SelectSingleNode("Styles") as XmlElement;
			if (stylesNode != null)
			{
				_styles.Bits = getInt(stylesNode.GetAttribute("Bits"));
				foreach (XmlElement el in stylesNode.SelectNodes("Style"))
				{
					StyleConfig sc = new StyleConfig();
					sc.Name = el.GetAttribute("Name");
					sc.Number = getInt(el.GetAttribute("Number"));
					sc.BackColor = getColor(el.GetAttribute("BackColor"));
					sc.Bold = getBool(el.GetAttribute("Bold"));
					try
					{
						sc.Case = (StyleCase)Enum.Parse(typeof(StyleCase), el.GetAttribute("Case"), true);
					}
					catch (ArgumentException) { }

					try
					{
						sc.CharacterSet = (CharacterSet)Enum.Parse(typeof(CharacterSet), el.GetAttribute("CharacterSet"), true);
					}
					catch (ArgumentException) { }

					sc.FontName = getString(el.GetAttributeNode("FontName"));
					sc.ForeColor = getColor(el.GetAttribute("ForeColor"));
					sc.IsChangeable = getBool(el.GetAttribute("IsChangeable"));
					sc.IsHotspot = getBool(el.GetAttribute("IsHotspot"));
					sc.IsSelectionEolFilled = getBool(el.GetAttribute("IsSelectionEolFilled"));
					sc.IsVisible = getBool(el.GetAttribute("IsVisible"));
					sc.Italic = getBool(el.GetAttribute("Italic"));
					sc.Size = getInt(el.GetAttribute("Size"));
					sc.Underline = getBool(el.GetAttribute("Underline"));
					sc.Inherit = getBool(el.GetAttribute("Inherit"));
					
					_styles.Add(sc);
				}

				//	This is a nifty added on hack made specifically for HTML.
				//	Normally the style config elements are quite managable as there
				//	are typically less than 10 when you don't count common styles.
				//	
				//	However HTML uses 9 different Sub languages that combined make 
				//	use of all 128 styles (well there are some small gaps). In order
				//	to make this more managable I did added a SubLanguage element that
				//	basically just prepends the Language's name and "." to the Style 
				//	Name definition.
				//
				//	So for example if you had the following
				//	<Styles>
				//		<SubLanguage Name="ASP JavaScript">
				//			<Style Name="Keyword" Bold="True" />
				//		</SubLanguage>
				//	</Styles>
				//	That style's name will get interpreted as "ASP JavaScript.Keyword".
				//	which if you look at the html.txt in LexerStyleNames you'll see it
				//	maps to Style # 62

				//	Yeah I copied and pasted from above. I know. Feel free to refactor
				//	this and check it in since you're so high and mighty.
				foreach (XmlElement subLanguage in stylesNode.SelectNodes("SubLanguage"))
				{
					string subLanguageName = subLanguage.GetAttribute("Name");
					foreach (XmlElement el in subLanguage.SelectNodes("Style"))
					{
						StyleConfig sc = new StyleConfig();
						sc.Name = subLanguageName + "." + el.GetAttribute("Name");
						sc.Number = getInt(el.GetAttribute("Number"));
						sc.BackColor = getColor(el.GetAttribute("BackColor"));
						sc.Bold = getBool(el.GetAttribute("Bold"));
						try
						{
							sc.Case = (StyleCase)Enum.Parse(typeof(StyleCase), el.GetAttribute("Case"), true);
						}
						catch (ArgumentException) { }

						try
						{
							sc.CharacterSet = (CharacterSet)Enum.Parse(typeof(CharacterSet), el.GetAttribute("CharacterSet"), true);
						}
						catch (ArgumentException) { }

						sc.FontName = getString(el.GetAttributeNode("FontName"));
						sc.ForeColor = getColor(el.GetAttribute("ForeColor"));
						sc.IsChangeable = getBool(el.GetAttribute("IsChangeable"));
						sc.IsHotspot = getBool(el.GetAttribute("IsHotspot"));
						sc.IsSelectionEolFilled = getBool(el.GetAttribute("IsSelectionEolFilled"));
						sc.IsVisible = getBool(el.GetAttribute("IsVisible"));
						sc.Italic = getBool(el.GetAttribute("Italic"));
						sc.Size = getInt(el.GetAttribute("Size"));
						sc.Underline = getBool(el.GetAttribute("Underline"));
						sc.Inherit = getBool(el.GetAttribute("Inherit"));

						_styles.Add(sc);
					}
				}
			}
			stylesNode = null;

			XmlElement undoRedoNode = langNode.SelectSingleNode("UndoRedo") as XmlElement;
			if (undoRedoNode != null)
			{
				_undoRedoIsUndoEnabled = getBool(undoRedoNode.GetAttribute("IsUndoEnabled"));
			}
			undoRedoNode = null;


			XmlElement whiteSpaceNode = langNode.SelectSingleNode("WhiteSpace") as XmlElement;
			if (whiteSpaceNode != null)
			{
				_whiteSpace_BackColor = getColor(whiteSpaceNode.GetAttribute("BackColor"));
				_whiteSpace_ForeColor = getColor(whiteSpaceNode.GetAttribute("ForeColor"));
				_whiteSpace_Mode = (WhiteSpaceMode)Enum.Parse(typeof(WhiteSpaceMode), whiteSpaceNode.GetAttribute("Mode"), true);
				_whiteSpace_UseWhiteSpaceBackColor = getBool(whiteSpaceNode.GetAttribute("UseWhiteSpaceBackColor"));
				_whiteSpace_UseWhiteSpaceForeColor = getBool(whiteSpaceNode.GetAttribute("UseWhiteSpaceForeColor"));
			}
			whiteSpaceNode = null;

			configDocument = null;
		}