Example #1
0
 public void ForEach()
 {
     var patterns = new PatternList();
       int count = 0;
       patterns.ForEach(pattern => count++);
       Assert.AreEqual(count, patterns.Count);
 }
Example #2
0
 public void GetEnumerator()
 {
     var patterns = new PatternList();
       int count = 0;
       foreach (var pattern in patterns)
     {
       count++;
     }
       Assert.AreEqual(count, patterns.Count);
 }
Example #3
0
 public void GetPixels()
 {
     var patterns = new PatternList();
       foreach (var pattern in patterns)
     {
       int width, height, bpp, numBytes;
       pattern.GetPixels(out width, out height, out bpp, out numBytes);
       Assert.AreEqual(width * height * bpp, numBytes);
     }
 }
Example #4
0
 public void GetInfo()
 {
     var patterns = new PatternList();
       foreach (var pattern in patterns)
     {
       var info = pattern.Info;
       Assert.IsTrue(info.Width > 0);
       Assert.IsTrue(info.Height > 0);
       Assert.IsTrue(info.Bpp > 0);
     }
 }
        /// <summary>
        /// Validate Invalid WTML files.
        /// </summary>
        /// <param name="nodeName">XML node name</param>
        public static void InvalidateWTMLFiles(string nodeName, string errorMessage)
        {
            // Get Values from XML File
            string filePath = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.InputFilePath);

            // Copy Web config file in Web virtual directory.
            CopyWebConfigFile(filePath);

            // Start IEExplorer
            CommonHelperMethods.StartApplication();
            System.Threading.Thread.Sleep(5000);

            if (GetParentElement(Constants.DefaultPageName, "null"))
            {
                PatternList.ParentElement = parentElement;
            }
            if (GetChildElement(Constants.AddressBoxName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            AutomationElement addressBox = childElement;

            // Enter Url in Web browser address box..
            PatternList.DoEnterText(ConfigurationManager.AppSettings["AspxPage"]);
            System.Threading.Thread.Sleep(3000);
            PatternList.DoSendKeys("{ENTER}");
            System.Threading.Thread.Sleep(10000);

            // Get Parent Window name
            if (GetChildElement(Constants.SharingServiceWindowName, "null"))
            {
                PatternList.ParentElement = parentElement;
            }

            // Validate the error message
            if (GetChildElement(errorMessage, "null"))
            {
                PatternList.ChildElement = childElement;
            }
            System.Threading.Thread.Sleep(4000);

            Assert.AreEqual(errorMessage, childElement.Current.Name);

            // Close IE Brrowser.
            if (GetChildElement(Constants.CloseButtonName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            PatternList.DoClick();
        }
    public override void OnInspectorGUI()
    {
        //draws the default inspector gui
        //DrawDefaultInspector();

        //get the target
        LevelGeneratorScript lvl = (LevelGeneratorScript)target;

        //get the size of array in real time
        lvl.patternAmount = lvl.patternLists.Length;
        EditorGUILayout.LabelField("LEVEL GENERATOR CUSTOM EDITOR", EditorStyles.boldLabel);
        Spaces (2);
        lvl.dialogueSystem = (GameObject)EditorGUILayout.ObjectField("Dialogue", lvl.dialogueSystem, typeof(GameObject), false);
        EditorGUILayout.LabelField("Total Number of Pattern Objects: " + lvl.patternLists.Length, EditorStyles.boldLabel);
        Spaces (1);

        for(int i = 0; i < lvl.patternLists.Length; ++i)
        {
            EditorGUI.indentLevel = 1;
            EditorGUILayout.LabelField("Pattern Object " + (i + 1).ToString());
            EditorGUI.indentLevel = 2;
            lvl.patternLists[i].waitTime = EditorGUILayout.FloatField("Wait Time", lvl.patternLists[i].waitTime);
            lvl.patternLists[i].enemyPattern = (GameObject)EditorGUILayout.ObjectField("Pattern Object", lvl.patternLists[i].enemyPattern, typeof(GameObject), false);
            EditorGUI.indentLevel = 1;
            Spaces(2);
        }

        //buttons to handle the patterns list
        if(GUILayout.Button("Add Pattern Object"))
        {
            //increase the size of the array then add the new object at the end
            lvl.patternAmount += 1;
            System.Array.Resize(ref lvl.patternLists, lvl.patternAmount);
            PatternList p = new PatternList();
            lvl.patternLists[lvl.patternAmount - 1] = p;
        }
        else if(GUILayout.Button("Remove Last Pattern Object"))
        {
            //delete the final element then decrease the size of the array
            lvl.patternAmount -= 1;
            lvl.patternLists[lvl.patternAmount] = null;
            System.Array.Resize(ref lvl.patternLists, lvl.patternAmount);
        }

        //sync with original inspector
        if(GUI.changed)
        {
            EditorUtility.SetDirty(lvl);
        }
    }
Example #7
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);
            }
        }
Example #8
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);
        }
Example #9
0
    public void TryCreateRemapPattern_DecodeChunky_AsExpected(IList <string> patterns, int width, int height,
                                                              int planes, int size, IList <PlaneCoordinate> expectedDecoded, IList <int> expectedEncoded)
    {
        var result = PatternList.TryCreatePatternList(patterns, PixelPacking.Chunky, width, height, planes, size);

        result.Switch(
            success =>
        {
            var actual = Enumerable.Range(0, width * height * planes)
                         .Select(x => success.Result.GetDecodeIndex(x))
                         .ToArray();

            CollectionAssert.AreEqual(expectedDecoded, actual);
        },
            failed => Assert.Fail(failed.Reason));
    }
Example #10
0
    public void TryCreateRemapPattern_EncodePlanar_AsExpected(IList <string> patterns, int width, int height,
                                                              int planes, int size, IList <PlaneCoordinate> expectedDecoded, IList <int> expectedEncoded)
    {
        var result = PatternList.TryCreatePatternList(patterns, PixelPacking.Planar, width, height, planes, size);

        result.Switch(
            success =>
        {
            var actual = Enumerable.Range(0, planes)
                         .Cartesian(
                Enumerable.Range(0, height),
                Enumerable.Range(0, width),
                (p, y, x) => new PlaneCoordinate((short)x, (short)y, (short)p))
                         .Select(x => success.Result.GetEncodeIndex(x))
                         .ToArray();

            CollectionAssert.AreEqual(expectedEncoded, actual);
        },
            failed => Assert.Fail(failed.Reason));
    }
Example #11
0
        override public bool Execute()
        {
            // Look for script-fu-selection-to-pattern as example. The basic idea
            // is to create a new image and save it as a .pat file

            var  selection = ActiveImage.Selection;
            bool nonEmpty;
            var  bounds = selection.Bounds(out nonEmpty);
            int  width  = bounds.Width;
            int  height = bounds.Height;

            var image = new Image(width, height, ActiveImage.BaseType);
            var layer = new Layer(image, "test", width, height,
                                  ImageType.Rgb, 100,
                                  LayerModeEffects.Normal);

            image.InsertLayer(layer, 0);
            Console.WriteLine("{0} {1}", image.Width, image.Height);

            ActiveDrawable.EditCopy();
            layer.EditPaste(true);

            string filename = Gimp.Directory + System.IO.Path.DirectorySeparatorChar
                              + "patterns" + System.IO.Path.DirectorySeparatorChar +
                              _name + ".pat";

            image.Save(RunMode.Noninteractive, filename, filename);

            // Fix me: next lines should work so we can actually set the name
            // of the pattern!
            // Procedure procedure = new Procedure("file_pat_save");
            // procedure.Run(image, layer, filename, filename, _name);

            image.Delete();
            PatternList.Refresh();

            return(false);
        }
 public bool Contains(Pattern item)
 {
     return(PatternList.Contains(item));
 }
 /// <summary>
 /// Initialize the auto-implementated properties 
 /// </summary>
 private void Initialize()
 {
     Patterns = new PatternList();
     Definitions = new DefinitionList();
 }
Example #14
0
        public override void RenderControl(Control c, IGraphics g)
        {
            for (int i = 0; i < styleNames.Count; i++)
            {
                List <Location> locs  = styleLocations[i];
                List <Path>     paths = stylePaths[i];

                if (styleNames[i] != (string)c.Style)
                {
                    continue;
                }
                if (styleTypes[i] != c.GetType())
                {
                    if ((c.GetType().Assembly == Assembly.GetExecutingAssembly()) || !c.GetType().IsSubclassOf(styleTypes[i]))
                    {
                        continue;
                    }
                }
                if ((styleStates[i] & c.State) != styleStates[i])
                {
                    continue;
                }

                PatternList plist = styleOperations[i];

                for (int j = 0; j < plist.Count; j++)
                {
                    g.Save();

                    Path path = (paths[j] != null) ? paths[j].Clone() : c.Path.Clone();
                    path.Control = c;

                    if (locs[j] != null)
                    {
                        // This is a little hackish, but I can't think of a better way
                        // Without reworking major chunks of the geometry classes

                        Control tmp = new Control();
                        tmp.Path     = path;
                        tmp.Parent   = c;
                        path.Control = tmp;

                        Location loc = locs[j].Clone();
                        loc.Control = tmp;

                        g.Translate(loc.RealL, loc.RealT);
                        loc.HandleRel();

                        path       = tmp.Path.ClonePixels();
                        tmp.Parent = null;
                    }

                    path.Apply(g);

                    plist[j].Apply(g, path.W, path.H);

                    if (plist[j].Type == PatternType.Fill)
                    {
                        g.Fill();
                    }
                    else
                    {
                        g.Stroke();
                    }

                    g.Restore();
                }
            }
        }
 /// <summary>
 /// Default constructor.
 /// 
 /// Not important as this class can never be created. 
 /// However all lower level patterns will bypass this constructor
 /// </summary>
 /// <param name="name">Name of the pattern.</param>
 internal PatternComplex(String name)
     : base(name) 
 {
     Patterns = new PatternList();
 }
 public void Clear()
 {
     PatternList.Clear();
 }
 public void RemoveAt(int index)
 {
     PatternList.RemoveAt(index);
 }
 public void Insert(int index, Pattern item)
 {
     PatternList.Insert(index, item);
 }
Example #19
0
        public uint GetContentVersion() => default;     // 0x00AEB2C0-0x00AEB2D0

        public Result CheckProfanityWords(out PatternList[] checkResults, PatternList patterns, string[] words)
        {
            checkResults = default;
            return(default);
Example #20
0
 public void AddPatern(Pattern p)
 {
     PatternList.Add(p);
 }
Example #21
0
 public void CountNone()
 {
     // Test for non-existing patterns
       var patterns = new PatternList("nonsense");
       Assert.AreEqual(0, patterns.Count);
 }
Example #22
0
 public void CountAllTwo()
 {
     var patterns = new PatternList();
       Assert.IsTrue(patterns.Count > 0);
 }
 public void CopyTo(Pattern[] array, int arrayIndex)
 {
     PatternList.CopyTo(array, arrayIndex);
 }
 public int IndexOf(Pattern item)
 {
     return(PatternList.IndexOf(item));
 }
Example #25
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 bool Remove(Pattern item)
 {
     return(PatternList.Remove(item));
 }
 private static extern Result CheckProfanityWords(
     IntPtr profanityFilter, [Out] PatternList[] checkResults, PatternList patterns,
     [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr)]
     string[] words, long wordCount);
 IEnumerator <Pattern> IEnumerable <Pattern> .GetEnumerator()
 {
     return(PatternList.GetEnumerator());
 }
 public Result CheckProfanityWords([Out] PatternList[] checkResults, PatternList patterns, string[] words)
 {
     return(CheckProfanityWords(_profanityFilter, checkResults, patterns, words, words.Length));
 }
Example #30
0
        private void UpdateDisplay()
        {
            _updating = true;
            PatternList.SuspendLayout();

            int oldIndex = PatternList.SelectedIndex;

            if (oldIndex == -1)
            {
                oldIndex = 0;
            }

            PatternList.Items.Clear();
            int index = 0;

            for (int i = 0; i < counts.Count; i++)
            {
                string str = index.ToString() + ": ";
                if (isBool)
                {
                    str += values[i][0] == 'T' ? "On" : "Off";
                }
                else
                {
                    str += values[i].ToString();
                }

                PatternList.Items.Add(str + ("\t(x" + counts[i] + ")"));
                index += counts[i];
            }
            PatternList.Items.Add("Loop to: " + loopAt);

            if (oldIndex >= PatternList.Items.Count)
            {
                oldIndex = PatternList.Items.Count - 1;
            }
            PatternList.SelectedIndex = oldIndex;

            if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < values.Count)
            {
                index = Global.MovieSession.MovieControllerAdapter.Definition.BoolButtons.IndexOf(selectedButton);
                if (selectedButton == "Default bool Auto-Fire")
                {
                    index = tastudio.BoolPatterns.Length + 1;
                }
                if (index != -1)
                {
                    LagBox.Checked   = tastudio.BoolPatterns[index].SkipsLag;
                    OnOffBox.Checked = values[PatternList.SelectedIndex][0] == 'T';
                    CountNum.Value   = (decimal)counts[PatternList.SelectedIndex];
                }
                else
                {
                    if (selectedButton == "Default float Auto-Fire")
                    {
                        index = tastudio.FloatPatterns.Length + 1;
                    }
                    else
                    {
                        index = Global.MovieSession.MovieControllerAdapter.Definition.FloatControls.IndexOf(selectedButton);
                    }

                    LagBox.Checked = tastudio.FloatPatterns[index].SkipsLag;
                    ValueNum.Value = Convert.ToDecimal(values[PatternList.SelectedIndex]);
                    CountNum.Value = (decimal)counts[PatternList.SelectedIndex];
                }
            }
            else if (PatternList.SelectedIndex == values.Count)
            {
                CountNum.Value = (decimal)loopAt;
            }

            PatternList.ResumeLayout();
            _updating = false;
        }
Example #31
0
 public void SetPattern(PatternList pattern)
 {
     Pattern = pattern;
 }
Example #32
0
        private ScanResult_Word GetNextComplexWord(String Text, Segment CurrentSegment, int StartPositon)
        {
            if (StartPositon >= Text.Length)
            {
                return(new ScanResult_Word());
            }

            ScanResult_Word Result = new ScanResult_Word();

            int CurrentPosition = 0;

            //look for keywords


            PatternListList keywordsList = CurrentSegment.BlockType.KeywordsList;

            PatternList List = null;

            for (int i = 0; i < keywordsList.Count; i++)
            {
                List = keywordsList[i];

                PatternCollection complexPatterns = List.ComplexPatterns;

                Pattern Word = null;

                for (int j = 0; j < complexPatterns.Count; j++)
                {
                    Word = complexPatterns[j];

                    PatternScanResult psr = Word.IndexIn(Text, StartPositon, false, Separators);
                    CurrentPosition = psr.Index;
                    if ((CurrentPosition < Result.Position || Result.HasContent == false) && psr.Token != "")
                    {
                        Result.HasContent = true;
                        Result.Position   = CurrentPosition;
                        Result.Token      = psr.Token;
                        Result.Pattern    = Word;
                        Result.ParentList = List;

                        if (List.NormalizeCase)
                        {
                            if (!Word.IsComplex)
                            {
                                Result.Token = Word.StringPattern;
                            }
                        }
                    }
                }
            }

            //look for operators

            PatternListList pattList = CurrentSegment.BlockType.OperatorsList;


            PatternList patternList = null;

            for (int i = 0; i < pattList.Count; i++)
            {
                patternList = pattList[i];

                PatternCollection complexPatterns = patternList.ComplexPatterns;

                for (int j = 0; j < complexPatterns.Count; j++)
                {
                    Pattern Word = complexPatterns[j];

                    PatternScanResult psr = Word.IndexIn(Text, StartPositon, false, Separators);

                    CurrentPosition = psr.Index;

                    if ((CurrentPosition < Result.Position || Result.HasContent == false) && psr.Token != "")
                    {
                        Result.HasContent = true;
                        Result.Position   = CurrentPosition;
                        Result.Token      = psr.Token;
                        Result.Pattern    = Word;
                        Result.ParentList = patternList;

                        if (patternList.NormalizeCase)
                        {
                            if (!Word.IsComplex)
                            {
                                Result.Token = Word.StringPattern;
                            }
                        }
                    }
                }
            }

            if (Result.HasContent)
            {
                return(Result);
            }
            else
            {
                return(new ScanResult_Word());
            }
        }
 public void Add(Pattern item)
 {
     PatternList.Add(item);
 }
Example #34
0
        private void UpdateDisplay()
        {
            _updating = true;
            PatternList.SuspendLayout();

            int oldIndex = PatternList.SelectedIndex;

            if (oldIndex == -1)
            {
                oldIndex = 0;
            }

            PatternList.Items.Clear();
            int index = 0;

            for (int i = 0; i < _counts.Count; i++)
            {
                string str = $"{index}: ";
                if (IsBool)
                {
                    str += _values[i][0] == 'T' ? "On" : "Off";
                }
                else
                {
                    str += _values[i];
                }

                PatternList.Items.Add($"{str}\t(x{_counts[i]})");
                index += _counts[i];
            }

            PatternList.Items.Add($"Loop to: {_loopAt}");

            if (oldIndex >= PatternList.Items.Count)
            {
                oldIndex = PatternList.Items.Count - 1;
            }

            PatternList.SelectedIndex = oldIndex;

            if (PatternList.SelectedIndex != -1 && PatternList.SelectedIndex < _values.Count)
            {
                index = _tastudio.MovieSession.MovieController.Definition.BoolButtons.IndexOf(SelectedButton);
                if (SelectedButton == "Default bool Auto-Fire")
                {
                    index = _tastudio.BoolPatterns.Length - 1;
                }

                if (index != -1)
                {
                    LagBox.Checked   = _tastudio.BoolPatterns[index].SkipsLag;
                    OnOffBox.Checked = _values[PatternList.SelectedIndex][0] == 'T';
                    CountNum.Value   = _counts[PatternList.SelectedIndex];
                }
                else
                {
                    if (SelectedButton == "Default float Auto-Fire")
                    {
                        index = _tastudio.AxisPatterns.Length - 1;
                    }
                    else
                    {
                        index = _tastudio.MovieSession.MovieController.Definition.AxisControls.IndexOf(SelectedButton);
                    }

                    LagBox.Checked = _tastudio.AxisPatterns[index].SkipsLag;
                    ValueNum.Value = Convert.ToDecimal(_values[PatternList.SelectedIndex]);
                    CountNum.Value = _counts[PatternList.SelectedIndex];
                }
            }
            else if (PatternList.SelectedIndex == _values.Count)
            {
                CountNum.Value = _loopAt;
            }

            PatternList.ResumeLayout();
            _updating = false;
        }
        /// <summary>
        /// General method to validate WTML files
        /// </summary>
        /// <param name="nodeName">Xml NodeName</param>
        /// <param name="isDemFile">Check For Dem File</param>
        /// <param name="isPlatFile">Check Foe Plat File</param>
        public static void ValidateWTMLTagAndDownloadFiles(string nodeName, bool isDemFile, bool isPlatFile)
        {
            // Get Values from XML File
            string filePath            = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.InputFilePath);
            string outputFile          = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.OutputWTMLFile1Node);
            string tagsNode            = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.TagsNode);
            string filesCount          = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.GridItemsNode);
            string demCheck            = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.DemCheckNode);
            string checkTileImage      = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.CheckTileNode);
            string thumbNailUrlCheck   = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.ThumbanailImageValue);
            string thumbNailWindowName = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.ThumbnailImageWindowname);
            string sourceLocationText  = utilityObj.XmlUtil.GetTextValue(nodeName, Constants.SourceLocationNode);

            // Copy Web config file in Web virtual directory.
            CopyWebConfigFile(filePath);

            // Start IEExplorer
            CommonHelperMethods.StartApplication();
            System.Threading.Thread.Sleep(5000);
            if (GetParentElement(Constants.DefaultPageName, "null"))
            {
                PatternList.ParentElement = parentElement;
            }
            if (GetChildElement(Constants.AddressBoxName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            AutomationElement addressBox = childElement;

            // Enter Url in Web browser address box..
            PatternList.DoEnterText(ConfigurationManager.AppSettings["AspxPage"]);
            System.Threading.Thread.Sleep(3000);
            PatternList.DoSendKeys("{ENTER}");
            System.Threading.Thread.Sleep(16000);

            if (GetParentElement(Constants.SharingServiceWindowName, "null"))
            {
                PatternList.ParentElement = parentElement;
            }

            ////  Download WTML file on Local machine and validate
            if (GetChildElement("WWT - Tile Service Sample", "null"))
            {
                PatternList.ChildElement = childElement;
            }

            System.Threading.Thread.Sleep(2000);

            // Do tabs to find the dowload button.
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{TAB}");
            PatternList.DoSendKeys("{ENTER}");

            ////  PatternList.DoClick();
            System.Threading.Thread.Sleep(4000);

            if (GetChildElement(Constants.SaveButtonName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            string currentDir            = Directory.GetCurrentDirectory();
            string updatedOutputWTMLPath = Path.Combine(currentDir + outputFile);

            // Get download button
            AutomationElementCollection downlodWTMLButton =
                childElement.FindAll(TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.SplitButton));

            PatternList.ChildElement = downlodWTMLButton[0];

            PatternList.DoClick();
            System.Threading.Thread.Sleep(2000);
            PatternList.DoSendKeys("{DOWN}");
            PatternList.DoSendKeys("{ENTER}");

            System.Threading.Thread.Sleep(4000);
            PatternList.DoSendKeys(updatedOutputWTMLPath);
            System.Threading.Thread.Sleep(2000);
            PatternList.DoSendKeys("{ENTER}");

            // Validate whether the WTML file is downloaded on local machine.
            Assert.IsTrue(File.Exists(updatedOutputWTMLPath));

            // Validate Urls of WTML file.
            ValidateWTMLUrls(updatedOutputWTMLPath, nodeName, isDemFile);

            // Close download PopUp.
            if (GetChildElement(Constants.CloseButtonName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            PatternList.DoClick();

            System.Threading.Thread.Sleep(7000);

            PatternList.ChildElement = addressBox;
            if (isDemFile)
            {
                // Enter Url in Web browser.
                PatternList.DoEnterText(checkTileImage);
                System.Threading.Thread.Sleep(3000);
                PatternList.DoSendKeys("{ENTER}");
                System.Threading.Thread.Sleep(3000);
                PatternList.DoEnterText(thumbNailUrlCheck);
                System.Threading.Thread.Sleep(3000);
                PatternList.DoSendKeys("{ENTER}");
                System.Threading.Thread.Sleep(10000);
                PatternList.ChildElement = addressBox;
                PatternList.DoEnterText(demCheck);
                System.Threading.Thread.Sleep(3000);
                PatternList.DoSendKeys("{ENTER}");

                // Close IE Brrowser.
                if (GetChildElement(Constants.CloseButtonName, "null"))
                {
                    PatternList.ChildElement = childElement;
                }

                PatternList.DoClick();
            }
            else if (isPlatFile)
            {
                // Enter Url in Web browser.
                PatternList.DoEnterText(checkTileImage);
                System.Threading.Thread.Sleep(3000);
                PatternList.DoSendKeys("{ENTER}");
                System.Threading.Thread.Sleep(8000);

                if (GetChildElement(thumbNailWindowName, "null"))
                {
                    PatternList.ChildElement = childElement;
                }
            }

            System.Threading.Thread.Sleep(6000);

            // Close IE Brrowser.
            if (GetChildElement(Constants.CloseButtonName, "null"))
            {
                PatternList.ChildElement = childElement;
            }

            PatternList.DoClick();
        }
        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));
                                }
                            }
                        }
                    }
                }
            }
        }
Example #37
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);
        }
 private static extern Result MaskProfanityWordsInText(
     IntPtr profanityFilter, ref int profanityWordCount,
     string text, PatternList patterns);
 public IEnumerator GetEnumerator()
 {
     return(PatternList.GetEnumerator());
 }
        public Result MaskProfanityWordsInText(ref int profanityWordCount, string inText, out string outText, PatternList patterns)
        {
            outText = string.Copy(inText);
            Result result = MaskProfanityWordsInText(_profanityFilter, ref profanityWordCount, outText, patterns);

            outText = outText.TrimEnd('\0');
            return(result);
        }
Example #41
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);
        }