예제 #1
0
        public void Draw(string uiText, SpriteFont uiFont, int uiSize, Color uiColor)
        {
            var v2 = Vector2.Transform(StartV, Matrix.Invert(Camera.Transform));

            //Sb.DrawString(Font, logMsg, cord, Color.Black);
            Sb.DrawString(uiFont, uiText, v2, uiColor);
        }
예제 #2
0
        private void GenerateFunctionStub(Routine function, RoutineModel model)
        {
            var paramStrings = function.Parameters
                               .Select(p => $"{Code.Reference(p.ClrType())} {(string.IsNullOrEmpty(p.Name) ? p.Name : Code.Identifier(p.Name))}");

            var identifier = GenerateIdentifierName(function, model);

            Sb.AppendLine();

            Sb.AppendLine($"[DbFunction(\"{function.Name}\", \"{function.Schema}\")]");

            if ((function as Function) !.IsScalar)
            {
                var returnType = paramStrings.First();
                var parameters = string.Empty;

                if (function.Parameters.Count > 1)
                {
                    parameters = string.Join(", ", paramStrings.Skip(1));
                }

                Sb.AppendLine($"public static {returnType}{identifier}({parameters})");

                Sb.AppendLine("{");
                using (Sb.Indent())
                {
                    Sb.AppendLine("throw new NotSupportedException(\"This method can only be called from Entity Framework Core queries\");");
                }

                Sb.AppendLine("}");
            }
예제 #3
0
        /// <summary>
        /// Handkles escape key - wipes out the input
        /// </summary>
        private void HandleEscape()
        {
            int currentLength = Sb.Length + 1; //so the esc char is also wiped out

            Sb.Clear();
            PrintWithPrompt(currentLength);
        }
        private void GenerateOnModelCreating(RoutineModel model)
        {
            Sb.AppendLine();
            Sb.AppendLine("protected void OnModelCreatingGeneratedProcedures(ModelBuilder modelBuilder)");
            Sb.AppendLine("{");

            using (Sb.Indent())
            {
                foreach (var procedure in model.Routines.Cast <Procedure>())
                {
                    if (procedure.NoResultSet)
                    {
                        continue;
                    }

                    int i = 1;
                    foreach (var resultSet in procedure.Results)
                    {
                        var suffix = $"{i++}";

                        if (!procedure.SupportsMultipleResultSet)
                        {
                            suffix = string.Empty;
                        }

                        var typeName = GenerateIdentifierName(procedure, model) + "Result" + suffix;

                        Sb.AppendLine($"modelBuilder.Entity<{typeName}>().HasNoKey().ToView(null);");
                    }
                }
            }

            Sb.AppendLine("}");
        }
예제 #5
0
        private int AlphaBeta(int[,] board, int nextPlayer, int depth, bool mini, bool init, int alpha, int beta)
        {
            if (depth == 0)
            {
                return(Sb.Score(board, Player));
            }

            List <int> moves = GetValidMoves(board);

            if (moves.Count == 0)
            {
                return(Sb.Score(board, Player));
            }

            Dictionary <int, int> results = new Dictionary <int, int>();

            int newAlpha = alpha;
            int newBeta  = beta;

            for (int i = 0; i < moves.Count; i++)
            {
                int[,] newBoard = Utils.ChangeBoard(board, moves[i], nextPlayer);

                var result = AlphaBeta(newBoard, Utils.OtherPlayer(nextPlayer), depth - 1, !mini, false, newAlpha, newBeta);
                results.Add(moves[i], result);

                //alphaBeta part
                if (mini)
                {
                    newBeta = result < newBeta ? result : newBeta;
                }
                else
                {
                    newAlpha = result < newAlpha ? newAlpha : result;
                }
                if (newBeta <= newAlpha)
                {
                    break;
                }
            }

            if (init)
            {
                int maxValue = results.Values.Max();
                var result   = results.FirstOrDefault(x => x.Value == maxValue);
                return(result.Key);
            }

            if (mini)
            {
                int minValue = results.Values.Min();
                return(minValue);
            }
            else
            {
                int maxValue = results.Values.Max();
                return(maxValue);
            }
        }
예제 #6
0
        private string ProcessSqlMacro(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return(value);
            }

            // вычисляем макросы, т.к. могут использоваться в запросе
            var subsValue = Sb.Substitute(value);

            if (!subsValue.StartsWith(SqlMacroSuf))
            {
                return(subsValue);
            }

            try
            {
                // вычленяем запрос
                var sql = subsValue.Replace(SqlMacroSuf, String.Empty);
                sql = sql.Substring(0, sql.Length - 1);

//                foreach (var param in Params)
//                {
//                    var paramName = param.OutputParamCode[0] == '{' ? param.OutputParamCode : "{" + param.OutputParamCode + "}";
//                    sql = sql.Replace(paramName, param.Value);
//                }

                using (var mgr = IoC.Instance.Resolve <IBPProcessManager>())
                {
                    var table = mgr.ExecuteDataTable(sql);
                    if (table == null || table.Rows.Count == 0)
                    {
                        throw new DeveloperException("Вернулось 0 строк данных");
                    }

                    if (table.Rows[0].IsNull(0))
                    {
                        throw new DeveloperException("Вернулось пустое значение");
                    }

                    var name = Convert.ToString(table.Rows[0][0], CultureInfo.InvariantCulture);
                    if (string.IsNullOrEmpty(name))
                    {
                        throw new DeveloperException("Вернулась пустая строка");
                    }

                    // текст может быть в ковычках
                    subsValue = name.Replace("'", "");
                }
            }
            catch (Exception ex)
            {
                var message = string.Format("Ошибка получения значения по макросу {0}. {1}", value, ex.Message);
                throw new DeveloperException(message, ex);
            }

            // приводим еще раз, т.к. могли появиться новые макросы
            return(Sb.Substitute(subsValue));
        }
예제 #7
0
        public string Parse(IByteBuffer value)
        {
            Buf = value;
            ReadPacketLen();
            int  packet_type  = Buf.ReadInt();
            byte encrypt_type = Buf.ReadByte();

            if (packet_type == 0x0A)
            {
                Sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine();
                if (encrypt_type == 0x01)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0A01();
                }
                else if (encrypt_type == 0x02)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0A02();
                }
                else if (encrypt_type == 0x00)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0A00();
                }
                else
                {
                    throw new InvalidOperationException("invalid encrypt_type: " + encrypt_type.HexPadLeft());
                }
            }
            else if (packet_type == 0x0B)
            {
                Sb.Append(packet_type.HexPadLeft().HexDump()).Append(" //packet_type").AppendLine();
                if (encrypt_type == 0x01)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0B01();
                }
                else if (encrypt_type == 0x02)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0B02();
                }
                else if (encrypt_type == 0x00)
                {
                    Sb.Append(encrypt_type.HexPadLeft().HexDump()).Append(" //encrypt_type").AppendLine();
                    Resolve0B00();
                }
                else
                {
                    throw new InvalidOperationException("invalid encrypt_type: " + encrypt_type.HexPadLeft());
                }
            }
            else
            {
                throw new InvalidOperationException("invalid packet_type: " + packet_type.HexPadLeft());
            }
            return(Sb.ToString());
        }
예제 #8
0
 //---------------------------------------------------------------------
 public string CombinePersistentDataPath(string path, bool for_lua = false)
 {
     Sb.Length = 0;
     Sb.Append(PersistentDataPath);
     Sb.Append("/");
     Sb.Append(path);
     return(Sb.ToString());
 }
예제 #9
0
 //---------------------------------------------------------------------
 public string CombineWWWStreamingAssetsPath(string path)
 {
     Sb.Length = 0;
     Sb.Append(WWWStreamingAssetsPath);
     Sb.Append("/");
     Sb.Append(path);
     return(Sb.ToString());
 }
예제 #10
0
 private void ShowSubtotal(ISubtotalResult sub)
 {
     if (sub.Items == null)
     {
         Sb.AppendLine($"{m_Path}\t{m_Formatter.GetFundString(sub.Fund)}");
     }
     VisitChildren(sub);
 }
예제 #11
0
 //---------------------------------------------------------------------
 public string CombineWWWPersistentDataPath(string path)
 {
     Sb.Length = 0;
     Sb.Append(WWWPersistentDataPath);
     Sb.Append("/");
     Sb.Append(path);
     return(Sb.ToString());
 }
예제 #12
0
 /// <summary>
 /// Handles backspace
 /// </summary>
 private void HandleBackspace()
 {
     //remove a char
     if (Sb.Length > 0)
     {
         Sb.Remove(Sb.Length - 1, 1);
     }
     PrintWithPrompt(1);
 }
        public override void UnExecute()
        {
            //Should add error checking here
            var entryLength = Entries[Entries.Count - 1].Length;
            var totalLength = Sb.Length;

            Sb.Remove(totalLength - entryLength, entryLength);
            Entries.RemoveAt(Entries.Count - 1);
        }
예제 #14
0
        /// <summary>
        ///     Moves the specified blocks.
        /// </summary>
        /// <param name="blocks">The blocks.</param>
        private void Move(int blocks)
        {
            // Store starting point.
            string startPoint = Coordinates();

            for (var i = 0; i < blocks; i++)
            {
                // Move 1 block at a time - required for Part 2
                int x = CurrentPoint.X;
                int y = CurrentPoint.Y;
                switch (CurrentDirection)
                {
                case Direction.East:
                    x++;
                    break;

                case Direction.West:
                    x--;
                    break;

                case Direction.North:
                    y++;
                    break;

                case Direction.South:
                    y--;
                    break;

                default:
                    Console.WriteLine(
                        $"Huh? It seems that you're trying to move in a non-standard direction. ({CurrentDirection})");
                    break;
                }

                // Set current position.
                CurrentPoint = new Point(x, y);

                // If there are any points in our log of previously visited points (X and Y coordinates match),
                // and we have not found a previously-visited block, set this block as our first revisited block.
                if (Points.Any(point => CurrentPoint.X == point.X && CurrentPoint.Y == point.Y) &&
                    FirstRevisitedPoint.X == 0 &&
                    FirstRevisitedPoint.Y == 0)
                {
                    FirstRevisitedPoint = CurrentPoint;
                }

                // Add the current point to our log of positions.
                Points.Add(CurrentPoint);
            }

            // Add the current movement to our log.
            Sb.AppendLine(string.Join(",", CurrentDirection.ToString(), blocks.ToString(), CurrentPoint.X.ToString(),
                                      CurrentPoint.Y.ToString()));
            Console.WriteLine(
                $"Travelled {blocks.ToString().PadLeft(6)} blocks {CurrentDirection.ToString().PadRight(10)} from {startPoint.PadRight(5)} to {Coordinates().PadRight(8)}");
        }
예제 #15
0
 public void Draw(FloatPoint center, Vector2 size)
 {
     Sb.Draw(Texture,
             destinationRectangle: new Rectangle((int)center.X, (int)center.Y, (int)size.X, (int)size.Y),
             sourceRectangle: new Rectangle(0, 0, (int)SizeX, (int)SizeY),
             color: Color.White,
             rotation: (MathHelper.PiOver2 / 3.0f) + (MathHelper.PiOver2 / 1.5f) * Rotation,
             origin: new Vector2(size.X / 2, size.Y / 2)
             );
 }
예제 #16
0
파일: 4033003.cs 프로젝트: qifanyyy/CLCDSA
 public void Dispose()
 {
     if (!this.IsReactive)
     {
         this.Out.Write(Sb.ToString());
     }
     if (!this.Out.Equals(Console.Out))
     {
         this.Out.Dispose();
     }
 }
        private void AppendValue(ModuleParameter parameter)
        {
            var value = parameter.Nullable ? $"{Code.Identifier(parameter.Name)} ?? Convert.DBNull" : $"{Code.Identifier(parameter.Name)}";

            if (parameter.Output)
            {
                value = parameter.Nullable ? $"{Code.Identifier(parameter.Name)}?._value ?? Convert.DBNull" : $"{Code.Identifier(parameter.Name)}?._value";
            }

            Sb.AppendLine($"Value = {value},");
        }
예제 #18
0
        public void Draw(Texture2D texture)
        {
            var v2 = Vector2.Transform(StartV, Matrix.Invert(Camera.Transform));

            Sb.Draw(
                texture,
                destinationRectangle: new Rectangle((int)v2.X, (int)v2.Y, (int)Size.X, (int)Size.Y),
                sourceRectangle: new Rectangle(0, 0, 100, 100),
                color: Color.White
                // origin: new Vector2(Size.X / 2, Size.Y / 2)
                );
        }
        public override void UnExecute()
        {
            if (!Entries.Any())
            {
                return;
            }

            var lastEntry = Entries.Last();

            Sb.Remove(Sb.Length - lastEntry.Length, lastEntry.Length);

            Entries.Remove(lastEntry);
        }
예제 #20
0
    void DoSwap()
    {
        if (Fb && Sb && Fb.GetComponent <heap_balloon> ()._CurSurface&& Sb.GetComponent <heap_balloon> ()._CurSurface)
        {
            GameObject first  = Fb.GetComponent <heap_balloon> ()._CurSurface;
            GameObject second = Sb.GetComponent <heap_balloon> ()._CurSurface;

            Vector3 temp = new Vector3(first.transform.position.x, first.transform.position.y, first.transform.position.z);
            first.transform.position  = new Vector3(second.transform.position.x, second.transform.position.y, second.transform.position.z);
            second.transform.position = temp;
            StartCoroutine(moveDelay(first, second));
        }
    }
예제 #21
0
    public string GetJSONString(DataTable Dt)
    {
        string[]      StrDc   = new string[Dt.Columns.Count];
        string        HeadStr = string.Empty;
        StringBuilder Sb      = new StringBuilder();

        if (Dt.Rows.Count > 0)
        {
            if (Dt.Columns.Count > 0)
            {
                for (int i = 0; i < Dt.Columns.Count; i++)
                {
                    StrDc[i] = Dt.Columns[i].Caption;

                    HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";
                }

                HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);


                // Sb.Append("{\"" + Dt.TableName + "\" : [");
                Sb.Append("[");

                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    string TempStr = HeadStr;
                    Sb.Append("{");

                    for (int j = 0; j < Dt.Columns.Count; j++)
                    {
                        TempStr = TempStr.Replace("<br>", Environment.NewLine).Replace(Dt.Columns[j] + j.ToString() + "¾", Dt.Rows[i][j].ToString());
                    }

                    Sb.Append(TempStr + "},");
                }

                Sb = new StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1));
                //Sb.Append("]}");
                Sb.Append("]");
            }
            else
            {
                Sb.Append("[]");
            }
        }
        else
        {
            Sb.Append("[]");
        }
        return(Sb.ToString());
    }
예제 #22
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            int           i;
            string        exclusion, date = GetDistinctDate(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday) - CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now.AddDays(1 - DateTime.Now.Day), CalendarWeekRule.FirstDay, DayOfWeek.Sunday) + 1);
            List <string> code = new List <string>
            {
                AxAPI.GetFutureCodeByIndex(e.nErrCode)
            };

            for (i = 2; i < 4; i++)
            {
                foreach (var om in AxAPI.GetActPriceList().Split(';'))
                {
                    exclusion = AxAPI.GetOptionCode(om.Insert(3, "."), i, date);

                    if (code.Exists(o => o.Equals(exclusion)))
                    {
                        continue;
                    }

                    code.Add(exclusion);
                }
            }
            code.RemoveAt(1);
            Sb = new StringBuilder(32);
            var absence = Sql.GetSchema("Columns").Rows;

            for (i = 0; i < code.Count; i++)
            {
                if (absence.Cast <DataRow>().Where(o => o.ItemArray.Contains(code[i])).Any() == false)
                {
                    var sql = Sql.CreateCommand();
                    sql.CommandText    = GetQuery(code[i], date);
                    sql.CommandTimeout = 0;
                    sql.CommandType    = CommandType.Text;
                    sql.BeginExecuteNonQuery();
                }
                Sb.Append(code[i]);

                if (i > 0 && i % 99 == 0 || i == code.Count - 1)
                {
                    AxAPI.CommKwRqData(Sb.ToString(), 0, 100, 3, "OPTFOFID", new Random().Next(1000, 10000).ToString());
                    Sb = new StringBuilder(32);

                    continue;
                }
                Sb.Append(';');
            }
            code.Clear();
        }
예제 #23
0
파일: Hex.cs 프로젝트: ursinewalrus/Hexes
        public void Draw()
        {
            //https://www.codeproject.com/Articles/1119973/Part-I-Creating-a-Digital-Hexagonal-Tile-Map
            //public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth);
            var effect = SpriteEffects.None;

            //:TODO list of flippables
            //if you want weird effects that animate way too fast
            //if (RandomEffectSet == false &&  Name == "boulder")
            //{
            //    Effect = (SpriteEffects)new Random().Next(3);
            //    RandomEffectSet = true;
            //}
            Sb.Draw(texture: Texture,
                    destinationRectangle: new Rectangle((int)Center.X, (int)Center.Y, (int)SizeX * 2, (int)SizeY * 2),
                    //this is inconsistent -> maybe not anymore
                    sourceRectangle: new Rectangle(ResizeLeft, 0, ResizeRight, (int)SizeY),
                    color: Color,
                    origin: new Vector2(SizeX / 2, SizeY / 2)
                    //scale: new Vector2(9000,0.5f),
                    //effects: Effect
                    //layerDepth: 0.0f
                    );
            if (Highlighted)
            {
                Sb.Draw(texture: HighlightedTexture,
                        destinationRectangle: new Rectangle((int)Center.X, (int)Center.Y, (int)SizeX * 2, (int)SizeY * 2),
                        //this is inconsistent -> maybe not anymore
                        sourceRectangle: new Rectangle(ResizeLeft, 0, ResizeRight, (int)SizeY),
                        color: Color,
                        origin: new Vector2(SizeX / 2, SizeY / 2)
                        //scale: new Vector2(9000,0.5f),
                        //effects: SpriteEffects.None,
                        //layerDepth: 0.0f
                        );
            }
            foreach (Line line in Edges)
            {
                //if (Hovered)
                //{
                //    line.Draw(Color.Yellow);
                //}
                //else
                //{
                //    line.Draw(Color.Black);
                //}
                line.Draw();
            }
        }
예제 #24
0
        /// <summary>
        /// Export the graph associated to the specified data into a csv file.
        /// </summary>
        /// <param name="xLabel"></param>
        /// <param name="yLabel"></param>
        /// <param name="categories"></param>
        /// <param name="graphList"></param>
        public void ExportGraph(String xLabel, String yLabel, List <String> categories, IEnumerable <FusionChartsDataset> graphList)
        {
            var str = String.Concat(xLabel, Separator, yLabel);

            Sb.AppendLine(Format(str));

            for (var i = 0; i < categories.Count; i++)
            {
                var str2 = graphList.Aggregate(String.Empty, (current, d) => String.Concat(current, d.Values[i], Separator));

                str = String.Concat(categories[i], Separator, str2.TrimEnd(Separator));

                Sb.AppendLine(Format(str.Replace('.', ',')));
            }
        }
예제 #25
0
 //maybe also a draw that just takes the R/Q cords?
 public void Draw(Vector2 center)
 {
     //special draw for factions :TODO
     if (Controllable)
     {
         Sb.DrawString(Font, "A", center - new Vector2(50, 50), Color.Black);
     }
     Sb.Draw(Texture,
             destinationRectangle: new Rectangle((int)center.X, (int)center.Y, (int)SizeX, (int)SizeY),
             sourceRectangle: new Rectangle(0, 0, (int)SizeX, (int)SizeY),
             color: Color.White,
             rotation: (MathHelper.PiOver2 / 3.0f) + (MathHelper.PiOver2 / 1.5f) * Rotation,
             origin: new Vector2(SizeX / 2, SizeY / 2)
             );
 }
        StringBuilder CreatePath(int col, int row)
        {
            //  'b'   represents black square
            //  'w'   represents white square
            //  '↑'    represents upwards
            //  '↓'   represents downwards
            //  '→'   represents right side
            //  '←'   represents left side
            //  '0'    untouch squares
            //  'X'   represents the borders


            if (Machine.ContainsKey(new Position(col, row)))
            {
                Sb.Append(Machine.CurrentCotainsKeyColor == true ? "b" : "w");

                switch (Machine.CurrentCotainsDirection)
                {
                case Direction.UP:
                    Sb.Append("↑  ");
                    break;

                case Direction.DOWN:
                    Sb.Append("↓  ");
                    break;

                case Direction.LEFT:
                    Sb.Append("←  ");
                    break;

                case Direction.RIGH:
                    Sb.Append("→  ");
                    break;

                default:
                    break;
                }
            }
            else
            {
                // untouch squares
                Sb.Append("0   ");
            }

            return(Sb);
        }
예제 #27
0
        public HttpResponseMessage EditExam([FromBody] ExamInfo m)
        {
            if (m == null)
            {
                return(ResultHelper.Failed("类容不能为空"));
            }
            var eInfo = MongoDbHelper.FindOne <E_Info>(m.ID, DbName.E_Info);

            if (eInfo == null)
            {
                return(ResultHelper.Failed("未找到该次考试信息"));
            }
            eInfo.tet = m.TchEndTime;
            eInfo.set = m.StuEndTime;
            eInfo.enm = m.ExamName;
            if (Function.ConvertDateI(DateTime.Now) < eInfo.sst && Function.ConvertDateI(DateTime.Now) < eInfo.tst)//考试还没开始导入
            {
                eInfo.sst    = m.StuStartTime;
                eInfo.tst    = m.TchStartTime;
                eInfo.stcfm  = 0;
                eInfo.tchcfm = 0;
                eInfo.sbs    = new List <Sb>();
                eInfo.stps   = new List <Stp>();
                foreach (var item in m.subNames)
                {
                    Sb sb = new Sb();
                    sb._id   = item.Key;
                    sb.sbnm  = item.Value;
                    sb.stct  = 0;
                    sb.tchct = 0;
                    eInfo.sbs.Add(sb);
                }
                string[] stuType = m.stuTypes.Split(',');
                foreach (var item in stuType)
                {
                    Stp sTp = new Stp()
                    {
                        _id = ObjectId.GenerateNewId(), tp = item
                    };
                    eInfo.stps.Add(sTp);
                }
            }
            MongoDbHelper.ReplaceOne(m.ID, eInfo, DbName.E_Info);
            return(ResultHelper.OK());
        }
        //Appends the message, along with a date and report level
        public void Append(string dateTime, string reportLevel, string message)
        {
            //Parses the reportLevel to an integer, so as to check
            //if the message is a high enough reportLevel to be appended
            int lvl = (int)ReportLevel.Parse(typeof(ReportLevel), reportLevel);

            if (lvl >= (int)ReportLevel)
            {
                Sb.AppendFormat(Layout.Format, dateTime, reportLevel, message);
                Console.WriteLine(Sb.ToString());
                //Clearing the stringBuilder is important,
                //or else the second message will contain the entirety of the first aswell,
                //resulting in unwanted behaviour
                Sb.Clear();
                //Increments the message counter
                appendedMessages++;
            }
        }
예제 #29
0
        /// <summary>
        /// Prints a current command with Prompt
        /// </summary>
        /// <param name="clearAfter">How many chars after the promt + command should be cleared</param>
        /// <param name="cursorPosition">Where to place the cursor once command is printed</param>
        private void PrintWithPrompt(int clearAfter = 0, int?cursorPosition = null)
        {
            Console.CursorLeft = 0;

            PrintPrompt();
            Console.Write(Sb.ToString());

            if (clearAfter > 0)
            {
                Console.Write(string.Join("", Enumerable.Repeat(" ", clearAfter).ToArray()));
                Console.CursorLeft -= clearAfter;
            }

            if (cursorPosition.HasValue)
            {
                Console.CursorLeft = (int)cursorPosition;
            }
        }
예제 #30
0
파일: Line.cs 프로젝트: ursinewalrus/Hexes
        //https://gamedev.stackexchange.com/questions/44015/how-can-i-draw-a-simple-2d-line-in-xna-without-using-3d-primitives-and-shders
        //https://gamedev.stackexchange.com/questions/26013/drawing-a-texture-line-between-two-vectors-in-xna-wp7
        public void Draw()
        {
            Vector2 edge  = EndV - StartV;
            float   angle = (float)Math.Atan2(edge.Y, edge.X);

            //float drawPosZ = Color.Yellow == lineColor ? 0f : 0.01f;

            Sb.Draw(Texture,
                    StartV,
                    null,
                    LineColor,
                    (float)Math.Atan2(EndV.Y - StartV.Y, EndV.X - StartV.X),
                    new Vector2(0f, (float)Texture.Height / 2),
                    new Vector2(Vector2.Distance(StartV, EndV), WidthMultiplier), //float for width
                    SpriteEffects.None,
                    0f
                    );
        }