Esempio n. 1
0
        void LoadStyle(XmlElement style)
        {
            string       name  = style.GetAttribute("Name");
            Type         type  = TypeStore.Find(style.GetAttribute("Type"));
            ControlState state = (ControlState)Enum.Parse(typeof(ControlState), style.GetAttribute("State"));

            PatternList     plist     = new PatternList();
            List <Location> locations = new List <Location>();
            List <Path>     paths     = new List <Path>();

            XMLStyleLoader xl = new XMLStyleLoader();

            foreach (XmlNode child in style)
            {
                Pattern  ptn = null;
                Path     pth = null;
                Location loc = null;

                foreach (XmlNode child2 in child)
                {
                    if (child2.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    object obj = xl.Load(child2);

                    if (obj is Pattern)
                    {
                        ptn = (Pattern)obj;
                    }
                    if (obj is Location)
                    {
                        loc = (Location)obj;
                    }
                    if (obj is Path)
                    {
                        pth = (Path)obj;
                    }
                }

                if (ptn == null)
                {
                    continue;
                }

                ptn.Type = (PatternType)Enum.Parse(typeof(PatternType), child.LocalName);

                plist.Add(ptn);
                paths.Add(pth);
                locations.Add(loc);
            }

            styleNames.Add(name);
            styleTypes.Add(type);
            styleStates.Add(state);
            styleOperations.Add(plist);
            styleLocations.Add(locations);
            stylePaths.Add(paths);
        }
Esempio n. 2
0
        private void OpenDataSetHandler()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                PatternList.Add(new Pattern(openFileDialog.FileName));

                var series = PlotModelHelper.CreateScatterSerie(PatternList.Last().Points, PatternList.Last().Color);

                PlotModelPattern.Series.Add(series);
                PlotModelPattern.InvalidatePlot(true);
            }
        }
Esempio n. 3
0
        private void TransformMatrixHandler()
        {
            CalibMatrix = AffineMatrix.CalculateMatrix(SelectedA, SelectedB);

            DecomposeMatrix = AffineMatrix.Decompose(CalibMatrix);

            PatternList.Add(new Pattern("None"));

            PatternList.Last().Points = AffineMatrix.CalculateBack(SelectedA.Points, CalibMatrix);

            var series = PlotModelHelper.CreateScatterSerie(PatternList.Last().Points, PatternList.Last().Color);

            PlotModelPattern.Series.Add(series);
            PlotModelPattern.InvalidatePlot(true);
        }
        private void ParseBlock(XmlNode node)
        {
            string Name = "", Style = "";
            bool   IsMultiline       = false;
            bool   TerminateChildren = false;
            Color  BackColor         = Color.Transparent;

            foreach (XmlAttribute att in node.Attributes)
            {
                if (att.Name.ToLowerInvariant() == "name")
                {
                    Name = att.Value;
                }
                if (att.Name.ToLowerInvariant() == "style")
                {
                    Style = att.Value;
                }
                if (att.Name.ToLowerInvariant() == "ismultiline")
                {
                    IsMultiline = bool.Parse(att.Value);
                }
                if (att.Name.ToLowerInvariant() == "terminatechildren")
                {
                    TerminateChildren = bool.Parse(att.Value);
                }
                if (att.Name.ToLowerInvariant() == "backcolor")
                {
                    BackColor = Color.FromName(att.Value);
                    //Transparent =false;
                }
            }

            //create block object here
            SpanDefinition.SpanDefinition bl = GetBlock(Name);
            bl.BackColor         = BackColor;
            bl.Name              = Name;
            bl.MultiLine         = IsMultiline;
            bl.Style             = GetStyle(Style);
            bl.TerminateChildren = TerminateChildren;


            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.NodeType == XmlNodeType.Element)
                {
                    if (n.Name.ToLowerInvariant() == "scope")
                    {
                        //bool IsComplex=false;
                        //bool IsSeparator=false;
                        string Start          = "";
                        string End            = "";
                        string style          = "";
                        string text           = "";
                        string EndIsSeparator = "";
                        string StartIsComplex = "false";
                        string EndIsComplex   = "false";
                        string StartIsKeyword = "false";
                        string EndIsKeyword   = "false";
                        string spawnStart     = "";
                        string spawnEnd       = "";
                        string EscapeChar     = "";
                        string CauseIndent    = "false";

                        bool expanded = true;

                        foreach (XmlAttribute att in n.Attributes)
                        {
                            switch (att.Name.ToLowerInvariant())
                            {
                            case "start":
                                Start = att.Value;
                                break;

                            case "escapechar":
                                EscapeChar = att.Value;
                                break;

                            case "end":
                                End = att.Value;
                                break;

                            case "style":
                                style = att.Value;
                                break;

                            case "text":
                                text = att.Value;
                                break;

                            case "defaultexpanded":
                                expanded = bool.Parse(att.Value);
                                break;

                            case "endisseparator":
                                EndIsSeparator = att.Value;
                                break;

                            case "startiskeyword":
                                StartIsKeyword = att.Value;
                                break;

                            case "startiscomplex":
                                StartIsComplex = att.Value;
                                break;

                            case "endiscomplex":
                                EndIsComplex = att.Value;
                                break;

                            case "endiskeyword":
                                EndIsKeyword = att.Value;
                                break;

                            case "spawnblockonstart":
                                spawnStart = att.Value;
                                break;

                            case "spawnblockonend":
                                spawnEnd = att.Value;
                                break;

                            case "causeindent":
                                CauseIndent = att.Value;
                                break;
                            }
                        }
                        if (Start != "")
                        {
                            //bl.StartPattern =new Pattern (Pattern,IsComplex,false,IsSeparator);
                            //bl.StartPatterns.Add (new Pattern (Pattern,IsComplex,IsSeparator,true));
                            bool blnStartIsComplex = bool.Parse(StartIsComplex);
                            bool blnEndIsComplex   = bool.Parse(EndIsComplex);
                            bool blnCauseIndent    = bool.Parse(CauseIndent);

                            var scope = new Scope.Scope {
                                Style = GetStyle(style), ExpansionText = text, DefaultExpanded = expanded, CauseIndent = blnCauseIndent
                            };

                            var             StartP     = new Pattern.Pattern(Start, blnStartIsComplex, false, bool.Parse(StartIsKeyword));
                            Pattern.Pattern endPattern = EscapeChar != "" ? new Pattern.Pattern(End, false, bool.Parse(EndIsKeyword), EscapeChar) : new Pattern.Pattern(End, blnEndIsComplex, false, bool.Parse(EndIsKeyword));

                            if (EndIsSeparator != "")
                            {
                                endPattern.IsSeparator = bool.Parse(EndIsSeparator);
                            }

                            scope.Start = StartP;
                            scope.EndPatterns.Add(endPattern);
                            bl.ScopePatterns.Add(scope);
                            if (spawnStart != "")
                            {
                                scope.spawnSpanOnStart = GetBlock(spawnStart);
                            }
                            if (spawnEnd != "")
                            {
                                scope.spawnSpanOnEnd = GetBlock(spawnEnd);
                            }
                        }
                    }
                    if (n.Name.ToLowerInvariant() == "bracket")
                    {
                        //bool IsComplex=false;
                        //bool IsSeparator=false;
                        string Start = "";
                        string End   = "";
                        string style = "";

                        string StartIsComplex = "false";
                        string EndIsComplex   = "false";

                        string StartIsKeyword = "false";
                        string EndIsKeyword   = "false";
                        string IsMultiLineB   = "true";

                        foreach (XmlAttribute att in n.Attributes)
                        {
                            switch (att.Name.ToLowerInvariant())
                            {
                            case "start":
                                Start = att.Value;
                                break;

                            case "end":
                                End = att.Value;
                                break;

                            case "style":
                                style = att.Value;
                                break;

                            case "endisseparator":
                                if (att.Name.ToLowerInvariant() == "startisseparator")
                                {
                                    if (att.Name.ToLowerInvariant() == "startiskeyword")
                                    {
                                        StartIsKeyword = att.Value;
                                    }
                                }
                                break;

                            case "startiscomplex":
                                StartIsComplex = att.Value;
                                break;

                            case "endiscomplex":
                                EndIsComplex = att.Value;
                                break;

                            case "endiskeyword":
                                EndIsKeyword = att.Value;
                                break;

                            case "ismultiline":
                                IsMultiLineB = att.Value;
                                break;
                            }
                        }
                        if (Start != "")
                        {
                            var pl = new PatternList {
                                Style = GetStyle(style)
                            };

                            bool blnStartIsComplex = bool.Parse(StartIsComplex);
                            bool blnEndIsComplex   = bool.Parse(EndIsComplex);
                            bool blnIsMultiLineB   = bool.Parse(IsMultiLineB);

                            var StartP = new Pattern.Pattern(Start, blnStartIsComplex, false, bool.Parse(StartIsKeyword));
                            var EndP   = new Pattern.Pattern(End, blnEndIsComplex, false, bool.Parse(EndIsKeyword));

                            StartP.MatchingBracket    = EndP;
                            EndP.MatchingBracket      = StartP;
                            StartP.BracketType        = BracketType.StartBracket;
                            EndP.BracketType          = BracketType.EndBracket;
                            StartP.IsMultiLineBracket = EndP.IsMultiLineBracket = blnIsMultiLineB;

                            pl.Add(StartP);
                            pl.Add(EndP);
                            bl.OperatorsList.Add(pl);
                        }
                    }
                }

                if (n.Name.ToLowerInvariant() == "keywords")
                {
                    foreach (XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLowerInvariant() == "patterngroup")
                        {
                            var pl = new PatternList();
                            bl.KeywordsList.Add(pl);
                            foreach (XmlAttribute att in cn.Attributes)
                            {
                                switch (att.Name.ToLowerInvariant())
                                {
                                case "style":
                                    pl.Style = GetStyle(att.Value);
                                    break;

                                case "name":
                                    pl.Name = att.Value;
                                    break;

                                case "normalizecase":
                                    pl.NormalizeCase = bool.Parse(att.Value);
                                    break;

                                case "casesensitive":
                                    pl.CaseSensitive = bool.Parse(att.Value);
                                    break;
                                }
                            }
                            foreach (XmlNode pt in cn.ChildNodes)
                            {
                                if (pt.Name.ToLowerInvariant() == "pattern")
                                {
                                    bool   IsComplex   = false;
                                    bool   IsSeparator = false;
                                    string Category    = null;
                                    string Pattern     = "";
                                    if (pt.Attributes != null)
                                    {
                                        foreach (XmlAttribute att in pt.Attributes)
                                        {
                                            switch (att.Name.ToLowerInvariant())
                                            {
                                            case "text":
                                                Pattern = att.Value;
                                                break;

                                            case "iscomplex":
                                                IsComplex = bool.Parse(att.Value);
                                                break;

                                            case "isseparator":
                                                IsSeparator = bool.Parse(att.Value);
                                                break;

                                            case "category":
                                                Category = (att.Value);
                                                break;
                                            }
                                        }
                                    }
                                    if (Pattern != "")
                                    {
                                        var pat = new Pattern.Pattern(Pattern, IsComplex, IsSeparator, true)
                                        {
                                            Category = Category
                                        };
                                        pl.Add(pat);
                                    }
                                }
                                else if (pt.Name.ToLowerInvariant() == "patterns")
                                {
                                    string Patterns = pt.ChildNodes[0].Value;
                                    Patterns = Patterns.Replace("\t", " ");
                                    while (Patterns.IndexOf("  ") >= 0)
                                    {
                                        Patterns = Patterns.Replace("  ", " ");
                                    }


                                    foreach (string Pattern in Patterns.Split())
                                    {
                                        if (Pattern != "")
                                        {
                                            pl.Add(new Pattern.Pattern(Pattern, false, false, true));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //if (n.Name == "Operators")
                //	ParseStyle(n);
                if (n.Name.ToLowerInvariant() == "operators")
                {
                    foreach (XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLowerInvariant() == "patterngroup")
                        {
                            var pl = new PatternList();
                            bl.OperatorsList.Add(pl);
                            foreach (XmlAttribute att in cn.Attributes)
                            {
                                switch (att.Name.ToLowerInvariant())
                                {
                                case "style":
                                    pl.Style = GetStyle(att.Value);
                                    break;

                                case "name":
                                    pl.Name = att.Value;
                                    break;

                                case "normalizecase":
                                    pl.NormalizeCase = bool.Parse(att.Value);
                                    break;

                                case "casesensitive":
                                    pl.CaseSensitive = bool.Parse(att.Value);
                                    break;
                                }
                            }

                            foreach (XmlNode pt in cn.ChildNodes)
                            {
                                if (pt.Name.ToLowerInvariant() == "pattern")
                                {
                                    bool   IsComplex   = false;
                                    bool   IsSeparator = false;
                                    string Pattern     = "";
                                    string Category    = null;
                                    if (pt.Attributes != null)
                                    {
                                        foreach (XmlAttribute att in pt.Attributes)
                                        {
                                            switch (att.Name.ToLowerInvariant())
                                            {
                                            case "text":
                                                Pattern = att.Value;
                                                break;

                                            case "iscomplex":
                                                IsComplex = bool.Parse(att.Value);
                                                break;

                                            case "isseparator":
                                                IsSeparator = bool.Parse(att.Value);
                                                break;

                                            case "category":
                                                Category = (att.Value);
                                                break;
                                            }
                                        }
                                    }
                                    if (Pattern != "")
                                    {
                                        var pat = new Pattern.Pattern(Pattern, IsComplex, IsSeparator, false)
                                        {
                                            Category = Category
                                        };
                                        pl.Add(pat);
                                    }
                                }
                                else if (pt.Name.ToLowerInvariant() == "patterns")
                                {
                                    string Patterns = pt.ChildNodes[0].Value;
                                    Patterns = Patterns.Replace("\t", " ");
                                    while (Patterns.IndexOf("  ") >= 0)
                                    {
                                        Patterns = Patterns.Replace("  ", " ");
                                    }

                                    foreach (string Pattern in Patterns.Split())
                                    {
                                        if (Pattern != "")
                                        {
                                            pl.Add(new Pattern.Pattern(Pattern, false, false, false));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (n.Name.ToLowerInvariant() == "childblocks")
                {
                    foreach (XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLowerInvariant() == "child")
                        {
                            foreach (XmlAttribute att in cn.Attributes)
                            {
                                if (att.Name.ToLowerInvariant() == "name")
                                {
                                    bl.childSpanDefinitions.Add(GetBlock(att.Value));
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private void ParseBlock(XmlNode node)
        {
            string Name="", Style="" , PatternStyle="";
            bool   IsMultiline=false;
            bool   TerminateChildren=false;
            Color  BackColor=Color.Transparent;
            foreach (XmlAttribute att in node.Attributes)
            {
                if (att.Name.ToLower () =="name")
                    Name=att.Value;
                if (att.Name.ToLower () =="style")
                    Style=att.Value;
                if (att.Name.ToLower () =="patternstyle")
                    PatternStyle=att.Value;
                if (att.Name.ToLower () =="ismultiline")
                    IsMultiline=bool.Parse (att.Value);
                if (att.Name.ToLower () =="terminatechildren")
                    TerminateChildren=bool.Parse (att.Value);
                if (att.Name.ToLower () =="backcolor")
                {
                    BackColor =Color.FromName (att.Value);
                    //Transparent =false;
                }
            }

            //create block object here
            BlockType bl=GetBlock(Name);
            bl.BackColor =BackColor;
            bl.Name = Name;
            bl.MultiLine = IsMultiline;
            bl.Style = GetStyle(Style);
            bl.TerminateChildren =TerminateChildren;
            //		if (PatternStyle!="")
            //			bl.PatternStyle = GetStyle(PatternStyle);
            //		else
            //			bl.PatternStyle = bl.Style;

            foreach(XmlNode n in node.ChildNodes)
            {
                if (n.NodeType == XmlNodeType.Element)
                {
                    if (n.Name.ToLower () == "scope")
                    {
                        //bool IsComplex=false;
                        //bool IsSeparator=false;
                        string Start="";
                        string End="";
                        string style="";
                        string text="";
                        string EndIsSeparator="";
                        string StartIsSeparator="";
                        string StartIsComplex="false";
                        string EndIsComplex="false";
                        string StartIsKeyword="false";
                        string EndIsKeyword="false";
                        string spawnstart="";
                        string spawnend="";
                        string EscapeChar="";
                        string CauseIndent="false";

                        bool	expanded=true;

                        foreach(XmlAttribute att in n.Attributes)
                        {
                            if (att.Name.ToLower () == "start")
                                Start=att.Value;
                            if (att.Name.ToLower () == "escapechar")
                                EscapeChar=att.Value;
                            if (att.Name.ToLower () == "end")
                                End=att.Value;
                            if (att.Name.ToLower () == "style")
                                style=att.Value;
                            if (att.Name.ToLower () == "text")
                                text=att.Value;
                            if (att.Name.ToLower () == "defaultexpanded")
                                expanded=bool.Parse (att.Value);
                            if (att.Name.ToLower () == "endisseparator")
                                EndIsSeparator=att.Value;
                            if (att.Name.ToLower () == "startisseparator")
                                StartIsSeparator=att.Value;
                            if (att.Name.ToLower () == "startiskeyword")
                                StartIsKeyword=att.Value;
                            if (att.Name.ToLower () == "startiscomplex")
                                StartIsComplex=att.Value;
                            if (att.Name.ToLower () == "endiscomplex")
                                EndIsComplex=att.Value;
                            if (att.Name.ToLower () == "endiskeyword")
                                EndIsKeyword=att.Value;
                            if (att.Name.ToLower () == "spawnblockonstart")
                                spawnstart=att.Value;
                            if (att.Name.ToLower () == "spawnblockonend")
                                spawnend=att.Value;
                            if (att.Name.ToLower () == "causeindent")
                                CauseIndent=att.Value;
                        }
                        if (Start != "")
                        {
                            //bl.StartPattern =new Pattern (Pattern,IsComplex,false,IsSeparator);
                            //bl.StartPatterns.Add (new Pattern (Pattern,IsComplex,IsSeparator,true));
                            Scope scop=new Scope ();
                            scop.Style =GetStyle(style);
                            scop.ExpansionText =text;
                            scop.DefaultExpanded =expanded;
                            bool blnStartIsComplex=bool.Parse (StartIsComplex);
                            bool blnEndIsComplex=bool.Parse (EndIsComplex);
                            bool blnCauseIndent=bool.Parse (CauseIndent);
                            scop.CauseIndent = blnCauseIndent;

                            Pattern StartP=new Pattern (Start,blnStartIsComplex,false,bool.Parse (StartIsKeyword));
                            Pattern EndP=null;
                            if (EscapeChar!="")
                            {
                                EndP=new Pattern (End,blnEndIsComplex,false,bool.Parse (EndIsKeyword),EscapeChar);
                            }
                            else
                            {
                                EndP=new Pattern (End,blnEndIsComplex,false,bool.Parse (EndIsKeyword));
                            }

                            if (EndIsSeparator!="")
                                EndP.IsSeparator = bool.Parse (EndIsSeparator);
                            scop.Start =StartP;
                            scop.EndPatterns.Add(EndP);
                            bl.ScopePatterns.Add (scop);
                            if (spawnstart!="")
                            {
                                scop.SpawnBlockOnStart = GetBlock(spawnstart);
                            }
                            if (spawnend!="")
                            {
                                scop.SpawnBlockOnEnd = GetBlock(spawnend);
                            }
                        }
                    }
                    if (n.Name.ToLower () == "bracket")
                    {
                        //bool IsComplex=false;
                        //bool IsSeparator=false;
                        string Start="";
                        string End="";
                        string style="";

                        string EndIsSeparator="";
                        string StartIsSeparator="";

                        string StartIsComplex="false";
                        string EndIsComplex="false";

                        string StartIsKeyword="false";
                        string EndIsKeyword="false";
                        string IsMultiLineB="true";

                        foreach(XmlAttribute att in n.Attributes)
                        {
                            if (att.Name.ToLower () == "start")
                                Start=att.Value;
                            if (att.Name.ToLower () == "end")
                                End=att.Value;
                            if (att.Name.ToLower () == "style")
                                style=att.Value;
                            if (att.Name.ToLower () == "endisseparator")
                                EndIsSeparator=att.Value;
                            if (att.Name.ToLower () == "startisseparator")
                                StartIsSeparator=att.Value;
                            if (att.Name.ToLower () == "startiskeyword")
                                StartIsKeyword=att.Value;
                            if (att.Name.ToLower () == "startiscomplex")
                                StartIsComplex=att.Value;
                            if (att.Name.ToLower () == "endiscomplex")
                                EndIsComplex=att.Value;
                            if (att.Name.ToLower () == "endiskeyword")
                                EndIsKeyword=att.Value;
                            if (att.Name.ToLower () == "ismultiline")
                                IsMultiLineB=att.Value;
                        }
                        if (Start != "")
                        {
                            PatternList pl=new PatternList ();
                            pl.Style =GetStyle(style);

                            bool blnStartIsComplex=bool.Parse (StartIsComplex);
                            bool blnEndIsComplex=bool.Parse (EndIsComplex);
                            bool blnIsMultiLineB=bool.Parse (IsMultiLineB);

                    Pattern StartP=new Pattern (Start,blnStartIsComplex,false,bool.Parse (StartIsKeyword));
                    Pattern EndP=new Pattern (End,blnEndIsComplex,false,bool.Parse (EndIsKeyword));

                    StartP.MatchingBracket = EndP;
                    EndP.MatchingBracket =StartP;
                    StartP.BracketType = BracketType.StartBracket;
                    EndP.BracketType = BracketType.EndBracket;
                    StartP.IsMultiLineBracket =EndP.IsMultiLineBracket = blnIsMultiLineB;

                    pl.Add (StartP);
                    pl.Add (EndP);
                    bl.OperatorsList.Add (pl);
                        }
                    }

                }

                if (n.Name.ToLower () == "keywords")
                    foreach(XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLower () =="patterngroup")
                        {
                            PatternList pl=new PatternList ();
                            bl.KeywordsList.Add (pl);
                            foreach(XmlAttribute att in cn.Attributes)
                            {
                                if (att.Name.ToLower () == "style")
                                    pl.Style = GetStyle(att.Value);

                                if (att.Name.ToLower () == "name")
                                    pl.Name = att.Value;

                                if (att.Name.ToLower () == "normalizecase")
                                    pl.NormalizeCase = bool.Parse (att.Value);

                                if (att.Name.ToLower () == "casesensitive")
                                    pl.CaseSensitive = bool.Parse (att.Value);

                            }
                            foreach(XmlNode pt in cn.ChildNodes)
                            {
                                if (pt.Name.ToLower () == "pattern")
                                {
                                    bool IsComplex=false;
                                    bool IsSeparator=false;
                                    string Category=null;
                                    string Pattern="";
                                    if (pt.Attributes != null)
                                    {
                                        foreach(XmlAttribute att in pt.Attributes)
                                        {
                                            if (att.Name.ToLower () == "text")
                                                Pattern=att.Value;
                                            if (att.Name.ToLower () == "iscomplex")
                                                IsComplex=bool.Parse (att.Value);
                                            if (att.Name.ToLower () == "isseparator")
                                                IsSeparator=bool.Parse (att.Value);
                                            if (att.Name.ToLower () == "category")
                                                Category=(att.Value);

                                        }
                                    }
                                    if (Pattern!="")
                                    {
                                        Pattern pat=new Pattern (Pattern,IsComplex,IsSeparator,true);
                                        pat.Category=Category;
                                        pl.Add (pat);
                                    }

                                }
                                else if (pt.Name.ToLower () == "patterns")
                                {
                                    string Patterns=pt.ChildNodes[0].Value;
                                    Patterns=Patterns.Replace ("\t"," ");
                                    while (Patterns.IndexOf ("  ")>=0)
                                        Patterns=Patterns.Replace ("  "," ");

                                    foreach(string Pattern in Patterns.Split ())
                                    {
                                        if (Pattern !="")
                                            pl.Add (new Pattern (Pattern,false,false,true));
                                    }
                                }
                            }
                        }
                    }
                //if (n.Name == "Operators")
                //	ParseStyle(n);
                if (n.Name.ToLower () == "operators")
                    foreach(XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLower () =="patterngroup")
                        {
                            PatternList pl=new PatternList ();
                            bl.OperatorsList.Add (pl);
                            foreach(XmlAttribute att in cn.Attributes)
                            {
                                if (att.Name.ToLower () == "style")
                                    pl.Style = GetStyle(att.Value);

                                if (att.Name.ToLower () == "name")
                                    pl.Name = att.Value;

                                if (att.Name.ToLower () == "normalizecase")
                                    pl.NormalizeCase = bool.Parse (att.Value);

                                if (att.Name.ToLower () == "casesensitive")
                                    pl.CaseSensitive = bool.Parse (att.Value);
                            }

                            foreach(XmlNode pt in cn.ChildNodes)
                            {
                                if (pt.Name.ToLower () == "pattern")
                                {
                                    bool IsComplex=false;
                                    bool IsSeparator=false;
                                    string Pattern="";
                                    string Category=null;
                                    if (pt.Attributes != null)
                                    {
                                        foreach(XmlAttribute att in pt.Attributes)
                                        {
                                            if (att.Name.ToLower () == "text")
                                                Pattern=att.Value;
                                            if (att.Name.ToLower () == "iscomplex")
                                                IsComplex=bool.Parse (att.Value);
                                            if (att.Name.ToLower () == "isseparator")
                                                IsSeparator=bool.Parse (att.Value);
                                            if (att.Name.ToLower () == "category")
                                                Category=(att.Value);

                                        }
                                    }
                                    if (Pattern!="")
                                    {
                                        Pattern pat=new Pattern (Pattern,IsComplex,IsSeparator,false);
                                        pat.Category=Category;
                                        pl.Add (pat);
                                    }
                                }
                                else if (pt.Name.ToLower () == "patterns")
                                {
                                    string Patterns=pt.ChildNodes[0].Value;
                                    Patterns=Patterns.Replace ("\t"," ");
                                    while (Patterns.IndexOf ("  ")>=0)
                                        Patterns=Patterns.Replace ("  "," ");

                                    foreach(string Pattern in Patterns.Split ())
                                    {
                                        if (Pattern !="")
                                            pl.Add (new Pattern (Pattern,false,false,false));
                                    }
                                }
                            }
                        }
                    }

                if (n.Name.ToLower () == "childblocks")
                {
                    foreach(XmlNode cn in n.ChildNodes)
                    {
                        if (cn.Name.ToLower () =="child")
                        {
                            foreach(XmlAttribute att in cn.Attributes)
                                if (att.Name.ToLower () == "name")
                                    bl.ChildBlocks.Add (GetBlock(att.Value));
                        }
                    }
                }
            }
        }
 public void Add(Pattern item)
 {
     PatternList.Add(item);
 }
Esempio n. 7
0
        void LoadStyle(XmlElement style)
        {
            string name = style.GetAttribute("Name");
            Type type = TypeStore.Find(style.GetAttribute("Type"));
            ControlState state = (ControlState)Enum.Parse(typeof(ControlState), style.GetAttribute("State"));

            PatternList plist = new PatternList();
            List<Location> locations = new List<Location>();
            List<Path> paths = new List<Path>();

            XMLStyleLoader xl = new XMLStyleLoader();

            foreach (XmlNode child in style)
            {
                Pattern ptn = null;
                Path pth = null;
                Location loc = null;

                foreach (XmlNode child2 in child)
                {
                    if (child2.NodeType != XmlNodeType.Element)
                        continue;

                    object obj = xl.Load(child2);

                    if (obj is Pattern)
                        ptn = (Pattern)obj;
                    if (obj is Location)
                        loc = (Location)obj;
                    if (obj is Path)
                        pth = (Path)obj;
                }

                if (ptn == null)
                    continue;

                ptn.Type = (PatternType)Enum.Parse(typeof(PatternType), child.LocalName);

                plist.Add(ptn);
                paths.Add(pth);
                locations.Add(loc);
            }

            styleNames.Add(name);
            styleTypes.Add(type);
            styleStates.Add(state);
            styleOperations.Add(plist);
            styleLocations.Add(locations);
            stylePaths.Add(paths);
        }
Esempio n. 8
0
 public void AddPatern(Pattern p)
 {
     PatternList.Add(p);
 }
Esempio n. 9
0
        // A sample pattern list
        static PatternList CreatePatternList()
        {
            var patterns = new PatternList();

            var input  = new double[] { one, one, one, one, one };
            var output = new double[] { one };

            patterns.Add(input, output);

            input  = new double[] { one, one, one, one, zero };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, zero, one, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, one, one, zero, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, zero, one, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { zero, one, one, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, one, zero, one, zero };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, one };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, one };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, one };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, one };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { one, one, one, zero, zero };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { one, one, zero, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, zero, one, zero, one };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { one, one, one, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { zero, one, one, one, zero };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { one, one, zero, one, one };
            output = new double[] { one };
            patterns.Add(input, output);

            input  = new double[] { zero, one, zero, one, zero };
            output = new double[] { zero };
            patterns.Add(input, output);

            input  = new double[] { zero, zero, zero, zero, zero };
            output = new double[] { zero };
            patterns.Add(input, output);

            return(patterns);
        }