示例#1
0
        internal string FetchVehicleInfo(string regNum)
        {
            string searchReport = "Hittade ingen fordon med det reg-numret";

            using (SqlConnection connection = new SqlConnection(CONNECTION_STRING))
            {
                connection.Open();

                Console.WriteLine("Search result: ");
                SqlCommand command = new SqlCommand("SELECT v.Id, vh.Description, ph.ParkLocation FROM Vehicles V INNER JOIN VehicleTypes vh ON vh.Id = V.VehicleTypeId INNER JOIN ParkingSpace ph ON v.ParkingSpaceId = ph.Id WHERE RegNum = @regNum; ", connection);

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@regNum";
                param.Value         = regNum;
                command.Parameters.Add(param);
                command.CommandTimeout = 5;
                SqlDataReader searchResult = command.ExecuteReader();
                while (searchResult.Read())
                {
                    searchReport = TextFormater.VehicleSearchResult((int)searchResult[0],
                                                                    (string)searchResult[1],
                                                                    (int)searchResult[2],
                                                                    regNum);

                    //Console.WriteLine("id: {0}, typ: {1} plats: {2}",
                    //    searchResult[0],
                    //    searchResult[1]);
                }
                //int location = (int)searchResult[2];
                //string type = (string)searchResult[1];
                //int id =(int) searchResult[0];
                //searchReport = string.Format($"id: {id} typ: {type} {location} regnummer: {regNum}");
            }
            return(searchReport);
        }
示例#2
0
        public void Text_formater_should_identify_underscore_or_camel_case_text()
        {
            var textFormater = new TextFormater();

            Assert.That(textFormater.GetText("Hello_world_format_me_well"), Is.EqualTo("Hello world format me well"));
            Assert.That(textFormater.GetText("HelloWorldFormatMeWell"), Is.EqualTo("Hello world format me well"));
        }
示例#3
0
        public YesNoDialog(ContentManager content, string message)
        {
            Sprite = new Sprite(content, "General\\Dialog_BG");

            yesButton          = new Button(new Sprite(content, "General\\YesBtn_Normal"), new Sprite(content, "General\\YesBtn_Hover"));
            yesButton.Position = new Vector2(Sprite.Position.X + Sprite.Bound.Width / 2 - yesButton.Sprite.Bound.Width - 30,
                                             Sprite.Position.Y + Sprite.Bound.Height - 45
                                             );
            yesButton.ButtonEvent += YesBtn_Clicked;

            noButton          = new Button(new Sprite(content, "General\\NoBtn_Normal"), new Sprite(content, "General\\NoBtn_Hover"));
            noButton.Position = new Vector2(Sprite.Position.X + Sprite.Bound.Width / 2 + 30,
                                            Sprite.Position.Y + Sprite.Bound.Height - 45
                                            );
            noButton.ButtonEvent += NoBtn_Clicked;

            font = content.Load <SpriteFont>("ArialBold");

            messagePosition = new Vector2(Sprite.Position.X, Sprite.Position.Y);
            messageText     = TextFormater.getIntance().WordWrap(font, message, Sprite.Bound.Width - 60);

            Origin = new Vector2(Sprite.Bound.Width / 2, Sprite.Bound.Height / 2);

            float textheight = font.MeasureString(messageText).Y;
            float ratio      = (Sprite.Bound.Height + textheight) / Sprite.Bound.Height;

            Sprite.Scale = new Vector2(1, ratio);

            oldMousePos = new Point(0, 0);

            IsShow = false;

            inputControls = new InputController();
        }
示例#4
0
        public void JustifyTextOneShortWordSuccess()
        {
            TextFormater target   = new TextFormater();
            string       actual   = target.Justify("Thislinewillnotbejustified.", 80);
            const string expected = "Thislinewillnotbejustified.";

            Assert.AreEqual(expected, actual);
        }
示例#5
0
        public void JustifyTextMoreThanHalfOfWidthSuccess()
        {
            TextFormater target   = new TextFormater();
            string       actual   = target.Justify("This line will be justified because it is 45.", 80);
            const string expected = "This   line    will     be         justified          because     it    is   45.";

            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void JustifyText1Success()
        {
            TextFormater target   = new TextFormater();
            string       actual   = target.Justify("This is a test of a line to be fitted to a 80 character line.", 80);
            const string expected = "This  is  a  test  of  a   line   to    be   fitted  to  a  80  character  line.";

            Assert.AreEqual(expected, actual);
        }
示例#7
0
        public void Justify2Words19to19_Success()
        {
            TextFormater target   = new TextFormater();
            string       actual   = target.Justify("[Required] Required", 29);
            const string expected = "[Required] Required";

            Assert.AreEqual(expected, actual);
        }
        public new string ToString()
        {
            TextFormater tf = new TextFormater()
            {
                LevelDelta = 4
            };

            ToString(ref tf, 0);
            return(tf.StartFormat());
        }
示例#9
0
        public void BreakIntoLines1ShortWord80Width1LineSuccess()
        {
            TextFormater  target   = new TextFormater();
            List <string> actual   = target.BreakIntoLines("This", 80);
            List <string> expected = new List <string>()
            {
                "This"
            };

            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public DetailSideBar(ContentManager _content)
        {
            inputController = new InputController();
            contentManager  = _content;

            this.Sprite               = new Sprite(_content, "General\\detail");
            this.Sprite.Position      = new Vector2(0, 0);
            this.CardPreview          = new Sprite(SpriteManager.getInstance(_content).GetSprite(SpriteID.BBackSide));
            this.CardPreview.Position = new Vector2(this.Position.X + 5, this.Position.Y + 70);

            font         = _content.Load <SpriteFont>("ArialSmall");
            descPosition = new Vector2(this.Position.X + 15, this.Position.Y + 375);
            textBoxRect  = new Rectangle((int)descPosition.X, (int)descPosition.Y, 165, 140);

            //CARD DESCRIPTION LAY TRONG CARD DATA
            this.Description = CardData != null ? CardData.Description : "";
            //this.Description = "Dong thu nhat. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello. Hello.";

            this.Description = TextFormater.getIntance().WordWrap(font, this.Description, 170);

            scrollBtn = new Button(new Sprite(_content, "General\\scroll_bar"));
            scrollBtn.Sprite.Frame = new Rectangle(16, 16, 16, 16);

            scrollBtn.Position = new Vector2(this.Position.X + 189, this.Position.Y + 381);
            scrollBarHeight    = 129 - scrollBtn.Sprite.Frame.Height;

            var normalup = new Sprite(_content, "General\\scroll_bar");

            normalup.Frame = new Rectangle(16, 0, 16, 16);

            var hoverup = new Sprite(_content, "General\\scroll_bar");

            hoverup.Frame = new Rectangle(32, 0, 16, 16);

            upBtn              = new Button(normalup, hoverup);
            upBtn.Position     = new Vector2(this.Position.X + 189, this.Position.Y + 365);
            upBtn.ButtonEvent += MoveTextUp;

            var normaldown = new Sprite(_content, "General\\scroll_bar");

            normaldown.Frame = new Rectangle(16, 146, 16, 16);

            var hoverdown = new Sprite(_content, "General\\scroll_bar");

            hoverdown.Frame = new Rectangle(32, 146, 16, 16);

            downBtn              = new Button(normaldown, hoverdown);
            downBtn.Position     = new Vector2(this.Position.X + 189, this.Position.Y + 511);
            downBtn.ButtonEvent += MoveTextDown;
        }
示例#11
0
        public void BreakIntoLines10Words80Width3LinesSuccess()
        {
            TextFormater  target = new TextFormater();
            List <string> actual =
                target.BreakIntoLines(
                    "This is text should give no meaning what so ever. We are in this moment changing to second line. We should now be on the second line and if we write som more we get to the third line.",
                    80);
            List <string> expected = new List <string>()
            {
                "This is text should give no meaning what so ever. We are in this moment",
                "changing to second line. We should now be on the second line and if we write",
                "som more we get to the third line."
            };

            Assert.AreEqual(expected, actual);
        }
        public void ToString(ref TextFormater formater, int nowLevel)
        {
            bool   HaveText       = Text != null && Text != "";
            bool   HaveAttributes = Attributes.Count > 0;
            bool   HaveSubTag     = SubTags.Count > 0;
            string Start          = "";
            string Att            = "";
            string End            = "";
            string addition       = "";
            bool   OneLine        = true;

            if ((HaveText || HaveSubTag))
            {
                End     = $"</{Name}>";
                OneLine = !HaveSubTag;
            }
            else
            {
                End      = $"";
                OneLine  = true;
                addition = "/";
            }
            if (HaveAttributes)
            {
                List <string> attFormat = new List <string>();
                foreach (KeyValuePair <string, string> KeyPair in Attributes)
                {
                    attFormat.Add($"{KeyPair.Key}=\"{KeyPair.Value}\"");
                }
                Att = $" {String.Join(" ",attFormat)}";
            }
            Start = $"<{Name}{Att}{addition}>";
            if (OneLine)
            {
                formater.AddString(nowLevel, TextAlign.Top, $"{Start}{Text??""}{End}");
            }
            else
            {
                formater.AddString(nowLevel, TextAlign.Top, $"{Start}{Text ?? ""}");
                foreach (BinaryXmlTag sub in SubTags)
                {
                    sub.ToString(ref formater, nowLevel + 1);
                }
                formater.AddString(nowLevel, TextAlign.Top, End);
            }
        }
示例#13
0
        public void SetCardPreview(string cardid)
        {
            SpriteID spriteId;

            if (Enum.TryParse("B" + cardid, false, out spriteId))
            {
                this.CardPreview.Texture = SpriteManager.getInstance(contentManager).GetTexture(spriteId);
            }

            this.CardData = Cards.CardProvider.GetInstance().GetCardById(cardid);

            this.Description = CardData != null ? CardData.Description : "";
            this.Description = TextFormater.getIntance().WordWrap(font, this.Description, 170);

            //Reset Position
            descPosition       = new Vector2(this.Position.X + 15, this.Position.Y + 375);
            scrollBtn.Position = new Vector2(this.Position.X + 189, this.Position.Y + 381);
        }
示例#14
0
 public void Setup()
 {
     this.textFormater = new TextFormater();
 }