private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e) { if (e.Index < 0 || e.Index >= listBox1.Items.Count) { return; } if (listBox1.Items[e.Index] is GCListBoxEntry) { GCListBoxEntry lb = listBox1.Items[e.Index] as GCListBoxEntry; if (lb.SubtitleHeight < 0 || lb.TitleHeight < 0) { SizeF sz; if (lb.Title.Length > 0) { sz = e.Graphics.MeasureString(lb.Title, listBoxTitleFont); lb.TitleHeight = Convert.ToInt32(sz.Height); } else { lb.TitleHeight = 0; } if (lb.Subtitle.Length > 0) { sz = e.Graphics.MeasureString(lb.Subtitle, listBoxSubtitleFont); lb.SubtitleHeight = Convert.ToInt32(sz.Height); } else { lb.SubtitleHeight = 0; } } e.ItemHeight = lb.SubtitleHeight + lb.TitleHeight + 3 * listBoxItemPadding; } }
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0 || e.Index >= listBox1.Items.Count) { return; } if (listBox1.Items[e.Index] is GCListBoxEntry) { GCListBoxEntry lb = listBox1.Items[e.Index] as GCListBoxEntry; if ((e.State & DrawItemState.Selected) != 0) { e.Graphics.FillRectangle(Brushes.LightYellow, e.Bounds); } else { e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds); } if (lb.TitleHeight > 0) { e.Graphics.DrawString(lb.Title, listBoxTitleFont, Brushes.Black, 2 * listBoxItemPadding, e.Bounds.Top + listBoxItemPadding); } if (lb.SubtitleHeight > 0) { e.Graphics.DrawString(lb.Subtitle, listBoxSubtitleFont, Brushes.DarkGray, 2 * listBoxItemPadding, e.Bounds.Top + 2 * listBoxItemPadding + lb.TitleHeight); } } }
public void FillListView() { GCFestivalTithiMasa p; updatingList = true; listBox1.BeginUpdate(); listBox1.Items.Clear(); foreach (GCFestivalBook book in GCFestivalBookCollection.Books) { if (book.CollectionId >= 0 && book.CollectionId < GCFestivalBookCollection.Books.Count && (filterToBook == null || filterToBook == book)) { foreach (GCFestivalBase fba in book.Festivals) { if (fba.nDeleted == 0) { GCListBoxEntry lbe = new GCListBoxEntry(); fba.updateListBoxEntry(lbe); listBox1.Items.Add(lbe); } } } } updatingList = false; listBox1.EndUpdate(); }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { GCListBoxEntry item = GetSelectedItem(); if (item != null && item.Tag != null) { if (item.Tag is GCFestivalTithiMasa) { } else if (item.Tag is GCFestivalEkadasi) { } else if (item.Tag is GCFestivalMasaDay) { } else if (item.Tag is GCFestivalRelated) { } else if (item.Tag is GCFestivalSankranti) { } else if (item.Tag is GCFestivalSpecial) { } } }
private void RemoveItemFromListBox(GCFestivalBase fb) { for (int i = 0; i < listBox1.Items.Count; i++) { GCListBoxEntry lb = listBox1.Items[i] as GCListBoxEntry; if (lb.Tag == fb) { listBox1.Items.RemoveAt(i); break; } } }
/// <summary> /// Fill main listbox with related events /// </summary> public void FillRelativeEvents() { listBox1.Items.Clear(); if (EventObject.EventsCount > 0) { foreach (GCFestivalRelated r in EventObject.Events) { GCListBoxEntry lb = new GCListBoxEntry(); r.updateListBoxEntry(lb); listBox1.Items.Add(lb); } } }
private void textBox1_TextChanged(object sender, EventArgs e) { if (changingFilter) { return; } if (textBox1.Text.Length == 0) { FillListView(); return; } changingFilter = true; string[] sp = textBox1.Text.Trim().ToLower().Split(' '); int A, B; updatingList = true; listBox1.BeginUpdate(); listBox1.Items.Clear(); foreach (GCFestivalBook book in GCFestivalBookCollection.Books) { foreach (GCFestivalBase fb in book.Festivals) { A = 0; B = 0; if (sp.Length > 0) { foreach (string s in sp) { A++; if (fb.Text.IndexOf(s, 0, StringComparison.CurrentCultureIgnoreCase) >= 0) { B++; } } } if (A == B) { GCListBoxEntry lb = new GCListBoxEntry(); fb.updateListBoxEntry(lb); listBox1.Items.Add(lb); } } } updatingList = false; listBox1.EndUpdate(); changingFilter = false; }
/// <summary> /// Delete Event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { GCListBoxEntry item = GetSelectedItem(); if (item != null && item.Tag != null && Controller.ViewContainer != null) { AskDeleteObject dlg = new AskDeleteObject(); AskDeleteObjectController dlgCtrl = new AskDeleteObjectController(dlg); dlg.Tag = item.Tag; dlg.InitialLabel = "Are you sure to remove following event?"; dlg.DetailLabel = (item.Tag as GCFestivalBase).Text; dlg.OnButtonYes += new TBButtonPressed(onDeleteEvent); dlgCtrl.ShowInContainer(Controller.ViewContainer, GVControlAlign.Fill); } }
/// <summary> /// Edit event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { GCListBoxEntry item = GetSelectedItem(); if (item != null && item.Tag != null) { GCFestivalBase b = item.Tag as GCFestivalBase; EventDetails d = new EventDetails(); d.EventObject = b; d.OnButtonOK += new TBButtonPressed(onNewEventDoneOK); d.OnButtonCancel += new TBButtonPressed(onNewEventDoneCancel); d.OnButtonRelated += new TBButtonPressed(onNewEventDoneRelated); EventDetailsController dc = new EventDetailsController(d); dc.ShowInContainer(Controller.ViewContainer, GVControlAlign.Fill); } }
/// <summary> /// User interface handler for DELETE related event button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonDelete_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0 && listBox1.SelectedIndex < listBox1.Items.Count) { GCListBoxEntry lbe = listBox1.Items[listBox1.SelectedIndex] as GCListBoxEntry; if (lbe != null && lbe.Tag != null) { AskDeleteObject d = new AskDeleteObject(); d.Tag = lbe.Tag; d.InitialLabel = "Are you sure to remove following event?"; d.DetailLabel = (lbe.Tag as GCFestivalBase).Text; AskDeleteObjectController dc = new AskDeleteObjectController(d); d.OnButtonYes += new TBButtonPressed(askDeleteEvent1_OnButtonYes); if (ViewContainer != null) { ViewContainer.AddControl(dc, GVControlAlign.Fill); } } } }
/// <summary> /// User interface handler for EDIT related event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonEdit_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0 && listBox1.SelectedIndex < listBox1.Items.Count) { GCListBoxEntry lbe = listBox1.Items[listBox1.SelectedIndex] as GCListBoxEntry; if (lbe != null && lbe.Tag != null && lbe.Tag is GCFestivalRelated) { GCFestivalRelated r = lbe.Tag as GCFestivalRelated; EventRelatedDetails d = new EventRelatedDetails(); EventRelatedDetailsController dc = new EventRelatedDetailsController(d); dc.ViewContainer = Controller.ViewContainer; d.setEvent(r); d.setParentEvent(EventObject); d.OnEventDetailChanged += new TBButtonPressed(onRelatedEventChanged); if (ViewContainer != null) { ViewContainer.AddControl(dc, GVControlAlign.Fill); } } } }