コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            int num;

            if (!int.TryParse(Release.Text, out num))
            {
                MessageBox.Show("请输入释放空间号码!");
                return;
            }
            if (number < num)
            {
                MessageBox.Show("还未申请此存储空间!");
                return;
            }
            if (!stoed[num - 1].allocated)
            {
                MessageBox.Show("此存储空间已经释放!");
                return;
            }
            else
            {
                stoed[num - 1].allocated = false;
                for (int i = stoed[num - 1].Address; i < stoed[num - 1].Address + stoed[num - 1].Length; i++)
                {
                    space[i] = false;
                }
                sto = Storage.storages(space);
                DataBindingSource.DataSource = sto;
                DataBindingSource.ResetBindings(true);
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int length;

            if (!int.TryParse(Request.Text, out length))
            {
                MessageBox.Show("请输入申请空间大小!");
                return;
            }
            int address = Storage.request(length, sto);

            if (address == 12345)
            {
                MessageBox.Show("主存空间不足!");
                return;
            }
            else
            {
                for (int i = address; i < address + length; i++)
                {
                    space[i] = true;
                }
                number++;
                stoed.Add(new Storage(number, address, length, true));
                sto = Storage.storages(space);
                DataBindingSource.DataSource = sto;
                DataBindingSource.ResetBindings(true);
            }
        }
コード例 #3
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            Int32 selectedIndex = contactDataGrid.CurrentRow.Index;

            DataBindingSource.RemoveAt(selectedIndex);

            // refresh items in case item count is 0
            // to disable the edit and delete buttons
            RefreshItems();
        }
コード例 #4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            //make new contacts object and add it to bindingSource
            Contact            newContact = new Contact();
            ContactDetailsForm dirForm    = new ContactDetailsForm();

            // META data binding source - modify newContact without the
            // need to pass it directly ;)
            dirForm.DataBindingSource.DataSource = newContact;
            dirForm.canDelete = false;
            dirForm.ShowDialog(); //show model contact details form

            if (dirForm.closeAccept == true)
            {
                DataBindingSource.Add(newContact);
                RefreshItems(); //since new contact added, refresh the items in grid view
            }
        }
コード例 #5
0
        private void addFromCutCopy_Click(object sender, EventArgs e)
        {
            using (Stream stream = new FileStream(defaultPath, FileMode.Open, FileAccess.Read))
            {
                IFormatter         formatter = new BinaryFormatter();
                Contact            x         = (Contact)formatter.Deserialize(stream);
                ContactDetailsForm dirForm   = new ContactDetailsForm();

                dirForm.DataBindingSource.DataSource = x;
                dirForm.canDelete = false;
                dirForm.ShowDialog();

                if (dirForm.closeAccept == true)
                {
                    DataBindingSource.Add(x);
                    RefreshItems();
                }
            }
        }
コード例 #6
0
        private void contactDataGrid_DragDrop(object sender, DragEventArgs e)
        {
            string sourceText = (string)e.Data.GetData(typeof(string));

            string[] terms = sourceText.Split('\n');

            //make new contacts object and add it to bindingSource
            Contact newContact = new Contact();

            newContact.FirstName = (terms.Length >= 1) ? terms[0].Split(' ')[0] : newContact.FirstName;
            newContact.LastName  = (terms.Length >= 1) ? (terms[0].Split(' ').Length > 1)? terms[0].Split(' ')[1] : newContact.LastName : newContact.LastName;
            newContact.CellPhone = (terms.Length >= 2) ? terms[1] : newContact.CellPhone;
            newContact.HomePhone = (terms.Length >= 3) ? terms[2] : newContact.HomePhone;
            newContact.Address1  = (terms.Length >= 4)? terms[3]: newContact.Address1;
            newContact.City      = (terms.Length >= 5) ? terms[4] : newContact.City;
            newContact.State     = (terms.Length >= 6) ? terms[5] : newContact.State;
            newContact.Zip       = (terms.Length >= 7) ? terms[6] : newContact.Zip;
            newContact.Country   = (terms.Length >= 8) ? terms[7] : newContact.Country;



            ContactDetailsForm dirForm = new ContactDetailsForm();



            // META data binding source - modify newContact without the
            // need to pass it directly ;)
            dirForm.DataBindingSource.DataSource = newContact;
            dirForm.canDelete = false;
            dirForm.ShowDialog(); //show model contact details form

            if (dirForm.closeAccept == true)
            {
                DataBindingSource.Add(newContact);
                RefreshItems(); //since new contact added, refresh the items in grid view
            }
        }