Пример #1
0
        public void addingNewEventArgs_ctor_normal_should_set_expected_values()
        {
            var expected = new GenericParameterHelper();
            var target = new AddingNewEventArgs<GenericParameterHelper>();
            target.NewItem = expected;

            var actual = target.NewItem;

            actual.Should().Be.EqualTo( expected );
            target.Cancel.Should().Be.False();
        }
Пример #2
0
        object IBindingList.AddNew()
        {
#pragma warning disable CS0436 // Type conflicts with imported type
            var args = new AddingNewEventArgs();
#pragma warning restore CS0436 // Type conflicts with imported type
            OnAddingNew(args);

            if (args.NewObject == null)
            {
                throw new JsonException("Could not determine new value to add to '{0}'.".FormatWith(CultureInfo.InvariantCulture, GetType()));
            }

            if (!(args.NewObject is JToken))
            {
                throw new JsonException("New item to be added to collection must be compatible with {0}.".FormatWith(CultureInfo.InvariantCulture, typeof(JToken)));
            }

            JToken newItem = (JToken)args.NewObject;
            Add(newItem);

            return(newItem);
        }
Пример #3
0
        object IBindingList.AddNew()
        {
            AddingNewEventArgs args = new AddingNewEventArgs();

            OnAddingNew(args);

            if (args.NewObject == null)
            {
                throw new JsonException("Could not determine new value to add to '{0}'.".FormatWith(CultureInfo.InvariantCulture, GetType()));
            }

            if (!(args.NewObject is JToken))
            {
                throw new JsonException("New item to be added to collection must be compatible with {0}.".FormatWith(CultureInfo.InvariantCulture, typeof(JToken)));
            }

            JToken newItem = (JToken)args.NewObject;

            Add(newItem);

            return(newItem);
        }
Пример #4
0
        object IBindingList.AddNew()
        {
            AddingNewEventArgs e = new AddingNewEventArgs();

            this.OnAddingNew(e);
            if (e.NewObject == null)
            {
                throw new JsonException(
                          "Could not determine new value to add to '{0}'.".FormatWith((IFormatProvider)CultureInfo.InvariantCulture,
                                                                                      (object)this.GetType()));
            }
            if (!(e.NewObject is JToken))
            {
                throw new JsonException(
                          "New item to be added to collection must be compatible with {0}.".FormatWith(
                              (IFormatProvider)CultureInfo.InvariantCulture, (object)typeof(JToken)));
            }
            JToken newObject = (JToken)e.NewObject;

            this.Add((object)newObject);
            return((object)newObject);
        }
Пример #5
0
        protected override void OnAddingNew(AddingNewEventArgs e)
        {
            if (AllowNew)
            {
                IRow newRow = m_WrappedTable.CreateRow();
                e.NewObject = newRow;

                for (int i = 0; i < newRow.Fields.FieldCount; i++)
                {
                    IField curField = newRow.Fields.get_Field(i);
                    if (curField.Editable && curField.IsNullable)
                    {
                        newRow.set_Value(i, curField.DefaultValue);
                    }
                }
                bool weStartedEditing = StartEditOp();
                newRow.Store();
                StopEditOp(weStartedEditing);

                base.OnAddingNew(e);
            }
        }
Пример #6
0
        protected override void OnAddingNew(AddingNewEventArgs e)
        {
            SynchronizationContext ctx = SynchronizationContext.Current;

            if (ctx == null)
            {
                BaseAddingNew(e);
            }
            else
            {
                try
                {
                    ctx.Send(delegate
                    {
                        BaseAddingNew(e);
                    }, null);
                }
                catch (Exception)
                {
                    Console.WriteLine("Error");
                }
            }
        }
Пример #7
0
        private void BlocksBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            ReportBlock x = new ReportBlock();

            e.NewObject = x;
            ReportTemplate t = (ReportTemplate)reportsBindingSource.Current;

            if (t.Blocks == null)
            {
                t.Blocks = new List <ReportBlock>();
            }
            if (!string.IsNullOrEmpty(this.viewIDComboBox.Text))
            {
                ds = (DataViewDataSource)DMEEditor.GetDataSource(this.viewIDComboBox.Text);
                EntityStructure           ent = ds.GetEntityStructure(this.entityIDComboBox.Text, true);
                List <ReportBlockColumns> ls  = new List <ReportBlockColumns>();
                if (ent != null)
                {
                    int i = 0;
                    foreach (EntityField item in ent.Fields)
                    {
                        ReportBlockColumns c = new ReportBlockColumns();
                        c.ColumnName  = item.fieldname;
                        c.ColumnSeq   = i;
                        c.DisplayName = item.fieldname;
                        c.Show        = true;
                        i            += 1;

                        ls.Add(c);
                    }
                }
                x.BlockColumns = ls;
            }


            t.Blocks.Add(x);
        }
        protected override object AddNewCore()
        {
            AddingNewEventArgs e = new AddingNewEventArgs(null);

            OnAddingNew(e);
            T newItem = (T)e.NewObject;

            if (newItem == null)
            {
                newItem = (T)Activator.CreateInstance(typeof(T), nonPublic: true);
            }

            object trackable = newItem as IChangeTrackable <T>;

            if (trackable == null)
            {
                trackable = ChangeTrackingFactory.Default.AsTrackable(newItem, ChangeStatus.Added, _ItemCanceled, _ChangeTrackingSettings, _Graph);
                var editable = (IEditableObject)trackable;
                editable.BeginEdit();
            }
            Add((T)trackable);

            return(trackable);
        }
Пример #9
0
        void UsersBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            if (this.LoginType == LoginType.UsernamePassword)
            {
                return;
            }
            // Note that MSDN states:
            //    You cannot set the NewObject property when bound to a DataView or DataTable because you cannot add a new DataRowView to the list
            // But you can call AddNew inside this AddingNew event and change the default values if e.NewObject is set to the dataRowView
            //
            // When you set e.NewObject to something other then null:
            // * if the BindingSource.List.Count was increased during the eventhandler then it won't add e.NewObject to the list
            BindingSource bindingSource = sender as BindingSource;

            DataRowView dataRowView = ((DataView)bindingSource.List).AddNew();

            UsersSource.UsersRow affectedRow = (UsersSource.UsersRow)dataRowView.Row;
            affectedRow.UserName      = _newCardUserEdiNumber;
            affectedRow.FriendlyName  = _newCardUserFriendlyName;
            affectedRow.NewPassword   = new SecureString();
            affectedRow.UseCardReader = true;

            e.NewObject = dataRowView;
        }
Пример #10
0
        private void bindingInvoice_AddingNew(object sender, AddingNewEventArgs e)
        {
            /* This event will be called several times during form initialization.
             * We don't want to do anything with it until the runtime authors
             * list has been passed in. */

            // Exit if no project list
            if (m_Invoices == null)
            {
                return;
            }

            // Create a new project
            commandInsertInvoice createInvoice = new commandInsertInvoice();
            InvoiceItem          newInvoice    = (InvoiceItem)m_AppController.ExecuteCommand(createInvoice);

            /* Since the BindingSource is managing the collection, we pass the new
             * author to the BindingSource, using the NewObject property of the
             * event args. The BindingSource will add the new author to the
             * AuthorList for us. */

            // Add it to theAuthors list
            e.NewObject = newInvoice;
        }
        protected override object AddNewCore()
        {
            AddingNewEventArgs e = new AddingNewEventArgs(null);

            OnAddingNew(e);
            T newItem = (T)e.NewObject;

            if (newItem == null)
            {
                newItem = Activator.CreateInstance <T>();
            }

            object trackable = newItem as IChangeTrackable <T>;

            if (trackable == null)
            {
                trackable = newItem.AsTrackable(ChangeStatus.Added, _ItemCanceled, _MakeComplexPropertiesTrackable, _MakeCollectionPropertiesTrackable);
                var editable = (IEditableObject)trackable;
                editable.BeginEdit();
            }
            Add((T)trackable);

            return(trackable);
        }
Пример #12
0
 void _list_AddingNew(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new EmailType();
     ((EmailType)e.NewObject).evtIsSavable
         += new IsSavableHandler(s_evtIsSavable);
 }
Пример #13
0
 private void categoriaBindingSource_AddingNew(object sender, AddingNewEventArgs e)
 {
     HabilitaComponentesEdicao(true);
 }
Пример #14
0
 private void list_AddinDeta(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new V_INV_DETA_INGR();
 }
Пример #15
0
 // Accesing the 'base' member directly from anonymous method results in 'unverifiable' code (Compiler warning), so we use these helper methods (As compiler suggests)
 private void BaseOnAddingNew(AddingNewEventArgs e)
 {
     base.OnAddingNew(e);
 }
Пример #16
0
	void BindingSource_AddingNew (object sender, AddingNewEventArgs e)
	{
		e.NewObject = new Customer ("Source");
	}
Пример #17
0
 private void bsPrePack_AddingNew(object sender, AddingNewEventArgs e)
 {
 }
Пример #18
0
 protected void _actions_AddingNew(object sender, AddingNewEventArgs e)
 {
     AssertIsReady();
 }
Пример #19
0
 void _list_AddingNew(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new Student();
     ((Student)e.NewObject).evtIsSavable
         += new IsSavableHandler(s_evtIsSavable);
 }
Пример #20
0
	void BindingList_AddingNew (object sender, AddingNewEventArgs e)
	{
		e.NewObject = new Customer ("List");
	}
        private void InParametersentitiesBindingSource_AddingNew(object sender, AddingNewEventArgs e)
        {
            EntityStructure x = new EntityStructure();

            e.NewObject = x;
        }
Пример #22
0
 protected override void OnAddingNew(AddingNewEventArgs e)
 {
     e.NewObject = new TaskServer(this);
     base.OnAddingNew(e);
 }
Пример #23
0
 private void bindingSource1_AddingNew(object sender, AddingNewEventArgs e)
 {
 }
Пример #24
0
 public void AddingNew_Handler(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new Person(_textbox1.Text, _textbox2.Text, _textbox3.Text,
                              ConvertRadioButtonToGender(), _dateTimePicker.Value);
 }
Пример #25
0
 /// <summary>
 /// 添加新数据设置默认值
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void tCB_DEPTSTANDARDBindingSource_AddingNew(object sender, AddingNewEventArgs e)
 {
     dstNDD_Word.NDD_WORD.WORDIDColumn.DefaultValue = Guid.NewGuid().ToString();
 }
 private void Variants_AddingNew(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new Variante();
 }
Пример #27
0
 protected override void OnAddingNew(AddingNewEventArgs e)
 {
     Invoke((Action <AddingNewEventArgs>)base.OnAddingNew, e);
 }
Пример #28
0
 protected override void OnAddingNew(AddingNewEventArgs e)
 {
     // BindingList<T> возможно ошибка: EndNew вызывается дважды вместо одного раза
     _addingNew = 2;
     base.OnAddingNew(e);
 }
Пример #29
0
 private void infoLecteurBindingSource_AddingNew(object sender, AddingNewEventArgs e)
 {
     e.NewObject = new InfoLecteur();
 }
Пример #30
0
 private void BdsWarehouseIODetailAddingNew(object sender, AddingNewEventArgs e)
 {
 }
Пример #31
0
 /// <summary>
 /// Gets called when user is added to the DataGridView
 /// </summary>
 /// <param name="sender">Object which triggered the event</param>
 /// <param name="e">Parameters of the Event</param>
 private void BindingSource_AddingNew(object sender, AddingNewEventArgs e)
 {
     Logger.debug("Adding user to data source.", origin: "ChatMail.AdminView");
     e.NewObject = new User();
 }
Пример #32
0
 void BaseAddingNew(AddingNewEventArgs e)
 {
     base.OnAddingNew(e);
 }
Пример #33
0
 private void phieuthuBindingSource_AddingNew(object sender, AddingNewEventArgs e)
 {
     this.lblPTNgayLap.Text = string.Format("Ngày {0} tháng {1} năm {2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year);
     this.txtPTHoTen.Focus();
 }