public RouteModel() { Steps = new BindingList <StepModel>(); Steps.ListChanged += (s, e) => { CalculateStepCount(); }; Encounters = new BindingList <EncounterModel>(); Encounters.ListChanged += (s, e) => { OnPropertyChanged(nameof(Encounters)); }; AddStepsCommand = new Command(() => true, (s, e) => { Steps.AddNew(); FocusedSteps = Steps.Last(); }); RemoveStepsCommand = new Command(() => FocusedSteps != null && Steps.Count > 1, (s, e) => { Steps.Remove(FocusedSteps); FocusedSteps = null; }); ShowAboutCommand = new Command(() => true, ShowAbout); Steps.AddNew(); FocusedSteps = Steps[0]; PossibleZones = new BindingList <ZoneModel>(Const.Zones.ToList()); CalculateStepCount(); }
public Window1() { NamedRects = new BindingList <NamedRectangle>(); NamedRects.ListChanged += HandleListChangedEventHandler;; CurrentlySelectedNamedRect = NamedRects.AddNew(); NamedRects.AddNew(); NamedRects.AddNew(); FixDuplicateNames(); var TestString = "She sells seashells on the seashore"; InitializeComponent(); lstRects.ItemsSource = NamedRects; }
private void materialFlatButton2_Click(object sender, EventArgs e) { TipoItemDataSource.AddNew(); dataGridView1.Rows[dataGridView1.Rows.Count - 1].ReadOnly = false; dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["RowType"].Value = "T"; dataGridView1[dataGridView1.Rows.Count - 1, 2].Value = 99; }
static readonly private int FirstHotkeyCommandIdentifier = 10000; // Arbitrary choosen. GE by default starts at 9000 for it's own scripts. /// <summary> /// Adds a new script, without saving it to GE's settings file. /// </summary> static public void AddNew(string name, string arguments, string icon, bool enabled = true, string command = "git", bool addToRevisionGridContextMenu = true, GitUI.Script.ScriptEvent onEvent = GitUI.Script.ScriptEvent.ShowInUserMenuBar, bool askConfirmation = false, bool runInBackground = false, bool isPowerShell = false) { GitExtScriptList = GitUI.Script.ScriptManager.GetScripts(); GitUI.Script.ScriptInfo newScript = GitExtScriptList.AddNew(); newScript.Enabled = enabled; newScript.Name = name; newScript.Command = command; newScript.Arguments = arguments; newScript.AddToRevisionGridContextMenu = addToRevisionGridContextMenu; newScript.OnEvent = onEvent; newScript.AskConfirmation = askConfirmation; newScript.RunInBackground = runInBackground; newScript.IsPowerShell = isPowerShell; newScript.HotkeyCommandIdentifier = FirstHotkeyCommandIdentifier + GitExtScriptList.Count; newScript.Icon = icon; SvnScriptList.Add(newScript); }
BindingList <Customer> GetData(int custCount, int orderCount) { BindingList <Customer> custList = new BindingList <Customer>(); Random r = new Random(); for (int i = 0; i < custCount; i++) { Customer cust = custList.AddNew(); cust.ID = i; cust.Name = "Name" + i; for (int j = 0; j < orderCount; j++) { cust.Orders.Add(new Order() { ID = j }); int productCount = r.Next(10); for (int k = 0; k < productCount; k++) { cust.Orders[j].Products.Add(new Product() { ID = k, Name = "Product" + k, Price = r.Next(100) }); } } } return(custList); }
private void BtnAgregarArticulo_Click(object sender, EventArgs e) { if (int.TryParse(txtCantidad.Text, out int cantidad)) { if (cantidad > ExistenciaArticulo) { MessageBox.Show($"No contamos con la cantidad indicada de artículos en existencia.\n la cantidad actual del artículo es: {ExistenciaArticulo}"); txtCantidad.Text = ExistenciaArticulo.ToString(); } else { var detalleNota = DetallesNotas.FirstOrDefault(x => x.IdArticulo.ToString() == txtIdArticulo.Text); if (detalleNota != null) { detalleNota.Cantidad = cantidad; } else { DgvDetalleNota data = DetallesNotas.AddNew(); data.Cantidad = cantidad; data.IdArticulo = Convert.ToInt32(txtIdArticulo.Text); data.Articulo = txtDescripcionArticulo.Text; data.PrecioVenta = Convert.ToDecimal(txtPrecioUnitario.Text); data.Total = data.Cantidad * data.PrecioVenta; DetallesNotas.EndNew(DetallesNotas.IndexOf(data)); } LimpiarArticulo(); } } else { MessageBox.Show("Ingrese una cantidad válida."); } }
public void AddingNew_RemoveWithNotAllowNewByDefault_CallsListChanged() { var bindingList = new BindingList <string>(); bool calledAddingNew = false; AddingNewEventHandler handler = (object sender, AddingNewEventArgs e) => calledAddingNew = true; bindingList.AddingNew += handler; bool calledListChanged = false; bindingList.ListChanged += (object sender, ListChangedEventArgs e) => { calledListChanged = true; Assert.Equal(ListChangedType.Reset, e.ListChangedType); Assert.Equal(-1, e.NewIndex); }; // Make sure removing the handler was successful. bindingList.AddingNew -= handler; Assert.True(calledListChanged); Assert.Throws <MissingMethodException>(() => bindingList.AddNew()); Assert.False(calledAddingNew); }
/// <summary> /// /// </summary> /// <param name="editForm"></param> /// <param name="editCols"></param> /// <param name="detailEntitys"></param> /// <param name="dataInDocType"></param> public void ShowBatchAppendDataToGrid() { if (_EditCols == null || _EditCols.Values.Count == 0) { return; } _ColumnEditCfgInfo = _EditCols.Values.FirstOrDefault(o => o.DefaultBatchAdd == true); if (_ColumnEditCfgInfo == null) { throw new MB.Util.APPException("在批量增加时,在对应的XML 配置文件中没发现配置DefaultBatchAdd 为True 的配置项!", MB.Util.APPMessageType.DisplayToUser); } System.Windows.Forms.Form parentForm = _EditForm as System.Windows.Forms.Form; System.Windows.Forms.Control parentHoster = MB.WinBase.ShareLib.Instance.GetInvokeDataHosterControl(parentForm); MB.WinBase.IFace.IDataAssistant dataAssistant = null; object mainEntity = null; if (parentHoster != null) { dataAssistant = MB.WinBase.ObjectDataFilterAssistantHelper.Instance.CreateDataAssistantObject(this, _ColumnEditCfgInfo, parentForm); } else { mainEntity = _DetailEntitys.AddNew(); dataAssistant = MB.WinBase.ObjectDataFilterAssistantHelper.Instance.CreateDataAssistantObject(this, mainEntity, _ColumnEditCfgInfo, _EditForm.ClientRuleObject); } if (dataAssistant != null) { dataAssistant.MultiSelect = true; dataAssistant.MaxSelectRows = _ColumnEditCfgInfo.MaxSelectRows; dataAssistant.AfterGetObjectData += new GetObjectDataAssistantEventHandle(dataAssistant_AfterGetObjectData); (dataAssistant as System.Windows.Forms.Form).ShowDialog(); } if (mainEntity != null) { bool exists = MB.WinBase.UIDataEditHelper.Instance.CheckExistsEntityState(mainEntity); if (exists) { MB.WinBase.UIDataEditHelper.Instance.SetEntityState(mainEntity, Util.Model.EntityState.Deleted); } _DetailEntitys.Remove((T)mainEntity); } }
/// <summary> /// Adds a new Window to the windows list /// </summary> /// <param name="name">The Name of the window</param> /// <param name="window">The window to add</param> public void WindowsAdd(string name, string window) { profileWindow wp = windows.AddNew(); wp.name = name; wp.value = window; //this.windows.Add(wp); }
public DataGridViewModel() { using (var sr = new StreamReader("./Data.txt")) { while (!sr.EndOfStream) { var h = people.AddNew(); h.ParseFromString(sr.ReadLine()); } } people.ListChanged += (sender, args) => { using (var sw = new StreamWriter("./Data.txt")) { foreach (var human in people) { sw.WriteLine(human); } } }; // people.Add(new Human // { // BirthDate = new DateTime(1990, 6, 13).ToShortDateString(), // FirstName = "Alan", // LastName = "Smith", // Gender = Gender.Male // }); // people.Add(new Human // { // BirthDate = new DateTime(1960, 4, 23).ToShortDateString(), // FirstName = "Megan", // LastName = "Jons", // Gender = Gender.Female // }); // people.Add(new Human // { // BirthDate = new DateTime(1985, 9, 12).ToShortDateString(), // FirstName = "Emily", // LastName = "Keller", // Gender = Gender.Female // }); // people.Add(new Human // { // BirthDate = new DateTime(1991, 6, 11).ToShortDateString(), // FirstName = "Jeremy", // LastName = "Watson", // Gender = Gender.Male // }); // people.Add(new Human // { // BirthDate = new DateTime(1996, 7, 3).ToShortDateString(), // FirstName = "Christian", // LastName = "Woods", // Gender = Gender.Male // }); }
/// <summary> /// Add or append list of ColorItem to the current list /// </summary> /// <param name="sender"></param> /// <param name="colorItemList"></param> public static void AddColors(this BindingList <nf.ColorItem> sender, List <nf.ColorItem> colorItemList) { foreach (var colorItem in colorItemList) { var item = sender.AddNew(); item.Name = colorItem.Name; item.Color = colorItem.Color; } }
private void btnAdd_Click(object sender, EventArgs e) { ScriptInfoProxy script = _scripts.AddNew(); script.HotkeyCommandIdentifier = Math.Max(ScriptManager.MinimumUserScriptID, _scripts.Max(s => s.HotkeyCommandIdentifier)) + 1; script.Name = "<New Script>"; BindScripts(_scripts, script); }
private void btnSave_Click(object sender, EventArgs e) { //Guardar(); UserDataSource.AddNew(); //dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["_RegType"].Value = "Temp"; // Mostrar(); //Limpiar(); }
private void AddButton_Click(object sender, EventArgs e) { //_people.Add(CreatePerson()); var person = _people.AddNew(); if (person.FirstName.Contains("7")) { _people.CancelNew(_people.IndexOf(person)); } }
/// <summary> /// Skickar in de attribut som skapar ny lärare /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { Larare larare = lararLista.AddNew(); personalNamnText.Text = ""; int.Parse(personalPersonalIDText.Text); long.Parse(personalPersonnummerText.Text); personalEmailText.Text = ""; int.Parse(personalTelNrText.Text); }
public void TestAddNew_CancelDifferentIndex() { List <object> list = new List <object>(); list.Add(new object()); list.Add(new object()); BindingList <object> l = new BindingList <object>(list); bool adding_event_raised = false; object o = new object(); bool list_changed = false; ListChangedType change_type = ListChangedType.Reset; int list_changed_index = -1; l.AddingNew += delegate(object sender, AddingNewEventArgs e) { adding_event_raised = true; Assert.Null(e.NewObject); }; l.ListChanged += delegate(object sender, ListChangedEventArgs e) { list_changed = true; change_type = e.ListChangedType; list_changed_index = e.NewIndex; }; object rv = l.AddNew(); Assert.True(adding_event_raised, "2"); Assert.NotNull(rv); Assert.Equal(3, l.Count); Assert.Equal(2, l.IndexOf(rv)); Assert.True(list_changed, "6"); Assert.Equal(ListChangedType.ItemAdded, change_type); Assert.Equal(2, list_changed_index); list_changed = false; l.CancelNew(0); Assert.False(list_changed, "9"); Assert.Equal(3, l.Count); l.CancelNew(2); Assert.True(list_changed, "11"); Assert.Equal(ListChangedType.ItemDeleted, change_type); Assert.Equal(2, list_changed_index); Assert.Equal(2, l.Count); }
public override void Novi() { if (!IdSektora.HasValue) { fView.UpozoriKorisnika("Izaberite sektor"); return; } var odeljenje = fOdeljenja.AddNew(); odeljenje.SektorID = IdSektora; fView.FokusirajOdeljenje(odeljenje); }
public void KreirajNovu() { if (!IdPublikacije.HasValue) { fView.UpozoriKorisnika("Izaberite publikaciju"); return; } var rubrika = fRubrike.AddNew(); rubrika.PublikacijaID = IdPublikacije; fView.FokusirajRubriku(rubrika); }
public void ListChanged_AddRemove_Success() { var bindingList = new BindingList <int>(); bool calledListChanged = false; ListChangedEventHandler handler = (object sender, ListChangedEventArgs e) => calledListChanged = true; bindingList.ListChanged += handler; // Make sure removing the handler was successful. bindingList.ListChanged -= handler; bindingList.AddNew(); Assert.False(calledListChanged); }
private void ConstructUI() { cmb_Operator.DataSource = Enum.GetValues(typeof(Operator_Num)); // 事件绑定 dgv_Slope.CriterionsToBeModified += DgvSlopeOnCriterionsToBeModified; // dgv_Platform.CriterionsToBeModified += DgvSlopeOnCriterionsToBeModified; // _autoSchemes = new BindingList <AutoProtectionCriterions>(); _autoSchemes.AddingNew += AutoSchemesOnAddingNew; _autoSchemes.AddNew(); // cbb_AutoSchemes.DataSource = _autoSchemes; // }
public void AddNew_CancelNewMultipleIndices_RemovesAddNewIndex() { var list = new List <object> { new object(), new object() }; var bindingList = new BindingList <object>(list); bool calledAddingNew = false; bool calledListChanged = false; ListChangedType listChangedType = ListChangedType.Reset; int listChangedIndex = -1; bindingList.AddingNew += (object sender, AddingNewEventArgs e) => { calledAddingNew = true; Assert.Null(e.NewObject); }; bindingList.ListChanged += (object sender, ListChangedEventArgs e) => { calledListChanged = true; listChangedType = e.ListChangedType; listChangedIndex = e.NewIndex; }; object newValue = bindingList.AddNew(); Assert.True(calledAddingNew); Assert.NotNull(newValue); Assert.Equal(3, bindingList.Count); Assert.Equal(2, bindingList.IndexOf(newValue)); Assert.True(calledListChanged); Assert.Equal(ListChangedType.ItemAdded, listChangedType); Assert.Equal(2, listChangedIndex); // Cancelling index 0 does not change the list. calledListChanged = false; bindingList.CancelNew(0); Assert.False(calledListChanged); Assert.Equal(3, bindingList.Count); // Cancelling index 2 changes the list. bindingList.CancelNew(2); Assert.True(calledListChanged); Assert.Equal(ListChangedType.ItemDeleted, listChangedType); Assert.Equal(2, listChangedIndex); Assert.Equal(2, bindingList.Count); }
// Add the new part unless the part number contains // spaces. In that case cancel the add. private void button1_Click(object sender, EventArgs e) { Part newPart = listOfParts.AddNew(); if (newPart.PartName.Contains(" ")) { MessageBox.Show("Part names cannot contain spaces."); listOfParts.CancelNew(listOfParts.IndexOf(newPart)); } else { textBox2.Text = randomNumber.Next(9999).ToString(); textBox1.Text = "Enter part name"; } }
public void AddNew_NullArgsNewObject_ReturnsNotNul() { var bindingList = new BindingList <object>(); bool calledAddingNew = false; bindingList.AddingNew += delegate(object sender, AddingNewEventArgs e) { calledAddingNew = true; Assert.Null(e.NewObject); }; Assert.NotNull(bindingList.AddNew()); Assert.True(calledAddingNew); }
public void TestAddNew_EndDifferentIndexThenCancel() { BindingList <object> l = new BindingList <object>(); bool adding_event_raised = false; object o = new object(); bool list_changed = false; ListChangedType change_type = ListChangedType.Reset; int list_changed_index = -1; l.AddingNew += delegate(object sender, AddingNewEventArgs e) { adding_event_raised = true; Assert.IsNull(e.NewObject, "1"); }; l.ListChanged += delegate(object sender, ListChangedEventArgs e) { list_changed = true; change_type = e.ListChangedType; list_changed_index = e.NewIndex; }; object rv = l.AddNew(); Assert.IsTrue(adding_event_raised, "2"); Assert.IsNotNull(rv, "3"); Assert.AreEqual(1, l.Count, "4"); Assert.AreEqual(0, l.IndexOf(rv), "5"); Assert.IsTrue(list_changed, "6"); Assert.AreEqual(ListChangedType.ItemAdded, change_type, "7"); Assert.AreEqual(0, list_changed_index, "8"); list_changed = false; l.EndNew(2); Assert.AreEqual(1, l.Count, "9"); Assert.IsFalse(list_changed, "10"); l.CancelNew(0); Assert.IsTrue(list_changed, "11"); Assert.AreEqual(ListChangedType.ItemDeleted, change_type, "12"); Assert.AreEqual(0, list_changed_index, "13"); }
public void TestAddNew() { BindingList <object> l = new BindingList <object>(); bool adding_event_raised = false; object o = new object(); l.AddingNew += delegate(object sender, AddingNewEventArgs e) { adding_event_raised = true; Assert.IsNull(e.NewObject, "1"); }; object rv = l.AddNew(); Assert.IsTrue(adding_event_raised, "2"); Assert.IsNotNull(rv, "3"); }
public void AddNew_SetArgsNewObject_ReturnsNewObject() { BindingList <object> bindingList = new BindingList <object>(); bool calledAddingNew = false; var newObject = new object(); bindingList.AddingNew += (object sender, AddingNewEventArgs e) => { calledAddingNew = true; Assert.Null(e.NewObject); e.NewObject = newObject; }; Assert.Same(newObject, bindingList.AddNew()); Assert.True(calledAddingNew); }
public void AddNew_EndDifferenceIndexThanCancel_Success() { var bindingList = new BindingList <object>(); bool calledAddingNew = false; bool calledListChanged = false; ListChangedType listChangedType = ListChangedType.Reset; int listChangedIndex = -1; bindingList.AddingNew += (object sender, AddingNewEventArgs e) => { calledAddingNew = true; Assert.Null(e.NewObject); }; bindingList.ListChanged += (object sender, ListChangedEventArgs e) => { calledListChanged = true; listChangedType = e.ListChangedType; listChangedIndex = e.NewIndex; }; // Make sure AddNew changed the list. object newValue = bindingList.AddNew(); Assert.True(calledAddingNew); Assert.NotNull(newValue); Assert.Equal(1, bindingList.Count); Assert.Equal(0, bindingList.IndexOf(newValue)); Assert.True(calledListChanged); Assert.Equal(ListChangedType.ItemAdded, listChangedType); Assert.Equal(0, listChangedIndex); // EndNew with an invalid index does not change the list. calledListChanged = false; bindingList.EndNew(2); Assert.Equal(1, bindingList.Count); Assert.False(calledListChanged); // CancelNew with a valid index changes the list. bindingList.CancelNew(0); Assert.True(calledListChanged); Assert.Equal(ListChangedType.ItemDeleted, listChangedType); Assert.Equal(0, listChangedIndex); }
public void AddNew_CancelDifferentIndexThenEnd_Success() { var list = new BindingList <object>(); bool calledAddingNew = false; bool calledListChanged = false; ListChangedType listChangedType = ListChangedType.Reset; int listChangedIndex = -1; list.AddingNew += delegate(object sender, AddingNewEventArgs e) { calledAddingNew = true; Assert.Null(e.NewObject); }; list.ListChanged += delegate(object sender, ListChangedEventArgs e) { calledListChanged = true; listChangedType = e.ListChangedType; listChangedIndex = e.NewIndex; }; // Make sure AddNew changed the list. object newValue = list.AddNew(); Assert.True(calledAddingNew); Assert.NotNull(newValue); Assert.Equal(1, list.Count); Assert.Equal(0, list.IndexOf(newValue)); Assert.True(calledListChanged); Assert.Equal(ListChangedType.ItemAdded, listChangedType); Assert.Equal(0, listChangedIndex); // Calling CancelNew on an invalid index does not change the list. calledListChanged = false; list.CancelNew(2); Assert.Equal(1, list.Count); Assert.False(calledListChanged); // Calling EndNew does not change the list. list.EndNew(0); Assert.Equal(1, list.Count); Assert.False(calledListChanged); }
public void TestAddNew_SettingArgsNewObject() { BindingList <object> l = new BindingList <object>(); bool adding_event_raised = false; object o = new object(); l.AddingNew += delegate(object sender, AddingNewEventArgs e) { adding_event_raised = true; Assert.Null(e.NewObject); e.NewObject = o; }; object rv = l.AddNew(); Assert.True(adding_event_raised, "2"); Assert.Same(o, rv); }
public void TestAddNew_End() { BindingList <object> l = new BindingList <object>(); bool adding_event_raised = false; object o = new object(); bool list_changed = false; ListChangedType change_type = ListChangedType.Reset; int list_changed_index = -1; l.AddingNew += delegate(object sender, AddingNewEventArgs e) { adding_event_raised = true; Assert.Null(e.NewObject); }; l.ListChanged += delegate(object sender, ListChangedEventArgs e) { list_changed = true; change_type = e.ListChangedType; list_changed_index = e.NewIndex; }; object rv = l.AddNew(); Assert.True(adding_event_raised, "2"); Assert.NotNull(rv); Assert.Equal(1, l.Count); Assert.Equal(0, l.IndexOf(rv)); Assert.True(list_changed, "6"); Assert.Equal(ListChangedType.ItemAdded, change_type); Assert.Equal(0, list_changed_index); list_changed = false; l.EndNew(0); Assert.Equal(1, l.Count); Assert.False(list_changed, "10"); }
public Window1() { NamedRects=new BindingList<NamedRectangle>(); NamedRects.ListChanged+=HandleListChangedEventHandler;; CurrentlySelectedNamedRect=NamedRects.AddNew(); NamedRects.AddNew(); NamedRects.AddNew(); FixDuplicateNames(); var TestString="She sells seashells on the seashore"; InitializeComponent(); lstRects.ItemsSource=NamedRects; }