Пример #1
0
            public override void OnUpdate()
            {
                if (this.Element != null && this.NeedsToResize)
                {
                    this.NeedsToResize = false;

                    string  text        = this.NextTextToShow;
                    Vector2 messageSize = CalculateMessageSize(ref text);
                    this.WrappedNextTextToShow = text;

                    float textInset = 6;

                    this.LastRequestedWidth  = textInset + messageSize.x + textInset;
                    this.LastRequestedHeight = textInset + messageSize.y + textInset;

                    float referenceSideLength = 50;
                    float xScale = this.LastRequestedWidth / referenceSideLength;
                    float yScale = this.LastRequestedHeight / referenceSideLength;

                    ArcenUI_Image.SubImage subImage = this.Element.SubImages[0];
                    subImage.Img.rectTransform.sizeDelta = new Vector2(referenceSideLength * xScale, referenceSideLength * yScale);

                    float textSideLength = referenceSideLength - (textInset * 2);

                    SubText subText = this.Element.SubTexts[0];
                    subText.ReferenceText.rectTransform.sizeDelta = new Vector2(textSideLength * xScale, textSideLength * yScale);
                }
                base.OnUpdate();
            }
Пример #2
0
        private static SubText GetNextNonEmptyLine(SourceTextReader reader)
        {
            SubText line = null;

            do
            {
                line = reader.ReadLine();
            }while (line != null && line.Trim() == string.Empty);

            return(line);
        }
            public override void HandleSubTextMouseover(SubText SubText)
            {
                int index = this.SubTexts.IndexOf(SubText);

                if (index < 0)
                {
                    return;
                }
                TextId id         = (TextId)index;
                string idAsString = id.ToString();

                string tooltip = SubText.Tooltip;

                switch (id)
                {
                case TextId.FuelOrPower:
                    GameEntityTypeData typeData = this.TypeToBuild;
                    if (typeData == null)
                    {
                        return;
                    }
                    else if (typeData.BalanceStats.SquadFuelConsumption > 0)
                    {
                        idAsString = "Fuel";
                    }
                    else if (typeData.BalanceStats.SquadPowerConsumption > 0)
                    {
                        idAsString = "Power";
                    }
                    else
                    {
                        return;
                    }
                    break;

                case TextId.Attack:
                case TextId.Defense:
                    tooltip = tooltip.Replace("{0}", ExternalConstants.Instance.Balance_DamageMultiplierWhenCounteringDefense.ReadableString);
                    break;
                }

                string key = "EntityTooltipPanel_" + idAsString;

                if (!Language.Current.Contains(key))
                {
                    return;
                }
                Window_AtMouseTooltipPanel.bPanel.Instance.SetText(Language.Current.GetValue(key) + tooltip);
            }
Пример #4
0
 public void ConfigureResourceDictionary(ResourceDictionary dictionary, string prefix)
 {
     Default.ConfigureResourceDictionary(dictionary, prefix);
     Highlight.ConfigureResourceDictionary(dictionary, prefix + "Highlight");
     KeyText.ConfigureResourceDictionary(dictionary, prefix + "KeyText");
     SubText.ConfigureResourceDictionary(dictionary, prefix + "SubText");
     HyperlinkText.ConfigureResourceDictionary(dictionary, prefix + "HyperlinkText");
     FavoriteCounter.ConfigureResourceDictionary(dictionary, prefix + "FavoriteCounter");
     RetweetCounter.ConfigureResourceDictionary(dictionary, prefix + "RetweetCounter");
     RetweetMarker.ConfigureResourceDictionary(dictionary, prefix + "RetweetMarker");
     FavoriteAndRetweetButton.ConfigureResourceDictionary(dictionary, prefix + "FavAndRtButton");
     FavoriteButton.ConfigureResourceDictionary(dictionary, prefix + "FavoriteButton");
     ColoredFavoriteButton.ConfigureResourceDictionary(dictionary, prefix + "ColoredFavoriteButton");
     RetweetButton.ConfigureResourceDictionary(dictionary, prefix + "RetweetButton");
     ColoredRetweetButton.ConfigureResourceDictionary(dictionary, prefix + "ColoredRetweetButton");
     MentionButton.ConfigureResourceDictionary(dictionary, prefix + "MentionButton");
     DeleteButton.ConfigureResourceDictionary(dictionary, prefix + "DeleteButton");
 }
Пример #5
0
        private void NewCertWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!Prompt)
            {
                DialogResult = NewCert != null ? true : false;
            }
            else
            {
                string exe      = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName;
                string longTime = null;
                if (ExpirationDate.HasValue)
                {
                    longTime = Convert.ToString(ExpirationDate.Value.ToFileTimeUtc());
                }

                var procInfo = new ProcessStartInfo(exe,
                                                    "/LaunchNewCert:" + SubText.Replace(" ", "%20") + "," +
                                                    FriendName.Replace(" ", "%20") + "," +
                                                    SavedAlgorithm + "," + SavedKeyLength + "," + longTime)
                {
                    Verb           = "RunAs",
                    CreateNoWindow = false
                };
                try
                {
                    var proc = Process.Start(procInfo);
                }
                catch (Win32Exception ex)
                {
                    Prompt = false;
                    storeComboBox.SelectedIndex = 0;
                    if (ex.Message == "The operation was canceled by the user")
                    {
                        e.Cancel = true;
                        return;
                    }
                    else
                    {
                        throw new Win32Exception("Woah!", ex);
                    }
                }
            }
        }
Пример #6
0
        public override string ToString()
        {
            string outp = "\n";

            outp += "Id: " + Id + "\n";
            outp += "QuestionText: " + QuestionText + "\n";
            if (!SubText.Equals(null))
            {
                outp += SubText + "\n";
            }

            for (int i = 0; i < AnswerText.Length; i++)
            {
                outp += "- " + AnswerText[i];
                if (i == RightAnswer)
                {
                    outp += "  <- Right";
                }
                outp += "\n";
            }
            return(outp);
        }
Пример #7
0
 public static ParsedValue <string> Parse(this SubText text)
 {
     return(Parse(text, s => s));
 }
Пример #8
0
 public static ParsedValue <T> Parse <T>(this SubText text, Func <string, T> parse)
 {
     return(new ParsedValue <T>(parse(text.ToString()), text.UnderlyingSpan));
 }
Пример #9
0
    private static SubText GetLCS(SubText oldText, SubText newText, int MatchLength)
    {
        int oldLength      = oldText.text.Length;
        int newLength      = newText.text.Length;
        int foundLCSlength = 0;
        int endPosOld      = 0;
        int endPosNew      = 0;

        SubText foundLCS = new SubText {
            text = ""
        };

        for (int l = 0; l < newLength; l++)
        {
            for (int k = 0; k < oldLength; k++)
            {
                for (int j = endPosNew; j < newLength; j++)
                {
                    if (j < endPosNew)
                    {
                        j = endPosNew;
                    }

                    int newLen = newLength - j - l;
                    if (newLen < MatchLength)
                    {
                        break;
                    }

                    if (newLen <= foundLCSlength)
                    {
                        break;
                    }

                    for (int i = endPosOld; i < oldLength; i++)
                    {
                        if (endPosOld > i)
                        {
                            i = endPosOld;
                        }

                        int oldLen = oldLength - i - k;

                        if (oldLen <= foundLCSlength)
                        {
                            break;
                        }

                        if (oldLen != newLen)
                        {
                            continue;
                        }

                        string oldSub = oldText.text.Substring(i, oldLen);
                        string newSub = newText.text.Substring(j, newLen);

                        if (newSub != oldSub)
                        {
                            continue;
                        }

                        foundLCS.newStartPos = j;
                        foundLCS.oldStartPos = i;
                        foundLCS.text        = newSub;

                        foundLCSlength = newLen;
                        endPosOld      = i + newLen;
                        endPosNew      = j + newLen;
                    }
                }
            }
        }

        return(foundLCS);
    }
Пример #10
0
    private static List <SubText> GetLCScollection(string _oldText, string _newText)
    {
        SubText oldText = new SubText
        {
            text        = _oldText,
            newStartPos = 0,
            oldStartPos = 0
        };

        SubText newText = new SubText
        {
            text        = _newText,
            newStartPos = 0,
            oldStartPos = 0
        };

        List <SubText> newTextBlocks = new List <SubText> {
            newText
        };
        List <SubText> oldTextBlocks = new List <SubText> {
            oldText
        };
        List <SubText> lcsBlocks = new List <SubText>();

        int oldPos = -1;
        int newPos = -1;

        while (true)
        {
            SubText foundLCS = new SubText {
                text = ""
            };
            for (int i = 0; i < newTextBlocks.Count && i < oldTextBlocks.Count; i++)
            {
                SubText tempLCS = GetLCS(oldTextBlocks[i], newTextBlocks[i], 3);

                if (tempLCS.text.Length > foundLCS.text.Length)
                {
                    foundLCS = tempLCS;
                    oldPos   = i;
                    newPos   = i;
                }
            }

            if (foundLCS.text.Length == 0)
            {
                break;
            }

            string[] newSplitTexts = new string[2];
            newSplitTexts[0] = newTextBlocks[newPos].text.Substring(0, foundLCS.newStartPos);
            newSplitTexts[1] = newTextBlocks[newPos].text.Substring(foundLCS.newStartPos + foundLCS.text.Length);

            int offset = 0;
            for (int i = 0; i < 2; i++)
            {
                if (newSplitTexts[i].Length > 0)
                {
                    SubText newSubText = new SubText
                    {
                        text        = newSplitTexts[i],
                        oldStartPos = newTextBlocks[newPos].oldStartPos + offset,
                        newStartPos = newTextBlocks[newPos].newStartPos + offset
                    };

                    newTextBlocks.Add(newSubText);
                }
                offset = foundLCS.text.Length;
            }

            string[] oldSplitTexts = new string[2];
            oldSplitTexts[0] = oldTextBlocks[oldPos].text.Substring(0, foundLCS.oldStartPos);
            oldSplitTexts[1] = oldTextBlocks[oldPos].text.Substring(foundLCS.oldStartPos + foundLCS.text.Length);

            offset = 0;
            for (int i = 0; i < 2; i++)
            {
                if (oldSplitTexts[i].Length > 0)
                {
                    SubText oldSubText = new SubText
                    {
                        text        = oldSplitTexts[i],
                        oldStartPos = oldTextBlocks[oldPos].oldStartPos + offset,
                        newStartPos = oldTextBlocks[oldPos].newStartPos + offset
                    };

                    oldTextBlocks.Add(oldSubText);
                }

                offset = foundLCS.text.Length;
            }

            foundLCS.newStartPos += newTextBlocks[newPos].newStartPos;
            foundLCS.oldStartPos += oldTextBlocks[oldPos].oldStartPos;

            oldTextBlocks.RemoveAt(oldPos);
            newTextBlocks.RemoveAt(newPos);

            oldTextBlocks = oldTextBlocks.OrderBy(f => f.oldStartPos).ToList();
            newTextBlocks = newTextBlocks.OrderBy(f => f.newStartPos).ToList();

            lcsBlocks.Add(foundLCS);
        }

        List <SubText> finalBlocks = new List <SubText>();

        foreach (SubText lcsBlock in lcsBlocks)
        {
            SubText block = lcsBlock;
            block.blockType = BlockType.LCStext;
            finalBlocks.Add(block);
        }

        foreach (SubText newTextBlock in newTextBlocks)
        {
            SubText block = newTextBlock;
            block.blockType = BlockType.AddedText;
            finalBlocks.Add(block);
        }

        foreach (SubText oldTextBlock in oldTextBlocks)
        {
            SubText block = oldTextBlock;
            block.blockType = BlockType.RemovedText;
            finalBlocks.Add(block);
        }

        finalBlocks = finalBlocks.OrderBy(f => f.newStartPos).ToList();

        return(finalBlocks);
    }
Пример #11
0
 public LineScanner(SubText line)
 {
     _line = line;
 }
            public override void OnUpdate()
            {
                if (!this.HaveGottenScaleInfo && this.Element != null)
                {
                    this.HaveGottenScaleInfo = true;
                    //float referenceWidth = 300;
                    float referenceHeight = 345;
                    float requestedHeight = this.Element.Height * ArcenUI.Instance.PixelsPerPercent_Y;
                    float scaleRatio      = requestedHeight / referenceHeight;
                    this.XScale = scaleRatio;
                    this.YScale = scaleRatio;
                    //Rect rect = this.Element.ReferenceImage.rectTransform.rect;
                    //rect.width = referenceWidth * this.XScale;
                    //rect.height = referenceHeight * this.YScale;
                    //this.Element.ReferenceImage.rectTransform.SetWidth( rect.width );
                    //this.Element.ReferenceImage.rectTransform.SetHeight( rect.height );

                    //if ( ArcenUI.Instance.PixelsPerPercent_X != ArcenUI.Instance.PixelsPerPercent_Y )
                    //{
                    //    float adjustmentMultiplier = ArcenUI.Instance.PixelsPerPercent_Y / ArcenUI.Instance.PixelsPerPercent_X;
                    //    Vector3 mainImageScale = this.Element.ReferenceImage.transform.localScale;
                    //    mainImageScale.x *= adjustmentMultiplier;
                    //    this.Element.ReferenceImage.transform.localScale = mainImageScale;
                    //    referenceWidth *= adjustmentMultiplier;
                    //}

                    //Rect rect = this.Element.ReferenceImage.rectTransform.rect;
                    //this.XScale = rect.width / referenceWidth;
                    //this.YScale = rect.height / referenceHeight;

                    for (int i = 0; i < this.Element.SubImages.Length; i++)
                    {
                        ArcenUI_Image.SubImage image = this.Element.SubImages[i];

                        switch (i)
                        {
                        case (int)ImageId.Unused1:
                        case (int)ImageId.Unused2:
                        case (int)ImageId.Unused3:
                            continue;     // horrible hack, it's because these are actually duplicate references and all kinds of bad things will happen if they get multiplied more than once
                        }

                        Vector3 scale = image.Img.transform.localScale;
                        scale.x *= this.XScale;
                        scale.y *= this.YScale;
                        image.Img.transform.localScale = scale;

                        Vector3 position = image.Img.transform.localPosition;
                        position.x *= this.XScale;
                        position.y *= this.YScale;
                        image.Img.transform.localPosition = position;
                    }

                    for (int i = 0; i < this.Element.SubTexts.Length; i++)
                    {
                        SubText text = this.Element.SubTexts[i];

                        Vector3 scale = text.ReferenceText.transform.localScale;
                        scale.x *= this.XScale;
                        scale.y *= this.YScale;
                        text.ReferenceText.transform.localScale = scale;

                        Vector3 position = text.ReferenceText.transform.localPosition;
                        position.x *= this.XScale;
                        position.y *= this.YScale;
                        text.ReferenceText.transform.localPosition = position;
                    }
                }
                base.OnUpdate();
            }
 public virtual void HandleSubTextMouseover(SubText SubText)
 {
 }
 static void Main(string[] args)
 {
     var text               = new Text();
     var subText            = new SubText();
     var presentationObject = new PersentationObject();
 }