public ListWithListBoxItems() { Title = "List with ListBoxItem"; ListBox lstbox = new ListBox(); lstbox.Height = 150; lstbox.Width = 150; lstbox.SelectionChanged += ListBoxOnSelectionChanged; Content = lstbox; PropertyInfo[] props = typeof(Colors).GetProperties(); foreach (PropertyInfo prop in props) { Color clr = (Color)prop.GetValue(null, null); bool isBlack = .222 * clr.R + .707 * clr.G + .071 * clr.B > 128; ListBoxItem item = new ListBoxItem(); item.Content = prop.Name; item.Background = new SolidColorBrush(clr); item.Foreground = isBlack ? Brushes.Black : Brushes.White; item.HorizontalContentAlignment = HorizontalAlignment.Center; item.Padding = new Thickness(2); lstbox.Items.Add(item); } }
protected void Page_Load(object sender, EventArgs e) { ListBox1 = new Obout.ListBox.ListBox(); ListBox1.ID = "ListBox1"; ListBoxItem item1 = new ListBoxItem(); item1.Text = "Item 1"; item1.Value = "1"; ListBox1.Items.Add(item1); ListBoxItem item2 = new ListBoxItem(); item2.Text = "Item 2"; item2.Value = "2"; ListBox1.Items.Add(item2); ListBoxItem item3 = new ListBoxItem(); item3.Text = "Item 3"; item3.Value = "3"; ListBox1.Items.Add(item3); ListBoxItem item4 = new ListBoxItem(); item4.Text = "Item 4"; item4.Value = "4"; ListBox1.Items.Add(item4); ListBoxItem item5 = new ListBoxItem(); item5.Text = "Item 5"; item5.Value = "5"; ListBox1.Items.Add(item5); ListBox1Container.Controls.Add(ListBox1); }
protected void Page_Load(object sender, EventArgs e) { ListBox1 = new Obout.ListBox.ListBox(); ListBox1.ID = "ListBox1"; ListBox1.Width = Unit.Pixel(175); ListBox1.SelectedIndex = 2; ListBoxItem item1 = new ListBoxItem(); item1.Text = "USA"; item1.Value = "1"; item1.ImageUrl = "resources/Images/flags/flag_usa.png"; ListBox1.Items.Add(item1); ListBoxItem item2 = new ListBoxItem(); item2.Text = "UK"; item2.Value ="2"; item2.ImageUrl = "resources/Images/flags/flag_england.png"; ListBox1.Items.Add(item2); ListBoxItem item3 = new ListBoxItem(); item3.Text = "Germany"; item3.Value = "3"; item3.ImageUrl = "resources/Images/flags/flag_germany.png"; ListBox1.Items.Add(item3); ListBoxItem item4 = new ListBoxItem(); item4.Text = "France"; item4.Value = "4"; item4.ImageUrl = "resources/Images/flags/flag_france.png"; ListBox1.Items.Add(item4); ListBoxItem item5 = new ListBoxItem(); item5.Text = "Russia"; item5.Value = "5"; item5.ImageUrl = "resources/Images/flags/flag_russia.png"; ListBox1.Items.Add(item5); ListBoxItem item6 = new ListBoxItem(); item6.Text = "India"; item6.Value = "6"; item6.ImageUrl = "resources/Images/flags/flag_india.png"; ListBox1.Items.Add(item6); ListBoxItem item7 = new ListBoxItem(); item7.Text = "Japan"; item7.Value = "7"; item7.ImageUrl = "resources/Images/flags/flag_japan.png"; ListBox1.Items.Add(item7); ListBoxItem item8 = new ListBoxItem(); item8.Text = "China"; item8.Value = "8"; item8.ImageUrl = "resources/Images/flags/flag_china.png"; ListBox1.Items.Add(item8); ListBox1Container.Controls.Add(ListBox1); }
public void AddItem(ListBoxItem obj) { if (this.InvokeRequired) { AddListBoxItem_ dlgt = new AddListBoxItem_(AddItem); Invoke(dlgt, new object[] { obj }); } else { this.Items.Add(obj); } }
private void UpdateComboBox() { categoryCmbBox.ItemsSource = null; categoryCmbBox.Items.Clear(); var categories = db.Categories.ToList(); List<ListBoxItem> items = new List<ListBoxItem>(); foreach (var category in categories) { var item = new ListBoxItem(category.Id, category.Name); items.Add(item); } categoryCmbBox.ItemsSource = items; categoryCmbBox.SelectedIndex = 1; }
private void PopulateVehicles(List<Vehicle> carsToDisplay) { RegisteredCars.Items.Clear(); foreach (var vehicle in carsToDisplay) { var newListBoxItem = new ListBoxItem(); newListBoxItem.Content = vehicle.Manufacturer + " " + vehicle.Model + " " + vehicle.RegistrationNumber; newListBoxItem.Tag = vehicle; RegisteredCars.Items.Add(newListBoxItem); } }
private void UpdateComboBox() { purchaseCmbBox.ItemsSource = null; purchaseCmbBox.Items.Clear(); using (var db = new Model.BudgetModel()) { var sources = db.Sources.ToList(); List<ListBoxItem> items = new List<ListBoxItem>(); foreach (var source in sources) { var item = new ListBoxItem(source.Id, source.Name); items.Add(item); } purchaseCmbBox.ItemsSource = items; } purchaseDataTime.SelectedDate = DateTime.Today; }
private void UpdateComboBox() { goodsComboBox.ItemsSource = null; goodsComboBox.Items.Clear(); using (var db = new Model.BudgetModel()) { var categories = db.Categories.ToList(); List<ListBoxItem> items = new List<ListBoxItem>(); foreach (var category in categories) { var item = new ListBoxItem(category.Id, category.Name); items.Add(item); } goodsComboBox.ItemsSource = items; } goodsComboBox.SelectedIndex = 1; }
void addElementToListbox(string folderText) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; Image folderImg = new Image(); BitmapImage fld = new BitmapImage(); fld.BeginInit(); fld.UriSource = new Uri(@"Images/folder.png", UriKind.RelativeOrAbsolute); fld.EndInit(); folderImg.Source = fld; folderImg.Width = 40; folderImg.Height = 40; folderImg.Margin = new Thickness(10, 10, 0, 10); sp.Children.Add(folderImg); Label folderName = new Label(); folderName.Content = folderText; folderName.Background = Brushes.Transparent; folderName.BorderBrush = Brushes.Transparent; folderName.Margin = new Thickness(30, 15, 0, 15); folderName.FontSize = 14; folderName.FontFamily = new FontFamily("Tahoma"); sp.Children.Add(folderName); ListBoxItem item = new ListBoxItem(); item.Content = sp; ListBox.Items.Add(item); }
/// <summary> /// Initializes a new instance of the CheckListBoxIndicatorItem class. /// </summary> /// <param name="offset"> /// The offset. /// </param> /// <param name="isSelected"> /// true if this CheckListBoxIndicatorItem is selected. /// </param> /// <param name="relatedListBoxItem"> /// The related list box item. /// </param> public CheckListBoxIndicatorItem(double offset, bool isSelected, ListBoxItem relatedListBoxItem) { Offset = offset; IsSelected = isSelected; RelatedListBoxItem = relatedListBoxItem; }
private void Add区域属性() { ListBoxEx con = new ListBoxEx { Width = 160, Height = 140, ItemHeight = 16 }; ListBoxItem item = new ListBoxItem("根据时间", "0"); ListBoxItem item2 = new ListBoxItem("限速", "1"); ListBoxItem item3 = new ListBoxItem("进区域报警给驾驶员", "2"); ListBoxItem item4 = new ListBoxItem("进区域报警给平台", "3"); ListBoxItem item5 = new ListBoxItem("出区域报警给驾驶员", "4"); ListBoxItem item6 = new ListBoxItem("出区域报警给平台", "5"); ListBoxItem item7 = new ListBoxItem("南纬", "6"); ListBoxItem item8 = new ListBoxItem("西经", "7"); con.DrawMode = DrawMode.OwnerDrawFixed; con.FormattingEnabled = true; con.IsCheckBox = true; con.SelectionMode = SelectionMode.MultiSimple; con.Items.AddRange(new object[] { item, item2, item3, item4, item5, item6, item7, item8 }); this._区域属性 = new AutoDropDown(con); base.Controls.Add(this._区域属性); this._区域属性.VisibilityChange += new VisibleChanged(this._区域属性_VisibilityChange); }
/// <summary> /// 쪽지 및 파일 전송 수신자 추가 폼에서 "전체" 라디오 버튼 클릭시 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void radiobt_all_Click(object sender, EventArgs e) { try { AddMemberForm addMemberForm = ChatUtils.GetParentAddMemberForm((RadioButton)sender); ListBox addbox = addMemberForm.AddListBox; addMemberForm.combobox_team.Visible = false; addMemberForm.label_choice.Visible = false; ListBox box = addMemberForm.CurrInListBox; box.Items.Clear(); GetAllMemberDelegate getAll = new GetAllMemberDelegate(GetAllMember); Hashtable all = (Hashtable)Invoke(getAll, null); if (all != null && all.Count != 0) { foreach (DictionaryEntry de in all) { if (de.Value != null) { UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(memTree.Nodes, de.Key.ToString()); ListBoxItem item = new ListBoxItem(userObj); if (ListBox.NoMatches == addbox.FindStringExact(item.Text)) { box.Items.Add(item); } } } } } catch (Exception exception) { logWrite(exception.ToString()); } }
public void RLSList_Set(ref ListBoxItem lbi, RLS rls) { Thickness thick = new Thickness(5.0); Grid gr = new Grid(); gr.ColumnDefinitions.Add(new ColumnDefinition()); gr.ColumnDefinitions[0].Width = new GridLength(2.0, GridUnitType.Star); gr.ColumnDefinitions.Add(new ColumnDefinition()); gr.ColumnDefinitions[1].Width = new GridLength(0.7, GridUnitType.Star); gr.ColumnDefinitions.Add(new ColumnDefinition()); gr.ColumnDefinitions[2].Width = new GridLength(0.7, GridUnitType.Star); gr.ColumnDefinitions.Add(new ColumnDefinition()); gr.ColumnDefinitions[3].Width = new GridLength(1.0, GridUnitType.Star); gr.ColumnDefinitions.Add(new ColumnDefinition()); gr.ColumnDefinitions[4].Width = new GridLength(1.0, GridUnitType.Star); gr.HorizontalAlignment = HorizontalAlignment.Stretch; gr.ShowGridLines = true; TextBlock nameTextBlock = new TextBlock(); nameTextBlock.Text = rls.Name; nameTextBlock.Margin = thick; Grid.SetColumn(nameTextBlock, 0); TextBlock typeTextBlock = new TextBlock(); switch (rls.Type) { case RLSType.PRL: { typeTextBlock.Text = "ПРЛ"; }; break; case RLSType.VRL: { typeTextBlock.Text = "ВРЛ"; }; break; case RLSType.NRZ: { typeTextBlock.Text = "НРЗ"; }; break; } typeTextBlock.Margin = thick; Grid.SetColumn(typeTextBlock, 1); TextBlock distTextBlock = new TextBlock(); distTextBlock.Text = rls.Distance.ToString() + " км"; distTextBlock.Margin = thick; Grid.SetColumn(distTextBlock, 2); Button grdColorButton = new Button(); grdColorButton.Background = Brushes.DarkGreen; grdColorButton.Margin = thick; Grid.SetColumn(grdColorButton, 3); grdColorButton.Click += new RoutedEventHandler(ColorButton_Click); Button vsrColorButton = new Button(); vsrColorButton.Background = Brushes.White; vsrColorButton.Margin = thick; Grid.SetColumn(vsrColorButton, 4); vsrColorButton.Click += new RoutedEventHandler(ColorButton_Click); gr.Children.Add(nameTextBlock); gr.Children.Add(typeTextBlock); gr.Children.Add(distTextBlock); gr.Children.Add(grdColorButton); gr.Children.Add(vsrColorButton); lbi.Content = gr; }
public void SetCurrInListBox(Hashtable table, TreeNodeCollection collection) { if (table != null && table.Count != 0) { foreach (DictionaryEntry de in table) { if (de.Value != null) { UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(collection, de.Key.ToString()); if (userObj == null || userObj.Id == "") continue; ListBoxItem item = new ListBoxItem(userObj); if (ListBox.NoMatches == AddListBox.FindStringExact(item.Text)) { CurrInListBox.Items.Add(item); } } } } }
private void treeViewDrop(object sender, DragEventArgs e) { Point pos = e.GetPosition(treeView); HitTestResult result = VisualTreeHelper.HitTest(treeView, pos); if (result == null) { return; } ListBoxItem newChild = new ListBoxItem(); newChild = e.Data.GetData(typeof(ListBoxItem)) as ListBoxItem; TreeViewItem addChild = new TreeViewItem(); TreeViewItem selectedItem = Utils.FindVisualParent <TreeViewItem>(result.VisualHit); if (selectedItem == null) { treeView.Items.Add(addChild); if (newChild.Content.ToString().Contains("防火墙")) { addChild.Header = newChild.Content.ToString(); addChild.Style = this.FindResource("SimpleTreeViewItemFireWall") as Style; } else if (newChild.Content.ToString().Contains("电脑")) { addChild.Header = "电脑"; addChild.Style = this.FindResource("SimpleTreeViewItemComputer") as Style; } else if (newChild.Content.ToString().Contains("PLC")) { RenameWindow Rename = new RenameWindow(); Rename.ShowDialog(); addChild.Header = StaticGlobal.newPLC; addChild.Style = this.FindResource("SimpleTreeViewItemPLC") as Style; } else { addChild.Header = newChild.Content.ToString(); addChild.Style = this.FindResource("SimpleTreeViewItemPLC") as Style; } } else { TreeViewItem parent = selectedItem as TreeViewItem; parent.Items.Add(addChild); if (newChild.Content.ToString().Contains("防火墙")) { addChild.Header = newChild.Content.ToString(); addChild.Style = this.FindResource("SimpleTreeViewItemFireWall") as Style; } else if (newChild.Content.ToString().Contains("电脑")) { addChild.Header = "电脑"; addChild.Style = this.FindResource("SimpleTreeViewItemComputer") as Style; } else if (newChild.Content.ToString().Contains("PLC")) { RenameWindow Rename = new RenameWindow(); Rename.ShowDialog(); addChild.Header = StaticGlobal.newPLC; addChild.Style = this.FindResource("SimpleTreeViewItemPLC") as Style; } else { addChild.Header = newChild.Content.ToString(); addChild.Style = this.FindResource("SimpleTreeViewItemPLC") as Style; } parent.IsExpanded = true; } }
/// <summary> /// Gets the drag format when this instance is being dragged above or below another row. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <returns> /// The drag format used when this instance is being dragged above or below another row. /// </returns> public static string GetMoveDragFormat(ListBoxItem listBoxItem) { return((string)listBoxItem.GetValue(MoveDragFormatProperty)); }
/// <summary> /// Sets the content template when this instance is being dragged above or below another row. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <param name="value">A data template used when this instance is being dragged above or below another row.</param> public static void SetMoveDragContentTemplate(ListBoxItem listBoxItem, DataTemplate value) { listBoxItem.SetValue(MoveDragContentTemplateProperty, value); }
/// <summary> /// Gets the content template when this instance is being dragged above or below another row. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <returns> /// A data template used when this instance is being dragged above or below another row. /// </returns> public static DataTemplate GetMoveDragContentTemplate(ListBoxItem listBoxItem) { return((DataTemplate)listBoxItem.GetValue(MoveDragContentTemplateProperty)); }
public StickerSpriteItem(int columns, IList <TLStickerItem> stickers, double stickerHeight, double panelWidth, MouseEventHandler onStickerMouseEnter, bool showEmoji = false) { Stickers = stickers; _stickerHeight = stickerHeight; var panelMargin = new Thickness(4.0, 0.0, 4.0, 0.0); var panelActualWidth = panelWidth - panelMargin.Left - panelMargin.Right; //472, 438 var stackPanel = new Grid { Width = panelActualWidth, Margin = panelMargin, Background = new SolidColorBrush(Colors.Transparent) }; for (var i = 0; i < columns; i++) { stackPanel.ColumnDefinitions.Add(new ColumnDefinition()); } for (var i = 0; i < stickers.Count; i++) { var binding = new Binding { Mode = BindingMode.OneWay, Path = new PropertyPath("Self"), Converter = new DefaultPhotoConverter(), ConverterParameter = StickerHeight }; var stickerImage = new Image { Height = StickerHeight, Margin = new Thickness(0, 12, 0, 12), VerticalAlignment = VerticalAlignment.Top, CacheMode = new BitmapCache() }; if (onStickerMouseEnter != null) { stickerImage.MouseEnter += onStickerMouseEnter; } stickerImage.SetBinding(Image.SourceProperty, binding); StickerImage = stickerImage; var grid = new Grid(); grid.Children.Add(stickerImage); if (showEmoji) { var document22 = stickers[i].Document as TLDocument22; if (document22 != null) { var bytes = Encoding.BigEndianUnicode.GetBytes(document22.Emoticon); var bytesStr = BrowserNavigationService.ConvertToHexString(bytes); var emojiImage = new Image { Height = 32, Width = 32, Margin = new Thickness(12, 12, 12, 12), HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Source = new BitmapImage(new Uri(string.Format("/Assets/Emoji/Separated/{0}.png", bytesStr), UriKind.RelativeOrAbsolute)) }; grid.Children.Add(emojiImage); } } var listBoxItem = new ListBoxItem { Content = grid, DataContext = stickers[i] }; Microsoft.Phone.Controls.TiltEffect.SetIsTiltEnabled(listBoxItem, true); listBoxItem.Tap += Sticker_OnTap; //grid.DataContext = stickers[i]; Grid.SetColumn(listBoxItem, i); stackPanel.Children.Add(listBoxItem); } Children.Add(stackPanel); View.Width = panelWidth; }
void IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: ((ProfileWindow)target).Loaded += new RoutedEventHandler(this.Window_Loaded); ((ProfileWindow)target).Closing += new CancelEventHandler(this.Window_Closing); return; case 2: ((Grid)target).MouseLeftButtonDown += new MouseButtonEventHandler(this.Grid_MouseLeftButtonDown); return; case 3: this.lvMenu = (ListBox)target; this.lvMenu.SelectionChanged += new SelectionChangedEventHandler(this.lvMenu_SelectionChanged); return; case 4: this.shippingMenuItem = (ListBoxItem)target; return; case 5: this.privacyMenuItem = (ListBoxItem)target; return; case 6: this.BtnClose = (Button)target; this.BtnClose.Click += new RoutedEventHandler(this.BtnClose_Click); return; case 7: this.txtProfileName = (TextBox)target; return; case 8: this.chSameBilling = (CheckBox)target; this.chSameBilling.Checked += new RoutedEventHandler(this.chSameBilling_Checked); this.chSameBilling.Unchecked += new RoutedEventHandler(this.chSameBilling_Checked); return; case 9: this.chOneCheckoutPerSite = (CheckBox)target; return; case 10: this.cmbGroup = (ComboBox)target; return; case 11: this.MenusFrame = (System.Windows.Controls.Frame)target; return; case 12: this.btnGenerateDummy = (Button)target; this.btnGenerateDummy.Click += new RoutedEventHandler(this.btnGenerateDummy_Click); return; case 13: this.btnSave = (Button)target; this.btnSave.Click += new RoutedEventHandler(this.btnSave_Click); return; case 14: this.btnCancel = (Button)target; this.btnCancel.Click += new RoutedEventHandler(this.btnCancel_Click); return; } this._contentLoaded = true; }
/// <summary> /// Loads configuration data from the provided file. /// </summary> /// <param name="fileName">The name of the file to load.</param> private void LoadConfigurationFile(string fileName) { fileName = (fileName + "").Trim(); UserConfiguration uc = new UserConfiguration(); uc = uc.Deserialize(fileName); this.serialIdList = uc.SerialIds; this.emailList = uc.Emails; this.agencyList = (uc.Agencies != null ? (uc.Agencies.Length > 0 ? uc.Agencies.Split(new char[] { ',' }) : null) : null); this.postalCodeList = (uc.PostalCodes != null ? (uc.PostalCodes.Length > 0 ? uc.PostalCodes.Split(new char[] { ',' }) : null) : null); this.usagePerDay.Text = (uc.DataUsage.Daily.Value == -1 ? "" : uc.DataUsage.Daily.Value.ToString()); this.usagePerWeek.Text = (uc.DataUsage.Weekly.Value == -1 ? "" : uc.DataUsage.Weekly.Value.ToString()); this.hitsPerDay.Text = (uc.AfltHits.Daily.Value == -1 ? "" : uc.AfltHits.Daily.Value.ToString()); this.hitsPerWeek.Text = (uc.AfltHits.Weekly.Value == -1 ? "" : uc.AfltHits.Weekly.Value.ToString()); if (this.emailList != null) { if (this.emailList.Length > 0) { ResetText(); this.emails.Text = this.emailList; } } this.serialIds.Text = this.serialIdList; ListBoxItem[] lbi = null; List <ListBoxItem> items = null; if (this.agencyList != null) { lbi = new ListBoxItem[this.agencies.Items.Count]; this.agencies.Items.CopyTo(lbi, 0); items = lbi.ToList(); for (int i = 0; i < this.agencyList.Length; i++) { ListBoxItem item = null; try { item = items.Where(x => x.Content.ToString() == this.agencyList[i]).First(); } catch (InvalidOperationException) { //NOP } if (item != null) { this.agencies.SelectedItems.Add(item); } } } if (this.postalCodeList != null) { lbi = new ListBoxItem[this.postalCodes.Items.Count]; this.postalCodes.Items.CopyTo(lbi, 0); items = lbi.ToList(); for (int i = 0; i < this.postalCodeList.Length; i++) { ListBoxItem item = null; try { item = items.Where(x => x.Content.ToString() == this.postalCodeList[i]).First(); } catch (InvalidOperationException) { } if (item != null) { this.postalCodes.SelectedItems.Add(item); } } } }
private void PopulateEmployees(List<Employee> employeesToDisplay) { RegisteredEmployees.Items.Clear(); foreach (var employee in employeesToDisplay) { var newListBoxItem = new ListBoxItem(); newListBoxItem.Content = employee.Name + " " + employee.Position; newListBoxItem.Tag = employee; RegisteredEmployees.Items.Add(newListBoxItem); } }
/// <summary> /// Sets the drag format when this instance is being dragged above or below another row. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <param name="format">The drag format used when this instance is being dragged above or below another row.</param> public static void SetMoveDragFormat(ListBoxItem listBoxItem, string format) { listBoxItem.SetValue(MoveDragFormatProperty, format); }
private void arrangeItem(Direction direction) { if (lstCurrent.SelectedItems.Count <= 0) return; var selected = (ListBoxItem)lstCurrent.SelectedItem; if (direction == Direction.Up) { selected.DisplayIndex--; //Get previous item var previous = (ListBoxItem) lstCurrent.Items[lstCurrent.SelectedIndex - 1]; previous.DisplayIndex++; } if (direction == Direction.Down) { selected.DisplayIndex++; //Get next item var next = (ListBoxItem)lstCurrent.Items[lstCurrent.SelectedIndex + 1]; next.DisplayIndex--; } //Create ArrayList of current items var originList = new ArrayList(lstCurrent.Items); //Comparer for sorting var comparer = new ListBoxItem(); //Clear and repopulate origin Listbox sorted originList.Sort(comparer); lstCurrent.Items.Clear(); lstCurrent.Items.AddRange(originList.ToArray()); //Reselect item lstCurrent.SelectedItem = selected; PropertyChanged = true; }
private void onlineMembersTimer_Tick(object sender, EventArgs e) { listBoxContactlist.Items.Clear(); var onlineMembers = mainWindow.proxy.GetOnlineMembers(); foreach (var member in onlineMembers) { var listBoxItem = new ListBoxItem(); listBoxItem.Content = member; listBoxItem.MouseDoubleClick += this.listBoxItem_MouseDoubleClick; listBoxContactlist.Items.Add(listBoxItem); } }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { lsTasks.Items.Clear(); curTasks.Clear(); try { if (chb1.IsChecked == true && dtP.SelectedDate == null) { foreach (task item in tasks) { if (item.status == 0) { string pr = ""; string st = ""; if (item.status == 1) { st = "Выполнено"; } if (item.status == 0) { st = "Не выполнено"; } switch (item.pr) { case 0: pr = "Низкий"; break; case 1: pr = "Средний"; break; case 2: pr = "Высокий"; break; } ListBoxItem ls = new ListBoxItem(); ls.BorderBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ls.Content = "Название: " + item.name + "\n Для кого: " + MainFunc.FindUser(item.userT, UsersList).login + " (" + MainFunc.FindUser(item.userT, UsersList).fio + ")" + "\n Дата для выполнения: " + item.time_work + "\n Приотритет: " + pr + "\n Статус: " + st; lsTasks.Items.Add(ls); curTasks.Add(item); } } } else if (chb1.IsChecked == false && dtP.SelectedDate == null) { UpdList(); } else if (chb1.IsChecked == false && dtP.SelectedDate != null) { foreach (task item in tasks) { if (DateTime.Parse(item.time_work) == dtP.SelectedDate) { string pr = ""; string st = ""; if (item.status == 1) { st = "Выполнено"; } if (item.status == 0) { st = "Не выполнено"; } switch (item.pr) { case 0: pr = "Низкий"; break; case 1: pr = "Средний"; break; case 2: pr = "Высокий"; break; } ListBoxItem ls = new ListBoxItem(); ls.BorderBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255)); ls.Content = "Название: " + item.name + "\n Для кого: " + MainFunc.FindUser(item.userT, UsersList).login + " (" + MainFunc.FindUser(item.userT, UsersList).fio + ")" + "\n Дата для выполнения: " + item.time_work + "\n Приотритет: " + pr + "\n Статус: " + st; lsTasks.Items.Add(ls); curTasks.Add(item); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Gets the deselection enabled property. If enabled, and the row is clicked while selected, the row is deselected. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <returns> /// <c>true</c> if deselecting row when selected and clicked, otherwise <c>false</c>. /// </returns> public static bool GetIsDeselectionEnabled(ListBoxItem listBoxItem) { return((bool)listBoxItem.GetValue(IsDeselectionEnabledProperty)); }
private void OpenContextMenu(ListBoxItem item) { //Creates a context menu for selected ListBox item, with options to add item to the playing queue, and navigation options, depending on the type of item selected var menu = new ContextMenu(); MenuItem menuItem; if (item.Content is Track) { var track = (Track)item.Content; if (track != player.Queue.CurrentTrack) { menuItem = new MenuItem() { Header = "Play Next", Icon = (Canvas)this.FindResource("PlayNextIcon") }; menuItem.Click += AddTrackToFront; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Add To Queue", Icon = (Canvas)this.FindResource("AddToQueueIcon") }; menuItem.Click += AddTrackToBack; menu.Items.Add(menuItem); } menuItem = new MenuItem() { Header = "Go To Album", Icon = (Canvas)this.FindResource("AlbumMenuIcon") }; menuItem.Click += GoToAlbum; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Artist", Icon = (Canvas)this.FindResource("ArtistMenuIcon") }; foreach (var artist in track.Artists.Concat(track.Remixers)) { var submenuItem = new MenuItem() { Header = artist.Name }; submenuItem.Click += GoToArtist; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Genre", Icon = (Canvas)this.FindResource("GenreMenuIcon") }; foreach (var genre in track.Genres) { var submenuItem = new MenuItem() { Header = genre.Name }; submenuItem.Click += GoToGenre; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); } else if (item.Content is QueueItem) { var track = ((QueueItem)item.Content).Track; if (track != player.Queue.CurrentTrack) { menuItem = new MenuItem() { Header = "Move To Front" }; menuItem.Click += MoveToFrontOfQueue; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Move To Back" }; menuItem.Click += MoveToBackOfQueue; menu.Items.Add(menuItem); } menuItem = new MenuItem() { Header = "Go To Album", Icon = (Canvas)this.FindResource("AlbumMenuIcon") }; menuItem.Click += GoToAlbum; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Artist", Icon = (Canvas)this.FindResource("ArtistMenuIcon") }; foreach (var artist in track.Artists.Concat(track.Remixers)) { var submenuItem = new MenuItem() { Header = artist.Name }; submenuItem.Click += GoToArtist; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Genre", Icon = (Canvas)this.FindResource("GenreMenuIcon") }; foreach (var genre in track.Genres) { var submenuItem = new MenuItem() { Header = genre.Name }; submenuItem.Click += GoToGenre; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); } else if (item.Content is Album) { var album = (Album)item.Content; menuItem = new MenuItem() { Header = "Play Next", Icon = (Canvas)this.FindResource("PlayNextIcon") }; menuItem.Click += AddTracksToFront; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Add To Queue", Icon = (Canvas)this.FindResource("AddToQueueIcon") }; menuItem.Click += AddTracksToBack; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Artist", Icon = (Canvas)this.FindResource("ArtistMenuIcon") }; foreach (var artist in album.Artists) { var submenuItem = new MenuItem() { Header = artist.Name }; submenuItem.Click += GoToArtist; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Go To Genre", Icon = (Canvas)this.FindResource("GenreMenuIcon") }; foreach (var genre in album.Tracks.SelectMany(t => t.Genres)) { var submenuItem = new MenuItem() { Header = genre.Name }; submenuItem.Click += GoToGenre; menuItem.Items.Add(submenuItem); } menu.Items.Add(menuItem); } else { menuItem = new MenuItem() { Header = "Play Next", Icon = (Canvas)this.FindResource("PlayNextIcon") }; menuItem.Click += AddTracksToFront; menu.Items.Add(menuItem); menuItem = new MenuItem() { Header = "Add To Queue", Icon = (Canvas)this.FindResource("AddToQueueIcon") }; menuItem.Click += AddTracksToBack; menu.Items.Add(menuItem); } item.ContextMenu = menu; }
/// <summary> /// Moves the selected items from the origin to the destination. /// </summary> /// <param name="origin">The origin.</param> /// <param name="destination">The destination.</param> private void moveItem(ListBox origin, ListBox destination) { if (origin.SelectedItems.Count <= 0) return; //Create ArrayList of current items var originList = new ArrayList(origin.Items); //Create ArrayList of destination items var destinationList = new ArrayList(destination.Items); //Add selected items from origin listbox to destination list foreach (ListBoxItem item in origin.SelectedItems) { destinationList.Add(item); } //remove the selected items from the origin list foreach (var item in origin.SelectedItems) { originList.Remove(item); } //Comparer for sorting var comparer = new ListBoxItem(); //Clear and repopulate origin Listbox sorted originList.Sort(comparer); origin.Items.Clear(); origin.Items.AddRange(originList.ToArray()); //Clear and repopulate destination Listbox sorted destinationList.Sort(comparer); destination.Items.Clear(); destination.Items.AddRange(destinationList.ToArray()); PropertyChanged = true; }
/// <summary> /// Sets the deselection enabled property. If enabled, and the row is clicked while selected, the row is deselected. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <param name="value">if set to <c>true</c> deselects the row when selected and clicked.</param> public static void SetIsDeselectionEnabled(ListBoxItem listBoxItem, bool value) { listBoxItem.SetValue(IsDeselectionEnabledProperty, value); }
/// <summary> /// Sets the command used to move another row above this one using drag and drop. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <param name="command">The command to move a row above this instance.</param> public static void SetMoveAboveCommand(ListBoxItem listBoxItem, ICommand command) { listBoxItem.SetValue(MoveAboveCommandProperty, command); }
private void Add路线属性() { ListBoxEx con = new ListBoxEx { Width = 160, Height = 100, ItemHeight = 16 }; ListBoxItem item = new ListBoxItem("根据时间", "0") { Tag = 1 }; ListBoxItem item2 = new ListBoxItem("进路线报警给驾驶员", "2") { Tag = 4 }; ListBoxItem item3 = new ListBoxItem("进路线报警给平台", "3") { Tag = 8 }; ListBoxItem item4 = new ListBoxItem("出路线报警给驾驶员", "4") { Tag = 16 }; ListBoxItem item5 = new ListBoxItem("出路线报警给平台", "5") { Tag = 32 }; con.DrawMode = DrawMode.OwnerDrawFixed; con.FormattingEnabled = true; con.IsCheckBox = true; con.SelectionMode = SelectionMode.MultiSimple; con.Items.AddRange(new object[] { item, item2, item3, item4, item5 }); this._路线属性 = new AutoDropDown(con); base.Controls.Add(this._路线属性); this._路线属性.VisibilityChange += new VisibleChanged(this._路线属性_VisibilityChange); }
private void combobox_team_SelectedValueChangedAll(object sender, EventArgs e) { try { AddMemberForm addMemberForm = ChatUtils.GetParentAddMemberForm((ComboBox)sender); ComboBox box = addMemberForm.combobox_team; ListBox addbox = addMemberForm.AddListBox; string teamname = (String)box.SelectedItem; if (teamname == "기타") teamname = ""; GetMemberDelegate getmember = new GetMemberDelegate(ChatUtils.GetMember); Hashtable memTable = (Hashtable)Invoke(getmember, new object[] { treesource, teamname }); int num = box.Parent.Controls.Count; ListBox listbox = addMemberForm.CurrInListBox; listbox.Items.Clear(); foreach (DictionaryEntry de in memTable) { string tempid = (String)de.Key; UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(memTree.Nodes, tempid); ListBoxItem item = new ListBoxItem(userObj); if (ListBox.NoMatches == addbox.FindStringExact(item.Text)) { listbox.Items.Add(item); } } } catch (Exception exception) { logWrite(exception.ToString()); } }
//扫描线程 private void Scaning() { Dispatcher.Invoke(new Action(() => { Scanbutton.IsEnabled = false; LayoutRoot.Visibility = Visibility.Visible; ScanlistBox.Items.Clear(); //treeView.Items.Clear(); })); StaticGlobal.FireWalldevices.Clear(); StaticGlobal.FwMACandIP.Clear(); StaticGlobal.fwdev_list.Clear(); string inserttext = ""; IDevicesCheck devConfirm = new DevicesCheck(); StaticGlobal.fwdev_list = devConfirm.CheckDevices(scanstarttext, scanendtext); string propertySql = ""; for (int i = 0; i < StaticGlobal.fwdev_list.Count(); i++) { for (int j = 0; j < StaticGlobal.fwdev_list[i].getProtecDev_list().Count(); j++) { string fw_ip = StaticGlobal.fwdev_list[i].getDev_IP(); string fw_mac = StaticGlobal.fwdev_list[i].getDev_MAC(); string dev_ip = StaticGlobal.fwdev_list[i].getProtecDev_list()[j].getDev_IP(); string dev_mac = StaticGlobal.fwdev_list[i].getProtecDev_list()[j].getDev_MAC(); string dev_type = StaticGlobal.fwdev_list[i].getProtecDev_list()[j].getDev_type(); inserttext += "INSERT INTO firewallip VALUES ('" + fw_ip + "','" + fw_mac + "','" + dev_ip + "','" + dev_mac + "','" + dev_type + "');"; propertySql += "INSERT INTO fwproperty values('" + fw_mac + "','" + fw_mac + "','" + fw_ip + "',NULL);"; } } string propertySql1 = "truncate table fwproperty;" + propertySql; db.dboperate(propertySql1); MySqlConnection conn = new MySqlConnection(StaticGlobal.ConnectionString); conn.Open(); string sqltext = "truncate table firewallip;" + inserttext + "select fw_ip,fw_mac,dev_ip,dev_mac,dev_type from firewallip order by 1;"; MySqlCommand cm = new MySqlCommand(sqltext, conn); MySqlDataReader dr = cm.ExecuteReader(); List <string> firewallmac = new List <string>(); int index = 0; //绑定 while (dr.Read()) { if (!firewallmac.Contains(dr[1])) { firewallmac.Add(dr[1].ToString()); StaticGlobal.FwMACandIP.Add(dr[1].ToString(), dr[0].ToString()); Dispatcher.Invoke(new Action(() => { ListBoxItem item1 = new ListBoxItem(); item1.Content = scanstarttext + "-" + scanendtext; item1.Style = this.FindResource("SimpleListBoxItemIPScanRange") as Style; ScanlistBox.Items.Add(item1); ListBoxItem item = new ListBoxItem(); item.Content = "防火墙 MAC: " + dr[1]; item.Style = this.FindResource("SimpleListBoxItemFireWall") as Style; ScanlistBox.Items.Add(item); ListBoxItem item2 = new ListBoxItem(); item2.Content = dr[4] + " IP: " + dr[2]; item2.Style = this.FindResource("SimpleListBoxItemPLC") as Style; ScanlistBox.Items.Add(item2); })); FireWallDevices firewalldevices = new FireWallDevices(index, dr[0].ToString(), dr[1].ToString()); StaticGlobal.FireWalldevices.Add(firewalldevices); index++; } else { Dispatcher.Invoke(new Action(() => { ListBoxItem item1 = new ListBoxItem(); item1.Content = scanstarttext + "-" + scanendtext; item1.Style = this.FindResource("SimpleListBoxItemIPScanRange") as Style; ScanlistBox.Items.Add(item1); ListBoxItem item = new ListBoxItem(); item.Content = dr[4] + " IP: " + dr[2]; item.Style = this.FindResource("SimpleListBoxItemPLC") as Style; ScanlistBox.Items.Add(item); })); } } index = 0; dr.Close(); conn.Close(); Thread.Sleep(500); Dispatcher.Invoke(new Action(() => { Scanbutton.IsEnabled = true; LayoutRoot.Visibility = Visibility.Collapsed; })); ScanThread.Abort(); }
/// <summary> /// Gets the command used to move another row below this one using drag and drop. /// </summary> /// <param name="listBoxItem">The list box item.</param> /// <returns> /// The command to move a row below this instance. /// </returns> public static ICommand GetMoveBelowCommand(ListBoxItem listBoxItem) { return((ICommand)listBoxItem.GetValue(MoveBelowCommandProperty)); }
public ListBoxItem ListItem(ushort ID, string file, string line, string description, System.Drawing.Bitmap Icon) { // Load Image Image ErrorIcon = Main.CreateImage(Icon, 14, 14, HorizontalAlignment.Center); Grid ListItem = new Grid(); ListItem.ColumnDefinitions.Add(new ColumnDefinition() // ID { Width = new GridLength(12, GridUnitType.Pixel) }); ListItem.ColumnDefinitions.Add(new ColumnDefinition() // icon { Width = new GridLength(14, GridUnitType.Pixel) }); ListItem.ColumnDefinitions.Add(new ColumnDefinition() // line { Width = new GridLength(65, GridUnitType.Pixel) }); ListItem.ColumnDefinitions.Add(new ColumnDefinition()); // description ListItem.ColumnDefinitions.Add(new ColumnDefinition() // file { Width = new GridLength(1, GridUnitType.Auto), MinWidth = 50 }); TextBlock IDColumn = new TextBlock() { Text = ID.ToString(CultureInfo.InvariantCulture.NumberFormat) }; TextBlock lineColumn = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Center, Text = Properties.Resources.Line + ": " + line }; TextBlock descriptionColumn = new TextBlock() { Text = description }; TextBlock fileColumn = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Right, Text = file }; IDColumn.SetValue(Grid.ColumnProperty, 0); ErrorIcon.SetValue(Grid.ColumnProperty, 1); lineColumn.SetValue(Grid.ColumnProperty, 2); descriptionColumn.SetValue(Grid.ColumnProperty, 3); fileColumn.SetValue(Grid.ColumnProperty, 4); ListItem.Children.Add(IDColumn); ListItem.Children.Add(ErrorIcon); ListItem.Children.Add(lineColumn); ListItem.Children.Add(descriptionColumn); ListItem.Children.Add(fileColumn); ListBoxItem Item = new ListBoxItem() { Uid = file + "|" + line, Content = ListItem, HorizontalContentAlignment = HorizontalAlignment.Stretch }; EventsManager.ListBoxItem ListBoxEvents = new EventsManager.ListBoxItem(); Item.MouseDoubleClick += ListBoxEvents.MouseDoubleClick; return(Item); }
private void listBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape || e.KeyValue == 115)//YellowBtn { e.Handled = true; this.Close(); return; } if (e.KeyValue == 18 && Program.Default.EnableChgQty == 1)//RedBtn { if (rows != null && listBox1.SelectedIndex > 0 && listBox1.SelectedIndex < listBox1.Items.Count) { OpenNETCF.Windows.Forms.ListItem li = listBox1.Items[listBox1.SelectedIndex]; ListBoxItem lbi = new ListBoxItem(li.Text); FChangeQtyForm.MForm.Barcode = lbi.Barcode.ToString(); FChangeQtyForm.MForm.ProductName = lbi.ProductName.ToString(); FChangeQtyForm.MForm.FactQuantity = lbi.FactQuantity; FChangeQtyForm.MForm.PlanQuantity = lbi.PlanQuantity; DialogResult dr = FChangeQtyForm.MForm.ShowDialog(); if (dr == DialogResult.OK) { int diff = FChangeQtyForm.MForm.NewQuantity - FChangeQtyForm.MForm.FactQuantity; //ScannedProductsDataSet.ScannedBarcodesRow scannedRow = null; List<ScannedProductsDataSet.ScannedBarcodesRow > scannedList = new List<ScannedProductsDataSet.ScannedBarcodesRow>(); for (int i=0;i<rows.Length;i++) { if (rows[i].Barcode == lbi.Barcode) scannedList.Add(rows[i]); //break; } if (FChangeQtyForm.MForm.NewQuantity >= 0) { ProductsDataSet.ProductsTblRow r = products[lbi.Barcode]; ProductsDataSet.DocsTblRow docRow = null; foreach (ProductsDataSet.DocsTblRow d in docsRows) { if (d.NavCode == r.NavCode) { docRow = d; break; } } if (diff < 0) { foreach (ScannedProductsDataSet.ScannedBarcodesRow s in scannedList) { if (s.FactQuantity >= Math.Abs(diff)) { ActionsClass.Action.ChangeQtyPosition(docRow, s, diff); //s.FactQuantity += diff; break; } else { int sgn = Math.Sign(diff); diff = (Math.Abs(diff) - s.FactQuantity) * sgn; ActionsClass.Action.ChangeQtyPosition(docRow, s, sgn * s.FactQuantity); } } } else //diff >0 { ScannedProductsDataSet.ScannedBarcodesRow s = null; if (scannedList.Count > 0) s = scannedList[0]; else s = ActionsClass.Action.AddScannedRow( lbi.Barcode, _docType, _docId, diff, 0); ActionsClass.Action.ChangeQtyPosition(docRow, s, diff); } //ActionsClass.Action.ChangeQtyPosition(scannedList, diff); RefreshData(); } } } e.Handled = true; return; } }
//-------------------Imprimer les relevés des élèves sélectionnés------------------- public void imprimerBulletinAnnuel(int annee, string classe) { //on vérifit si tous les champs ont été corectement rempli if ((cmbClasse.Text != null && txtAnnee.Text != null) && (cmbClasse.Text != "" && txtAnnee.Text != "")) { //--------------------- Action pour une classe particulière //Configure the ProgressBar ProgressBar1.Minimum = 0; ProgressBar1.Maximum = 1; ProgressBar1.Value = 0; //Stores the value of the ProgressBar double value = 0; //Create a new instance of our ProgressBar Delegate that points // to the ProgressBar's SetValue method. UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar1.SetValue); //on affiche la barre de progression ProgressBar1.Visibility = System.Windows.Visibility.Visible; // ***********calcul des moyennes //remplissage de la table "moyennes" for (int i = 0; i < listBoxEleve.Items.Count; i++) { ListBoxItem item = listBoxEleve.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem; if (item != null) { CheckBox myCheckBox = FindVisualChild <CheckBox>(item) as CheckBox; if (myCheckBox.IsChecked.Value) { // bulletinsAnnuelBL.genererBulletinAnnuelDunEleve((listBoxEleve.Items[i] as ElementListeEleve).matricule, annee, classe); //MessageBox.Show("Matricule = " + (listBoxEleve.Items[i] as ElementListeEleve).matricule + " || Nom= " + (listBoxEleve.Items[i] as ElementListeEleve).nom + "=" + classe + "=" + annee.ToString()); string matricule = (listBoxEleve.Items[i] as ElementListeEleve).matricule; EleveBE eleve = new EleveBE(); eleve.matricule = matricule; eleve = bulletinsAnnuelBL.rechercherEleve(eleve); bulletinsAnnuelBL.genererBulletinAnnuelDunEleve(matricule, Convert.ToInt16(txtAnnee.Text), classe, eleve.photo); value += 1; Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value }); } } } MessageBox.Show("Opération Terminée !! "); //on cache la barre de progression ProgressBar1.Visibility = System.Windows.Visibility.Hidden; } else { MessageBox.Show("Tous les champs doivent êtres remplis !! "); } }
private void UpdateComboBoxs() { categoryCmbBox.ItemsSource = null; categoryCmbBox.Items.Clear(); using (var db = new Model.BudgetModel()) { var categories = db.Categories.ToList(); List<ListBoxItem> items = new List<ListBoxItem>(); foreach (var category in categories) { var item = new ListBoxItem(category.Id, category.Name); items.Add(item); } categoryCmbBox.ItemsSource = items; } unitOfMeasureCmbBox.ItemsSource = null; unitOfMeasureCmbBox.Items.Clear(); using (var db = new Model.BudgetModel()) { var unitOFMeasures = db.UnitOfMeasures.ToList(); List <ComplexListBoxItem>items = new List<ComplexListBoxItem>(); foreach (var unitOFMeasure in unitOFMeasures) { var item = new ComplexListBoxItem(unitOFMeasure.Id, unitOFMeasure.Name, unitOFMeasure.ShortName); items.Add(item); } unitOfMeasureCmbBox.ItemsSource = items; } }
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem); SelectDataTemplate(lbi.Content); }
void Binding_SelectedItemChanged(Control sender, ListBoxItem value) { SourcePropertyChanged(sender, null); }
private void AddQuery(object sender, RoutedEventArgs args) { if (_query == QueryType.Film) { var title = FilmTitleInput.Text; var language = LanguageSelect.SelectedIndex; if (!int.TryParse(FilmLengthFrom.Text, out var lenFrom)) { lenFrom = 0; } if (!int.TryParse(FilmLengthTo.Text, out var lenTo)) { lenTo = -1; } var category = CategorySelect.SelectedIndex; var rating = RatingSelect.SelectedIndex; var query = ""; if (title.Length > 0) { query += $"film.title LIKE '%{title}%'"; } if (lenTo != -1) { if (query.Length > 0) { query += " AND "; } query += $"film.length BETWEEN {lenFrom} AND {lenTo}"; } if (language != -1) { if (query.Length > 0) { query += " AND "; } query += $"film.language_id = {language + 1}"; } if (rating != -1) { if (query.Length > 0) { query += " AND "; } query += $"film.rating = \'{((TextBlock) RatingSelect.SelectedItem).Text}\'"; } if (category != -1) { if (query.Length > 0) { query += " AND "; } query += $"category.category_id = {category + 1}"; } var films = _database.GetFilmsWithFilter(query); Output.Items.Clear(); foreach (var film in films) { var item = new ListBoxItem { Content = film }; item.Selected += SelectItemFromOutput; Output.Items.Add(item); } } else if (_query == QueryType.Actor) { var name = ActorFirstNameInput.Text; var surname = ActorLastNameInput.Text; var query = ""; if (name.Length > 0) { query += $"actor.first_name LIKE '%{name}%'"; } if (surname.Length > 0) { if (query.Length > 0) { query += " AND "; } query += $"actor.last_name LIKE '%{surname}%'"; } var actors = _database.GetActorsWithFilter(query); Output.Items.Clear(); foreach (var actor in actors) { var item = new ListBoxItem() { Content = actor }; item.Selected += SelectItemFromOutput; Output.Items.Add(item); } } else if (_query == QueryType.Language) { int index = LanguagesList.SelectedIndex; var query = ""; if (index != -1) { query += $"film.language_id = {index + 1}"; } var films = _database.GetFilmsWithFilter(query); Output.Items.Clear(); foreach (var film in films) { var item = new ListBoxItem() { Content = film }; item.Selected += SelectItemFromOutput; Output.Items.Add(item); } } }
void FillList(string[] fileNames) { Sources = new Dictionary<string, string>(); foreach (var fileName in fileNames) { var lbItem = new ListBoxItem(fileName, Path.GetFileName(fileName)); Sources[lbItem.Key] = File.ReadAllText(lbItem.Key); lbInputFiles.Items.Add(lbItem); } }
private void ColumnTypeChanged(ListBoxItem item, System.Type newType) { DataGridViewColumn dataGridViewColumn = item.DataGridViewColumn; DataGridViewColumn destColumn = Activator.CreateInstance(newType) as DataGridViewColumn; ITypeResolutionService tr = this.liveDataGridView.Site.GetService(iTypeResolutionServiceType) as ITypeResolutionService; ComponentDesigner componentDesignerForType = DataGridViewAddColumnDialog.GetComponentDesignerForType(tr, newType); CopyDataGridViewColumnProperties(dataGridViewColumn, destColumn); CopyDataGridViewColumnState(dataGridViewColumn, destColumn); this.columnCollectionChanging = true; int selectedIndex = this.selectedColumns.SelectedIndex; this.selectedColumns.Focus(); base.ActiveControl = this.selectedColumns; try { ListBoxItem selectedItem = (ListBoxItem) this.selectedColumns.SelectedItem; bool flag = (bool) this.userAddedColumns[selectedItem.DataGridViewColumn]; string str = string.Empty; if (this.columnsNames.Contains(selectedItem.DataGridViewColumn)) { str = (string) this.columnsNames[selectedItem.DataGridViewColumn]; this.columnsNames.Remove(selectedItem.DataGridViewColumn); } if (this.userAddedColumns.Contains(selectedItem.DataGridViewColumn)) { this.userAddedColumns.Remove(selectedItem.DataGridViewColumn); } if (selectedItem.DataGridViewColumnDesigner != null) { TypeDescriptor.RemoveAssociation(selectedItem.DataGridViewColumn, selectedItem.DataGridViewColumnDesigner); } this.selectedColumns.Items.RemoveAt(selectedIndex); this.selectedColumns.Items.Insert(selectedIndex, new ListBoxItem(destColumn, this, componentDesignerForType)); this.columnsPrivateCopy.RemoveAt(selectedIndex); destColumn.DisplayIndex = -1; this.columnsPrivateCopy.Insert(selectedIndex, destColumn); if (!string.IsNullOrEmpty(str)) { this.columnsNames[destColumn] = str; } this.userAddedColumns[destColumn] = flag; this.FixColumnCollectionDisplayIndices(); this.selectedColumns.SelectedIndex = selectedIndex; this.propertyGrid1.SelectedObject = this.selectedColumns.SelectedItem; } finally { this.columnCollectionChanging = false; } }
public void AddEnemyToList(string enemyName) { string nameOfEnemy = ""; string levelOfEnemy = ""; string enemyPicturePath = ""; switch (enemyName.ToLower()) { case "warrior": nameOfEnemy = "Warrior"; levelOfEnemy = "{LVL 34}"; enemyPicturePath = "warrior-icon.png"; break; case "warrior-black": nameOfEnemy = "Black Knight"; levelOfEnemy = "{LVL 55}"; enemyPicturePath = "warrior-black.png"; break; case "bandit": nameOfEnemy = "Bandit"; levelOfEnemy = "{LVL 15}"; enemyPicturePath = "Bandit.png"; break; case "mudcrawler": nameOfEnemy = "MudCrawler"; levelOfEnemy = "{LVL 9}"; enemyPicturePath = "MudCrawler.png"; break; case "scuffedspider": nameOfEnemy = "Spider"; levelOfEnemy = "{LVL 3}"; enemyPicturePath = "scuffedspider.png"; break; case "wizard": nameOfEnemy = "Wizard"; levelOfEnemy = "{LVL 63}"; enemyPicturePath = "mage-icon.png"; break; default: break; } ListBoxItem item = new ListBoxItem(); StackPanel new_item = new StackPanel(); new_item.Orientation = Orientation.Horizontal; Image img = new Image(); BitmapImage bitImage = new BitmapImage(); bitImage.BeginInit(); bitImage.UriSource = new Uri("/Images/" + enemyPicturePath, UriKind.Relative); bitImage.EndInit(); img.Source = bitImage; EnemyPicture.Source = bitImage; img.Width = 32; img.Height = 32; TextBlock entityLevel = new TextBlock(); entityLevel.Text = levelOfEnemy; entityLevel.FontWeight = FontWeights.Bold; entityLevel.FontSize = 16; entityLevel.VerticalAlignment = VerticalAlignment.Center; TextBlock entityName = new TextBlock(); entityName.Text = nameOfEnemy; entityName.FontSize = 15.5; entityName.FontWeight = FontWeights.Bold; entityName.VerticalAlignment = VerticalAlignment.Center; new_item.Children.Add(img); new_item.Children.Add(entityLevel); new_item.Children.Add(entityName); item.Content = new_item; item.Background = Brushes.Red; item.BorderBrush = Brushes.Black; item.BorderThickness = new Thickness(3, 3, 3, 0); ActiveEnemies.Items.Add(item); BitmapImage playerBitImage = new BitmapImage(); playerBitImage.BeginInit(); playerBitImage.UriSource = new Uri("/Images/warrior-icon.png", UriKind.Relative); playerBitImage.EndInit(); PlayerPicture.Source = playerBitImage; }
internal static void SetLastSelected(ListBox i, ListBoxItem value) => i.SetValue(LastSelectedProperty, value);
private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_15_Items() { System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>(); // e_16 element ListBoxItem e_16 = new ListBoxItem(); e_16.Name = "e_16"; e_16.Content = "Selection 1"; items.Add(e_16); // e_17 element ListBoxItem e_17 = new ListBoxItem(); e_17.Name = "e_17"; e_17.Content = "Selection 2"; items.Add(e_17); // e_18 element ListBoxItem e_18 = new ListBoxItem(); e_18.Name = "e_18"; e_18.Content = "Selection 3"; items.Add(e_18); // e_19 element ListBoxItem e_19 = new ListBoxItem(); e_19.Name = "e_19"; e_19.Content = "Selection 4"; items.Add(e_19); // e_20 element ListBoxItem e_20 = new ListBoxItem(); e_20.Name = "e_20"; e_20.Content = "Selection 5"; items.Add(e_20); // e_21 element ListBoxItem e_21 = new ListBoxItem(); e_21.Name = "e_21"; e_21.Content = "Selection 6"; items.Add(e_21); return items; }
private void BtnHandIn_Click(object sender, RoutedEventArgs e) { //STOP THE STOPWATCH stopWatch.Stop(); int index = 0; List <string> userOrder = new List <string>(); //GET ALL THE VALUES FROM THE USERS SUBMITTED ORDER AND STORE THEM IN THE LIST ABOVE foreach (var item in LstBooks.Items) { Grid grid = LstBooks.Items[index] as Grid; index++; foreach (var listBoxItem in grid.Children) { if (listBoxItem is ListBoxItem) { ListBoxItem currentListBoxItem = listBoxItem as ListBoxItem; userOrder.Add(currentListBoxItem.Content.ToString()); } } } int mark = 0; txtResultDialogUser.Text = ""; txtResultDialogUser.Inlines.Add("Submitted Order\n\n"); txtResultCorrect.Inlines.Add("Correct Order\n\n"); //CALCULATE HOW MANY MARKS THE USER SCORED for (int i = 0; i < books.Count; i++) { //ADD THE CORRECT ANSWER txtResultCorrect.Inlines.Add(new Run(books[i] + "\n") { Foreground = new SolidColorBrush(Colors.Green) }); //CHECK IF THE USER'S ORDER EQUALS THE CORRECT ORDER if (userOrder[i].Equals(books[i])) { //DISPLAY THE ANSWER IN GREEN txtResultDialogUser.Inlines.Add(new Run(userOrder[i] + "\n") { Foreground = new SolidColorBrush(Colors.Green) }); mark++; } else { //DISPLAY THE ANSWER IN RED txtResultDialogUser.Inlines.Add(new Run(userOrder[i] + "\n") { Foreground = new SolidColorBrush(Colors.Red) }); } } //CONVERT TIME double time = stopWatch.ElapsedMilliseconds / 1000.0; txtResultScore.Inlines.Add("You have scored " + mark + " out of 10\n" + "Your final time was " + stopWatch.Elapsed.Seconds + "s " + stopWatch.Elapsed.Milliseconds + "ms"); //IF THE USER SCORED 3 OR MORE ANSWERS CORRECT, //TAKE THE TIME INTO CONSIDERATION (TO PREVENT ABUSE) if (mark >= 3) { User.LowestTime = time; } else { txtResultScore.Inlines.Add(new Run("\n*Time will not be counted as " + "you scored less than 3/10") { Foreground = Brushes.Red }); } //SET THE HIGHEST SCORE TO THE MARK //(WILL ONLY BE SET IF THE SCORE IS GREATER AS DEFINED THE USER CLASS LOGIC) if (mark > 0) { User.HighestScore = mark; } //UPDATE THE TOTAL CORRECT ANSWERS User.ReplaceBooksCorrectCount += mark; //OPEN THE RESULT DIALOG ResultDialog.IsOpen = true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { mainWindow = (MainWindow)this.Owner; this.Title += "you are " + mainWindow.username; currentConversations = new Dictionary<string, WindowDialog>(); var chatMessages = mainWindow.proxy.ReceiveFromChat(new ChatMessage(null, null)); foreach (var message in chatMessages) { listBoxChat.Items.Add(message.From + ": " + message.Text); } var onlineMembers = mainWindow.proxy.GetOnlineMembers(); foreach (var member in onlineMembers) { var listBoxItem = new ListBoxItem(); listBoxItem.Content = member; listBoxItem.MouseDoubleClick += this.listBoxItem_MouseDoubleClick; listBoxContactlist.Items.Add(listBoxItem); } ControlTimers(); }
private void cmdAdd_Click(object sender, RoutedEventArgs e) { try { Hashtable objMapping = new Hashtable(); foreach (UIElement item in stkMappingLabel.Children) { if (item.GetType() == typeof(ucComboxBox)) { ucComboxBox objTemp = item as ucComboxBox; if (objTemp != null) { if (objTemp.List.SelectedItems.Count > 0) { QuickSort <string> objQuickSort = new QuickSort <string>(Converter.ToStringArray(objTemp.List.SelectedItems)); objQuickSort.Sort(); objMapping.Add(objTemp.Text.Text, objQuickSort.Output); } } } } Pages.ProgressBar progressWindow = new Pages.ProgressBar( new AddItem( lstResults.SelectedItems, objMapping, _intParsingBase, CurrentEntityName, txtParseFrom.Text, Path, MediaName, MediaType, GetImage, ParseNfo, CleanTitle, UseSub, PatternType)); progressWindow.ShowDialog(); MediaServices.UpdateInfo(MediaName, Path, MediaType, ParseNfo, CurrentEntityName, CleanTitle, PatternType, GetImage, UseSub); string message = progressWindow.AddedItem + " new " + CurrentEntityName + " added to your collections"; if (progressWindow.NotAddedItem > 0) { message = message + Environment.NewLine + progressWindow.NotAddedItem + " were already present"; } IServices service = Util.GetService(CurrentEntityName); IList items = service.GetByMedia(MediaName); progressWindow = new Pages.ProgressBar(new SyncItems(items)); progressWindow.ShowDialog(); SyncPage syncPage = new SyncPage(); syncPage.messageText.Text = message; if (progressWindow.RemovedItems.Count > 0) { foreach (IMyCollectionsData item in progressWindow.RemovedItems) { ListBoxItem objItem = new ListBoxItem { IsSelected = true, Content = System.IO.Path.Combine(item.FilePath, item.FileName) }; objItem.DataContext = item; syncPage.lstResults.Items.Add(objItem); } } else { syncPage.lstResults.Visibility = Visibility.Collapsed; syncPage.lblSync.Visibility = Visibility.Collapsed; syncPage.Cancel.Visibility = Visibility.Hidden; syncPage.rowList.Height = new GridLength(0); syncPage.rowSyncMsg.Height = new GridLength(0); syncPage.Height = 135; syncPage.imgOk.ToolTip = "Ok"; } syncPage.ShowDialog(); RoutedEventArgs args = new RoutedEventArgs(CmdAddClickEvent); RaiseEvent(args); } catch (Exception ex) { CatchException(ex); } }
public void SetAddListBox(Object[] strArray, TreeNodeCollection collection) { if (strArray != null && strArray.Length > 0) { foreach (string str in strArray) { if (str.Length > 0) { string[] array = str.Split('('); string[] array1 = array[1].Split(')'); string userId = array1[0]; UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(collection, userId); if (userObj == null || userObj.Id == "") continue; ListBoxItem item = new ListBoxItem(userObj); AddListBox.Items.Add(item); } } } }
/// <summary> /// 绑定表单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BindFrm(object sender, FF.GenerWorkNodeCompletedEventArgs e) { #region 初始化数据. this.canvasMain.Children.Clear(); this.FrmDS = new DataSet(); try { if (e.Result.Length < 200) { throw new Exception(e.Result); } this.FrmDS.FromXml(e.Result); loadingWindow.DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Err", MessageBoxButton.OK); loadingWindow.DialogResult = true; return; } #endregion 初始化数据. this.InitToolbar(); string table = ""; try { this.dtMapAttrs = this.FrmDS.Tables["Sys_MapAttr"]; foreach (DataTable dt in this.FrmDS.Tables) { Glo.TempVal = dt.TableName; table = dt.TableName; switch (dt.TableName) { case "Sys_MapAttr": foreach (DataRow dr in dt.Rows) { if (dr["UIVisible"] == "0") { continue; } if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } string myPk = dr["MyPK"]; string FK_MapData = dr["FK_MapData"]; string keyOfEn = dr["KeyOfEn"]; string name = dr["Name"]; string defVal = dr["DefVal"]; string UIContralType = dr["UIContralType"]; string MyDataType = dr["MyDataType"]; string lgType = dr["LGType"]; bool isEnable = false; if (dr["UIIsEnable"].ToString() == "1") { isEnable = true; } double X = double.Parse(dr["X"]); double Y = double.Parse(dr["Y"]); if (X == 0) { X = 100; } if (Y == 0) { Y = 100; } string UIBindKey = dr["UIBindKey"]; switch (UIContralType) { case CtrlType.TextBox: TBType tp = TBType.String; switch (MyDataType) { case DataType.AppInt: tp = TBType.Int; break; case DataType.AppFloat: case DataType.AppDouble: tp = TBType.Float; break; case DataType.AppMoney: tp = TBType.Money; break; case DataType.AppString: tp = TBType.String; break; case DataType.AppDateTime: tp = TBType.DateTime; break; case DataType.AppDate: tp = TBType.Date; break; default: break; } BPTextBox tb = new BPTextBox(tp); tb.NameOfReal = keyOfEn; tb.Name = keyOfEn; tb.SetValue(Canvas.LeftProperty, X); tb.SetValue(Canvas.TopProperty, Y); tb.Text = this.GetValByKey(keyOfEn); //给控件赋值. tb.Width = double.Parse(dr["UIWidth"]); if (tb.Height > 24) { tb.TextWrapping = TextWrapping.Wrap; } tb.Height = double.Parse(dr["UIHeight"]); if (isEnable) { tb.IsEnabled = true; } else { tb.IsEnabled = false; } this.canvasMain.Children.Add(tb); break; case CtrlType.DDL: BPDDL ddl = new BPDDL(); ddl.Name = keyOfEn; ddl.HisLGType = lgType; ddl.Width = double.Parse(dr["UIWidth"]); ddl.UIBindKey = UIBindKey; ddl.HisLGType = lgType; if (lgType == LGType.Enum) { DataTable dtEnum = this.FrmDS.Tables["Sys_Enum"]; foreach (DataRow drEnum in dtEnum.Rows) { if (drEnum["EnumKey"].ToString() != UIBindKey) { continue; } ListBoxItem li = new ListBoxItem(); li.Tag = drEnum["IntKey"].ToString(); li.Content = drEnum["Lab"].ToString(); ddl.Items.Add(li); } if (ddl.Items.Count == 0) { throw new Exception("@没有从Sys_Enum中找到编号为(" + UIBindKey + ")的枚举值。"); } } else { ddl.BindEns(UIBindKey); } ddl.SetValue(Canvas.LeftProperty, X); ddl.SetValue(Canvas.TopProperty, Y); //给控件赋值. ddl.SetSelectVal(this.GetValByKey(keyOfEn)); this.canvasMain.Children.Add(ddl); break; case CtrlType.CheckBox: BPCheckBox cb = new BPCheckBox(); cb.Name = keyOfEn; cb.Content = name; Label cbLab = new Label(); cbLab.Name = "CBLab" + cb.Name; cbLab.Content = name; cbLab.Tag = keyOfEn; cb.Content = cbLab; cb.SetValue(Canvas.LeftProperty, X); cb.SetValue(Canvas.TopProperty, Y); if (this.GetValByKey(keyOfEn) == "1") { cb.IsChecked = true; } else { cb.IsChecked = false; } this.canvasMain.Children.Add(cb); break; case CtrlType.RB: break; default: break; } } continue; case "Sys_FrmRB": DataTable dtRB = this.FrmDS.Tables["Sys_FrmRB"]; foreach (DataRow dr in dtRB.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPRadioBtn btn = new BPRadioBtn(); btn.Name = dr["MyPK"]; btn.GroupName = dr["KeyOfEn"]; btn.Content = dr["Lab"]; btn.UIBindKey = dr["EnumKey"]; btn.Tag = dr["IntKey"]; btn.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString())); btn.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString())); this.canvasMain.Children.Add(btn); } continue; case "Sys_MapDtl": foreach (DataRow dr in dt.Rows) { BPDtl dtl = new BPDtl(dr["No"], this.FrmDS); dtl.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); dtl.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); dtl.Width = double.Parse(dr["W"]); dtl.Height = double.Parse(dr["H"]); this.canvasMain.Children.Add(dtl); } continue; case "Sys_FrmEle": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPEle img = new BPEle(); img.Name = dr["MyPK"].ToString(); img.EleType = dr["EleType"].ToString(); img.EleName = dr["EleName"].ToString(); img.EleID = dr["EleID"].ToString(); img.Cursor = Cursors.Hand; img.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString())); img.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString())); img.Width = double.Parse(dr["W"].ToString()); img.Height = double.Parse(dr["H"].ToString()); this.canvasMain.Children.Add(img); } continue; case "Sys_MapData": if (dt.Rows.Count == 0) { continue; } foreach (DataRow dr in dt.Rows) { if (dr["No"] != Glo.FK_MapData) { continue; } Glo.HisMapData = new MapData(); Glo.HisMapData.FrmH = double.Parse(dt.Rows[0]["FrmH"]); Glo.HisMapData.FrmW = double.Parse(dt.Rows[0]["FrmW"]); Glo.HisMapData.No = (string)dt.Rows[0]["No"]; Glo.HisMapData.Name = (string)dt.Rows[0]["Name"]; // Glo.IsDtlFrm = false; this.canvasMain.Width = Glo.HisMapData.FrmW; this.canvasMain.Height = Glo.HisMapData.FrmH; this.scrollViewer1.Width = Glo.HisMapData.FrmW; } break; case "Sys_FrmBtn": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPBtn btn = new BPBtn(); btn.Name = dr["MyPK"]; btn.Content = dr["Text"].Replace(" ", " "); btn.HisBtnType = (BtnType)int.Parse(dr["BtnType"]); btn.HisEventType = (EventType)int.Parse(dr["EventType"]); if (dr["EventContext"] != null) { btn.EventContext = dr["EventContext"].Replace("~", "'"); } if (dr["MsgErr"] != null) { btn.MsgErr = dr["MsgErr"].Replace("~", "'"); } if (dr["MsgOK"] != null) { btn.MsgOK = dr["MsgOK"].Replace("~", "'"); } btn.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); btn.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); this.canvasMain.Children.Add(btn); } continue; case "Sys_FrmLine": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } string color = dr["BorderColor"]; if (string.IsNullOrEmpty(color)) { color = "Black"; } BPLine myline = new BPLine(dr["MyPK"], color, double.Parse(dr["BorderWidth"]), double.Parse(dr["X1"]), double.Parse(dr["Y1"]), double.Parse(dr["X2"]), double.Parse(dr["Y2"])); myline.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); myline.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); this.canvasMain.Children.Add(myline); } continue; case "Sys_FrmLab": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPLabel lab = new BPLabel(); lab.Name = dr["MyPK"]; string text = dr["Text"].Replace(" ", " "); text = text.Replace("@", "\n"); lab.Content = text; lab.FontSize = double.Parse(dr["FontSize"]); lab.Cursor = Cursors.Hand; lab.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); lab.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); if (dr["IsBold"] == "1") { lab.FontWeight = FontWeights.Bold; } else { lab.FontWeight = FontWeights.Normal; } string color = dr["FontColor"]; lab.Foreground = new SolidColorBrush(Glo.ToColor(color)); this.canvasMain.Children.Add(lab); } continue; case "Sys_FrmLink": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPLink link = new BPLink(); link.Name = dr["MyPK"]; link.Content = dr["Text"]; link.URL = dr["URL"]; link.WinTarget = dr["Target"]; link.FontSize = double.Parse(dr["FontSize"]); link.Cursor = Cursors.Hand; link.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); link.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); string color = dr["FontColor"]; if (string.IsNullOrEmpty(color)) { color = "Black"; } link.Foreground = new SolidColorBrush(Glo.ToColor(color)); this.canvasMain.Children.Add(link); } continue; case "Sys_FrmImg": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPImg img = new BPImg(); img.Name = dr["MyPK"]; img.Cursor = Cursors.Hand; img.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString())); img.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString())); img.Width = double.Parse(dr["W"].ToString()); img.Height = double.Parse(dr["H"].ToString()); this.canvasMain.Children.Add(img); } continue; case "Sys_FrmImgAth": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPImgAth ath = new BPImgAth(); ath.Name = dr["MyPK"]; ath.Cursor = Cursors.Hand; ath.SetValue(Canvas.LeftProperty, double.Parse(dr["X"].ToString())); ath.SetValue(Canvas.TopProperty, double.Parse(dr["Y"].ToString())); ath.Height = double.Parse(dr["H"].ToString()); ath.Width = double.Parse(dr["W"].ToString()); this.canvasMain.Children.Add(ath); } continue; case "Sys_MapM2M": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } BPM2M m2m = new BPM2M(dr["NoOfObj"]); m2m.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); m2m.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); m2m.Width = double.Parse(dr["W"]); m2m.Height = double.Parse(dr["H"]); this.canvasMain.Children.Add(m2m); } continue; case "Sys_FrmAttachment": foreach (DataRow dr in dt.Rows) { if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } string uploadTypeInt = dr["UploadType"].ToString(); if (uploadTypeInt == null) { uploadTypeInt = "0"; } AttachmentUploadType uploadType = (AttachmentUploadType)int.Parse(uploadTypeInt); if (uploadType == AttachmentUploadType.Single) { BPAttachment ath = new BPAttachment(dr["NoOfObj"], dr["Name"], dr["Exts"], double.Parse(dr["W"]), dr["SaveTo"].ToString()); ath.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); ath.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); ath.Label = dr["Name"] as string; ath.Exts = dr["Exts"] as string; ath.SaveTo = dr["SaveTo"] as string; ath.X = double.Parse(dr["X"]); ath.Y = double.Parse(dr["Y"]); if (dr["IsUpload"] == "1") { ath.IsUpload = true; } else { ath.IsUpload = false; } if (dr["IsDelete"] == "1") { ath.IsDelete = true; } else { ath.IsDelete = false; } if (dr["IsDownload"] == "1") { ath.IsDownload = true; } else { ath.IsDownload = false; } this.canvasMain.Children.Add(ath); continue; } if (uploadType == AttachmentUploadType.Multi) { BPAttachmentM athM = new BPAttachmentM(); athM.SetValue(Canvas.LeftProperty, double.Parse(dr["X"])); athM.SetValue(Canvas.TopProperty, double.Parse(dr["Y"])); athM.Name = dr["NoOfObj"]; athM.Width = double.Parse(dr["W"]); athM.Height = double.Parse(dr["H"]); athM.X = double.Parse(dr["X"]); athM.Y = double.Parse(dr["Y"]); athM.SaveTo = dr["SaveTo"]; athM.Text = dr["Name"]; athM.Label = dr["Name"]; this.canvasMain.Children.Add(athM); continue; } } continue; default: break; } } loadingWindow.DialogResult = true; } catch (Exception ex) { MessageBox.Show("err:" + table, ex.Message + " " + ex.StackTrace, MessageBoxButton.OK); } this.SetGridLines(); }
private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_11_Items() { System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>(); // e_12 element ListBoxItem e_12 = new ListBoxItem(); e_12.Name = "e_12"; e_12.Content = "Selection 1"; items.Add(e_12); // e_13 element ListBoxItem e_13 = new ListBoxItem(); e_13.Name = "e_13"; e_13.Content = "Selection 2"; items.Add(e_13); // e_14 element ListBoxItem e_14 = new ListBoxItem(); e_14.Name = "e_14"; e_14.Content = "Selection 3"; items.Add(e_14); // e_15 element ListBoxItem e_15 = new ListBoxItem(); e_15.Name = "e_15"; e_15.Content = "Selection 4"; items.Add(e_15); return items; }
/// <summary> /// 获取页面的数据 /// </summary> /// <returns></returns> public DataSet GenerFrmDataSet() { #region 创建数据表. DataTable dtMain = new DataTable(); dtMain.TableName = "Main"; dtMain.Columns.Add(new DataColumn("KeyOfEn", typeof(string))); dtMain.Columns.Add(new DataColumn("Val", typeof(string))); #endregion 创建数据表. #region 获取主表的值. foreach (DataRow dr in dtMapAttrs.Rows) { if (dr["UIVisible"] == "0") { continue; } if (dr["FK_MapData"] != Glo.FK_MapData) { continue; } DataRow drNew = dtMain.NewRow(); string keyOfEn = dr["KeyOfEn"]; UIElement ctl = this.canvasMain.FindName(keyOfEn) as UIElement; BPTextBox tb = ctl as BPTextBox; if (tb != null) { drNew[0] = keyOfEn; drNew[1] = tb.Text; dtMain.Rows.Add(drNew); continue; } BPDDL ddl = ctl as BPDDL; if (ddl != null) { ListBoxItem li = ddl.SelectedItem as ListBoxItem; if (li == null) { throw new Exception("@没有找到选择的item."); } drNew[0] = keyOfEn; drNew[1] = li.Tag.ToString(); dtMain.Rows.Add(drNew); continue; } BPCheckBox cb = ctl as BPCheckBox; if (cb != null) { drNew[0] = keyOfEn; if (cb.IsChecked == true) { drNew[1] = "1"; } else { drNew[1] = "0"; } dtMain.Rows.Add(drNew); continue; } } #endregion 获取从表的值. DataSet dsNodeData = new DataSet(); dsNodeData.Tables.Add(dtMain); #warning 这里仅仅处理了主表的保存,多从表,多m2m,附件,图片。都没有处理。 return(dsNodeData); }
private void OrderForm_Load(object sender, System.EventArgs e) { this.lbDoctorName.Text = this.m_infoOrder.Doctor.Name; this.lbHospital.Text = this.m_infoOrder.Doctor.HospitalName + " " + this.m_infoOrder.Doctor.Department; this.lbUserName.Text = this.m_infoOrder.User.Name; this.lbPhone.Text = this.m_infoOrder.User.PhoneNumber; this.lbCardId.Text = this.m_infoOrder.User.CardId; this.lbVisitTime.Text = this.m_infoOrder.VisitDate; this.lbFee.Text = "<font color=\"OrangeRed\">" + this.m_infoOrder.Fee + "</font>"; foreach (VisitTime current in this.m_infoOrder.VisitTimes) { ListBoxItem listBoxItem = new ListBoxItem(); listBoxItem.Text = string.Format("序号:{0} 时间:{1}", current.Index, current.Time); listBoxItem.Tag = current; this.lbxRegTime.Items.Add(listBoxItem); } }
/// <summary> /// First determine whether the drag data is supported. /// Second determine what type the container is. /// Third determine what operation to do (only copy is supported). /// And finally handle the actual drop when <code>bDrop</code> is true. /// </summary> /// <param name="bDrop">True to perform an actual drop, otherwise just return e.Effects</param> /// <param name="sender">DragDrop event <code>sender</code></param> /// <param name="e">DragDrop event arguments</param> private void DragOverOrDrop(bool bDrop, object sender, DragEventArgs e) { string[] files = this.GetData(e) as string[]; if (files != null) { e.Effects = DragDropEffects.None; ItemsControl dstItemsControl = sender as ItemsControl; // 'sender' is used when dropped in an empty area if (dstItemsControl != null) { foreach (string file in files) { if (sender is TabControl) { if (bDrop) { TabItem item = new TabItem(); item.Header = System.IO.Path.GetFileName(file); item.ToolTip = file; dstItemsControl.Items.Insert(0, item); item.IsSelected = true; } e.Effects = DragDropEffects.Copy; } else if (sender is ListBox) { if (bDrop) { ListBoxItem dstItem = Utilities.FindParentControlIncludingMe <ListBoxItem>(e.Source as DependencyObject); ListBoxItem item = new ListBoxItem(); item.Content = System.IO.Path.GetFileName(file); item.ToolTip = file; if (dstItem == null) { dstItemsControl.Items.Add(item); // ... if dropped on an empty area } else { dstItemsControl.Items.Insert(dstItemsControl.Items.IndexOf(dstItem), item); } item.IsSelected = true; item.BringIntoView(); } e.Effects = DragDropEffects.Copy; } else if (sender is TreeView) { if (bDrop) { if (e.Source is ItemsControl) { dstItemsControl = e.Source as ItemsControl; // Dropped on a TreeViewItem } TreeViewItem item = new TreeViewItem(); item.Header = System.IO.Path.GetFileName(file); item.ToolTip = file; dstItemsControl.Items.Add(item); item.IsSelected = true; item.BringIntoView(); } e.Effects = DragDropEffects.Copy; } else { throw new NotSupportedException("The item type is not implemented"); } // No need to loop through multiple // files if we're not dropping them if (!bDrop) { break; } } } e.Handled = true; } }
/// <summary>Loads the list views.</summary> private void loadLists() { lstCurrent.Items.Clear(); lstAvailable.Items.Clear(); //Set which ColumnHeader property to display lstCurrent.DisplayMember = "Text"; lstAvailable.DisplayMember = "Text"; foreach (ColumnHeader column in CurrentColumnsCollection) { if (string.IsNullOrEmpty(column.Text.Trim())) { continue; } var item = new ListBoxItem { Text = column.Text, Column = column, DisplayIndex = column.DisplayIndex }; if (column.Tag != null && int.Parse(column.Tag.ToString()) < 0) { lstAvailable.Items.Add(item); } else { lstCurrent.Items.Add(item); } } }
private void btnStart_Click(object sender, RoutedEventArgs e) { int count = IterationCount; int pass = 0; int fail = 0; int completed = 0; // Determine which test to use WirelessUnitTest test = ((ComboBoxItem)comboSelectTest.SelectedItem)?.DataContext as WirelessUnitTest; if (test == null) { return; } listBox.Items.Clear(); listBox.Items.Add(new ListBoxItem() { Content = $"Starting {count} iterations of {test.UnitTestMethod.Name}", Background = Brushes.LightBlue }); btnStart.IsEnabled = false; ThreadPool.QueueUserWorkItem((context) => { Stopwatch sw = new Stopwatch(); sw.Start(); Parallel.For(0, count, (index) => { WirelessUnitTestInstance instance = WirelessUnitTestInstance.RunUnitTest(LinkedWindow.Network, test); if (instance.TestPassed) { Interlocked.Increment(ref pass); } else { Interlocked.Increment(ref fail); Dispatcher.Invoke(() => { ListBoxItem lb = new ListBoxItem() { Content = $"({index}) Test Failed: {instance.TestException.ToString()}", DataContext = instance, Background = Brushes.LightPink }; lb.MouseDoubleClick += OpenTestFailureItem; listBox.Items.Add(lb); }); } if (Interlocked.Increment(ref completed) % 50 == 0) { Dispatcher.Invoke(() => { Title = $"Running tests... ({(pass + fail)}/{count})"; }); } }); sw.Stop(); double ms = Math.Floor(sw.Elapsed.TotalMilliseconds * 100) / 100; Dispatcher.Invoke(() => { listBox.Items.Add(new ListBoxItem() { Content = $"Completed in {ms}ms. {pass} Passed, {fail} Failed.", Background = Brushes.LightBlue }); Title = "Run Unit Tests"; btnStart.IsEnabled = true; }); }); }
private void PopulateRepairs(List<Repair> RepairsToDisplay) { RegisteredRepairs.Items.Clear(); foreach (var Repair in RepairsToDisplay) { var newListBoxItem = new ListBoxItem(); newListBoxItem.Content = Repair.Caption + " " + Repair.Date; newListBoxItem.Tag = Repair; RegisteredRepairs.Items.Add(newListBoxItem); } }
private static void Cm_Closed(object sender, RoutedEventArgs e) { if (sender is ContextMenu cm) { if (cmCancelled || (Keyboard.GetKeyStates(Key.Escape) & KeyStates.Down) > 0) { cm.IsOpen = false; MainWindow.Update(); return; } int sourceID = (int)cm.GetValue(SourceIDProperty); int targetID = (int)cm.GetValue(TargetIDProperty); Neuron nSource = MainWindow.theNeuronArray.GetNeuron(sourceID); Neuron nTarget = MainWindow.theNeuronArray.GetNeuron(targetID); int newSourceID = sourceID; int newTargetID = targetID; Control cc = Utils.FindByName(cm, "Target"); if (cc is TextBox tb) { string targetLabel = tb.Text; if (nTarget.label != targetLabel) { if (!int.TryParse(tb.Text, out newTargetID)) { newTargetID = targetID; Neuron n = MainWindow.theNeuronArray.GetNeuron(targetLabel); if (n != null) { newTargetID = n.id; } } } } cc = Utils.FindByName(cm, "Source"); if (cc is TextBox tb1) { string sourceLabel = tb1.Text; if (nSource.label != sourceLabel) { if (!int.TryParse(tb1.Text, out newSourceID)) { newSourceID = sourceID; Neuron n = MainWindow.theNeuronArray.GetNeuron(sourceLabel); if (n != null) { newSourceID = n.id; } } } } if (newSourceID < 0 || newSourceID >= MainWindow.theNeuronArray.arraySize || newTargetID < 0 || newTargetID >= MainWindow.theNeuronArray.arraySize ) { MessageBox.Show("Neuron outside array boundary!"); return; } cc = Utils.FindByName(cm, "SynapseWeight"); if (cc is ComboBox tb2) { float.TryParse(tb2.Text, out float newWeight); if (weightChanged) { theNeuronArrayView.lastSynapseWeight = newWeight; Utils.AddToValues(newWeight, synapseWeightValues); } } cc = Utils.FindByName(cm, "Model"); if (cc is ComboBox cb0) { ListBoxItem lbi = (ListBoxItem)cb0.SelectedItem; Synapse.modelType sm = (Synapse.modelType)System.Enum.Parse(typeof(Synapse.modelType), lbi.Content.ToString()); theNeuronArrayView.lastSynapseModel = sm; } if (newSourceID != sourceID || newTargetID != targetID) { MainWindow.theNeuronArray.SetUndoPoint(); MainWindow.theNeuronArray.GetNeuron((int)cm.GetValue(SourceIDProperty)).DeleteSynapseWithUndo((int)cm.GetValue(TargetIDProperty)); } Neuron nNewSource = MainWindow.theNeuronArray.GetNeuron(newSourceID); nNewSource.AddSynapseWithUndo(newTargetID, theNeuronArrayView.lastSynapseWeight, theNeuronArrayView.lastSynapseModel); cm.IsOpen = false; MainWindow.Update(); } }