Exemple #1
0
 private void GameLoopHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
 {
     if (message == "null")
     {
         AffHand();
         if (Cards.Count > 0)
         {
             int       x = ReadLine();
             Card.Card a = Cards[x];
             if (SendPacket <string>("Game", JsonConvert.SerializeObject(a)) == 1)
             {
                 System.Environment.Exit(1);
             }
             Cards.RemoveAt(x);
         }
         else
         {
             if (SendPacket <string>("Game", "end") == 1)
             {
                 System.Environment.Exit(1);
             }
         }
     }
     else
     {
         Console.WriteLine(message);
         _End = true;
     }
 }
Exemple #2
0
 public void AddCard(Card.Card newCard)
 {
     if (newCard != null)
     {
         Cards.Add(newCard);
     }
 }
Exemple #3
0
 public Account(double money, Card.Card creditCard_, Client.Client client_, int clientNumber_)
 {
     creditCard    = creditCard_;
     balance       = money;
     client        = client_;
     accauntNumber = String.Format(Convert.ToString(clientNumber_) + creditCard.CardNumber);
 }
Exemple #4
0
 public bool getMoney(Card.Card creditCard, double money)
 {
     try
     {
         int accountIndex = FindAccount(creditCard);
         if (accountIndex == -1)
         {
             throw new IndexOutOfRangeException("Ваш счет аннулирован");
         }
         if (accaunts[accountIndex].Balance < money)
         {
             throw new Exception("Нехватает средств");
         }
         if (money < 0)
         {
             throw new Exception("Введена отрициательная сумма");
         }
         accaunts[accountIndex].Balance -= money;
         return(true);
     }
     catch (IndexOutOfRangeException ex)
     {
         Console.WriteLine(ex.Message);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(false);
 }
Exemple #5
0
        // TOOLS FUNCTION
        public void DistribCard(Deck deck)
        {
            List <List <Card.Card> > NewDecks = new List <List <Card.Card> >();

            foreach (User user in _Users)
            {
                NewDecks.Add(new List <Card.Card>());
            }
            while (deck.Packet.Any())
            {
                foreach (List <Card.Card> tmp in NewDecks)
                {
                    Card.Card temp = deck.PickACard();
                    if (temp != null)
                    {
                        tmp.Add(temp);
                    }
                }
            }
            int index = 0;

            foreach (User currentUser in _Users)
            {
                foreach (Card.Card card in NewDecks[index])
                {
                    Console.WriteLine(card.Color + " " + card.Name);
                }
                SendPacket("Card", currentUser, JsonConvert.SerializeObject(NewDecks[index]));
                index += 1;
            }
        }
        public override IConstellation Clone(Card.Card parentCard)
        {
            HoldingCardsConstellation newConstellation = new HoldingCardsConstellation(this.constellationPattern);

            newConstellation.parentCard = new WeakReference <Card.Card>(parentCard);

            return(newConstellation);
        }
Exemple #7
0
 public static int Create(User.User user, Card.Card card, ProjectWorkType workType, string proof)
 => ExecuteScalarInt(
     @"INSERT INTO card_works(guid, user_id, card_id, work_type_id, proof)
                        VALUES (@guid, @user_id, @card_id, @work_type_id, @proof);
                        SELECT currval('card_works_id_seq');"
     , new {
     guid = Guid.NewGuid().ToString(), user_id = user.id, card_id = card.id, work_type_id = workType.id,
     proof
 }
     );
Exemple #8
0
        public async Task UpdateCard(Card.Card oldCard, Card.Card newCard, byte[] image = null)
        {
            if (image != null)
            {
                newCard.Image = GetImageFromSource(image);
            }

            await UpdateCardInServiceAsync(oldCard, newCard);

            UpdateCards();
        }
Exemple #9
0
 public Card.Card getCreditCard(Client.Client client, double money)
 {
     Card.Card creditCard = new Card.Card(this, client);//банк сделал карточку
     //проверили есть ли еще место в массиве аккаунтов(счетов)
     if (numOfClients == accaunts.Length)
     {
         Array.Resize(ref accaunts, numOfClients * 2);
     }
     accaunts[numOfClients] = new Account.Account(money, creditCard, client, numOfClients); //создали аккаунт
     ++numOfClients;                                                                        //сделали инкремент к числу клиентов
     return(creditCard);                                                                    //вернули карточку человеку
 }
Exemple #10
0
        public override bool WantPick(Prompt prompt, List <IPlayer> players)
        {
            var jd = new Card.Card(CardID.Jack, CardPower.JackDiamond, Suit.Diamond);

            Hand.Cards.Sort();
            if (Hand.Cards[0].Power >= CardPower.JackDiamond)
            {
                return(true);
            }
            var qc         = new Card.Card(CardID.Queen, CardPower.QueenClub, Suit.Clubs);
            var qs         = new Card.Card(CardID.Queen, CardPower.QueenSpade, Suit.Spades);
            var trumpCount = 0;
            var queenCount = 0;
            var pointCards = 0;

            foreach (var card in Hand)
            {
                if (card.IsTrump())
                {
                    ++trumpCount;
                }
                if (card.ID == CardID.Queen)
                {
                    ++queenCount;
                }
                if (card.Value >= 10)
                {
                    ++pointCards;
                }
            }
            if (queenCount == 4)
            {
                return(true);
            }
            if (Hand.Cards.Contains(jd))
            {
                return(false);
            }
            if ((players.First() == this || players.Last() == this) && Hand.Cards.Contains(qc) && Hand.Cards.Contains(qs))
            {
                return(true);
            }
            if (queenCount >= 2 && trumpCount >= 3 && pointCards >= 1)
            {
                return(true);
            }
            if (queenCount >= 1 && trumpCount >= 4 && pointCards >= 1)
            {
                return(true);
            }
            return(trumpCount >= 5);
        }
Exemple #11
0
 public double getCardBalance(Card.Card creditCard)
 {
     for (int i = 0; i < accaunts.Length; ++i)
     {
         Card.Card card = accaunts[i].CreditCard;
         if (card.Bank == creditCard.Bank && card.CardNumber == creditCard.CardNumber &&
             card.ClientName == card.ClientName)
         {
             return(accaunts[i].Balance);
         }
     }
     return(-1.0);
 }
Exemple #12
0
        public CardEntity PickCard(Card.Card card, bool isFliped = true)
        {
            if (this.CardEntityPicked == null)
            {
                CardEntity cardEntity = new CardEntity(this, card, isFliped);

                this.AddEntityToLayer(cardEntity);

                this.CardEntityPicked = cardEntity;

                return(cardEntity);
            }
            return(null);
        }
        public void AddCardToBoard(Card.Card cardToAdd, Vector2f position)
        {
            CardEntity cardEntity = new CardEntity(this, cardToAdd, true);

            this.AddEntityToLayer(cardEntity);

            cardEntity.Position = position;

            this.CardsHand.Add(cardEntity);

            this.CardCreated?.Invoke(cardEntity);

            this.UpdateCardsHandPosition();
        }
Exemple #14
0
        public CardEntity UnpickCard(BoardNotifLayer boardNotifLayer, string detailUnpicked)
        {
            if (this.BoardGameLayer.CardEntityPicked != null)
            {
                Card.Card cardToUnpick  = this.BoardGameLayer.CardEntityPicked.Card;
                Vector2f  startPosition = GetPositionFrom(detailUnpicked);

                if (this.BoardGameLayer.UnPickCard() && boardNotifLayer != null)
                {
                    return(boardNotifLayer.UnpickCard(cardToUnpick, startPosition));
                }
            }

            return(null);
        }
Exemple #15
0
        public override bool WantPick(Prompt prompt, List <IPlayer> players)
        {
            ICard JD = new Card.Card(CardID.Jack, CardPower.JackDiamond, Suit.Diamond);

            if (Hand.Cards.Contains(JD))
            {
                return(false);
            }
            int handPower = Hand.Cards.Aggregate(0, (total, card) => total + (int)card.Power);

            if (handPower >= (int)CardPower.QueenHeart + (int)CardPower.QueenDiamond + (int)CardPower.JackClub + (int)CardPower.KingTrump)
            {
                return(true);
            }
            return(false);
        }
        public CardEntity UnpickCard(Card.Card cardToUnpick, Vector2f startPosition)
        {
            CardEntity cardEntity = new CardEntity(this, cardToUnpick, true);

            this.AddEntityToLayer(cardEntity);

            cardEntity.Position = startPosition;

            this.CardsHand.Add(cardEntity);

            this.CardUnpicked.Invoke(cardEntity);

            this.UpdateCardsHandPosition();

            return(cardEntity);
        }
Exemple #17
0
 public int FindAccount(Card.Card creditCard)
 {   //метод ищет в массиве аккаунтов акк кредиктой, которую мы передали
     //как притерий поиска
     for (int i = 0; i < accaunts.Length; ++i)
     {
         Card.Card card = accaunts[i].CreditCard;
         //можно было бы сравнить адреса кредиток в памяти машины, но это противоречит свойствам предметной области
         //поэтому сравнение идет по трем критериям.
         if (card.Bank == creditCard.Bank && card.CardNumber == creditCard.CardNumber &&
             card.ClientName == creditCard.ClientName)
         {
             return(i);
         }
     }
     return(-1);
 }
Exemple #18
0
        public void Discard(Card.Card playCard)
        {
            var keyValuePair = _hands.FirstOrDefault(kvp =>
            {
                return(kvp.Value != null &&
                       kvp.Value.Any(p =>
                {
                    return p.Id == playCard.Id;
                }));
            });

            if (!default(KeyValuePair <Guid, Hand.Hand>).Equals(keyValuePair))
            {
                _hands[keyValuePair.Key] = keyValuePair.Value.Discard(playCard.Id);
                _discarded.Add(playCard);
            }
        }
Exemple #19
0
        private async Task RemoveCardInServiceAsync(Card.Card card)
        {
            using (var content = new MultipartFormDataContent())
                using (var req = new HttpRequestMessage()
                {
                    Method = HttpMethod.Delete,
                    RequestUri = new Uri($"{ RequestUri }/{card.Title}")
                })
                {
                    int size = GetSizeBySource(ImageToByteArray(card.Image));
                    content.Add(new StringContent(size.ToString()),
                                String.Format("\"{0}\"", "size"));
                    req.Content = content;

                    await httpClient.SendAsync(req);
                }
        }
        public void AddCardToCemetery(Card.Card cardToAdd, Vector2f startPosition)
        {
            CardEntity cardEntity = new CardEntity(this, cardToAdd, true);

            this.AddEntityToLayer(cardEntity);

            if (this.BoardToLayerPositionConverter != null)
            {
                CardBoardLevel testLevelNode = this.ownerLevelNode as CardBoardLevel;

                startPosition = this.BoardToLayerPositionConverter.BoardToLayerPosition(testLevelNode.BoardGameLayer, startPosition);
            }

            cardEntity.Position = startPosition;

            this.CardsCemetery.Add(cardEntity);

            this.CardDestroyed?.Invoke(cardEntity);

            this.UpdateCardsCimeteryPosition();
        }
        public override void StartNotif(World world)
        {
            base.StartNotif(world);

            this.mustNotifyBehaviorEnd = false;

            //this.CardBehaviorOwner.OnBehaviorStart(this);

            //this.NodeLevel.GetLayerFromPlayer(this.OwnerCardEntity.Card.Player).CardPileFocused = BoardPlayerLayer.BoardPlayerLayer.PileFocused.CEMETERY;

            foreach (string cardId in this.NewCardIds)
            {
                Card.Card newCard = world.CardLibrary.CreateCard(cardId, this.OwnerCardEntity.Card.CurrentOwner);

                this.NodeLevel.BoardNotifLayer.AddCardToBoard(newCard, new SFML.System.Vector2f(0, 0));
            }

            this.NodeLevel.GetLayerFromPlayer(this.OwnerCardEntity.Card.CurrentOwner).CardPileFocused = BoardPlayerLayer.BoardPlayerLayer.PileFocused.NONE;

            this.State = SocketNewCardState.PICK_CARD;
        }
Exemple #22
0
        private async Task UpdateCardInServiceAsync(Card.Card oldCard, Card.Card newCard)
        {
            using (var content = new MultipartFormDataContent())
            {
                int sizeNewImage = GetSizeBySource(ImageToByteArray(newCard.Image));
                int sizeOldImage = GetSizeBySource(ImageToByteArray(oldCard.Image));

                content.Add(new StringContent(sizeNewImage.ToString()),
                            String.Format("\"{0}\"", "newSize"));
                content.Add(new StringContent(sizeOldImage.ToString()),
                            String.Format("\"{0}\"", "oldSize"));
                content.Add(new StringContent(newCard.Title.ToString()), "newTitle");
                content.Add(new StringContent(oldCard.Title.ToString()), "oldTitle");

                if (newCard.Image != null)
                {
                    content.Add(new StreamContent(new MemoryStream(ImageToByteArray(newCard.Image))), "image", "file.png");
                }


                await httpClient.PutAsync(RequestUri, content);
            }
        }
Exemple #23
0
        private void                            GamePacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
        {
            User user;

            Console.WriteLine(message);

            if ((user = getUser(connection.ConnectionInfo.RemoteEndPoint.ToString())) == null)
            {
                return;
            }

            if (message.Equals("end"))
            {
                _Game._GameState = GameState.Done;
                return;
            }

            Card.Card newCard = new Card.Card();
            newCard.Color = JsonConvert.DeserializeObject <Card.Card>(message).Color;
            newCard.Val   = JsonConvert.DeserializeObject <Card.Card>(message).Val;
            newCard.Name  = JsonConvert.DeserializeObject <Card.Card>(message).Name;

            user._Card = newCard;
        }
        public CardEntity UnpickCard(Card.Card cardToUnpick, Vector2f startPosition)
        {
            CardEntity cardEntity = new CardEntity(this, cardToUnpick, true);

            this.AddEntityToLayer(cardEntity);

            cardEntity.Position = startPosition;

            switch (this.pilePicked)
            {
            case PileFocused.HAND:
                this.CardsHand.Add(cardEntity);
                break;

            case PileFocused.CEMETERY:
                this.CardsCemetery.Add(cardEntity);
                break;
            }

            this.NotifyCardUnpicked(cardEntity, this.pilePicked);

            switch (this.pilePicked)
            {
            case PileFocused.HAND:
                this.UpdateCardsHandPosition();
                break;

            case PileFocused.CEMETERY:
                this.UpdateCardsCimeteryPosition();
                break;
            }

            this.pilePicked = PileFocused.NONE;

            return(cardEntity);
        }
Exemple #25
0
 public Card.Card getCreditCard(Client.Client client, double money)
 {
     Card.Card creditCard = new Card.Card(this, client);//банк сделал карточку
     //проверили есть ли еще место в массиве аккаунтов(счетов)
     if (numOfClients == accaunts.Length) Array.Resize(ref accaunts, numOfClients * 2);
     accaunts[numOfClients] = new Account.Account(money, creditCard, client, numOfClients);//создали аккаунт
     ++numOfClients;//сделали инкремент к числу клиентов
     return creditCard;//вернули карточку человеку
 }
Exemple #26
0
 public void DisplayDraw(Participant.Participant participant)
 {
     Card.Card newCard = participant.Hand[^ 1];
 private PublicCard CreatePublicCardFromCard(Card.Card card)
 => new PublicCard(card.id,
Exemple #28
0
        static void Main(string[] args)
        {
            if (false)
            {
                var usbDevices = GetUSBDevices();

                foreach (var usbDevice in usbDevices)
                {
                    Console.WriteLine("Device ID: {0}, PNP Device ID: {1}, Description: {2}",
                        usbDevice.DeviceID, usbDevice.PnpDeviceID, usbDevice.Description);
                }

                Console.Read();
            }

            if (false)
            {

                Console.WriteLine("Starting test of zip file extraction:::");
                var header = true;
                using (ZipFile zip = ZipFile.Read("C:\\Documents and Settings\\idCardDev\\Desktop\\PoliceBadge.zip"))
                {
                    foreach (ZipEntry entry in zip)
                    {
                        if (header)
                        {
                            Console.WriteLine("ZipFile: {0}", zip.Name);
                            if ((zip.Comment != null) && (zip.Comment != ""))
                            {
                                Console.WriteLine("Comment: {0}", zip.Comment);
                            }
                            Console.WriteLine(new String('-', 72));
                            header = false;
                        }
                        Console.WriteLine("{1,-22} {2,8} {3,5:F0}%  {4,8} {5,3} {0}",
                            entry.FileName,
                            entry.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
                            entry.UncompressedSize,
                            entry.CompressionRatio,
                            entry.CompressedSize,
                            (entry.UsesEncryption) ? "Y" : "N");
                        entry.Extract("C:\\Program Files\\Datacard\\ID Works\\Projects", ExtractExistingFileAction.OverwriteSilently);
                    }
                }
            }
            try
            {
                Card.ICard2 idCard = new Card.Card();
                idCard.Initialize();
                //idCard.SetCardByName("PoliceBadge", "PoliceBadge");
                idCard.SetCardByName("BYUProximityCard", "BYUProximityCard");
                short numFields = idCard.GetFieldCount();
                for (short i = 0; i < numFields; i++)
                {
                    System.Console.Write("Accessing field[" + i + "] - ");
                    short fieldId = idCard.GetFieldID(i);
                    try
                    {
                        string data = (string)idCard.GetFieldData(fieldId);
                        System.Console.WriteLine(data);
                    }
                    catch (Exception e)
                    {
                        System.Console.WriteLine(e.Message);
                    }
                    System.Console.Write(fieldId + " | " + (short)Card.CARD_CONSTANTS.IC_FIELDATTRIBUTE_NAME  + " | ");
                    try
                    {
                        dynamic variable = idCard.GetFieldInfo(fieldId, (short) Card.CARD_CONSTANTS.IC_FIELDATTRIBUTE_NAME);
                        short type = idCard.GetFieldInfo(fieldId, (short) Card.CARD_CONSTANTS.IC_FIELDATTRIBUTE_FIELDTYPE);
                        string typeString = "";
                        switch (type)
                        {
                            case (short) Card.CARD_CONSTANTS.IC_FIELDTYPE_BARCODE:
                                typeString = "BARCODE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_DATE:
                                typeString = "DATE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_ENCODER:
                                typeString = "ENCODER";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_IMAGE:
                                typeString = "IMAGE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_NOPRINT:
                                typeString = "NOPRINT";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_SHAPE:
                                typeString = "SHAPE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_SIGNATURE:
                                typeString = "SIGNATURE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_STATICIMAGE:
                                typeString = "STATICIMAGE";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_STATICTEXT:
                                typeString = "STATICTEXT";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_TEXT:
                                typeString = "TEXT";
                                break;
                            case (short)Card.CARD_CONSTANTS.IC_FIELDTYPE_VARIABLEGRAPHIC:
                                typeString = "VARIABLEGRAPHIC";
                                break;
                            default:
                                typeString = "Not a valid type.{" + type + "}";
                                break;
                        }
                        System.Console.WriteLine(variable + " - " + typeString);
                    }
                    catch (Exception e)
                    {
                        System.Console.WriteLine("Does not have this attribute.[" + e.Message + "]");
                    }
                }
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
            if (false)
            {
                try
                {
                    CaptureServer.ICaptureServer captureServer = new CaptureServer.CaptureServer();

                    int numCaptureDevs;
                    captureServer.GetNumCaptureScripts(out numCaptureDevs);
                    for (int i = 0; i < numCaptureDevs; i++)
                    {
                        string desc, id, configName;
                        bool isCapture, isHidden, isDisplayable;
                        captureServer.GetScriptInfo(i, out desc, out id, out configName, out isCapture, out isHidden, out isDisplayable);

                        System.Console.WriteLine(i + " | " + desc + " | " + id + " | " + configName + " | " + isCapture + " | " + isHidden + " | " + isDisplayable);
                    }
                    int captureStatus;
                    int status = 0;
                    //captureServer.CaptureData("C:\\temp\\capture.jpg", "TruPhotoCamera002", 1, 1, ref status, out captureStatus);
                    captureServer.CaptureData("C:\\temp\\capture.jpg", "Canon_DSLR_Plugin_001", 1, 1, ref status, out captureStatus);

                    switch (captureStatus)
                    {
                        case (int)CaptureServer.CaptureStatus.CS_CAPTURE_OK:
                            System.Console.WriteLine("OK");
                            break;
                        case (int)CaptureServer.CaptureStatus.CS_CAPTURE_CANCELED:
                            System.Console.WriteLine("CANCELED");
                            break;
                        case (int)CaptureServer.CaptureStatus.CS_CAPTURE_NONE:
                            System.Console.WriteLine("NONE");
                            break;
                        case (int)CaptureServer.CaptureStatus.CS_CAPTURE_ERROR:
                            System.Console.WriteLine("ERROR");
                            break;
                        default:
                            System.Console.WriteLine("Not valid output{" + captureStatus + "}");
                            break;
                    }

                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                }
            }
            try
            {
                PreviewCallerLib.IPreviewCaller preview = new PreviewCallerLib.CPreviewCaller();
                preview.Initialize();
                //preview.SetCardByName("PoliceBadge", "PoliceBadge");
                //preview.SetCardByName("BYUIdCard", "BYUIdCard");
                preview.SetCardByName("BYUProximityCard", "BYUProximityCard");
                short photoId = preview.GetFieldIDFromName("Photo");
                //preview.SetFieldDataByFile(photoId, "C:\\temp\\capture.jpg", 0);
                preview.SetFieldDataByFile(photoId, "C:\\temp\\meSimpsons.jpg", 0);
                //preview.SetFieldDataByFile(photoId, "C:\\Documents and Settings\\idCardDev\\My Documents\\Downloads\\m-cosmo6.jpg", 0);
                short fNameId = preview.GetFieldIDFromName("Name");
                preview.SetFieldData(fNameId, "Andrew Largey");
                /*short rankId = preview.GetFieldIDFromName("Rank");
                preview.SetFieldData(rankId, "Card Master");*/
                short cardRoleId = preview.GetFieldIDFromName("CardRole");
                preview.SetFieldData(cardRoleId, "Card Master");
                short cardIdCompId = preview.GetFieldIDFromName("CardId");
                preview.SetFieldData(cardIdCompId, "72-757-2276 02");
                short custom2Id = preview.GetFieldIDFromName("ExpirationDate");
                preview.SetFieldData(custom2Id, "01-JAN-0001");
                //short beardOnlyId = preview.GetFieldIDFromName("BeardOnly");
                //preview.SetFieldData(beardOnlyId, "true");
                //short DTFSymbolId = preview.GetFieldIDFromName("DTFSymbol");
                //preview.SetFieldData(DTFSymbolId, "true");
                //short BeardWithDTFId = preview.GetFieldIDFromName("BeardWithDTF");
                //preview.SetFieldData(BeardWithDTFId, "true");
                preview.CreatePreviewWindowLong((short)Preview.CARD_CONSTANTS.IC_CARDSIDE_FRONT, 0);
                System.Console.WriteLine("Window should be displayed.");
                System.Console.ReadLine();
                preview.DestroyPreviewWindow((short)Preview.CARD_CONSTANTS.IC_CARDSIDE_FRONT);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
            if (true)
            {
                try
                {
                    PrintDialog.IPrintDialog printerDialog = new PrintDialog.PrintDialog();
                    int status;
                    printerDialog.DisplayPrintDialog("Hello World", "Prox 2", 0, 0, 1, out status);
                    if (status != 0)
                    {
                        PrintServer.IDataInput2 dataInput = new PrintServer.DataInput2();
                        dataInput.Initialize();
                        //dataInput.BeginCardByName("PoliceBadge", "PoliceBadge", false, true, printerDialog.PrinterName, (short)printerDialog.NumCopies, 0, false);
                        //dataInput.BeginCardByName("BYUIdCard", "BYUIdCard", true, true, printerDialog.PrinterName, (short)printerDialog.NumCopies, 0, false);
                        dataInput.BeginCardByName("BYUProximityCard", "BYUProximityCard", true, true, printerDialog.PrinterName, (short)printerDialog.NumCopies, 0, false);
                        //dataInput.SetFieldDataFromFileByName("Photo", "C:\\temp\\capture.jpg", false);
                        dataInput.SetFieldDataFromFileByName("Photo", "C:\\temp\\meSimpsons.jpg", false);
                        //dataInput.SetFieldDataFromFileByName("Photo", "C:\\Documents and Settings\\idCardDev\\My Documents\\Downloads\\m-cosmo6.jpg", false);
                        dataInput.SetFieldDataByName("Name", "Andrew Largey");
                        dataInput.SetFieldDataByName("CardRole", "Card Master");
                        dataInput.SetFieldDataByName("CardId", "72-757-2276 02");
                        dataInput.SetFieldDataByName("ExpirationDate", "01-JAN-0001");
                        //dataInput.SetFieldDataByName("BeardOnly", "true");
                        dataInput.SetSubFieldDataByName("MagneticStripe", "Track 2", "727572276=02133");

                        dataInput.EndCard();
                        System.Console.WriteLine("Hit enter when the printing is finished");
                        System.Console.ReadLine();
                    }
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                }
            }
            if (false)
            {

                Console.WriteLine("Cleaning up the unzipped archive");

                System.IO.Directory.Delete("C:\\Program Files\\Datacard\\ID Works\\Projects\\PoliceBadge", true);
            }

            //SetupDiGetClassDevs

            //System.Console.WriteLine("Attempting to read from the prox reader");

            //var input = Console.ReadLine();

            //Console.WriteLine(String.Format("Data Read from input: ({0})", input));

            if (false)
            {
                var fileName = "BYUProximityCard.zip";
                var projectDirectory = "C:\\Program Files\\Datacard\\ID Works\\Projects\\";

                Console.WriteLine(String.Format("Calculating MD5 of {0}", fileName));
                FileStream file = new FileStream(String.Format("{0}{1}", projectDirectory, fileName), FileMode.Open);
                MD5 md5 = new MD5CryptoServiceProvider();
                byte[] retVal = md5.ComputeHash(file);
                file.Close();
                var encoding = BitConverter.ToString(retVal).Replace("-", String.Empty);

                Console.WriteLine(String.Format("Resulting HASH: {0}", encoding));
            }

            if (false)
            {
                Console.WriteLine("Accessing the PROX Reader");
                long DeviceId = 0;
                pcProxDLLAPI.USBDisconnect();
                var rc = pcProxDLLAPI.usbConnect();
                if (rc == 1)
                {
                    DeviceId = pcProxDLLAPI.GetDID();
                    Console.WriteLine("Connected to: " + DeviceId.ToString());
                    Console.WriteLine("Connected to Device: " + pcProxDLLAPI.getDeviceName());
                    Console.WriteLine("Load a prox card and press enter when ready to read the card");
                    Console.ReadLine();
                    byte[] idBuf = new byte[8];
                    int idRaw = 0;
                    int id = 0;
                    int fac = 0;
                    short bits = 0;
                    bits = pcProxDLLAPI.getActiveID(8);
                    for (short z = 0; z < 8; z++)
                    {
                        byte byteRead = pcProxDLLAPI.getActiveID_byte(z);
                        idBuf[7 - z] = byteRead;
                        idRaw = idRaw | byteRead << (z * 8);
                        Console.WriteLine("Reading byte {0}:{1:D}", z, byteRead);
                        Console.WriteLine("Value so far {0:X}", idRaw);
                    }
                    if (bits > 0)
                    {
                        id = (int)(idRaw & 0x0FFFFL);
                        fac = idRaw >> 16;
                        fac = fac & 0x0FF;
                        Console.WriteLine("Card Bits={0:D}, FAC={1:D}, ID={2:D}", bits, fac, id);
                    }
                    pcProxDLLAPI.USBDisconnect();
                    Console.WriteLine("Disconnected from USB Reader");
                }
                else
                {
                    Console.WriteLine("Failed to connect to a USB device");
                }
            }

            System.Console.WriteLine("end");
            System.Console.ReadLine();
        }
Exemple #29
0
 public void AddValue(Card.Card card)
 {
     _bookCards.Add(card);
     //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("AddValue"));
 }
Exemple #30
0
        public async Task RemoveCard(Card.Card card)
        {
            await RemoveCardInServiceAsync(card);

            UpdateCards();
        }
 public abstract IConstellation Clone(Card.Card parentCard);