示例#1
0
        void card_objectChanged(ICard card, ICardObject obj, ChangeType change)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new Action <Card, ICardObject, ChangeType>((a, b, c) =>
                {
                    card_objectChanged(a, b, c);
                }), card, obj, change);
                return;
            }
            if (change == ChangeType.Deleted)
            {
                delNode(treeView1.Nodes, obj);
            }

            if (change == ChangeType.Created)
            {
                TreeNodeCollection parentNode = null;
                if (obj.Parent == null)
                {
                    parentNode = treeView1.Nodes;
                }
                else
                {
                    parentNode = objNodes[obj.Parent].Nodes;
                }

                TreeNode node = parentNode.Add(obj.ID.ToString("X04") + " " + obj.Description);
                node.ImageIndex         = getImageIndex(obj);
                node.SelectedImageIndex = node.ImageIndex;
                node.Tag      = obj;
                objNodes[obj] = node;
                if (obj is IObjectWithDataRecords)
                {
                    AddRecords(obj, node);
                }
                return;
            }
            else if (change == ChangeType.Selected)
            {
                objNodes[obj].NodeFont = selectedFont;
                return;
            }
            else if (change == ChangeType.Unselected)
            {
                objNodes[obj].NodeFont = DefaultFont;
                return;
            }
            else if (change == ChangeType.Modified)
            {
                if (obj is IObjectWithDataRecords)
                {
                    objNodes[obj].Nodes.Clear();
                    AddRecords(obj, objNodes[obj]);
                }
            }
        }
示例#2
0
        public void RemoveChild(ICardObject obj)
        {
            int i = childs.IndexOf(obj);

            if (i >= 0)
            {
                childs.RemoveAt(i);
                owner.ObjectChanged(obj, ChangeType.Deleted);
            }
        }
        public bool IsVerifiedAC(ICardObject obj, byte ac)
        {
            if (!(obj is IObjectWithAC))
            {
                throw new ISO7816Exception(Error.InternalError);
            }
            IObjectWithAC acObj     = obj as IObjectWithAC;
            byte          condition = acObj.AC[ac];

            if (condition == AC.Never)
            {
                return(false);
            }
            if (condition == AC.Always)
            {
                return(true);
            }
            BSO refrencedObject = obj is DF ? (obj as DF).GetChildBSO(condition, true) : obj.Parent.GetChildBSO(condition, true);

            if (context.securityStatus.ContainsKey(condition))
            {
                BSO bso = context.securityStatus[condition];
                if (refrencedObject == bso)
                {
                    if (bso.CurValidityCounter == 0)
                    {
                        context.securityStatus.Remove((byte)bso.ID);
                        return(false);
                    }
                    else if (bso.CurValidityCounter != 0xff)
                    {
                        bso.CurValidityCounter--;
                    }
                    return(true);
                }
                return(false);
            }
            else
            {
                // potrebbe essereun logical
                if (refrencedObject == null)
                {
                    return(false);
                }
                if (refrencedObject.Algo == BSOAlgo.Logic)
                {
                    int exprLen;
                    return(TestLogic(refrencedObject, refrencedObject.Data.Length - 1, out exprLen));
                }
                else
                {
                    return(false);
                }
            }
        }
        private static ICardCollection SetupFaceUpPileMock()
        {
            var faceUpPile = Substitute.For <ICardCollection>();

            faceUpPile.Count.Returns(1);

            ICardObject card = SetupHearts3CardMock();

            faceUpPile.PopNextCard().Returns(card);

            return(faceUpPile);
        }
 int getImageIndex(ICardObject obj)
 {
     if (obj is DF)
         return 1;
     else if (obj is EF)
         return 2;
     else if (obj is BSO)
         return 0;
     else if (obj is SecurityEnvironmenet)
         return 3;
     else return 0;
 }
示例#6
0
 void setOwner(ICardObject obj, IISO7816Card owner)
 {
     obj.Owner = owner;
     if (obj is DF)
     {
         DF df = obj as DF;
         foreach (var c in df.Childs)
         {
             setOwner(c, owner);
         }
     }
 }
示例#7
0
        private void Elimina(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }
            ICardObject obj = treeView1.SelectedNode.Tag as ICardObject;

            if (obj.Parent != null)
            {
                obj.Parent.RemoveChild(obj);
            }
        }
        public bool Equals(ICardObject x, ICardObject y)
        {
            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Type == null || y.Type == null)
            {
                return(false);
            }

            return(x.Type.Value == y.Type.Value);
        }
 bool delNode(TreeNodeCollection coll, ICardObject obj)
 {
     foreach (TreeNode c in coll)
     {
         if (c.Tag == obj)
         {
             c.Remove();
             return true;
         }
         if (c.Nodes.Count > 0)
             if (delNode(c.Nodes, obj))
                 return true;
     }
     return false;
 }
示例#10
0
        private void creaEFTLVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }
            ICardObject obj = treeView1.SelectedNode.Tag as ICardObject;

            if (!(obj is DF))
            {
                return;
            }
            DF df = obj as DF;

            card.CreateEFLinearTLV(1, df, 10);
        }
示例#11
0
        private void CreaSE(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                return;
            }
            ICardObject obj = treeView1.SelectedNode.Tag as ICardObject;

            if (!(obj is DF))
            {
                return;
            }
            DF df = obj as DF;

            card.CreateSE(1, df);
        }
示例#12
0
        private static void AddRecords(ICardObject obj, TreeNode node)
        {
            var recs   = obj as IObjectWithDataRecords;
            int numRec = 0;

            if (recs.Data == null)
            {
                return;
            }
            foreach (var v in recs.Data)
            {
                var recNode = node.Nodes.Add("Record " + numRec.ToString());
                recNode.Tag        = new RecObj(recs, numRec);
                recNode.ImageIndex = recNode.SelectedImageIndex = 4;
                numRec++;
            }
        }
示例#13
0
 bool delNode(TreeNodeCollection coll, ICardObject obj)
 {
     foreach (TreeNode c in coll)
     {
         if (c.Tag == obj)
         {
             c.Remove();
             return(true);
         }
         if (c.Nodes.Count > 0)
         {
             if (delNode(c.Nodes, obj))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#14
0
 int getImageIndex(ICardObject obj)
 {
     if (obj is DF)
     {
         return(1);
     }
     else if (obj is EF)
     {
         return(2);
     }
     else if (obj is BSO)
     {
         return(0);
     }
     else if (obj is SecurityEnvironmenet)
     {
         return(3);
     }
     else
     {
         return(0);
     }
 }
示例#15
0
 public int GetHashCode(ICardObject obj)
 {
     return(obj.Type.GetHashCode());
 }
 void setOwner(ICardObject obj, IISO7816Card owner)
 {
     obj.Owner = owner;
     if (obj is DF)
     {
         DF df = obj as DF;
         foreach (var c in df.Childs)
         {
             setOwner(c, owner);
         }
     }
 }
 private static void AddRecords(ICardObject obj, TreeNode node)
 {
     var recs = obj as IObjectWithDataRecords;
     int numRec = 0;
     if (recs.Data == null)
         return;
     foreach (var v in recs.Data)
     {
         var recNode = node.Nodes.Add("Record " + numRec.ToString());
         recNode.Tag = new RecObj(recs, numRec);
         recNode.ImageIndex = recNode.SelectedImageIndex = 4;
         numRec++;
     }
 }
        void card_objectChanged(ICard card, ICardObject obj, ChangeType change)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new Action<Card, ICardObject, ChangeType>((a, b, c) =>
                {
                    card_objectChanged(a, b, c);
                }), card, obj, change);
                return;
            }
            if (change == ChangeType.Deleted)
            {
                delNode(treeView1.Nodes, obj);
            }

            if (change == ChangeType.Created)
            {
                TreeNodeCollection parentNode = null;
                if (obj.Parent == null)
                    parentNode = treeView1.Nodes;
                else
                    parentNode = objNodes[obj.Parent].Nodes;

                TreeNode node = parentNode.Add(obj.ID.ToString("X04") + " " + obj.Description);
                node.ImageIndex = getImageIndex(obj);
                node.SelectedImageIndex = node.ImageIndex;
                node.Tag = obj;
                objNodes[obj] = node;
                if (obj is IObjectWithDataRecords)
                {
                    AddRecords(obj, node);
                }
                return;
            }
            else if (change == ChangeType.Selected)
            {
                objNodes[obj].NodeFont = selectedFont;
                return;
            }
            else if (change == ChangeType.Unselected)
            {
                objNodes[obj].NodeFont = DefaultFont;
                return;
            }
            else if (change == ChangeType.Modified)
            {
                if (obj is IObjectWithDataRecords)
                {
                    objNodes[obj].Nodes.Clear();
                    AddRecords(obj, objNodes[obj]);
                }
            }
        }
示例#19
0
 public bool TurnUpCard(ICardObject card)
 {
     return(false);
 }
示例#20
0
 public bool Equals(ICardObject other)
 {
     return(m_comparer.Equals(this, other));
 }
示例#21
0
 public void Add(ICardObject item)
 {
     m_cards.Push(item);
 }
示例#22
0
        private bool TurnUpCard(ICardObject card, GameObjectTransformModel deckTransformModel)
        {
            AddGameObjectToRenderQueue(card.CardGraphic, deckTransformModel.Position + new Vector3(25, 0), deckTransformModel.Rotation, deckTransformModel.Scale);

            return(true);
        }
示例#23
0
 public bool Contains(ICardObject item)
 {
     return(m_cards.Contains(item));
 }
示例#24
0
 public bool Remove(ICardObject item)
 {
     throw new NotSupportedException();
 }
示例#25
0
 public void RemoveChild(ICardObject obj) {
     int i = childs.IndexOf(obj);
     if (i >= 0)
     {
         childs.RemoveAt(i);
         owner.ObjectChanged(obj, ChangeType.Deleted);
     }
 }
示例#26
0
 public bool IsVerifiedAC(ICardObject obj,byte ac) {
     if (!(obj is IObjectWithAC))
         throw new ISO7816Exception(Error.InternalError);
     IObjectWithAC acObj = obj as IObjectWithAC;
     byte condition = acObj.AC[ac];
     if (condition == AC.Never)
         return false;
     if (condition == AC.Always)
         return true;
     BSO refrencedObject=obj is DF ? (obj as DF).GetChildBSO(condition, true) : obj.Parent.GetChildBSO(condition, true);
     if (context.securityStatus.ContainsKey(condition))
     {
         BSO bso=context.securityStatus[condition];
         if (refrencedObject == bso)
         {
             if (bso.CurValidityCounter == 0)
             {
                 context.securityStatus.Remove((byte)bso.ID);
                 return false;
             }
             else if (bso.CurValidityCounter != 0xff)
             {
                 bso.CurValidityCounter--;
             }
             return true;
         }
         return false;
     }
     else
     {
         // potrebbe essereun logical
         if (refrencedObject == null)
             return false;
         if (refrencedObject.Algo == BSOAlgo.Logic)
         {
             int exprLen;
             return TestLogic(refrencedObject, refrencedObject.Data.Length - 1, out exprLen);
         }
         else
             return false;
     }
 }