示例#1
0
        public async Task TeamsCommand(string queueName, string teamSizeStr, string splitModeStr)
        {
            try
            {
                TeamSize  size      = ParseTeamSize(teamSizeStr);
                SplitMode splitMode = ParseSplitMode(splitModeStr);

                var queue = await GetQueue(queueName);

                if (queue == null)
                {
                    throw new ArgumentException("Did not find any current inhouse queue for this channel.");
                }

                List <List <Player> > playerGroups = SplitQueue(size, queue, splitMode);
                int groupNumber = 1;

                foreach (List <Player> players in playerGroups)
                {
                    var matches = DivideTeams(players);

                    if (matches != null)
                    {
                        await Output.OutputUniqueMatches(matches, groupNumber, Context.Channel);
                    }

                    ++groupNumber;
                }
            }
            catch (Exception e)
            {
                await Context.Channel.SendMessageAsync($"Error: {e.Message}");
            }
        }
 public void SplitEnd(SplitMode split)
 {
     if (OnSplitEnd != null)
     {
         OnSplitEnd(splitDestructibles, split);
     }
 }
示例#3
0
        public SpellingFixerOptions(
            SpellingScopeFilter scopeFilter   = SpellingScopeFilter.All,
            VisibilityFilter symbolVisibility = VisibilityFilter.All,
            SplitMode splitMode       = SplitMode.CaseAndHyphen,
            int minWordLength         = 3,
            int codeContext           = 1,
            bool includeGeneratedCode = false,
            bool autoFix     = true,
            bool interactive = false,
            bool dryRun      = false)
        {
            if (codeContext < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(codeContext), codeContext, "");
            }

            ScopeFilter          = scopeFilter;
            SymbolVisibility     = symbolVisibility;
            SplitMode            = splitMode;
            MinWordLength        = minWordLength;
            CodeContext          = codeContext;
            IncludeGeneratedCode = includeGeneratedCode;
            AutoFix     = autoFix;
            Interactive = interactive;
            DryRun      = dryRun;
        }
        public void SetSplitMode(SplitMode mode)
        {
            int split = (mode == SplitMode.Off ? 1 : (mode == SplitMode.RdLc ? 2 : 3));

            _Comm.Send(new byte[] { (byte)OpeEventType.Ctl, (byte)CtlEventType.SplitMode, (byte)split });
            _Logger.Debug("(Tx) Ctl: [SplitMode={0}]", mode);
        }
示例#5
0
 public SpellcheckerOptions(
     SplitMode splitMode = SplitMode.CaseAndHyphen,
     int minWordLength   = 3)
 {
     SplitMode     = splitMode;
     MinWordLength = minWordLength;
 }
示例#6
0
 public static Regex GetSplitRegex(SplitMode splitMode)
 {
     return(splitMode switch
     {
         SplitMode.None => null,
         SplitMode.Case => _splitCaseRegex,
         SplitMode.Hyphen => _splitHyphenRegex,
         SplitMode.CaseAndHyphen => _splitCaseAndHyphenRegex,
         _ => throw new InvalidOperationException(),
     });
 public void StarrMovieSplitIntoThree()
 {
     if (!checkLoadedTextures())
     {
         return;
     }
     splitMode = SplitMode.THREE;
     soundController.playSound();
     movieController.playMovie();
     mainMenu.switchToPlayingMode();
 }
示例#8
0
        public static IEnumerable <Tuple <DateTime, DateTime> > Split(SplitMode mode, DateTime from, DateTime until)
        {
            //TODO
            // a) by channel
            Tuple <DateTime, DateTime> timeRange = Tuple.Create(from, until);

            return(new List <Tuple <DateTime, DateTime> >()
            {
                timeRange
            });
        }
示例#9
0
 public ExportFormat(int num, string name, DateTime from, DateTime until,
                     SplitMode mode = SplitMode.ByChannel,
                     IEnumerable <ExportChannel> channels = null)
 {
     this.Number      = num;
     this.Name        = name;
     this.DateFrom    = from;
     this.DateUntil   = until;
     this.SplitMode   = mode;
     this.ChannelList = channels;
 }
示例#10
0
 private void _SplitUC_SplitModeChanging(object sender, SplitMode mode)
 {
     try
     {
         _CmdManager.SetSplitMode(mode);
     }
     catch (Exception ex)
     {
         _Logger.Error("ERROR intentando cambiar modo de Split a " + mode, ex);
     }
 }
示例#11
0
        private void _SplitModeBT_Click(object sender, EventArgs e)
        {
            SplitMode mode = (SplitMode)((HMIButton)sender).Tag;

            if (mode != _Mode)
            {
                General.SafeLaunchEvent(SplitModeChanging, this, mode);
            }

            HideModeSelection();
        }
示例#12
0
 public SplitParameters(SplitMode mode)
 {
     if (mode != SplitMode.Chunk)
     {
         Parameters = mode;
     }
     else
     {
         Parameters = SplitMode.Char;
     }
 }
示例#13
0
 public TypedTextSettings(SplitMode splitMode)
 {
     this.splitMode         = splitMode;
     this.customSplitString = new List <string>()
     {
         ",", "\n"
     };
     this.defaultTypeDelay    = new TimeDelay(0.1f);
     this.customTypeDelays    = new List <CustomStringTimeDelay>();
     this.customPostTypePause = new List <CustomStringTimeDelay>();
 }
        public SynthGraphEditorSplitView( Rect rect, float splitPoint, SplitMode mode, ISynthGraphEditorView leftView, ISynthGraphEditorView rightView )
        {
            m_isResizing = false;

            m_viewRect = rect;
            m_splitPosition = splitPoint;

            m_leftView = leftView;
            m_rightView = rightView;

            m_splitMode = mode;
            CalcChildren();
        }
示例#15
0
 public bool Start(ExportFormat exportFormat)
 {
     //TODO
     try {
         IEnumerable <ExportChannel> channels = exportFormat.ChannelList;
         DateTime  from      = exportFormat.DateFrom;
         DateTime  until     = exportFormat.DateUntil;
         SplitMode splitMode = exportFormat.SplitMode;
         IEnumerable <Tuple <DateTime, DateTime> > timeRanges = RequestSplitter.Split(splitMode, from, until);
         IEnumerable <string> requests           = RequestSplitter.CreateUrls(timeRanges, channels);
         IEnumerable <string> fileNames          = Downloader.Download(requests);
         IEnumerable <string> convertedFileNames = FormatConverter.Convert(fileNames);
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
示例#16
0
 public Splitter(
     float initialValue,
     SplitViewOnGUIDelegate onDrawLeftDelegate,
     SplitViewOnGUIDelegate onDrawRightDelegate,
     SplitMode lockMode,
     float minValue,
     float barSize = 16f
     )
 {
     splitterValue            = initialValue;
     this.onDrawLeftDelegate  = onDrawLeftDelegate;
     this.onDrawRightDelegate = onDrawRightDelegate;
     this.lockMode            = lockMode;
     lockValues   = minValue;
     mouseCursor  = lockMode == SplitMode.Vertical ? MouseCursor.ResizeHorizontal : MouseCursor.ResizeVertical;
     rectOffset   = lockMode == SplitMode.Vertical ? VERTICAL_RECT_OFFSET : HORIZONTAL_RECT_OFFSET;
     this.barSize = barSize;
 }
示例#17
0
 public static int WriteLine(DisplayData data, Align align = Align.LeftFill, SplitMode splitMode = SplitMode.None)
 {
     return(WriteData(data, false, NextLine, align, splitMode));
 }
示例#18
0
 public VertexInfo(Vector2 pos, VertexDirection dir, SplitMode split)
 {
     Position  = pos;
     Direction = dir;
     Split     = split;
 }
 public void SetSplitMode(SplitMode mode)
 {
     Debug.Assert(mode != _StateManager.Split.Mode);
     _EngineCmdManager.SetSplitMode(mode);
 }
示例#20
0
 public static Rect[] Split(this Rect r, SplitMode splitMode, params float[] parts) => Split(r, splitMode, Vector2.zero, parts);
示例#21
0
 public Splitter(SplitMode mode)
 {
     Parameters = mode;
     _palette   = Palette.Auto;
 }
示例#22
0
        private List <List <Player> > SplitQueue(TeamSize sizeHint, InhouseQueue queue, SplitMode splitMode)
        {
            if (queue == null)
            {
                return(null);
            }

            List <Player> players = queue.Players.Values.ToList <Player>();

            if (splitMode == SplitMode.Random)
            {
                return(SplitQueueRandom(players, sizeHint));
            }
            else if (splitMode == SplitMode.SkillGroup)
            {
                return(SplitQueueSkillGroup(players, sizeHint));
            }
            else
            {
                return(null);
            }
        }
示例#23
0
        int SplitToQueries(List<string> queries, string phrase, SplitMode mode, int allowed_length)
        {
            List<string> parts;
            switch(mode)
            {
                case SplitMode.Separators:
                    parts = SplitToParts(phrase);
                    break;
                case SplitMode.Spaces:
                    parts = new List<string>(phrase.Split(new Char[] {' '}));
                    for(int i = 0; i < parts.Count - 1; i++)
                        parts[i] = parts[i] + " "; //add spaces
                    break;
                case SplitMode.Size:
                default:
                    parts = new List<string>();
                    //split to 50-chars blocks
                    for(int i = 0; i < phrase.Length - 1; i+= 50)
                    {
                        if(i + 50 <= phrase.Length)
                            parts.Add(phrase.Substring(i, 50));
                        else
                            parts.Add(phrase.Substring(i, phrase.Length - i));
                    }
                    break;
            }

            StringBuilder sb = new StringBuilder(500);
            int phrase_length = 0;
            int encoded_length = 0;
            string sub_query = "";

            foreach(string part in parts)
            {
                sub_query = HttpUtility.UrlEncode(part, Encoding.UTF8);
                if(encoded_length + sub_query.Length <= allowed_length && phrase_length + part.Length <= 500)
                {
                    sb.Append(part);
                    phrase_length += part.Length;
                    encoded_length += sub_query.Length;
                }
                else
                {
                    if(sb.Length > 0)
                    {
                        queries.Add(sb.ToString());
                        sb.Length = 0;
                        phrase_length = 0;
                        encoded_length = 0;
                    }

                    if(sub_query.Length <= allowed_length && part.Length <= 500)
                    {
                        sb.Append(part);
                        phrase_length += part.Length;
                        encoded_length += sub_query.Length;
                    }
                    else
                    { //very long phrase without separators - split it by space
                        int remainder_size = 0;
                        if(mode == SplitMode.Separators)
                            remainder_size = SplitToQueries(queries, part, SplitMode.Spaces, allowed_length);
                        else if(mode == SplitMode.Spaces)
                            remainder_size = SplitToQueries(queries, part, SplitMode.Size, allowed_length);
                        else
                            throw new InvalidOperationException("Wrong size of string : " + part);

                        //reset
                        sb.Length = 0;
                        phrase_length = 0;
                        encoded_length = 0;

                        if(remainder_size > 0 && remainder_size < allowed_length && queries[queries.Count - 1].Length < 500)
                        {  //here possible to add some text to end
                            sb.Append(queries[queries.Count - 1]);
                            phrase_length = sb.Length;
                            encoded_length = remainder_size;
                            queries.RemoveAt(queries.Count - 1);
                        }
                    }
                }
            }

            if(sb.Length > 0)
            {
                queries.Add(sb.ToString());
            }
            return encoded_length;
        }
示例#24
0
 public static int WriteData(DisplayData data, bool cls, int startLine, Align align, SplitMode splitMode)
 {
     return(WriteData(new[] { data }, cls, startLine, align, splitMode));
 }
示例#25
0
 public Split()
 {
     _Mode = (SplitMode)Settings.Default.SplitMode;
 }
示例#26
0
        public static int WriteData(IEnumerable <DisplayData> dataList, bool cls, int startLine, Align align, SplitMode splitMode)
        {
            Console.ResetColor();
            if (startLine > -1 && startLine <= Console.BufferHeight)
            {
                Console.SetCursorPosition(0, startLine);
            }
            var width = Console.BufferWidth;

            //var height = Console.BufferHeight;

            if (cls)
            {
                Console.Clear();
            }

            var cursorBeginPosition = Console.CursorTop;


            var offset = 0;

            foreach (var data in dataList)
            {
                #region Align Left
                //Align Left
                if (align == Align.Left)
                {
                    //string less or equal than screen size
                    if (data.WritableValue.Length <= width)
                    {
                        //string multi-line
                        if (data.WritableValue.Contains("\n"))
                        {
                            var stringDataList = data.WritableValue.Split(Convert.ToChar("\n"));
                            foreach (var stringData in stringDataList)
                            {
                                offset = width - stringData.Length;
                                //var spaceString = "";
                                //for (var i = 0; i < offset; i++) spaceString += " ";
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                if (offset == 0)
                                {
                                    Console.Write(stringData);
                                }
                                else
                                {
                                    Console.WriteLine(stringData);
                                }
                            }
                        }
                        //string single-line
                        else
                        {
                            offset = width - data.WritableValue.Length;
                            //var spaceString = "";
                            //for (var i = 0; i < offset; i++) spaceString += " ";
                            if (Console.ForegroundColor != data.Foreground)
                            {
                                Console.ForegroundColor = data.Foreground;
                            }
                            if (Console.BackgroundColor != data.Background)
                            {
                                Console.BackgroundColor = data.Background;
                            }
                            if (offset == 0)
                            {
                                Console.Write(data.WritableValue);
                            }
                            else
                            {
                                Console.WriteLine(data.WritableValue);
                            }
                        }
                    }
                    //string bigger than screen size
                    else
                    {
                        var stringList = new List <string>();
                        var newString  = "";
                        var charList   = data.WritableValue.ToCharArray();
                        var buffer     = false;
                        foreach (var c in charList)
                        {
                            if (c.ToString() == "\n")
                            {
                                buffer = true;
                                if (newString.Trim() != "")
                                {
                                    stringList.Add(newString);
                                }
                                newString = "";
                            }
                            else if (newString.Length < width - 1)
                            {
                                buffer     = true;
                                newString += c.ToString();
                            }
                            else
                            {
                                buffer     = false;
                                newString += c.ToString();
                                stringList.Add(newString);
                                newString = "";
                            }
                        }
                        if (buffer)
                        {
                            stringList.Add(newString);
                        }

                        foreach (var line in stringList)
                        {
                            //string multi-line
                            if (line.Contains("\n"))
                            {
                                var stringDataList = line.Split(Convert.ToChar("\n"));
                                foreach (string stringData in stringDataList)
                                {
                                    offset = width - stringData.Length;
                                    //var spaceString = "";
                                    //for (int i = 0; i < offset; i++) spaceString += " ";
                                    if (Console.ForegroundColor != data.Foreground)
                                    {
                                        Console.ForegroundColor = data.Foreground;
                                    }
                                    if (Console.BackgroundColor != data.Background)
                                    {
                                        Console.BackgroundColor = data.Background;
                                    }
                                    if (offset == 0)
                                    {
                                        Console.Write(stringData);
                                    }
                                    else
                                    {
                                        Console.WriteLine(stringData);
                                    }
                                }
                            }
                            //string single-line
                            else
                            {
                                offset = width - line.Length;
                                //var spaceString = "";
                                //for (int i = 0; i < offset; i++) spaceString += " ";
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                if (offset == 0)
                                {
                                    Console.Write(line);
                                }
                                else
                                {
                                    Console.WriteLine(line);
                                }
                            }
                        }
                    }
                }
                #endregion

                #region Align Left Fill
                //Align Left Fill
                else if (align == Align.LeftFill)
                {
                    //string less or equal than screen size
                    if (data.WritableValue.Length <= width)
                    {
                        //string multi-line
                        if (data.WritableValue.Contains("\n"))
                        {
                            var stringDataList = data.WritableValue.Split(Convert.ToChar("\n"));
                            foreach (var stringData in stringDataList)
                            {
                                offset = width - stringData.Length;
                                var spaceString = "";
                                for (var i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                Console.Write(stringData + spaceString);
                            }
                        }
                        //string single-line
                        else
                        {
                            offset = width - data.WritableValue.Length;
                            var spaceString = "";
                            for (var i = 0; i < offset; i++)
                            {
                                spaceString += " ";
                            }
                            if (Console.ForegroundColor != data.Foreground)
                            {
                                Console.ForegroundColor = data.Foreground;
                            }
                            if (Console.BackgroundColor != data.Background)
                            {
                                Console.BackgroundColor = data.Background;
                            }
                            Console.Write(data.WritableValue + spaceString);
                        }
                    }
                    //string bigger than screen size
                    else
                    {
                        var stringList = new List <string>();
                        var newString  = "";
                        var charList   = data.WritableValue.ToCharArray();
                        var buffer     = false;
                        foreach (var c in charList)
                        {
                            if (c.ToString() == "\n")
                            {
                                buffer = true;
                                if (newString.Trim() != "")
                                {
                                    stringList.Add(newString);
                                }
                                newString = "";
                            }
                            else if (newString.Length < width - 1)
                            {
                                buffer     = true;
                                newString += c.ToString();
                            }
                            else
                            {
                                buffer     = false;
                                newString += c.ToString();
                                stringList.Add(newString);
                                newString = "";
                            }
                        }
                        if (buffer)
                        {
                            stringList.Add(newString);
                        }

                        foreach (var line in stringList)
                        {
                            //string multi-line
                            if (line.Contains("\n"))
                            {
                                var stringDataList = line.Split(Convert.ToChar("\n"));
                                foreach (var stringData in stringDataList)
                                {
                                    offset = width - stringData.Length;
                                    var spaceString = "";
                                    for (var i = 0; i < offset; i++)
                                    {
                                        spaceString += " ";
                                    }
                                    if (Console.ForegroundColor != data.Foreground)
                                    {
                                        Console.ForegroundColor = data.Foreground;
                                    }
                                    if (Console.BackgroundColor != data.Background)
                                    {
                                        Console.BackgroundColor = data.Background;
                                    }
                                    Console.Write(stringData + spaceString);
                                }
                            }
                            //string single-line
                            else
                            {
                                offset = width - line.Length;
                                var spaceString = "";
                                for (var i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                Console.Write(line + spaceString);
                            }
                        }
                    }
                }
                #endregion

                #region Align Center
                //Align Center
                else if (align == Align.Center)
                {
                    //string less or equal than screen size
                    if (data.WritableValue.Length <= width)
                    {
                        //string multi-line
                        if (data.WritableValue.Contains("\n"))
                        {
                            var stringDataList = data.WritableValue.Split(Convert.ToChar("\n"));
                            foreach (var stringData in stringDataList)
                            {
                                offset = width / 2 - (stringData.Length / 2);
                                var spaceString = "";
                                for (var i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                Console.ResetColor();
                                Console.Write(spaceString);
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                if (offset == 0)
                                {
                                    Console.Write(stringData);
                                }
                                else
                                {
                                    Console.WriteLine(stringData);
                                }
                            }
                        }
                        //string single-line
                        else
                        {
                            offset = width / 2 - (data.WritableValue.Length / 2);
                            var spaceString = "";
                            for (var i = 0; i < offset; i++)
                            {
                                spaceString += " ";
                            }
                            Console.ResetColor();
                            Console.Write(spaceString);
                            if (Console.ForegroundColor != data.Foreground)
                            {
                                Console.ForegroundColor = data.Foreground;
                            }
                            if (Console.BackgroundColor != data.Background)
                            {
                                Console.BackgroundColor = data.Background;
                            }
                            if (offset == 0)
                            {
                                Console.Write(data.WritableValue);
                            }
                            else
                            {
                                Console.WriteLine(data.WritableValue);
                            }
                        }
                    }
                    //string bigger than screen size
                    else
                    {
                        var stringList = new List <string>();
                        var newString  = "";
                        var charList   = data.WritableValue.ToCharArray();
                        var buffer     = false;
                        foreach (var c in charList)
                        {
                            if (c.ToString() == "\n")
                            {
                                buffer = true;
                                if (newString.Trim() != "")
                                {
                                    stringList.Add(newString);
                                }
                                newString = "";
                            }
                            else if (newString.Length < width - 1)
                            {
                                buffer     = true;
                                newString += c.ToString();
                            }
                            else
                            {
                                buffer     = false;
                                newString += c.ToString();
                                stringList.Add(newString);
                                newString = "";
                            }
                        }
                        if (buffer)
                        {
                            stringList.Add(newString);
                        }

                        foreach (var line in stringList)
                        {
                            //string multi-line
                            if (line.Contains("\n"))
                            {
                                var stringDataList = line.Split(Convert.ToChar("\n"));
                                foreach (var stringData in stringDataList)
                                {
                                    offset = width / 2 - (stringData.Length / 2);
                                    var spaceString = "";
                                    for (int i = 0; i < offset; i++)
                                    {
                                        spaceString += " ";
                                    }
                                    Console.ResetColor();
                                    Console.Write(spaceString);
                                    if (Console.ForegroundColor != data.Foreground)
                                    {
                                        Console.ForegroundColor = data.Foreground;
                                    }
                                    if (Console.BackgroundColor != data.Background)
                                    {
                                        Console.BackgroundColor = data.Background;
                                    }
                                    if (offset == 0)
                                    {
                                        Console.Write(stringData);
                                    }
                                    else
                                    {
                                        Console.WriteLine(stringData);
                                    }
                                }
                            }
                            //string single-line
                            else
                            {
                                offset = width / 2 - (line.Length / 2);
                                var spaceString = "";
                                for (int i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                Console.ResetColor();
                                Console.Write(spaceString);
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                if (offset == 0)
                                {
                                    Console.Write(line);
                                }
                                else
                                {
                                    Console.WriteLine(line);
                                }
                            }
                        }
                    }
                }
                #endregion

                #region Align Center Fill
                //Align Center Fill
                else if (align == Align.CenterFill)
                {
                    //string less or equal than screen size
                    if (data.WritableValue.Length <= width)
                    {
                        //string multi-line
                        if (data.WritableValue.Contains("\n"))
                        {
                            var stringDataList = data.WritableValue.Split(Convert.ToChar("\n"));
                            foreach (var stringData in stringDataList)
                            {
                                offset = width / 2 - (stringData.Length / 2);
                                var spaceString = "";
                                for (var i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                var sLeft = "";
                                for (var i = spaceString.Length + stringData.Length; i < width; i++)
                                {
                                    sLeft += " ";
                                }
                                Console.Write(spaceString + stringData + sLeft);
                            }
                        }
                        //string single-line
                        else
                        {
                            offset = width / 2 - (data.WritableValue.Length / 2);
                            var spaceString = "";
                            for (var i = 0; i < offset; i++)
                            {
                                spaceString += " ";
                            }
                            if (Console.ForegroundColor != data.Foreground)
                            {
                                Console.ForegroundColor = data.Foreground;
                            }
                            if (Console.BackgroundColor != data.Background)
                            {
                                Console.BackgroundColor = data.Background;
                            }
                            var sLeft = "";
                            for (var i = spaceString.Length + data.WritableValue.Length; i < width; i++)
                            {
                                sLeft += " ";
                            }
                            Console.Write(spaceString + data.WritableValue + sLeft);
                        }
                    }
                    //string bigger than screen size
                    else
                    {
                        var stringList = new List <string>();
                        var newString  = "";
                        var charList   = data.WritableValue.ToCharArray();
                        var buffer     = false;
                        foreach (var c in charList)
                        {
                            if (c.ToString() == "\n")
                            {
                                buffer = true;
                                if (newString.Trim() != "")
                                {
                                    stringList.Add(newString);
                                }
                                newString = "";
                            }
                            else if (newString.Length < width - 1)
                            {
                                buffer     = true;
                                newString += c.ToString();
                            }
                            else
                            {
                                buffer     = false;
                                newString += c.ToString();
                                stringList.Add(newString);
                                newString = "";
                            }
                        }
                        if (buffer)
                        {
                            stringList.Add(newString);
                        }

                        foreach (var line in stringList)
                        {
                            //string multi-line
                            if (line.Contains("\n"))
                            {
                                var stringDataList = line.Split(Convert.ToChar("\n"));
                                foreach (var stringData in stringDataList)
                                {
                                    offset = width / 2 - (stringData.Length / 2);
                                    var spaceString = "";
                                    for (int i = 0; i < offset; i++)
                                    {
                                        spaceString += " ";
                                    }
                                    if (Console.ForegroundColor != data.Foreground)
                                    {
                                        Console.ForegroundColor = data.Foreground;
                                    }
                                    if (Console.BackgroundColor != data.Background)
                                    {
                                        Console.BackgroundColor = data.Background;
                                    }
                                    var sLeft = "";
                                    for (var i = spaceString.Length + stringData.Length; i < width; i++)
                                    {
                                        sLeft += " ";
                                    }
                                    Console.Write(spaceString + stringData + sLeft);
                                }
                            }
                            //string single-line
                            else
                            {
                                offset = width / 2 - (line.Length / 2);
                                var spaceString = "";
                                for (int i = 0; i < offset; i++)
                                {
                                    spaceString += " ";
                                }
                                if (Console.ForegroundColor != data.Foreground)
                                {
                                    Console.ForegroundColor = data.Foreground;
                                }
                                if (Console.BackgroundColor != data.Background)
                                {
                                    Console.BackgroundColor = data.Background;
                                }
                                var sLeft = "";
                                for (int i = spaceString.Length + line.Length; i < width; i++)
                                {
                                    sLeft += " ";
                                }
                                Console.Write(spaceString + line + sLeft);
                            }
                        }
                    }
                }
                #endregion
            }
            //Reset Color
            if ((splitMode == SplitMode.FilledLine && offset == 0) || splitMode == SplitMode.All)
            {
                Console.WriteLine();
            }
            Console.ResetColor();
            return(Console.CursorTop - cursorBeginPosition);
        }
示例#27
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="r"></param>
    /// <param name="vertical"></param>
    /// <param name="padding"></param>
    /// <param name="parts">Parts.
    ///     Value <  0 == Flexible Space
    ///     0 < Value < 1 == Percent
    ///     Value >= 1 == Fixed Pixels
    /// </param>
    /// <returns></returns>
    public static Rect[] Split(this Rect r, SplitMode splitMode, Vector2 padding, params float[] parts)
    {
        float freespace;
        float sizeFilled    = 0;
        float sizeFull      = 0;
        float sizeFreespace = 0;

        if (parts.Length == 1)
        {
            int   splitParts = Mathf.RoundToInt(parts[0]);
            float splitsizes = 1f / parts[0];

            parts = new float[splitParts];

            for (int x = 0; x < splitParts; x++)
            {
                parts[x] = splitsizes;
            }
        }

        List <float> sizes = new List <float>(parts);

        Rect[] rects = new Rect[parts.Length];

        float fixedTemp         = 0;
        int   numFlexibleSpaces = 0;

        if (splitMode == SplitMode.Vertical)
        {
            sizeFull = r.height;
        }
        else
        {
            sizeFull = r.width;
        }


        for (int x = 0; x < parts.Length; x++)
        {
            if (parts[x] < 1)
            {
                if (parts[x] < 0)
                {
                    //FlexibleSpace
                    fixedTemp = -1;
                    numFlexibleSpaces++;
                }
                else
                {
                    //Percent
                    if (splitMode == SplitMode.Vertical)
                    {
                        fixedTemp = parts[x] * r.height;
                    }
                    else
                    {
                        fixedTemp = parts[x] * r.width;
                    }
                }
            }
            else
            {
                //Num parts
                fixedTemp = parts[x];
            }

            sizes[x] = fixedTemp;

            if (fixedTemp > 0)
            {
                sizeFilled += fixedTemp;
            }
        }

        //Calculo de espacio libre. Calculan el tamaño maximo y el tamano ocupado, despues el espacio Flexible y se reparte en los huecos
        freespace     = sizeFull - sizeFilled;
        sizeFreespace = freespace / numFlexibleSpaces;
        for (int x = 0; x < sizes.Count; x++)
        {
            if (sizes[x] < 0)
            {
                sizes[x] = sizeFreespace;
            }
        }

        if (splitMode == SplitMode.Vertical)
        {
            for (int x = 0; x < sizes.Count; x++)
            {
                rects[x]        = new Rect(r);
                rects[x].height = sizes[x];
                if (x > 0)
                {
                    rects[x].y = rects[x - 1].yMax;
                }
                if (padding.x != 0 && padding.y != 0)
                {
                    rects[x] = rects[x].Expand(-padding.x, -padding.y);
                }
            }
        }
        else
        {
            for (int x = 0; x < sizes.Count; x++)
            {
                rects[x]       = new Rect(r);
                rects[x].width = sizes[x];
                if (x > 0)
                {
                    rects[x].x = rects[x - 1].xMax;
                }
                if (padding.x != 0 && padding.y != 0)
                {
                    rects[x] = rects[x].Expand(-padding.x, -padding.y);
                }
            }
        }


        return(rects);
    }
示例#28
0
        public static string Wrap(this string value, int charCountPerLine, SplitMode splitMode)
        {
            char[]        chars = value.ToCharArray();
            char          c;
            List <Word>   words             = new List <Word>();
            StringBuilder wordStringBuilder = new StringBuilder();

            for (int i = 0; i < chars.Length; i++)
            {
                c = chars[i];

                if (c == '\r' && i + 1 < chars.Length && chars[i + 1] == '\n')
                {
                    wordStringBuilder.AppendLine();
                    i++;
                }
                else
                {
                    wordStringBuilder.Append(c);
                }

                if (i + 1 >= chars.Length || (splitMode != SplitMode.Always && WORD_DELIMITERS.Contains(c)))
                {
                    words.Add(new Word(wordStringBuilder.ToString()));
                    wordStringBuilder.Clear();
                }
            }

            StringBuilder wrappedStringBuilder = new StringBuilder();

            int  currentLineCharCount = 0;
            int  fittingCharCount;
            bool wordProcessingFinished;

            foreach (Word w in words)
            {
                wordProcessingFinished = false;

                while (!wordProcessingFinished)
                {
                    if (currentLineCharCount > 0 && currentLineCharCount + w.Length > charCountPerLine)
                    {
                        wrappedStringBuilder.AppendLine();
                        currentLineCharCount = 0;
                    }

                    if (splitMode == SplitMode.Never)
                    {
                        wrappedStringBuilder.Append(w.Value);
                        currentLineCharCount  += w.Length;
                        wordProcessingFinished = true;
                    }
                    else
                    {
                        if (currentLineCharCount + w.Length > charCountPerLine)
                        {
                            fittingCharCount = charCountPerLine - currentLineCharCount;
                            wrappedStringBuilder.Append(w.Value.Substring(0, fittingCharCount));
                            w.Value = w.Value.Remove(0, fittingCharCount);
                            currentLineCharCount += fittingCharCount;
                        }
                        else
                        {
                            wrappedStringBuilder.Append(w.Value);
                            currentLineCharCount  += w.Length;
                            wordProcessingFinished = true;
                        }
                    }

                    if (wordProcessingFinished && w.EndsWithNewLine)
                    {
                        currentLineCharCount = 0;
                    }
                }
            }

            return(wrappedStringBuilder.ToString());
        }
示例#29
0
        int SplitToQueries(List <string> queries, string phrase, SplitMode mode, int allowed_length)
        {
            List <string> parts;

            switch (mode)
            {
            case SplitMode.Separators:
                parts = SplitToParts(phrase);
                break;

            case SplitMode.Spaces:
                parts = new List <string>(phrase.Split(new Char[] { ' ' }));
                for (int i = 0; i < parts.Count - 1; i++)
                {
                    parts[i] = parts[i] + " ";                             //add spaces
                }
                break;

            case SplitMode.Size:
            default:
                parts = new List <string>();
                //split to 50-chars blocks
                for (int i = 0; i < phrase.Length - 1; i += 50)
                {
                    if (i + 50 <= phrase.Length)
                    {
                        parts.Add(phrase.Substring(i, 50));
                    }
                    else
                    {
                        parts.Add(phrase.Substring(i, phrase.Length - i));
                    }
                }
                break;
            }

            StringBuilder sb             = new StringBuilder(500);
            int           phrase_length  = 0;
            int           encoded_length = 0;
            string        sub_query      = "";

            foreach (string part in parts)
            {
                sub_query = HttpUtility.UrlEncode(part, Encoding.UTF8);
                if (encoded_length + sub_query.Length <= allowed_length && phrase_length + part.Length <= 500)
                {
                    sb.Append(part);
                    phrase_length  += part.Length;
                    encoded_length += sub_query.Length;
                }
                else
                {
                    if (sb.Length > 0)
                    {
                        queries.Add(sb.ToString());
                        sb.Length      = 0;
                        phrase_length  = 0;
                        encoded_length = 0;
                    }

                    if (sub_query.Length <= allowed_length && part.Length <= 500)
                    {
                        sb.Append(part);
                        phrase_length  += part.Length;
                        encoded_length += sub_query.Length;
                    }
                    else
                    {                     //very long phrase without separators - split it by space
                        int remainder_size = 0;
                        if (mode == SplitMode.Separators)
                        {
                            remainder_size = SplitToQueries(queries, part, SplitMode.Spaces, allowed_length);
                        }
                        else if (mode == SplitMode.Spaces)
                        {
                            remainder_size = SplitToQueries(queries, part, SplitMode.Size, allowed_length);
                        }
                        else
                        {
                            throw new InvalidOperationException("Wrong size of string : " + part);
                        }

                        //reset
                        sb.Length      = 0;
                        phrase_length  = 0;
                        encoded_length = 0;

                        if (remainder_size > 0 && remainder_size < allowed_length && queries[queries.Count - 1].Length < 500)
                        {                          //here possible to add some text to end
                            sb.Append(queries[queries.Count - 1]);
                            phrase_length  = sb.Length;
                            encoded_length = remainder_size;
                            queries.RemoveAt(queries.Count - 1);
                        }
                    }
                }
            }

            if (sb.Length > 0)
            {
                queries.Add(sb.ToString());
            }
            return(encoded_length);
        }
示例#30
0
 public Splitter(SplitMode mode, Palette palette)
 {
     Parameters = mode;
     _palette   = palette;
 }
示例#31
0
 public TypedTextSettings(SplitMode splitMode)
 {
     this.splitMode = splitMode;
     this.customSplitString = new List<string>() {",", "\n"};
     this.defaultTypeDelay = new TimeDelay(0.1f);
     this.customTypeDelays = new List<CustomStringTimeDelay>();
     this.customPostTypePause = new List<CustomStringTimeDelay>();
 }