예제 #1
0
        public void CountTest()
        {
            var c = list.Count;

            list.Add("C");
            Assert.AreEqual(c + 1, list.Count);
        }
예제 #2
0
        private void btnPerson_Click(object sender, EventArgs e)
        {
            if (AddMode)
            {
                Person person = new Person(txtName.Text, txtSurname.Text, dtpDOB.Value, txtCellphone.Text, txtTelephone.Text, txtEmail.Text);
                person.Save();
                People.Add(person);
                NonClients.Add(person);

                MessageBox.Show("New Person Sucessfully Saved!", "Success!", MessageBoxButtons.OK);
            }
            else
            {
                PopulatePersonFromControls(selectedPersonInExisting);
                PopulatePersonFromControls(selectedPersonInNonClient); //This is a lazy way of keeping the 2 list synced. I'm not allowed to use Binding lists
                selectedPersonInExisting.Save();

                MessageBox.Show("Person Sucessfully Modified!", "Success!", MessageBoxButtons.OK);
            }

            btnPerson.Enabled = false;

            lsbxExistingPeople.Items.Clear();
            lsbxExistingPeople.Items.AddRange(People.ToArray());

            cbxNonClientPerson.Items.Clear();
            cbxNonClientPerson.Items.AddRange(NonClients.ToArray());
        }
예제 #3
0
        /// <exception cref="RelationshipException">
        /// The language of <paramref name="_base"/> does not equal.-or-
        /// <paramref name="_base"/> is earlier added base.-or-
        /// <paramref name="_base"/> is descendant of the interface.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="_base"/> is null.
        /// </exception>
        internal void AddBase(InterfaceType _base)
        {
            if (_base == null)
            {
                throw new ArgumentNullException("_base");
            }

            if (BaseList.Contains(_base))
            {
                throw new RelationshipException(
                          Strings.ErrorCannotAddSameBaseInterface);
            }
            if (_base.IsAncestor(this))
            {
                throw new RelationshipException(string.Format(Strings.ErrorCyclicBase,
                                                              Strings.Interface));
            }

            if (_base.Language != this.Language)
            {
                throw new RelationshipException(Strings.ErrorLanguagesDoNotEqual);
            }

            BaseList.Add(_base);
            Changed();
        }
예제 #4
0
        /// <exception cref="RelationException">
        /// The language of <paramref name="_base"/> does not equal.-or-
        /// <paramref name="_base"/> is earlier added base.-or-
        /// <paramref name="_base"/> is descendant of the interface.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="_base"/> is null.
        /// </exception>
        internal void AddBase(InterfaceType _base)
        {
            if (_base == null)
            {
                throw new ArgumentNullException("_base");
            }

            if (BaseList.Contains(_base))
            {
                throw new RelationException(
                          Strings.GetString("error_cannot_add_same_base_interface"));
            }
            if (_base.IsAncestor(this))
            {
                throw new RelationException(Strings.GetString("error_cyclic_base",
                                                              Strings.GetString("interface")));
            }

            if (_base.Language != this.Language)
            {
                throw new RelationException(Strings.GetString("error_languages_do_not_equal"));
            }

            BaseList.Add(_base);
            Modified();
        }
예제 #5
0
        /// <summary>
        /// Constructor by values
        /// </summary>
        /// <param name="Num"></param>
        /// <param name="Version"></param>
        /// <param name="Width"></param>
        /// <param name="Height"></param>
        /// <param name="XOffset"></param>
        /// <param name="YOffset"></param>
        /// <param name="HotSpots"></param>
        /// <param name="IsCompressed"></param>
        /// <param name="CompressedLength"></param>
        /// <param name="PixelData"></param>
        public BgfBitmap(
            uint Num,
            uint Version,
            uint Width,
            uint Height,
            int XOffset,
            int YOffset,
            IEnumerable <BgfBitmapHotspot> HotSpots,
            bool IsCompressed,
            int CompressedLength,
            byte[] PixelData)
        {
            num              = Num;
            version          = Version;
            this.Width       = Width;  // update pow2/multiple4 also
            this.Height      = Height; // update pow2 also
            xoffset          = XOffset;
            yoffset          = YOffset;
            isCompressed     = IsCompressed;
            compressedLength = CompressedLength;
            pixeldata        = PixelData;

            // hotspots to own list
            foreach (BgfBitmapHotspot obj in HotSpots)
            {
                hotspots.Add(obj);
            }
        }
예제 #6
0
 internal static void LoadItems <E>(BinaryReader reader, BaseList <E> target, Func <E> loader) where E : BaseItem
 {
     for (int i = reader.ReadInt32(); i > 0; i--)
     {
         E item = loader();
         target.Add(item);
     }
 }
예제 #7
0
        public void FillWithRandomData(BaseList <int> listObject)
        {
            int i;
            var rand = new Random();

            for (i = 0; i < rand.Next(10, 50); i++)
            {
                listObject.Add(rand.Next(0, 1000));
            }
        }
예제 #8
0
        private void btnReAssignTech_Click(object sender, EventArgs e)
        {
            Technician technician = (Technician)lsbxAvailableTechnicians.SelectedItem;

            AvailableTechnicians.Add(techTaskToModify.Technician);
            AvailableTechnicians.Remove(technician);                //reduce database accesses

            techTaskToModify.Technician = technician;

            txtCurrentTech.Text = technician.Person.FullName;
        }
예제 #9
0
        private void btnConfirmContract_Click(object sender, EventArgs e)
        {
            currentContract.SetNextID();
            currentContract.ContractName             = txtContractName.Text;
            currentContract.StartDate                = dtpContractStart.Value;
            currentContract.EndDate                  = dtpContractEnd.Value;
            currentContract.ContractDurationInMonths = (int)Math.Round(numDuration.Value);
            currentContract.MonthlyFee               = nudMonthlyFee.Value;

            currentContract.Save();
            AllContracts.Add(currentContract); //reduce database acesses.
        }
예제 #10
0
        public unsafe void ReadFrom(ref byte *Buffer)
        {
            ushort len = *((ushort *)Buffer);

            Buffer += TypeSizes.SHORT;

            guilds = new BaseList <GuildEntry>(len);
            for (ushort i = 0; i < len; i++)
            {
                guilds.Add(new GuildEntry(ref Buffer));
            }

            len     = *((ushort *)Buffer);
            Buffer += TypeSizes.SHORT;

            youDeclaredAllyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                youDeclaredAllyList.Add(new ObjectID(ref Buffer));
            }


            len     = *((ushort *)Buffer);
            Buffer += TypeSizes.SHORT;

            youDeclaredEnemyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                youDeclaredEnemyList.Add(new ObjectID(ref Buffer));
            }


            len     = *((ushort *)Buffer);
            Buffer += TypeSizes.SHORT;

            declaredYouAllyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                declaredYouAllyList.Add(new ObjectID(ref Buffer));
            }


            len     = *((ushort *)Buffer);
            Buffer += TypeSizes.SHORT;

            declaredYouEnemyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                declaredYouEnemyList.Add(new ObjectID(ref Buffer));
            }
        }
예제 #11
0
        public void UpdateFromModel(WelcomeInfo Model, bool RaiseChangedEvent)
        {
            if (RaiseChangedEvent)
            {
                characters.Clear();
                ads.Clear();

                foreach (CharSelectItem itm in Model.Characters)
                {
                    characters.Add(itm);
                }

                foreach (CharSelectAd ad in Model.Ads)
                {
                    ads.Add(ad);
                }

                MOTD = Model.MOTD;
            }
            else
            {
                characters.Clear();
                ads.Clear();

                foreach (CharSelectItem itm in Model.Characters)
                {
                    characters.Add(itm);
                }

                foreach (CharSelectAd ad in Model.Ads)
                {
                    ads.Add(ad);
                }

                motd = Model.MOTD;
            }
        }
예제 #12
0
        private void btnConfirmService_Click(object sender, EventArgs e)
        {
            if (rbCreateService.Checked)
            {
                currentService.SetNextID();
            }

            currentService.ServiceName        = txtServiceName.Text;
            currentService.Type               = cbxServiceType.Text;
            currentService.ServiceDescription = rtbServiceDescription.Text;

            currentService.Save();
            AllServices.Add(currentService); //reduce database acesses
            MessageBox.Show("Service successfully created");
        }
예제 #13
0
        private void btnCreateJob_Click(object sender, EventArgs e)
        {
            Task           aTask    = new Task(txtTaskTitle.Text, txtTaskDescription.Text, txtTaskType.Text, rtbNotes.Text, currentRequest, DateTime.Now, false); //New task created
            TechnicianTask techTask = new TechnicianTask(aTask, currentTech, dtpDeparture.Value, dtpArival.Value);                                                //New Tech Task

            AllUnfinishedTasks.Add(aTask);                                                                                                                        //reduce database calls
            AllTechnicianTasks.Add(techTask);                                                                                                                     //reduce database calls

            techTask.Save();                                                                                                                                      //actually put in database

            PopulateUnclaimedClientServiceRequests();
            PopulateTaskList();

            MessageBox.Show("Task Created and Assigned", "Success");
        }
예제 #14
0
 public void UpdateFromModel(GuildHallsInfo Model, bool RaiseChangedEvent)
 {
     if (RaiseChangedEvent)
     {
         GuildHalls.Clear();
         foreach (GuildHall obj in Model.GuildHalls)
         {
             GuildHalls.Add(obj);
         }
         IsVisible = false;
     }
     else
     {
         guildHalls.Clear();
         foreach (GuildHall obj in Model.GuildHalls)
         {
             guildHalls.Add(obj);
         }
         isVisible = false;
     }
 }
예제 #15
0
        protected bool TryAdminInfoObject(string Text)
        {
            AdminInfoObject adminInfoObj = AdminInfoObject.TryParse(Text);

            if (adminInfoObj != null)
            {
                AdminInfoObject existingObj = GetTrackedObjectByID(adminInfoObj.ID);

                if (existingObj != null)
                {
                    existingObj.UpdateFromModel(adminInfoObj, true);
                }
                else
                {
                    trackedObjects.Add(adminInfoObj);
                }

                return(true);
            }

            return(false);
        }
예제 #16
0
        /// <exception cref="ArgumentException">
        /// The language of <paramref name="_base"/> does not equal.-or-
        /// <paramref name="_base"/> is earlier added base.-or-
        /// <paramref name="_base"/> is descendant of the interface.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="_base"/> is null.
        /// </exception>
        internal void AddBase(InterfaceType _base)
        {
            if (_base == null)
            {
                throw new ArgumentNullException("_base");
            }

            if (BaseList.Contains(_base))
            {
                throw new ArgumentException("error_cannot_add_same_base_interface");
            }
            if (_base.IsAncestor(this))
            {
                throw new ArgumentException("interface");
            }

            if (_base.Language != this.Language)
            {
                throw new ArgumentException("error_languages_do_not_equal");
            }

            BaseList.Add(_base);
        }
예제 #17
0
 public void TestInit()
 {
     list = new BaseList <string>();
     list.Add("A");
     list.Add("B");
 }
예제 #18
0
        public void UpdateFromModel(DiplomacyInfo Model, bool RaiseChangedEvent)
        {
            if (RaiseChangedEvent)
            {
                // update states first to look them up in guilds
                YouDeclaredAllyList.Clear();
                foreach (ObjectID obj in Model.YouDeclaredAllyList)
                {
                    YouDeclaredAllyList.Add(obj);
                }

                YouDeclaredEnemyList.Clear();
                foreach (ObjectID obj in Model.YouDeclaredEnemyList)
                {
                    YouDeclaredEnemyList.Add(obj);
                }

                DeclaredYouAllyList.Clear();
                foreach (ObjectID obj in Model.DeclaredYouAllyList)
                {
                    DeclaredYouAllyList.Add(obj);
                }

                DeclaredYouEnemyList.Clear();
                foreach (ObjectID obj in Model.DeclaredYouEnemyList)
                {
                    DeclaredYouEnemyList.Add(obj);
                }

                // then guilds
                Guilds.Clear();
                foreach (GuildEntry obj in Model.Guilds)
                {
                    Guilds.Add(obj);
                }
            }
            else
            {
                // update states first to look them up in guilds
                youDeclaredAllyList.Clear();
                foreach (ObjectID obj in Model.YouDeclaredAllyList)
                {
                    youDeclaredAllyList.Add(obj);
                }

                youDeclaredEnemyList.Clear();
                foreach (ObjectID obj in Model.YouDeclaredEnemyList)
                {
                    youDeclaredEnemyList.Add(obj);
                }

                declaredYouAllyList.Clear();
                foreach (ObjectID obj in Model.DeclaredYouAllyList)
                {
                    declaredYouAllyList.Add(obj);
                }

                declaredYouEnemyList.Clear();
                foreach (ObjectID obj in Model.DeclaredYouEnemyList)
                {
                    declaredYouEnemyList.Add(obj);
                }

                // then guilds
                guilds.Clear();
                foreach (GuildEntry obj in Model.Guilds)
                {
                    guilds.Add(obj);
                }
            }
        }
예제 #19
0
        public int ReadFrom(byte[] Buffer, int StartIndex = 0)
        {
            int cursor = StartIndex;

            ushort len = BitConverter.ToUInt16(Buffer, cursor);                 // GuildsLEN  (2 bytes)

            cursor += TypeSizes.SHORT;

            guilds = new BaseList <GuildEntry>(len);
            for (ushort i = 0; i < len; i++)
            {
                GuildEntry obj = new GuildEntry(Buffer, cursor);                // GuildEntry (n bytes)
                guilds.Add(obj);
                cursor += obj.ByteLength;
            }

            len     = BitConverter.ToUInt16(Buffer, cursor);                    // YouDeclAllyLEN  (2 bytes)
            cursor += TypeSizes.SHORT;

            youDeclaredAllyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                ObjectID obj = new ObjectID(Buffer, cursor);                    // ObjectID (4/8 bytes)
                youDeclaredAllyList.Add(obj);
                cursor += obj.ByteLength;
            }

            len     = BitConverter.ToUInt16(Buffer, cursor);                    // YouDeclEnemyLEN  (2 bytes)
            cursor += TypeSizes.SHORT;

            youDeclaredEnemyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                ObjectID obj = new ObjectID(Buffer, cursor);                    // ObjectID (4/8 bytes)
                youDeclaredEnemyList.Add(obj);
                cursor += obj.ByteLength;
            }

            len     = BitConverter.ToUInt16(Buffer, cursor);                    // DeclYouAllyLEN  (2 bytes)
            cursor += TypeSizes.SHORT;

            declaredYouAllyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                ObjectID obj = new ObjectID(Buffer, cursor);                    // ObjectID (4/8 bytes)
                declaredYouAllyList.Add(obj);
                cursor += obj.ByteLength;
            }

            len     = BitConverter.ToUInt16(Buffer, cursor);                    // DeclYouEnemyLEN  (2 bytes)
            cursor += TypeSizes.SHORT;

            declaredYouEnemyList = new ObjectIDList <ObjectID>(len);
            for (ushort i = 0; i < len; i++)
            {
                ObjectID obj = new ObjectID(Buffer, cursor);                    // ObjectID (4/8 bytes)
                declaredYouEnemyList.Add(obj);
                cursor += obj.ByteLength;
            }

            return(ByteLength);
        }