예제 #1
0
        public void TestBoolParameters()
        {
            TagText tagText = new TagText();

            tagText.Load("<a b=true c=True d=false e=False>TEST</a>");

            Assert.AreEqual("TEST", tagText.Text);

            foreach (TagText.Node node in tagText.Nodes)
            {
                TagText.Parameter b = node.Parameters[0];
                Assert.AreEqual("b", b.Name);
                Assert.AreEqual("true", b.Value);
                Assert.AreEqual(true, b.GetBool());

                TagText.Parameter c = node.Parameters[1];
                Assert.AreEqual("c", c.Name);
                Assert.AreEqual("True", c.Value);
                Assert.AreEqual(true, c.GetBool());

                TagText.Parameter d = node.Parameters[2];
                Assert.AreEqual("d", d.Name);
                Assert.AreEqual("false", d.Value);
                Assert.AreEqual(false, d.GetBool());

                TagText.Parameter e = node.Parameters[3];
                Assert.AreEqual("e", e.Name);
                Assert.AreEqual("False", e.Value);
                Assert.AreEqual(false, e.GetBool());
            }
        }
예제 #2
0
        public string TestText(string _Text)
        {
            TagText tagText = new TagText();

            tagText.Load(_Text);
            return(tagText.Text);
        }
예제 #3
0
        public void TestIntegerParameters()
        {
            TagText tagText = new TagText();

            tagText.Load("<a b=0 c=-1 d=1>TEST</a>");

            Assert.AreEqual("TEST", tagText.Text);

            foreach (TagText.Node node in tagText.Nodes)
            {
                TagText.Parameter b = node.Parameters[0];
                Assert.AreEqual("b", b.Name);
                Assert.AreEqual("0", b.Value);
                Assert.AreEqual(0, b.GetInteger());

                TagText.Parameter c = node.Parameters[1];
                Assert.AreEqual("c", c.Name);
                Assert.AreEqual("-1", c.Value);
                Assert.AreEqual(-1, c.GetInteger());

                TagText.Parameter d = node.Parameters[2];
                Assert.AreEqual("d", d.Name);
                Assert.AreEqual("1", d.Value);
                Assert.AreEqual(1, d.GetInteger());
            }
        }
예제 #4
0
    public void SetHashTags(List <string> tags)
    {
        if (BindedLine.IsDone || BindedLine.Tree == null || BindedLine.Tree.TagHeapManager == null)
        {
            return;
        }

        List <TagText> removeList = new List <TagText>();

        foreach (TagText tagText in tagTexts_)
        {
            if (tags.Find((string t) => "#" + t == tagText.Text) == null)
            {
                removeList.Add(tagText);
            }
        }
        foreach (TagText removeText in removeList)
        {
            tagTexts_.Remove(removeText);
            BindedLine.Tree.TagHeapManager.BackToHeap(removeText);
        }
        foreach (string tag in tags)
        {
            if (tagTexts_.Find((TagText t) => t.Text == "#" + tag) == null)
            {
                TagText tagText = BindedLine.Tree.TagHeapManager.Instantiate(this.transform);
                tagText.Text = "#" + tag;
                tagText.Rect.anchoredPosition = Vector2.zero;
                tagText.gameObject.SetActive(isFocused == false);
                tagText.TextComponent.fontStyle = BindedLine.IsBold ? FontStyle.Bold : FontStyle.Normal;
                tagTexts_.Add(tagText);
                OnTextLengthChanged();
            }
        }
    }
예제 #5
0
        public bool Equals(TagMetadataItem input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Description == input.Description ||
                     (Description != null && Description.Equals(input.Description))
                     ) &&
                 (
                     TagText == input.TagText ||
                     (TagText != null && TagText.Equals(input.TagText))
                 ) &&
                 (
                     Groups == input.Groups ||
                     (Groups != null && Groups.SequenceEqual(input.Groups))
                 ) &&
                 (
                     IsDefault == input.IsDefault ||
                     (IsDefault != null && IsDefault.Equals(input.IsDefault))
                 ) &&
                 (
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                 ));
        }
예제 #6
0
        public void TestFloatParameters()
        {
            TagText tagText = new TagText();

            tagText.Load("<a b=0.0 c=-1.1 d=1.1>TEST</a>");

            Assert.AreEqual("TEST", tagText.Text);

            foreach (TagText.Node node in tagText.Nodes)
            {
                TagText.Parameter b = node.Parameters[0];
                Assert.AreEqual("b", b.Name);
                Assert.AreEqual("0.0", b.Value);
                Assert.AreEqual(0.0f, b.GetFloat());

                TagText.Parameter c = node.Parameters[1];
                Assert.AreEqual("c", c.Name);
                Assert.AreEqual("-1.1", c.Value);
                Assert.AreEqual(-1.1f, c.GetFloat());

                TagText.Parameter d = node.Parameters[2];
                Assert.AreEqual("d", d.Name);
                Assert.AreEqual("1.1", d.Value);
                Assert.AreEqual(1.1f, d.GetFloat());
            }
        }
예제 #7
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            string text = TagText.Text?.Trim();

            if (!string.IsNullOrEmpty(text))
            {
                AddTag(text);
            }

            TagText.Text = null;
            TagText.Focus();
        }
예제 #8
0
    public void IncrementalSearch(string text)
    {
        // いらないやつを消す
        foreach (TagText tagText in searchResults_)
        {
            if (tagText.Text.StartsWith("#" + text) == false || tagText.Text == "#" + text)
            {
                tagTextHeapManager_.BackToHeap(tagText);
            }
        }

        // 新しいやつを足す
        foreach (TagParent tagParent in GameContext.TagList)
        {
            if (string.IsNullOrEmpty(text) || (tagParent.Tag.StartsWith(text) && tagParent.Tag != text))
            {
                if (searchResults_.Find((t) => t.Text == "#" + tagParent.Tag) == null)
                {
                    TagText tagText = tagTextHeapManager_.Instantiate(LayoutParent.transform);
                    tagText.Text = "#" + tagParent.Tag;
                    searchResults_.Add(tagText);
                }
            }
        }
        foreach (string reservedTag in ReservedTags)
        {
            if (string.IsNullOrEmpty(text) || (reservedTag.StartsWith(text) && reservedTag != text))
            {
                if (searchResults_.Find((t) => t.Text == "#" + reservedTag) == null)
                {
                    TagText tagText = tagTextHeapManager_.Instantiate(LayoutParent.transform);
                    tagText.Text = "#" + reservedTag;
                    searchResults_.Add(tagText);
                }
            }
        }

        searchResults_.RemoveAll((TagText tagText) => tagText.gameObject.activeSelf == false);
        SortSeachResult();

        if (searchResults_.Count == 0)
        {
            Close();
        }
        else
        {
            selectedIndex_ = 0;
            UpdateLayout();
            OnTextLengthChanged();
        }
    }
예제 #9
0
    void SortSeachResult()
    {
        int index = 0;

        foreach (TagParent tagParent in GameContext.TagList)
        {
            TagText tagText = searchResults_.Find((TagText tt) => tt.Text == "#" + tagParent.Tag);
            if (tagText != null)
            {
                tagText.transform.SetSiblingIndex(index);
                ++index;
            }
        }
    }
예제 #10
0
        public bool Equals(GroupQuery input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     Name == input.Name ||
                     (Name != null && Name.Equals(input.Name))
                     ) &&
                 (
                     GroupType == input.GroupType ||
                     (GroupType != null && GroupType.Equals(input.GroupType))
                 ) &&
                 (
                     CreationDate == input.CreationDate ||
                     (CreationDate != null && CreationDate.Equals(input.CreationDate))
                 ) &&
                 (
                     SortBy == input.SortBy ||
                     (SortBy != null && SortBy.Equals(input.SortBy))
                 ) &&
                 (
                     GroupMemberCountFilter == input.GroupMemberCountFilter ||
                     (GroupMemberCountFilter.Equals(input.GroupMemberCountFilter))
                 ) &&
                 (
                     LocaleFilter == input.LocaleFilter ||
                     (LocaleFilter != null && LocaleFilter.Equals(input.LocaleFilter))
                 ) &&
                 (
                     TagText == input.TagText ||
                     (TagText != null && TagText.Equals(input.TagText))
                 ) &&
                 (
                     ItemsPerPage == input.ItemsPerPage ||
                     (ItemsPerPage.Equals(input.ItemsPerPage))
                 ) &&
                 (
                     CurrentPage == input.CurrentPage ||
                     (CurrentPage.Equals(input.CurrentPage))
                 ) &&
                 (
                     RequestContinuationToken == input.RequestContinuationToken ||
                     (RequestContinuationToken != null && RequestContinuationToken.Equals(input.RequestContinuationToken))
                 ));
        }
예제 #11
0
    public void Show(Vector2 position, string text = null)
    {
        if (rect_ == null)
        {
            Initialize();
        }
        rect_.anchoredPosition = position;
        this.gameObject.SetActive(true);
        selectedIndex_ = 0;
        UpdateLayout();

        searchResults_.Clear();
        foreach (TagParent tagParent in GameContext.TagList)
        {
            if (string.IsNullOrEmpty(text) || (tagParent.Tag.StartsWith(text) && tagParent.Tag != text))
            {
                if (searchResults_.Find((t) => t.Text == "#" + tagParent.Tag) == null)
                {
                    TagText tagText = tagTextHeapManager_.Instantiate(LayoutParent.transform);
                    tagText.Text = "#" + tagParent.Tag;
                    searchResults_.Add(tagText);
                }
            }
        }
        foreach (string reservedTag in ReservedTags)
        {
            if (string.IsNullOrEmpty(text) || (reservedTag.StartsWith(text) && reservedTag != text))
            {
                if (searchResults_.Find((t) => t.Text == "#" + reservedTag) == null)
                {
                    TagText tagText = tagTextHeapManager_.Instantiate(LayoutParent.transform);
                    tagText.Text = "#" + reservedTag;
                    searchResults_.Add(tagText);
                }
            }
        }
        SortSeachResult();

        if (searchResults_.Count > 0)
        {
            OnTextLengthChanged();
        }
        else
        {
            Close();
        }
    }
예제 #12
0
        public bool Equals(TagResponse input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     TagText == input.TagText ||
                     (TagText != null && TagText.Equals(input.TagText))
                     ) &&
                 (
                     IgnoreStatus == input.IgnoreStatus ||
                     (IgnoreStatus != null && IgnoreStatus.Equals(input.IgnoreStatus))
                 ));
        }
예제 #13
0
        public void TestColorParameters()
        {
            TagText tagText = new TagText();

            tagText.Load("<a b=#FFFFFFFF c=#000000FF d=#FF0000FF e=#00FF00FF f=#0000FFFF>TEST</a>");

            Assert.AreEqual("TEST", tagText.Text);

            foreach (TagText.Node node in tagText.Nodes)
            {
                TagText.Parameter white = node.Parameters[0];
                Assert.AreEqual("b", white.Name);
                Assert.AreEqual("#FFFFFFFF", white.Value);
                Assert.AreEqual(Color.white, white.GetColor());

                TagText.Parameter black = node.Parameters[1];
                Assert.AreEqual("c", black.Name);
                Assert.AreEqual("#000000FF", black.Value);
                Assert.AreEqual(Color.black, black.GetColor());

                TagText.Parameter red = node.Parameters[2];
                Assert.AreEqual("d", red.Name);
                Assert.AreEqual("#FF0000FF", red.Value);
                Assert.AreEqual(Color.red, red.GetColor());

                TagText.Parameter green = node.Parameters[3];
                Assert.AreEqual("e", green.Name);
                Assert.AreEqual("#00FF00FF", green.Value);
                Assert.AreEqual(Color.green, green.GetColor());

                TagText.Parameter blue = node.Parameters[4];
                Assert.AreEqual("f", blue.Name);
                Assert.AreEqual("#0000FFFF", blue.Value);
                Assert.AreEqual(Color.blue, blue.GetColor());
            }
        }
        /// <summary>
        /// Saves new item.
        /// </summary>
        public async Task SaveAsync()
        {
            var tags      = TagText.Split(',');
            var itemToAdd = new Item()
            {
                Text        = Name,
                Description = Description
            };

            foreach (var tag in tags)
            {
                itemToAdd.Tags.Add(new Tag()
                {
                    Id   = Guid.NewGuid(),
                    Name = tag
                });
            }

            await Repository.CreateAsync(itemToAdd);

            await Repository.SaveAsync();

            await Application.Current.MainPage.Navigation.PopModalAsync();
        }
        public TagText CreateTag(string name)
        {
            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var tag = new TagText { Name = name };

                    SetAudit(tag);
                    session.SaveOrUpdate(tag);
                    transaction.Commit();

                    return tag;
                }
            }
        }
        public static string CreateContents(string nameSpace, string className, string classDefaultInherit, List <TemplateObject> templateObjectList, string templateName)
        {
            StringBuilder result         = new StringBuilder();
            int           currentIndent  = 0;
            int           indentIncrease = 4;

            // Check if this is a special case like Core.cst where there is only one TagText
            // in the whole templateObjectList.
            if (templateObjectList.Count == 1 &&
                templateObjectList[0].TagType == typeof(TagText))
            {
                TagText tText = (TagText)templateObjectList[0].Object;

                // Check if a namespace is defined somewhere, then ignore this
                if (Regex.Matches(tText.Text, @"^namespace\s+\w+\s*$").Count == 0)
                {
                    // Find using statement and i3 the namespace should be inserted
                    MatchCollection mc = Regex.Matches(tText.Text, RegExConstants.RE_CS_USINGSTATEMENTS);

                    // Must be only one match
                    if (mc.Count == 1)
                    {
                        result.Append(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_USING].Value);

                        // Add namespace tag
                        result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

                        currentIndent += indentIncrease;

                        result.AppendLine(BreakLinesAndOutput(mc[0].Groups[RegExConstants.RE_CS_USINGSTATEMENTS_RESTOFFILE].Value, currentIndent));

                        currentIndent -= indentIncrease;

                        result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

                        return(result.ToString());
                    }
                }
            }

            // Create the using statements
            TagImport tagImport = GetTemplateObject <TagImport>(templateObjectList);

            bool usingSystem = false;
            bool usingSystemCollectionsGeneric = false;
            bool usingCodesmithEngine          = false;

            while (tagImport != null)
            {
                result.AppendLine(TemplateCreateUsingPart(tagImport, currentIndent));

                if (tagImport.Namespace.Equals("System", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystem = true;
                }

                if (tagImport.Namespace.Equals("System.Collections.Generic", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingSystemCollectionsGeneric = true;
                }

                if (tagImport.Namespace.Equals("CodeSmith.Engine", StringComparison.CurrentCultureIgnoreCase))
                {
                    usingCodesmithEngine = true;
                }

                tagImport = GetTemplateObject <TagImport>(templateObjectList);
            }

            // Add System and System.Collections.Generic

            if (!usingSystem)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System"), currentIndent));
            }

            if (!usingSystemCollectionsGeneric)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("System.Collections.Generic"), currentIndent));
            }

            if (!usingCodesmithEngine)
            {
                result.AppendLine(TemplateCreateUsingPart(new TagImport("CodeSmith.Engine"), currentIndent));
            }

            result.AppendLine();

            // Create namespace tag
            result.AppendLine(TemplateCreateNamespacePart(nameSpace, currentIndent));

            currentIndent += indentIncrease;

            // Find the CodeTemplate object in list
            TagCodeTemplate tagCodeTemplate = GetTemplateObject <TagCodeTemplate>(templateObjectList);

            if (tagCodeTemplate != null &&
                tagCodeTemplate.Inherits != string.Empty)
            {
                result.AppendLine(TemplateCreateClassPart(className, tagCodeTemplate.Inherits, currentIndent));
            }
            else
            {
                result.AppendLine(TemplateCreateClassPart(className, classDefaultInherit, currentIndent));
            }

            currentIndent += indentIncrease;

            // Create the properties
            TagProperty tagProperty = GetTemplateObject <TagProperty>(templateObjectList);

            while (tagProperty != null)
            {
                result.AppendLine(TemplateCreateProperty(tagProperty.Name, tagProperty.Type, currentIndent));

                tagProperty = GetTemplateObject <TagProperty>(templateObjectList);
            }

            result.AppendLine();

            StringBuilder __text = new StringBuilder();

            result.AppendLine(string.Format("{0}public override string OriginalTemplateName {{ get {{ return @\"{1}\"; }} }}\r\n", GetIndent(currentIndent), templateName));

            string templateComment = @"Generated from template: " + templateName;

            // Override the Render function
            result.AppendLine(string.Format("{0}public override void Render()\r\n{0}{{\r\n{1}TagFile(@\"{2}\");", GetIndent(currentIndent), GetIndent(currentIndent + indentIncrease), templateComment));

            // Find all TagCSharp and TagText items and create the code from that
            for (int i = 0; i < templateObjectList.Count; i++)
            {
                TemplateObject obj = templateObjectList[i];

                if (obj.TagType == typeof(TagCSharp))
                {
                    result.Append(BreakLinesAndOutput(((TagCSharp)obj.Object).Code, currentIndent));
                }
                else if ((obj.TagType == typeof(TagText)) || (obj.TagType == typeof(TagParameter)))
                {
                    int lookAheadIndex = i + 1;

                    while (lookAheadIndex < templateObjectList.Count)
                    {
                        if ((templateObjectList[lookAheadIndex].TagType == typeof(TagText)) || (templateObjectList[lookAheadIndex].TagType == typeof(TagParameter)))
                        {
                            lookAheadIndex++;
                        }
                        else
                        {
                            break;
                        }
                    }

                    // idx points to the next code fragment i.e. not Text or parameters

                    // create single string.format using the text and parameters
                    // advance i to skip ahead

                    // Do string replace " to "" and the other first ?? togr

                    string argumentList      = string.Empty;
                    int    stringFormatIndex = 0;

                    for (int i2 = i; i2 < lookAheadIndex; i2++)
                    {
                        argumentList = string.Concat(argumentList, string.Format("{{{0}}}", stringFormatIndex));
                        stringFormatIndex++;
                    }

                    StringBuilder code = new StringBuilder();
                    code.AppendLine(string.Format("__text.AppendFormat(\"{0}\\r\\n\"", argumentList));

                    for (int i3 = i; i3 < lookAheadIndex; i3++)
                    {
                        if (templateObjectList[i3].TagType == typeof(TagText))
                        {
                            TagText tText = (TagText)templateObjectList[i3].Object;

                            // Convert text. Change all " to ""
                            tText.Text = tText.Text.Replace("\"", "\"\"");

                            // Remove all consecutive \n and also all \n that is occuring alone not after a \r
                            tText.Text = Regex.Replace(tText.Text, "((?<=[^\r])\n)|(\n{2,})", string.Empty);
                            code.AppendLine(string.Format(",@\"{0}\"", tText.Text));
                        }
                        else
                        {
                            TagParameter tParam = (TagParameter)templateObjectList[i3].Object;
                            code.AppendLine(string.Format(",{0}", tParam.Parameter));
                        }
                    }

                    code.AppendLine(");");

                    result.Append(string.Format("{0}{1}", GetIndent(currentIndent), code.ToString()));
                    i = lookAheadIndex - 1;
                }
            }

            result.AppendLine(string.Format("{0}return;", GetIndent(currentIndent + indentIncrease)));

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine();

            // Add the script section the properties
            TagScript tagScript = GetTemplateObject <TagScript>(templateObjectList);

            while (tagScript != null)
            {
                result.AppendLine(tagScript.Text);

                tagScript = GetTemplateObject <TagScript>(templateObjectList);
            }

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            currentIndent -= indentIncrease;

            result.AppendLine(string.Format("{0}}}", GetIndent(currentIndent)));

            return(result.ToString());
        }
예제 #17
0
    void ProcessCharacters()
    {
        Scale = 1;

        if (m_TagText == null)
        {
            m_TagText = new TagText();
        }

        m_TagText.Load(Text);

        if (m_Lines == null)
        {
            m_Lines = new List <BitmapLine>();
        }
        else
        {
            m_Lines.Clear();
        }

        if (m_Characters == null)
        {
            m_Characters = new List <BitmapCharacter>();
        }

        int delta = m_TagText.Text.Length - m_Characters.Count;

        for (int i = 0; i < delta; i++)
        {
            m_Characters.Add(new BitmapCharacter());
        }

        for (int i = 0; i < m_Characters.Count; i++)
        {
            if (m_Characters[i] == null)
            {
                m_Characters[i] = new BitmapCharacter();
            }

            BitmapCharacter character = m_Characters[i];

            character.Index   = -1;
            character.Enabled = false;
            character.Visible = false;
            character.Tint    = Color.white;
            character.Offset  = Vector2.zero;
        }

        List <BitmapCharacter> line = new List <BitmapCharacter>();
        int index = 0;

        for (int i = 0; i < m_TagText.Text.Length; i++)
        {
            if (m_TagText.Text[i] == '\n')
            {
                m_Lines.Add(new BitmapLine(line));
                line.Clear();

                index++;
                continue;
            }

            BitmapCharacter character = m_Characters[index];

            character.Index     = i;
            character.Enabled   = true;
            character.Character = m_TagText.Text[i];

            BitmapGlyph glyph = Font.GetGlyph(character.Character);
            if (glyph != null)
            {
                Rect glyphRect = glyph.Rect;
                character.Visible        = true;
                character.Rect           = glyphRect.Scale(CharSize);
                character.BaselineOffset = glyph.Offset * CharSize;
                character.LineHeight     = Font.Ascender * CharSize;
                character.UV             = glyph.UV;
                character.Color          = color;
            }
            else if (character.Character == ' ')
            {
                Rect glyphRect = new Rect(0, 0, Font.SpaceWidth, 0);

                character.Visible = false;
                character.Rect    = glyphRect.Scale(CharSize);
            }

            line.Add(character);

            index++;
        }
        m_Lines.Add(new BitmapLine(line));
        line.Clear();
    }
 public static ListingTagTextViewModel Map(ListingTagTextViewModel viewModel, TagText entity)
 {
     return Mapper.Map(entity, viewModel);
 }