Exemple #1
0
        public void packageCardAckTest()
        {
            Player      p    = Board.Instance.Me;
            Card        c    = Board.Instance.GetCard(EnSemi.BASTONI, EnNumbers.CINQUE);
            PackageCard pkgc = new PackageCard(p, c);

            byte [] bs = pkgc.getAckMessage();

            PackageCard pkgcRec = new PackageCard(PackageBase.getMessageFromAck(bs));

            Assert.AreEqual(EnPackageType.MOVE, pkgcRec.type);
            Assert.AreSame(p, pkgcRec.player);
            Assert.AreSame(c, pkgcRec.card);
        }
Exemple #2
0
        public void AddCard(Package package)
        {
            if (InvokeRequired)
            {
                BeginInvoke((MethodInvoker) delegate { AddCard(package); });
                return;
            }

            // Create Card
            PackageCard card = new PackageCard(package);

            int packageCards   = 0;
            int combinedHeight = 0;
            int firstX         = 0;

            foreach (Control control in panel3.Controls)
            {
                if (control is PackageCard)
                {
                    if (packageCards == 0)
                    {
                        firstX = control.Location.X;
                    }
                    packageCards++;
                    combinedHeight += control.Height;
                }
            }

            Console.WriteLine(packageCards == 0 ? combinedHeight : combinedHeight + 40);
            panel3.Controls.Add(card);

            card.Location = new Point(firstX, packageCards == 0 ? combinedHeight : combinedHeight);
            if (packageCards == 0)
            {
                CenterHorizontally(card, packageCards == 0 ? 0 : SystemInformation.VerticalScrollBarWidth, 0);
            }
        }
Exemple #3
0
        public ActionResult AddPackage()
        {
            var    currentCpy = GetCurrentUser();
            string type       = Request["type"];
            string state;

            if (type == "3")//独家礼包要审核的
            {
                state = "2";
            }
            else
            {
                state = "3";
            }
            Package package = new Package();

            package.CompanyId      = currentCpy.Id;
            package.GameName       = Request["gamename"];
            package.ServerName     = Request["servername"];
            package.Type           = Request["type"];
            package.GiftName       = Request["name"];
            package.StartDate      = DateTime.Parse(Request["startdate"]);
            package.EndDate        = DateTime.Parse(Request["enddate"]);
            package.Url            = Request["url"];
            package.Memo           = Request["memo"];
            package.Msg            = Request["msg"];
            package.State          = state;
            package.Rec            = "0";
            package.Rec_Hot        = "0";
            package.Rec_Index      = "0";
            package.Rec_Hot_Time   = DateTime.Now;
            package.Rec_Time       = DateTime.Now;
            package.Rec_Index_Time = DateTime.Now;
            package.InTime         = DateTime.Now;

            if (PackageBll.Add(package) != null)
            {
                //如果不为空、拿到其添加的id 据研究db.saveChange()后、EF会返回最新的自增id
                //拆分字符串、拆分成一个一个逐个添加。
                string      code      = Request["code"];
                string[]    splitCode = code.Trim().Split('\n');
                PackageCard card      = null;
                for (int i = 0; i < splitCode.Length; i++)
                {
                    card           = new PackageCard();
                    card.PackageId = package.Id;
                    card.UserId    = 0;
                    card.InTime    = DateTime.Now;
                    if (splitCode[i] == "" || splitCode[i] == null)
                    {
                        continue;
                    }
                    card.Code = splitCode[i];
                    PackageCardBll.Add(card);
                }
                return(Content("ok"));
            }
            else
            {
                return(Content("no"));
            }
        }