Beispiel #1
0
        public static TextElements Eliminate(TextElements items, object expressions, bool issecondary = true)
        {
            int total      = 0;
            int totalcount = items.Count;

            for (int i = 0; i < items.Count; i++)
            {
                bool result = false;
                if (issecondary)
                {
                    result = XExpressionSuccess(items[i], expressions, items, total, totalcount);
                }
                else
                {
                    result = XExpressionSuccess(items[i], expressions);
                }
                if (!result)
                {
                    items.RemoveAt(i);
                    i--;
                    total++;
                    continue;
                }
                total++;
            }
            return(items);
        }
Beispiel #2
0
 public void RotateUiText(TextElements element)
 {
     if (mTextRotationCorutines[(int)element] == null)
     {
         mTextRotationCorutines[(int)element] = RotateText(element);
         StartCoroutine(mTextRotationCorutines[(int)element]);
     }
 }
Beispiel #3
0
        private TextEvulateResult Render_Parse(TextElement tag, object vars)
        {
            var loc = tag.GetAttribute("name");

            loc = this.EvulateText(loc)?.ToString();
            if (!this.ConditionSuccess(tag, "if") || !File.Exists(loc))
            {
                return(null);
            }
            string xpath    = tag.GetAttribute("xpath");
            bool   xpathold = false;

            if (string.IsNullOrEmpty(xpath))
            {
                xpath    = tag.GetAttribute("xpath_old");
                xpathold = true;
            }

            var content = File.ReadAllText(loc);
            var result  = new TextEvulateResult();

            result.Result = TextEvulateResultEnum.EVULATE_NOACTION;
            tag.Parent.SubElements.Remove(tag);
            if (string.IsNullOrEmpty(xpath))
            {
                this.Evulator.Parse(tag.Parent, content);
            }
            else
            {
                var tempitem = new TextElement();
                tempitem.ElemName = "#document";
                this.Evulator.Parse(tempitem, content);
                TextElements elems = null;
                if (!xpathold)
                {
                    elems = tempitem.FindByXPath(xpath);
                }
                else
                {
                    elems = tempitem.FindByXPathOld(xpath);
                }
                for (int i = 0; i < elems.Count; i++)
                {
                    elems[i].Parent = tag.Parent;
                    tag.Parent.SubElements.Add(@elems[i]);
                }
            }
            return(result);
        }
Beispiel #4
0
        public TextElement AddText(string text, int size, BrushColor color, Vector2 position)
        {
            if (!string.IsNullOrWhiteSpace(text) && size > 0 && color != null)
            {
                var element = new TextElement(this, position, size, color);
#warning change concat addition to lists eventually
                TextElements = TextElements.Concat(new TextElement[] { element }).ToArray();
                OnChanged.SafeInvoke(this);
                return(element);
            }
            else
            {
                throw new ArgumentException("AddText input arguments not valid");
            }
        }
Beispiel #5
0
 public NoteData ToData()
 {
     return(new NoteData()
     {
         BackgroundColor = BackgroundColor,
         DateCreated = Name.DateCreated,
         Name = Name.Name,
         DateLastModified = Name.DateLastModified,
         DateLastOpened = Name.DateLastOpened,
         Description = Name.Description,
         Id = Id,
         LineELementIds = LineElements.Select(l => l.Id).ToArray(),
         StrokeIds = Strokes.Select(s => s.Id).ToArray(),
         TextELementIds = TextElements.Select(t => t.Id).ToArray(),
     });
 }
Beispiel #6
0
    //Rotate text
    private IEnumerator RotateText(TextElements element)
    {
        Text textToRotate = mUiTextElements[(int)element];

        Debug.Log("Rotate" + element);

        float rotateByAngle = 0.0f;

        while (rotateByAngle < 360.0f)
        {
            textToRotate.rectTransform.Rotate(rotateByAngle, 0.0f, 0.0f);
            rotateByAngle += rotateSpeed * Time.deltaTime;
            yield return(null);
        }
        Vector3 currentRotation = textToRotate.rectTransform.rotation.eulerAngles;

        textToRotate.rectTransform.rotation = Quaternion.Euler(0.0f, currentRotation.y, currentRotation.z);

        mTextRotationCorutines[(int)element] = null;

        yield return(null);
    }
Beispiel #7
0
    public UIUpdater(IGame game, IUndo undo, IScoreQuery score, TextElements textElements)
    {
        if (game == null)
        {
            throw new ArgumentNullException("game");
        }
        if (undo == null)
        {
            throw new ArgumentNullException("undo");
        }
        if (score == null)
        {
            throw new ArgumentNullException("score");
        }
        if (textElements == null)
        {
            throw new ArgumentNullException("textElements");
        }

        if (textElements.Score == null)
        {
            throw new ArgumentException("Missing score text.");
        }
        if (textElements.DrawsLeft == null)
        {
            throw new ArgumentException("Missing draw text");
        }

        this.game  = game;
        this.undo  = undo;
        this.score = score;

        this.scoreText = textElements.Score;
        this.drawText  = textElements.DrawsLeft;

        ResetDrawText();
    }
Beispiel #8
0
        public static bool XExpressionSuccess(TextElement item, object expressions, TextElements baselist = null, int curindex = -1, int totalcounts = -1)
        {
            XPathActions actions = new XPathActions
            {
                XPathFunctions = new XPathFunctions()
            };

            actions.XPathFunctions.BaseItem = item;
            if (totalcounts != -1)
            {
                actions.XPathFunctions.TotalItems = totalcounts;
            }
            else
            {
                if (baselist != null)
                {
                    actions.XPathFunctions.TotalItems = baselist.Count;
                }
                else
                {
                    actions.XPathFunctions.TotalItems = item.Parent.SubElementsCount;
                }
            }

            if (curindex != -1)
            {
                actions.XPathFunctions.ItemPosition = curindex;
            }
            else
            {
                actions.XPathFunctions.ItemPosition = item.Index;
            }
            object[] result = null;
            if (expressions is XPathExpression eexp)
            {
                result = actions.EvulateActionSingle(eexp);
            }
            else if (expressions is IXPathExpressionItems expitem)
            {
                result = actions.EvulateAction(expitem);
            }
            if (result[0] == null || (result[0] is bool b) && !b)
            {
                return(false);
            }
            else if (TypeUtil.IsNumericType(result[0]))
            {
                int c          = (int)Convert.ChangeType(result[0], TypeCode.Int32) - 1;
                int totalcount = 0;
                if (totalcounts != -1)
                {
                    totalcount = totalcounts;
                }
                else
                {
                    if (baselist != null)
                    {
                        totalcount = baselist.Count;
                    }
                    else
                    {
                        totalcount = item.Parent.SubElementsCount;
                    }
                }
                if (c < -1 || c >= totalcount)
                {
                    return(false);
                }
                else
                {
                    return(c == actions.XPathFunctions.ItemPosition);
                }
            }
            return(true);
        }
Beispiel #9
0
 public void SetText(TextElements element, string text)
 {
     mUiTextElements[(int)element].text = text;
 }
Beispiel #10
0
    protected void initTranslationTable()
    {
        // if none was chosen, on site.master.cs the first one will be selected as default
        ProjectHelper.ProjectInfo Project = (ProjectHelper.ProjectInfo)Session["CurrentlyChosenProject"];
        string ProjDirectory = ConfigurationManager.AppSettings["ProjectDirectory"].ToString() + Project.Folder + "\\";
        string Language      = User.Identity.getUserLanguage(Session);
        string SourceLang    = User.Identity.GetSourceLanguage();

        SelectedProject.Text = Project.Name + " files";

        // Getting Directory + Language + ".xml" - if it doesn't exist, it will automatically be created on percentage calculation
        if (!File.Exists(ProjDirectory + Language + ".xml"))
        {
            XMLFile.ComputePercentage(Project, Language, null, SourceLang);
        }


        if (!File.Exists(ProjDirectory + Language + ".xml"))
        {
            showError("Language file for '" + Language + "' could not be created!"); return;
        }
        else
        {
            XmlDocument LanguageXML = XMLFile.GetXMLDocument(ProjDirectory + Language + ".xml");

            XmlNodeList AllFiles = LanguageXML.SelectNodes("/files[@language=\"" + Language + "\"]/file");

            DataSet oDs = new DataSet();
            oDs.ReadXml(ProjDirectory + Language + ".xml");

            if (oDs.Tables.Count >= 2)
            {
                FileList.DataSource = oDs.Tables[1];
            }

            FileList.DataBind();
        }


        //Check if a file is selected
        if (Session["SelectedFilename"] != null)
        {
            CurrentFile.Text = "Selected file: " + Convert.ToString(Session["SelectedFilename"]);
            Save.Visible     = true;

            XmlDocument SourceFile;

            if (Directory.Exists(Path.Combine(ProjDirectory, SourceLang)))
            {
                SourceFile = XMLFile.GetXMLDocument(Path.Combine(ProjDirectory, SourceLang, Convert.ToString(Session["SelectedFilename"]) + "." + SourceLang + ".resx"));
            }
            else
            {
                SourceFile = XMLFile.GetXMLDocument(ProjDirectory + Convert.ToString(Session["SelectedFilename"]) + ".resx");
            }

            if (SourceFile == null)
            {
                Session["SelectedFilename"] = null;
                Response.Redirect("/Account/Default.aspx"); // redirect to homepage, as this selected file does not longer seem to exist
                return;
            }

            XmlDocument TranslatedFile = XMLFile.GetXMLDocument(ProjDirectory + Language + "\\" + Convert.ToString(Session["SelectedFilename"]) + "." + Language + ".resx");
            DataTable   Table          = new DataTable();
            Table.Columns.Add("TextName");
            Table.Columns.Add("English");
            Table.Columns.Add("Translation");
            Table.Columns.Add("Comment");


            foreach (XmlNode Text in SourceFile.SelectNodes("/root/data"))
            {
                DataRow Row = Table.NewRow();
                Row["TextName"] = Text.Attributes["name"].InnerText;
                Row["English"]  = Server.HtmlEncode(Text.SelectSingleNode("value")?.InnerText);
                Row["Comment"]  = TranslatedFile?.SelectSingleNode("/root/data[@name=\"" + Row["Textname"].ToString() + "\"]/comment")?.InnerText ?? "";

                XmlNode Translated = TranslatedFile?.SelectSingleNode("/root/data[@name=\"" + Row["Textname"].ToString() + "\"]/value");
                if (Translated == null)
                {
                    Row["Translation"] = string.Empty;
                }
                else
                {
                    Row["Translation"] = Server.HtmlEncode(Translated.InnerText);
                }

                bool CanBeAdded = true;

                foreach (String notToCheck in XMLFile.NotArgs)
                {
                    if (Row["TextName"].ToString().Contains("." + notToCheck) ||
                        String.IsNullOrEmpty(Row["English"].ToString()))
                    {
                        CanBeAdded = false;
                    }
                }

                if (CanBeAdded && (!cb_showOnlyUntr.Checked || String.IsNullOrEmpty(Row["Translation"].ToString())))
                {
                    Table.Rows.Add(Row);
                }
            }
            TextElements.DataSource = Table;
            TextElements.DataBind();
            Save.Visible = true;
        }
        else
        {
            Save.Visible = false;
        }
    }
Beispiel #11
0
        private TextEvulateResult Render_Default(TextElement tag, object vars)
        {
            var loc = tag.GetAttribute("name");

            loc = this.EvulateText(loc)?.ToString();
            var parse = tag.GetAttribute("parse", "true");

            if (!File.Exists(loc) || !this.ConditionSuccess(tag, "if"))
            {
                return(null);
            }
            var content = File.ReadAllText(loc);
            var result  = new TextEvulateResult();

            if (parse == "false")
            {
                result.Result      = TextEvulateResultEnum.EVULATE_TEXT;
                result.TextContent = content;
            }
            else
            {
                var tempelem = new TextElement
                {
                    ElemName     = "#document",
                    BaseEvulator = this.Evulator
                };
                var tempelem2 = new TextElement
                {
                    ElemName     = "#document",
                    BaseEvulator = this.Evulator
                };

                string xpath    = tag.GetAttribute("xpath");
                bool   xpathold = false;
                if (string.IsNullOrEmpty(xpath))
                {
                    xpath    = tag.GetAttribute("xpath_old");
                    xpathold = true;
                }

                this.Evulator.Parse(tempelem2, content);
                if (string.IsNullOrEmpty(xpath))
                {
                    tempelem = tempelem2;
                }
                else
                {
                    TextElements elems = null;
                    if (!xpathold)
                    {
                        elems = tempelem2.FindByXPath(xpath);
                    }
                    else
                    {
                        elems = tempelem2.FindByXPathOld(xpath);
                    }
                    for (int i = 0; i < elems.Count; i++)
                    {
                        elems[i].Parent = tempelem;
                        tempelem.SubElements.Add(elems[i]);
                    }
                }
                var cresult = tempelem.EvulateValue(0, 0, vars);
                result.TextContent += cresult.TextContent;
                if (cresult.Result == TextEvulateResultEnum.EVULATE_RETURN)
                {
                    result.Result = TextEvulateResultEnum.EVULATE_RETURN;
                    return(result);
                }
                result.Result = TextEvulateResultEnum.EVULATE_TEXT;
            }
            return(result);
        }
Beispiel #12
0
 public void EnableText(TextElements element, bool active)
 {
     mUiTextElements[(int)element].gameObject.SetActive(active);
 }