Exemple #1
0
            public void GetRandomDocument(int size)
            {
                this.DocData = new List <IPrintable>();
                Random rnd = new Random();

                for (int i = 0; i < size; i++)
                {
                    DocData.Add(new Text());
                }
                for (int i = 0; i < DocData.Count; i++)
                {
                    int obj = rnd.Next(0, 3);
                    switch (obj)
                    {
                    case 0: DocData[i] = new Text(GenerateRandomText());; break;

                    case 1: DocData[i] = new Table(rnd.Next(2, 5), rnd.Next(2, 5)); break;

                    case 2: int color = rnd.Next(0, 3); ConsoleColor col = new ConsoleColor();
                        if (color == 0)
                        {
                            col = ConsoleColor.Red;
                        }
                        if (color == 1)
                        {
                            col = ConsoleColor.Green;
                        }
                        if (color == 2)
                        {
                            col = col = ConsoleColor.Blue;
                        }
                        DocData[i] = new ColorText(GenerateRandomText(), col); break;
                    }
                }
            }
        private void SetProgressDisplay(Color color)
        {
            percentBox.ThreadSafeSetLine(0, new ColorText(NiceNumbers.PercentString(progress, 3), color));

            float range = 1E10f, avg = 0;
            var   samples = timeLeftSamples.ToArray();

            if (samples.Length > 10)
            {
                range = samples.Max() - samples.Min();
                avg   = samples.Average();
            }

            if (range - 2.5f < avg * 0.2f || range < 2)
            {
                var text = "~ " + NiceNumbers.TimeStringMultiUnit(avg,
                                                                  range > 30 || avg > 60 * 10 ? 1 : 2);
                //if (range > 5)
                //    text += " +/-" + NiceNumbers.TimeStringMultiUnit(range);
                var colorText = new ColorText(text, color);
                timeLeftBox.ThreadSafeSetLine(0, colorText);
            }
            else
            {
                timeLeftBox.ThreadSafeSetLine(0, new PlainText(""));
            }
        }
Exemple #3
0
        /// <summary>
        /// сохранить в файл
        /// </summary>
        public void Save()
        {
            try
            {
                using (StreamWriter writer = new StreamWriter(@"Engine\Color\" + _name + "Color.txt"))
                {
                    writer.WriteLine(ColorUpBodyCandle.ToArgb());
                    writer.WriteLine(ColorUpBorderCandle.ToArgb());
                    writer.WriteLine(ColorDownBodyCandle.ToArgb());
                    writer.WriteLine(ColorDownBorderCandle.ToArgb());

                    writer.WriteLine(ColorBackSecond.ToArgb());
                    writer.WriteLine(ColorBackChart.ToArgb());
                    writer.WriteLine(ColorBackCursor.ToArgb());
                    writer.WriteLine(ColorText.ToArgb());
                }

                if (NeedToRePaintFormEvent != null)
                {
                    NeedToRePaintFormEvent();
                }
            }
            catch (Exception error)
            {
                SendNewMessage(error.ToString(), LogMessageType.Error);
            }
        }
Exemple #4
0
        static void Checking(int numTask)
        // Метод проверки логина
        {
            Console.Clear();
            Console.WriteLine("\n\n\nВведите логин для проверки соответствия требованиям РКН:\n");
            var correct = false;

            switch (numTask)
            {
            case 1:     // Проверка без регулярного выражения
                var sb = new StringBuilder(Console.ReadLine(), 10);
                correct = !char.IsNumber(sb[0]) && (sb.Length > 1 && sb.Length < 11);
                break;

            case 2:     // Проверка с регулярным выражением
                var regex = new Regex(@"^[A-Za-zА-я]{1}[0-9A-Za-zА-я]{1,9}$");
                correct = regex.IsMatch(Console.ReadLine());
                break;
            }
            if (correct)
            {
                ColorText.SetColorText("Логин ", ConsoleColor.Green, "соответствует", " требованиям РКН!");
            }
            else
            {
                ColorText.SetColorText("Логин ", ConsoleColor.Red, "не соответствует", " требованиям РКН!");
                ColorText.SetColorText("\n\nЛогин должен быть не больше ", ConsoleColor.Yellow, " 10-ти", "знаков,\n");
                ColorText.SetColorText("1-й знак ", ConsoleColor.Yellow, " не должен быть", "числом.");
            }
        }
Exemple #5
0
        /// <summary>
        /// Connects item to display
        /// </summary>
        /// <param name="item">Item to connect</param>
        /// <returns>ColorText object showing the item is connected, or tells the user the item is already connected</returns>
        public ColorText Connect(IItem item)
        {
            if (HasItem(item))
            {
                return(new ColorText(new string[] { $"This ", "Item", " is already connected." }, new ConsoleColor[] { ConsoleColor.White, ConsoleColor.Yellow, ConsoleColor.White }));
            }
            connectedTo.Add(item);
            List <string>       retStr = new List <string>();
            List <ConsoleColor> retClr = new List <ConsoleColor>();
            ColorText           left   = item.ListInfo(true);

            foreach (string str in left.GetLines())
            {
                retStr.Add(str);
            }
            foreach (ConsoleColor clr in left.Colors())
            {
                retClr.Add(clr);
            }
            retStr.Add(item.Type);
            retClr.Add(ConsoleColor.White);
            ColorText right = item.ListInfo(false);

            foreach (string str in right.GetLines())
            {
                retStr.Add(str);
            }
            foreach (ConsoleColor clr in right.Colors())
            {
                retClr.Add(clr);
            }
            retStr.Add($" connected to this {(IsMonitor ? "monitor" : "tv")}.\n");
            retClr.Add(ConsoleColor.White);
            return(new ColorText(retStr.ToArray(), retClr.ToArray()));
        }
Exemple #6
0
 void OnSerializingMethod(StreamingContext sc)
 {
     Images     = new string[] { Image, PushedImage };
     TextColor  = ColorText.ToString();
     GlyphColor = ColorGlyph.ToString();
     FontFamily = TextFormat.FontFamily.ToString();
     FontStyle  = TextFormat.FontStyle.ToString();
     FontWeight = TextFormat.FontWeight.ToString();
 }
        public void SaveInXML(XmlElement parentNode, CandleChartControl owner)
        {
            var node     = parentNode.AppendChild(parentNode.OwnerDocument.CreateElement("Comment"));
            var attrName = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Name"));

            attrName.Value = Name;
            var attrText = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Text"));

            attrText.Value = Text;
            var attrColor = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Color"));

            attrColor.Value = color.ToArgb().ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ColorText")).Value =
                ColorText.ToArgb().ToString();

            var attrPivotPrice = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("PivotPrice"));

            attrPivotPrice.Value = PivotPrice.ToString(CultureProvider.Common);


            var attrPivotTime = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("PivotTime"));

            attrPivotTime.Value = owner.chart.StockSeries.GetCandleOpenTimeByIndex((int)Math.Round(PivotIndex)).ToString(
                "ddMMyyyy HHmmss", CultureProvider.Common);
            var attrArrowLength = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ArrowLength"));

            attrArrowLength.Value = ArrowLength.ToString();
            var attrArrowAngle = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ArrowAngle"));

            attrArrowAngle.Value = ArrowAngle.ToString(CultureProvider.Common);

            var attrHideArrow = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("HideArrow"));

            attrHideArrow.Value = HideArrow.ToString();

            var attrHideBox = node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("HideBox"));

            attrHideBox.Value = HideBox.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("DrawFrame")).Value = DrawFrame.ToString();

            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ColorFill")).Value        = ColorFill.ToArgb().ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("FillTransparency")).Value = FillTransparency.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("TextCustom")).Value       = TextCustom;
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("magic")).Value            = Magic.ToString();
        }
        private void ConsoleTextBox_TextChanged(object sender, EventArgs e)
        {
            Color rgb = Color.White;
            int   pos = ConsoleTextBox.Text.IndexOf((char)27);

            if (pos != -1)
            {
                string newstrings = ConsoleTextBox.Text.Substring(pos + 1, ConsoleTextBox.Text.Length - pos - 1);
                ConsoleTextBox.Text = ConsoleTextBox.Text.Substring(0, pos);
                foreach (string item in newstrings.Split((char)27))
                {
                    if (item.StartsWith("[0;31m"))
                    {
                        rgb = Color.Red;
                    }
                    if (item.StartsWith("[0;36m"))
                    {
                        rgb = Color.Aqua;
                    }
                    if (item.StartsWith("[0;37m"))
                    {
                        rgb = Color.White;
                    }
                    string str = item.Substring(6, item.Length - 6);
                    if (str.Length == 0)
                    {
                        continue;
                    }
                    ConsoleTextBox.Text += str;
                    ColorText ct = new ColorText();
                    ct.c      = rgb;
                    ct.length = str.Length;
                    ct.start  = pos;
                    Colors.Add(ct);
                    pos += str.Length + 1;
                }
            }
            foreach (ColorText ct in Colors)
            {
                ConsoleTextBox.SelectionStart  = ct.start;
                ConsoleTextBox.SelectionLength = ct.length;
                ConsoleTextBox.SelectionColor  = ct.c;
            }
        }
Exemple #9
0
        //--------------------//

        #region Generate
        /// <summary>
        /// Generates a real dialog model from this XML-representation
        /// </summary>
        /// <param name="manager">The <see cref="DialogManager"/> instance that provides the resources for rendering of this dialog</param>
        /// <returns>The generated dialog model</returns>
        internal Render.Dialog GenerateRender(DialogManager manager)
        {
            // Load language XML
            string langName = (Resources.Culture == null) ? "English" : Resources.Culture.EnglishName.GetLeftPartAtFirstOccurrence(' ');

            _locale = LocaleFile.LoadLang(langName).ToDictionary();

            // Generate dialog model object
            DialogRender = TextureFileValid
                ? new Render.Dialog(manager, ColorText.ToColorValue(), _textureFile, _fontName, (uint)(_fontSize * EffectiveScale))
                : new Render.Dialog(manager, ColorText.ToColorValue());

            // Set dialog properites
            DialogRender.SetCaptionText(GetLocalized(_captionText));
            DialogRender.CaptionHeight = _captionHeight;
            UpdateColors();

            // Load custom button styles
            foreach (ButtonStyle style in ButtonStyles)
            {
                style.Parent = this;
                style.Generate();
            }

            // Generate control models from their view counterparts
            foreach (Control control in Controls)
            {
                control.Parent = this;
                control.Generate();
            }

            // Update control positions
            DialogRender.Resize += delegate
            {
                foreach (Control control in Controls)
                {
                    control.UpdateLayout();
                }
            };

            NeedsUpdate = false;
            return(DialogRender);
        }
Exemple #10
0
        static void StartTask()
        {
            while (true)
            {
                string[] anagramm;
                Console.Clear();
                Console.WriteLine("Введите через пробел 2 слова и я проверю, являются ли они анаграммами: ");
                try
                {
                    anagramm = Console.ReadLine().Split(' ');
                    if (anagramm.Length != 2)
                    {
                        continue;
                    }
                }
                catch
                {
                    continue;
                }

                var firstWord = anagramm[0].ToCharArray();
                Array.Sort(firstWord);
                var secondWord = anagramm[1].ToCharArray();
                Array.Sort(secondWord);

                if (Matches(firstWord, secondWord))
                {
                    ColorText.SetColorText("Слова ", ConsoleColor.Green, "являются", " анаграммами!\n\n");
                }
                else
                {
                    ColorText.SetColorText("Слова ", ConsoleColor.Red, "не являются", " анаграммами!\n\n");
                }

                if (Exit.ExitTask() != 1)
                {
                    break;
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Shows cached item
        /// </summary>
        /// <returns>ColorText object of current Item</returns>
        public ColorText ViewCurItem()
        {
            List <string> retStr = new List <string>()
            {
                $"Object type is: {curItem.SubType}\nNamed: {curItem.Name}\n\n"
            };
            List <ConsoleColor> retClr = new List <ConsoleColor>()
            {
                ConsoleColor.White
            };
            ColorText itm = curItem.ToText();

            foreach (string str in itm.GetLines())
            {
                retStr.Add(str);
            }
            foreach (ConsoleColor clr in itm.Colors())
            {
                retClr.Add(clr);
            }
            return(new ColorText(retStr.ToArray(), retClr.ToArray()));
        }
    private void SetUp(ColorText textColor, string message)
    {
        if (message == "")
        {
            HideTooltip();
            return;
        }

        transform.SetAsLastSibling();

        animator.SetTrigger("FadeIn");

        Color color = defaultColor;

        switch (textColor)
        {
        case ColorText.Default:
            color = defaultColor;
            break;

        case ColorText.Allowed:
            color = allowed;
            break;

        case ColorText.Forbidden:
            color = forbidden;
            break;
        }

        textField.color = color;
        textField.text  = message;

        Vector2 backgroundSize = new Vector2(textField.preferredWidth + textPadding * 2, textField.preferredHeight + textPadding * 2);

        backgroundRect.sizeDelta = backgroundSize;
    }
        public void SaveInXML(XmlElement parentNode, CandleChartControl owner)
        {
            var node = parentNode.AppendChild(parentNode.OwnerDocument.CreateElement("Asterisk"));

            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Name")).Value = Name;

            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Text")).Value  = Text;
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Sign")).Value  = Sign;
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("magic")).Value = Magic.ToString();

            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ColorLine")).Value = ColorLine.ToArgb().ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ColorFill")).Value = ColorFill.ToArgb().ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("ColorText")).Value = ColorText.ToArgb().ToString();

            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Price")).Value = Price.ToString(CultureProvider.Common);
            if (DateStart.HasValue)
            {
                node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("PivotTime")).Value =
                    DateStart.Value.ToString("ddMMyyyy HHmmss", CultureProvider.Common);
            }
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Shape")).Value        = Shape.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Transparency")).Value =
                Transparency.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("TransparencyText")).Value =
                TransparencyText.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("Radius")).Value =
                Radius.ToString();
            node.Attributes.Append(parentNode.OwnerDocument.CreateAttribute("magic")).Value = Magic.ToString();
        }
 public static void SetUpToolTip(ColorText textColor, string message) => instance.SetUp(textColor, message);
Exemple #15
0
 void CBC(String s)
 {
     word.text = ColorText.TextToColor(s, cbc);
 }
 public void GetRandomDocument(int size)
 {
     this.DocData = new List<IPrintable>();
     Random rnd = new Random();
     for (int i = 0; i < size; i++)
     {
         DocData.Add(new Text());
     }
     for (int i = 0; i < DocData.Count; i++)
     {
         int obj = rnd.Next(0, 3);
         switch (obj)
         {
             case 0: DocData[i] = new Text(GenerateRandomText()); ; break;
             case 1: DocData[i] = new Table(rnd.Next(2, 5), rnd.Next(2, 5)); break;
             case 2: int color = rnd.Next(0, 3); ConsoleColor col = new ConsoleColor();
                 if (color == 0) col = ConsoleColor.Red;
                 if (color == 1) col = ConsoleColor.Green;
                 if (color == 2) col = col = ConsoleColor.Blue;
                 DocData[i] = new ColorText(GenerateRandomText(), col); break;
         }
     }
 }
 public TranslationMessage(ColorText header, string key, params object[] args)
 {
     this.Header           = header;
     this.TranslationKey   = key;
     this.TranslationFills = args;
 }