void SetItemsAndSelect(DataGridViewComboBoxCell c, IEnumerable <string> items, string item)
 {
     SetItems(c.Items, items);
     if (items.Contains(item))
     {
         c.Value = item;
     }
     else
     {
         var missingItem = new MissingItem(item);
         c.Items.Insert(0, missingItem);
         c.Value = missingItem;
     }
 }
示例#2
0
        public void AddItem(string name)
        {
            int id = Store.Find(name);

            if (id < 0)
            {
                MissingItem detail = new MissingItem();
                detail.ItemName     = name;
                detail.IsOutOfStock = false;
                throw new FaultException <MissingItem>(detail);
            }

            payment += 1.06 * Store.PriceOf(id);
        }
示例#3
0
        public void AddItem(string name)
        {
            int item = Store.Find(name);

            if (item < 0)
            {
                MissingItem mi = new MissingItem {
                    Id = name, IsOutOfStock = false
                };
                throw new FaultException <MissingItem>(mi);
            }

            payment += Store.PriceOf(item);
        }
示例#4
0
    public override Interaction GetInteractionFor(LaraCroft user)
    {
        if (IsUsed)
        {
            return(null);
        }

        var hasKey      = user.Inventory.Items.Find(KeyName) != null;
        var interaction = (Interaction)null;

        if (hasKey)
        {
            interaction = new UseKey(user, this);
        }
        else
        {
            interaction = new MissingItem(user, this);
        }

        return(interaction);
    }
        internal void FromMissingItem(MissingItem mi)
        {
            SetAllNull();

            if (mi.Unused != null)
            {
                Unused = mi.Unused.Value;
            }
            if (mi.Calculated != null)
            {
                Calculated = mi.Calculated.Value;
            }
            if (mi.Caption != null)
            {
                Caption = mi.Caption.Value;
            }
            if (mi.PropertyCount != null)
            {
                PropertyCount = mi.PropertyCount.Value;
            }
            if (mi.FormatIndex != null)
            {
                FormatIndex = mi.FormatIndex.Value;
            }
            if (mi.BackgroundColor != null)
            {
                BackgroundColor = mi.BackgroundColor.Value;
            }
            if (mi.ForegroundColor != null)
            {
                ForegroundColor = mi.ForegroundColor.Value;
            }
            if (mi.Italic != null)
            {
                Italic = mi.Italic.Value;
            }
            if (mi.Underline != null)
            {
                Underline = mi.Underline.Value;
            }
            if (mi.Strikethrough != null)
            {
                Strikethrough = mi.Strikethrough.Value;
            }
            if (mi.Bold != null)
            {
                Bold = mi.Bold.Value;
            }

            SLTuplesType        tt;
            MemberPropertyIndex mpi;

            using (var oxr = OpenXmlReader.Create(mi))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Tuples))
                    {
                        tt = new SLTuplesType();
                        tt.FromTuples((Tuples)oxr.LoadCurrentElement());
                        Tuples.Add(tt);
                    }
                    else if (oxr.ElementType == typeof(MemberPropertyIndex))
                    {
                        // 0 is the default value.
                        mpi = (MemberPropertyIndex)oxr.LoadCurrentElement();
                        if (mpi.Val != null)
                        {
                            MemberPropertyIndexes.Add(mpi.Val.Value);
                        }
                        else
                        {
                            MemberPropertyIndexes.Add(0);
                        }
                    }
                }
            }
        }
        internal MissingItem ToMissingItem()
        {
            var mi = new MissingItem();

            if (Unused != null)
            {
                mi.Unused = Unused.Value;
            }
            if (Calculated != null)
            {
                mi.Calculated = Calculated.Value;
            }
            if ((Caption != null) && (Caption.Length > 0))
            {
                mi.Caption = Caption;
            }
            if (PropertyCount != null)
            {
                mi.PropertyCount = PropertyCount.Value;
            }
            if (FormatIndex != null)
            {
                mi.FormatIndex = FormatIndex.Value;
            }
            if ((BackgroundColor != null) && (BackgroundColor.Length > 0))
            {
                mi.BackgroundColor = new HexBinaryValue(BackgroundColor);
            }
            if ((ForegroundColor != null) && (ForegroundColor.Length > 0))
            {
                mi.ForegroundColor = new HexBinaryValue(ForegroundColor);
            }
            if (Italic)
            {
                mi.Italic = Italic;
            }
            if (Underline)
            {
                mi.Underline = Underline;
            }
            if (Strikethrough)
            {
                mi.Strikethrough = Strikethrough;
            }
            if (Bold)
            {
                mi.Bold = Bold;
            }

            foreach (var tt in Tuples)
            {
                mi.Append(tt.ToTuples());
            }

            foreach (var i in MemberPropertyIndexes)
            {
                if (i != 0)
                {
                    mi.Append(new MemberPropertyIndex {
                        Val = i
                    });
                }
                else
                {
                    mi.Append(new MemberPropertyIndex());
                }
            }

            return(mi);
        }
 void SetItemsAndSelect(DataGridViewComboBoxCell c, IEnumerable<string> items, string item)
 {
     SetItems(c.Items, items);
     if (items.Contains(item)) {
         c.Value = item;
     } else {
         var missingItem = new MissingItem(item);
         c.Items.Insert(0, missingItem);
         c.Value = missingItem;
     }
 }
示例#8
0
        internal MissingItem ToMissingItem()
        {
            MissingItem mi = new MissingItem();

            if (this.Unused != null)
            {
                mi.Unused = this.Unused.Value;
            }
            if (this.Calculated != null)
            {
                mi.Calculated = this.Calculated.Value;
            }
            if (this.Caption != null && this.Caption.Length > 0)
            {
                mi.Caption = this.Caption;
            }
            if (this.PropertyCount != null)
            {
                mi.PropertyCount = this.PropertyCount.Value;
            }
            if (this.FormatIndex != null)
            {
                mi.FormatIndex = this.FormatIndex.Value;
            }
            if (this.BackgroundColor != null && this.BackgroundColor.Length > 0)
            {
                mi.BackgroundColor = new HexBinaryValue(this.BackgroundColor);
            }
            if (this.ForegroundColor != null && this.ForegroundColor.Length > 0)
            {
                mi.ForegroundColor = new HexBinaryValue(this.ForegroundColor);
            }
            if (this.Italic != false)
            {
                mi.Italic = this.Italic;
            }
            if (this.Underline != false)
            {
                mi.Underline = this.Underline;
            }
            if (this.Strikethrough != false)
            {
                mi.Strikethrough = this.Strikethrough;
            }
            if (this.Bold != false)
            {
                mi.Bold = this.Bold;
            }

            foreach (SLTuplesType tt in this.Tuples)
            {
                mi.Append(tt.ToTuples());
            }

            foreach (int i in this.MemberPropertyIndexes)
            {
                if (i != 0)
                {
                    mi.Append(new MemberPropertyIndex()
                    {
                        Val = i
                    });
                }
                else
                {
                    mi.Append(new MemberPropertyIndex());
                }
            }

            return(mi);
        }
        internal MissingItem ToMissingItem()
        {
            MissingItem mi = new MissingItem();
            if (this.Unused != null) mi.Unused = this.Unused.Value;
            if (this.Calculated != null) mi.Calculated = this.Calculated.Value;
            if (this.Caption != null && this.Caption.Length > 0) mi.Caption = this.Caption;
            if (this.PropertyCount != null) mi.PropertyCount = this.PropertyCount.Value;
            if (this.FormatIndex != null) mi.FormatIndex = this.FormatIndex.Value;
            if (this.BackgroundColor != null && this.BackgroundColor.Length > 0) mi.BackgroundColor = new HexBinaryValue(this.BackgroundColor);
            if (this.ForegroundColor != null && this.ForegroundColor.Length > 0) mi.ForegroundColor = new HexBinaryValue(this.ForegroundColor);
            if (this.Italic != false) mi.Italic = this.Italic;
            if (this.Underline != false) mi.Underline = this.Underline;
            if (this.Strikethrough != false) mi.Strikethrough = this.Strikethrough;
            if (this.Bold != false) mi.Bold = this.Bold;

            foreach (SLTuplesType tt in this.Tuples)
            {
                mi.Append(tt.ToTuples());
            }

            foreach (int i in this.MemberPropertyIndexes)
            {
                if (i != 0) mi.Append(new MemberPropertyIndex() { Val = i });
                else mi.Append(new MemberPropertyIndex());
            }

            return mi;
        }
示例#10
0
        internal void FromMissingItem(MissingItem mi)
        {
            this.SetAllNull();

            if (mi.Unused != null) this.Unused = mi.Unused.Value;
            if (mi.Calculated != null) this.Calculated = mi.Calculated.Value;
            if (mi.Caption != null) this.Caption = mi.Caption.Value;
            if (mi.PropertyCount != null) this.PropertyCount = mi.PropertyCount.Value;
            if (mi.FormatIndex != null) this.FormatIndex = mi.FormatIndex.Value;
            if (mi.BackgroundColor != null) this.BackgroundColor = mi.BackgroundColor.Value;
            if (mi.ForegroundColor != null) this.ForegroundColor = mi.ForegroundColor.Value;
            if (mi.Italic != null) this.Italic = mi.Italic.Value;
            if (mi.Underline != null) this.Underline = mi.Underline.Value;
            if (mi.Strikethrough != null) this.Strikethrough = mi.Strikethrough.Value;
            if (mi.Bold != null) this.Bold = mi.Bold.Value;

            SLTuplesType tt;
            MemberPropertyIndex mpi;
            using (OpenXmlReader oxr = OpenXmlReader.Create(mi))
            {
                while (oxr.Read())
                {
                    if (oxr.ElementType == typeof(Tuples))
                    {
                        tt = new SLTuplesType();
                        tt.FromTuples((Tuples)oxr.LoadCurrentElement());
                        this.Tuples.Add(tt);
                    }
                    else if (oxr.ElementType == typeof(MemberPropertyIndex))
                    {
                        // 0 is the default value.
                        mpi = (MemberPropertyIndex)oxr.LoadCurrentElement();
                        if (mpi.Val != null) this.MemberPropertyIndexes.Add(mpi.Val.Value);
                        else this.MemberPropertyIndexes.Add(0);
                    }
                }
            }
        }