public static FrameworkElement Create(IClassificationFormatMap classificationFormatMap, string text, List<TextClassificationTag> tagsList, TextElementFlags flags) { bool useFastTextBlock = (flags & (TextElementFlags.TrimmingMask | TextElementFlags.WrapMask | TextElementFlags.FilterOutNewLines)) == (TextElementFlags.NoTrimming | TextElementFlags.NoWrap | TextElementFlags.FilterOutNewLines); bool filterOutNewLines = (flags & TextElementFlags.FilterOutNewLines) != 0; if (tagsList.Count != 0) { if (useFastTextBlock) { return new FastTextBlock((flags & TextElementFlags.NewFormatter) != 0, new TextSrc { text = ToString(text, filterOutNewLines), classificationFormatMap = classificationFormatMap, tagsList = tagsList.ToArray(), }); } var propsSpans = tagsList.Select(a => new TextRunPropertiesAndSpan(a.Span, classificationFormatMap.GetTextProperties(a.ClassificationType))); var textBlock = TextBlockFactory.Create(text, classificationFormatMap.DefaultTextProperties, propsSpans, TextBlockFactory.Flags.DisableSetTextBlockFontFamily | TextBlockFactory.Flags.DisableFontSize | (filterOutNewLines ? TextBlockFactory.Flags.FilterOutNewlines : 0)); textBlock.TextTrimming = GetTextTrimming(flags); textBlock.TextWrapping = GetTextWrapping(flags); return textBlock; } FrameworkElement fwElem; if (useFastTextBlock) { fwElem = new FastTextBlock((flags & TextElementFlags.NewFormatter) != 0) { Text = ToString(text, filterOutNewLines) }; } else { fwElem = new TextBlock { Text = ToString(text, filterOutNewLines), TextTrimming = GetTextTrimming(flags), TextWrapping = GetTextWrapping(flags), }; } return InitializeDefault(classificationFormatMap, fwElem); }
public PlayerSelector(List<Player> players) { InitializeComponent(); Players = players; CB_PlayerSelector.ItemsSource = Players.Select(p => p.Name).ToList(); }
private void OnTodoListStoreChanged(List<TodoItem> todoItems) { // Remove items that didn't come from the list var itemsToRemove = m_todoMainContext.TodoItems.Where(i => !todoItems.Select(ti => ti.Id).Contains(i.Id)).ToList(); foreach (var itemToRemove in itemsToRemove) { m_todoMainContext.TodoItems.Remove(itemToRemove); } // Add or modify all others foreach (var todoItem in todoItems) { var todoItemControl = m_todoMainContext.TodoItems.FirstOrDefault(i => i.Id == todoItem.Id); if (todoItemControl == null) { m_todoMainContext.TodoItems.Add(new TodoItemControl { Id = todoItem.Id, Label = todoItem.Label, IsCompleted = todoItem.IsCompleted }); } else { todoItemControl.Label = todoItem.Label; todoItemControl.IsCompleted = todoItem.IsCompleted; } } }
public bool ShowDialog() { var fileWorker = NetDocumentsModule.Instance.Container.Resolve<IFileSystemWorker>(); var app = new NdMultiDocumentApplication(); var eventsSource = InjectionContainer.Current.Resolve<IEventStream>(); _formats = FileFormat.Parse(Filters); app.SupportedFileTypesForSave = Convert(); app.DefaultSaveFormat = app.SupportedFileTypesForSave.Skip(plFormatIndex - 1).FirstOrDefault(); app.SupportedFileTypesForOpen = string.Join(",", _formats.Select(a => a.GetExtensionsAsString())); using (eventsSource.Of<DocumentSavedMessage>().SubscribeSafe(OnSaved, InjectionContainer.Current.Resolve<IExceptionLogger>())) { var helper = InjectionContainer.Current.Resolve<NdDialogHelper>(new DependencyOverride(typeof(IMultiDocumentApplication), app)); var withProperName = fileWorker.CreateTempFile(FileName); try { var doc = new Document(withProperName) { IsNew = string.IsNullOrEmpty(FileName)// one way to fill initial name to reuse the filename }; var res = helper.Save(doc, true); if (res == SaveResult.Saved) { return true; } return false; } finally { fileWorker.SafeDeletefile(withProperName); } } }
private Polygon GetPolygon(List<Vector2> points, KggCanvas.Color color = null) { return new Polygon(points .Select(x => new Vector2Ext(kggCanvas.Width / 2 + x.X * size, kggCanvas.Height / 2 - x.Y * size) ) .ToList() ,color); }
// STEP4 STEP4 STEP4 private string ReadWebRequestCallback(IAsyncResult callbackResult) { try { HttpWebRequest myRequest = (HttpWebRequest)callbackResult.AsyncState; HttpWebResponse myResponse = (HttpWebResponse)myRequest.EndGetResponse(callbackResult); using (StreamReader httpwebStreamReader = new StreamReader(myResponse.GetResponseStream())) { string fil = httpwebStreamReader.ReadToEnd(); FileToSave = fil; if (FileToSave != "") { FileManip f = new FileManip(); XML x = new XML(); list = x.Retrive(fil); if (list.Select(e=>e.Pubdate).Contains(LatestDate)) { } f.Update(Filename, FileToSave); } } myResponse.Close(); } catch (Exception we) { } }
/// <summary> /// Get the nodes from the selected text file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnNodefileSel_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; //openFileDialog.InitialDirectory = citiesIn.filepath; if (openFileDialog.ShowDialog() == true) { txtboxNodefile.Text = @"...\" + openFileDialog.SafeFileName; citiesIn.filepath = openFileDialog.FileName; } // set the value of the combobox nodelist = citiesIn.GetCitieses(); maxNumofCities = nodelist.Count; List<string> citynames = nodelist.Select(cityNode => cityNode.city).ToList(); comboboxStartCity.ItemsSource = citynames; comboboxStartCity.SelectedIndex = 0; lboxManualSelectNodes.ItemsSource = citynames; if (RandomNodeSelect.IsChecked == true) lboxManualSelectNodes.IsEnabled = false; else lboxManualSelectNodes.IsEnabled = true; // draw the circles _drawlines(citylisttodraw); }
public void AddSeries(ColumnSeries b, List<double> xAxis) { var ca = new CategoryAxis() { LabelField = "label", Labels = (IList<string>)xAxis.Select(i => i.ToString()).ToList() }; plot.Axes.Add(ca); plot.Series.Add(b); this.Root.Model = plot; }
public MainWindow() { InitializeComponent(); this.Loaded += MainWindow_Loaded; trackInfos = ReadTrackInfos(); var plateBarcodes = trackInfos.Select(x => x.plateBarcode).Distinct().ToList(); lstPlateBarcodes.ItemsSource = plateBarcodes; }
public void ImportStarted(string message, List<XMLImportProgressItem> items) { lvw.InvokeIfRequired(() => { lvw.ItemsSource = new ObservableCollection<ProgressItemViewModel>(items.Select((m) => { return new ProgressItemViewModel(m); })); }); }
public UsersWindows() { InitializeComponent(); user = new User(); users = user.GetAll(); userGrid.ItemsSource = users.Select(x => x.nombre).ToList() ; }
public void GenerateItemByFilter(Action<IEnumerable<InvoiceItemDto>, Exception> action, List<long> orderIdList) { var url = string.Format(invoiceItemAddressFormatString, 0, string.Empty); var sb = new StringBuilder(url); var strOrderLIst = ""; orderIdList.Select(c => strOrderLIst = strOrderLIst + c + ",").ToList(); sb.Append(string.Concat("?orderIdList=", strOrderLIst.Remove(strOrderLIst.Length - 1))); WebClientHelper.Get(new Uri(sb.ToString(), UriKind.Absolute), action, WebClientHelper.MessageFormat.Json,ApiConfig.Headers); }
private void ContextMenu_Opened(object sender, RoutedEventArgs e) { contextMenu.Items.Clear(); var me = new MenuItem(); var items = new List<KeyValuePair<int, string>>(); foreach (var item in Items) items.Add((KeyValuePair<int, string>)item); AddMenuItems(contextMenu, items.Select(x => Tuple.Create(x, x.Value.Split('/'))).ToArray()); }
public void dispatch_categories(List<string> CategoryList) { Category_Listbox.Dispatcher.Invoke( (Action)(() => { Category_Listbox.ItemsSource = CategoryList.Select(i=>i); }) ); Categories_Listbox.Dispatcher.Invoke( (Action)(() => { Categories_Listbox.ItemsSource = CategoryList.Select(i => i); }) ); category_list.Dispatcher.Invoke((Action)(() => { category_list.ItemsSource = CategoryList.Select(i => i); })); }
private void CleanMotionButton_Click(object sender, RoutedEventArgs e) { string bodyData = @"C:\Users\non\Desktop\Data\1222\L1\Student1SelectedUserBody.dump"; string timeData = @"C:\Users\non\Desktop\Data\1222\L1\Student1TimeData.dump"; List<string> statData = new List<string>() { @"C:\Users\non\Desktop\Data\1222\L1\L1StudentStatData.dump", }; List<Dictionary<JointType, CvPoint3D64f>> jointsSeq = Utility.ConvertToCvPoint((List<Dictionary<int, float[]>>)Utility.LoadFromBinary(bodyData)); List<DateTime> timeSeq = (List<DateTime>)Utility.LoadFromBinary(timeData); List<Dictionary<Bone, BoneStatistics>> boneStats = statData.Select(s => (Dictionary<Bone, BoneStatistics>)Utility.LoadFromBinary(s)).ToList(); MotionMetaData mmd = new MotionMetaData(jointsSeq, timeSeq, boneStats); }
public RouteDrawing() { InitializeComponent(); List<GeoCoordinate> locations = new List<GeoCoordinate>(); RouteServiceClient routeService = new RouteServiceClient("BasicHttpBinding_IRouteService"); routeService.CalculateRouteCompleted += (sender, e) => { var points = e.Result.Result.RoutePath.Points; var coordinates = points.Select(x => new GeoCoordinate(x.Latitude, x.Longitude)); var routeColor = Colors.Blue; var routeBrush = new SolidColorBrush(routeColor); var routeLine = new MapPolyline() { Locations = new LocationCollection(), Stroke = routeBrush, Opacity = 0.65, StrokeThickness = 5.0, }; foreach (var location in points) { routeLine.Locations.Add(new GeoCoordinate(location.Latitude, location.Longitude)); } RouteLayer.Children.Add(routeLine); }; RouteBingMap.SetView(LocationRect.CreateLocationRect(locations)); routeService.CalculateRouteAsync(new RouteRequest() { Credentials = new Credentials() { ApplicationId = "Ak-j1fNexs-uNWG_YoP2WZlthezPoUWsRvSexDLTGfjQ1XqKgnfR1nqeC2YbZZSn" }, Options = new RouteOptions() { RoutePathType = RoutePathType.Points }, Waypoints = new ObservableCollection<Waypoint>( locations.Select(x => new Waypoint() { Location = x.Location })) }); }
public void Bind(List<Track> musicItems) { var selectedItem = comboBox.SelectedValue as ComboBoxItem; items = musicItems.Select(t => new ComboBoxItem { NameWithSinger = t.GetNameWithSinger(), TimeString = t.GetTimeString(), Track = t }).ToList(); comboBox.ItemsSource = items; if (selectedItem != null) comboBox.SelectedItem = items.FirstOrDefault(i => selectedItem.Track.Equals(i.Track)); }
public MainWindow() { InitializeComponent(); List<JointType> temp = new List<JointType>(new JointType[] { JointType.FootLeft, JointType.FootRight, JointType.AnkleLeft, JointType.AnkleRight, JointType.KneeLeft, JointType.KneeRight, JointType.HipCenter, JointType.HipLeft, JointType.HipRight } ); legs_int = temp.Select(o=> (int)o).ToList(); List<JointType> right = new List<JointType>(new JointType[] { JointType.FootRight, JointType.AnkleRight, JointType.KneeRight, JointType.HipCenter, JointType.HipRight }); List<JointType> left = new List<JointType>(new JointType[] { JointType.FootLeft, JointType.AnkleLeft, JointType.KneeLeft, JointType.HipCenter, JointType.HipLeft }); leg_left = left.Select(o => (int)o).ToList(); leg_right = right.Select(o => (int)o).ToList(); timer.Interval = TimeSpan.FromMilliseconds(33); timer.Tick += timer_Tick; timer.Start(); }
public SelectorColumns(List<TreeWithKmh.MainPage.MetaColumn> columns) { //this.columns = new ObservableCollection<TreeWithKmh.MainPage.MetaColumn>(columns); this.originalColumns = columns; this.columns = columns.Select(it => new TreeWithKmh.MainPage.MetaColumn() { Header = it.Header, Visible = it.Visible, Binding = it.Binding, Booled = it.Booled, Converter = it.Converter }).ToList(); InitializeComponent(); ColumnList.ItemsSource = this.columns; }
private void ValidateProperty(string property) { var ctx = new ValidationContext(this) { MemberName = property }; var results = new List<System.ComponentModel.DataAnnotations.ValidationResult>(); if(Validator.TryValidateProperty(this.GetType().GetProperty(property).GetValue(this), ctx, results)) { if(_errors.ContainsKey(property)) { _errors.Remove(property); ErrorsChanged(this, new DataErrorsChangedEventArgs(property)); } return; } var errors = results.Select(x => x.ErrorMessage).ToArray(); _errors[property] = errors; ErrorsChanged(this, new DataErrorsChangedEventArgs(property)); }
private PopularFriendsWindow(String accessToken) { this.accessToken = accessToken; potencialFriends.Start(accessToken); InitializeComponent(); new Thread(delegate() { var persons = new List<VkApi.Person>(); while (potencialFriends.IsWork) { if (!potencialFriends.IsEmpty) { persons.AddRange(potencialFriends.LstItems); persons.Sort(delegate(VkApi.Person a, VkApi.Person b) { return -1 * a.mutual_friends.CompareTo(b.mutual_friends); }); //try //{ // foreach (var person in persons) // person.Photo = VkApi.ApiBase.GetImage(person.photo_50); //} //catch (Exception e) // { // e.GetType(); // } Dispatcher.BeginInvoke(new ThreadStart(delegate() { listBox.Items.Clear(); foreach (var person in persons.Select(a => new PersonInformationControl(a.Photo, a.first_name, a.last_name, a.mutual_friends, a.online, a.id))) listBox.Items.Add(person); })); } Thread.Sleep(100); } }).Start(); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { BuildApplicationBar(); // Affichage de l'historique if (IsolatedStorageSettings.ApplicationSettings.Contains("runHistory")) { List<FullRun> runHistory = new List<FullRun>(); /*DEBUG : Uncomment following line to clear run history*/ //IsolatedStorageSettings.ApplicationSettings["runHistory"] = runHistory; //This line clear run history /*END DEBUG*/ runHistory = (List<FullRun>)IsolatedStorageSettings.ApplicationSettings["runHistory"]; List<FullRun> runHistoryClone = runHistory.Select(i => i.Clone()).ToList(); runHistoryClone.Reverse(); historyListBox.ItemsSource = runHistoryClone; } getTotals(); }
private void BtnAdd_Click(object sender, RoutedEventArgs e) { List<int> ids=new List<int>(); foreach (CheckedImportFolder f in ImportFolders) { if (f.Checked) ids.Add(f.ImportFolderID); } if (ids.Count == 0) return; Scan s=new Scan(); s.Status = (int) ScanStatus.Standby; s.CreationTIme = DateTime.Now; s.ImportFolders = string.Join(",", ids.Select(a => a.ToString())); RepoFactory.Scan.Save(s); SelectedScan = s; this.DialogResult = true; this.Close(); }
public ShowNearbyPoi() { InitializeComponent(); this.ApplicationTitle.Text = Globals.AppName; Building b = LocationService.CurrentBuilding; if (b == null) this.NavigationService.GoBack(); if (b.Building_Floors == null) this.NavigationService.GoBack(); //A graph would make everything better. poiVerts = (from v in b.Vertices where v.AbsoluteLocations.First().altitude == Map2D.mCurrentSelectedFloor && v.SymbolicLocations.FirstOrDefault() != null select v).ToList(); nearbyPoiListBox.ItemsSource = poiVerts.Select(v => v.SymbolicLocations.First()); nearbyPoiListBox.SelectionChanged += new SelectionChangedEventHandler(nearbyPoiListBox_SelectionChanged); }
public MainWindow() { InitializeComponent(); var seconds = new List<Second> { new Second(0), new Second(60), new Second(120), new Second(180), new Second(240), new Second(300), new Second(360), new Second(420), new Second(480), new Second(540), new Second(600), }; var vms = seconds.Select(s => new SecondVM(s)); lv.ItemsSource = vms; }
void HandleCustomContextMenuEntry(ContextMenuEntry currentEntry, Category aCategory, VideoInfo aVideo) { List<KeyValuePair<string, ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, ContextMenuEntry>>(); while (true) { bool execute = currentEntry.Action == ContextMenuEntry.UIAction.Execute; if (currentEntry.Action == ContextMenuEntry.UIAction.GetText) { SearchDialog dlg = new SearchDialog() { Owner = this }; dlg.tbxSearch.Text = currentEntry.UserInputText ?? ""; dlg.lblHeading.Text = currentEntry.DisplayText; if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.tbxSearch.Text)) { currentEntry.UserInputText = dlg.tbxSearch.Text; execute = true; } else break; } if (currentEntry.Action == ContextMenuEntry.UIAction.ShowList) { PlaybackChoices dlg = new PlaybackChoices() { Owner = this }; dlg.lblHeading.Content = currentEntry.DisplayText; dialogOptions.Clear(); foreach (var subEntry in currentEntry.SubEntries) { dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(subEntry.DisplayText, subEntry)); } dlg.lvChoices.ItemsSource = dialogOptions.Select(dO => dO.Key).ToList(); dlg.lvChoices.SelectedIndex = 0; if (dlg.ShowDialog() != true) break; else currentEntry = dialogOptions[dlg.lvChoices.SelectedIndex].Value; } if (execute) { waitCursor.Visibility = System.Windows.Visibility.Visible; Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback( delegate() { return SelectedSite.ExecuteContextMenuEntry(aCategory, aVideo, currentEntry); }, delegate(Gui2UtilConnector.ResultInfo resultInfo) { waitCursor.Visibility = System.Windows.Visibility.Hidden; if (ReactToResult(resultInfo, currentEntry.DisplayText)) { if (resultInfo.ResultObject is ContextMenuExecutionResult) { var cmer = resultInfo.ResultObject as ContextMenuExecutionResult; if (!string.IsNullOrEmpty(cmer.ExecutionResultMessage)) { notification.Show(currentEntry.DisplayText, cmer.ExecutionResultMessage); } if (cmer.RefreshCurrentItems) { CategorySelected(SelectedCategory); } if (cmer.ResultItems != null && cmer.ResultItems.Count > 0) { DisplaySearchResultItems(currentEntry.DisplayText, cmer.ResultItems); } } } }); break; } } }
void ShowContextMenuForVideo(VideoInfo video) { List<KeyValuePair<string, ContextMenuEntry>> dialogOptions = new List<KeyValuePair<string, ContextMenuEntry>>(); if (!(SelectedSite is DownloadedVideoUtil)) { dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Concurrent), null)); dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(string.Format("{0} ({1})", Translation.Instance.Download, Translation.Instance.Queued), null)); if (!(SelectedSite is FavoriteUtil) && OnlineVideoSettings.Instance.FavDB != null) { dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(Translation.Instance.AddToFavourites, null)); } } foreach (var entry in SelectedSite.GetContextMenuEntries(SelectedCategory, video)) { dialogOptions.Add(new KeyValuePair<string, ContextMenuEntry>(entry.DisplayText, entry)); } if (dialogOptions.Count > 0) { PlaybackChoices dlg = new PlaybackChoices() { Owner = this }; dlg.lblHeading.Content = string.Format("{0}: {1}", Translation.Instance.Actions, video.Title); dlg.lvChoices.ItemsSource = dialogOptions.Select(dO => dO.Key).ToList(); dlg.lvChoices.SelectedIndex = 0; if (dlg.ShowDialog() == true) { if (dialogOptions[dlg.lvChoices.SelectedIndex].Value == null) { if (dlg.lvChoices.SelectedItem.ToString().Contains(Translation.Instance.Concurrent)) { SaveVideo_Step1(DownloadList.Create(DownloadInfo.Create(video, SelectedCategory, SelectedSite))); } else if (dlg.lvChoices.SelectedItem.ToString().Contains(Translation.Instance.Queued)) { SaveVideo_Step1(DownloadList.Create(DownloadInfo.Create(video, SelectedCategory, SelectedSite)), true); } else if (dlg.lvChoices.SelectedItem.ToString().Contains(Translation.Instance.AddToFavourites)) { AddFavoriteVideo(video); } } else HandleCustomContextMenuEntry(dialogOptions[dlg.lvChoices.SelectedIndex].Value, SelectedCategory, video); } } }
private static void updateCharactersByLeague(List<Character> chars) { var allLeagues = chars.Select(c => c.League).Distinct(); foreach (var league in allLeagues) ApplicationState.AllCharactersByLeague[league] = new List<string>(); if (Settings.Lists.ContainsKey("MyLeagues")) foreach (var league in Settings.Lists["MyLeagues"]) if (!ApplicationState.AllCharactersByLeague.ContainsKey(league)) ApplicationState.AllCharactersByLeague[league] = new List<string>(); foreach (var character in chars) ApplicationState.AllCharactersByLeague[character.League].Add(character.Name); }
private void saveTabs() { List<String> paths = new List<String>(); foreach (KeyValuePair<TabItem, ExplorerBrowser> pair in browsers) { //If the navigation location has changed if (pair.Value.NavigationLog.Count > 0 && pair.Value.NavigationLogIndex != -1) { paths.Add(pair.Value.NavigationLog.ElementAt(pair.Value.NavigationLogIndex).ParsingName); } //Otherwise, use initial navigation location else { paths.Add(pair.Value.NavigationTarget.ParsingName); } } FancyExplorer.Properties.Settings.Default.autosavedTabs = String.Join(",", paths.Select(x => x)); FancyExplorer.Properties.Settings.Default.Save(); }
private void getdata() { DataTable table = dbOperation.GetDbHelper().GetDataSet(string.Format("call p_report_day_country('{0}','{1}','{2}','{3}','{4}')", Sj, DeptId, ItemId, ResultId, DeptType)).Tables[0]; currenttable = table; List<DeptItemInfo> list = new List<DeptItemInfo>(); list.Clear(); for (int i = 0; i < table.Rows.Count; i++) { DeptItemInfo info = new DeptItemInfo(); //info.DeptId = table.Rows[i][0].ToString(); info.DeptName = table.Rows[i][1].ToString(); //info.ItemId = table.Rows[i][2].ToString(); info.ItemName = table.Rows[i][3].ToString(); info.Count = table.Rows[i][4].ToString(); info.Sum = table.Rows[i][5].ToString(); info.Yin = table.Rows[i][6].ToString(); info.Yang = table.Rows[i][7].ToString(); info.Yisi = table.Rows[i][8].ToString(); list.Add(info); } //得到行和列标题 及数量 string[] DeptNames = list.Select(t => t.DeptName).Distinct().ToArray(); string[] ItemNames = list.Select(t => t.ItemName).Distinct().ToArray(); //创建DataTable DataTable tabledisplay = new DataTable(); //表中第一行第一列交叉处一般显示为第1列标题 tabledisplay.Columns.Add(new DataColumn("序号")); tabledisplay.Columns.Add(new DataColumn("部门名称")); MyColumns.Add("序号", new MyColumn("序号", "序号") { BShow = true, Width = 5 }); MyColumns.Add("部门名称", new MyColumn("部门名称", "部门名称") { BShow = true, Width = 16 }); //表中后面每列的标题其实是列分组的关键字 for (int i = 0; i < ItemNames.Length; i++) { DataColumn column = new DataColumn(ItemNames[i]); tabledisplay.Columns.Add(column); MyColumns.Add(ItemNames[i].ToString(), new MyColumn(ItemNames[i].ToString(), ItemNames[i].ToString()) { BShow = true, Width = 10 }); } //表格后面为合计列 tabledisplay.Columns.Add(new DataColumn("合计")); MyColumns.Add("合计", new MyColumn("合计", "合计") { BShow = true, Width = 10 }); switch (ResultId) { case "": tabledisplay.Columns.Add(new DataColumn("阴性样本")); tabledisplay.Columns.Add(new DataColumn("疑似阳性样本")); tabledisplay.Columns.Add(new DataColumn("阳性样本")); MyColumns.Add("阴性样本", new MyColumn("阴性样本", "阴性样本") { BShow = true, Width = 10 }); MyColumns.Add("疑似阳性样本", new MyColumn("疑似阳性样本", "疑似阳性样本") { BShow = true, Width = 10 }); MyColumns.Add("阳性样本", new MyColumn("阳性样本", "阳性样本") { BShow = true, Width = 10 }); break; case "1": tabledisplay.Columns.Add(new DataColumn("阴性样本")); MyColumns.Add("阴性样本", new MyColumn("阴性样本", "阴性样本") { BShow = true, Width = 10 }); break; case "0": tabledisplay.Columns.Add(new DataColumn("疑似阳性样本")); MyColumns.Add("疑似阳性样本", new MyColumn("疑似阳性样本", "疑似阳性样本") { BShow = true, Width = 10 }); break; case "2": tabledisplay.Columns.Add(new DataColumn("阳性样本")); MyColumns.Add("阳性样本", new MyColumn("阳性样本", "阳性样本") { BShow = true, Width = 10 }); break; default: break; } //为表中各行生成数据 for (int i = 0; i < DeptNames.Length; i++) { var row = tabledisplay.NewRow(); //每行第0列为行分组关键字 row[0] = i + 1 ; row[1] = DeptNames[i]; //每行的其余列为行列交叉对应的汇总数据 for (int j = 0; j < ItemNames.Length; j++) { string num = list.Where(t => t.DeptName == DeptNames[i] && t.ItemName == ItemNames[j]).Select(t => t.Count).FirstOrDefault(); if (num == null || num == "") { num = '0'.ToString(); } row[ItemNames[j]] = num; } row[ItemNames.Length + 2] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Sum).FirstOrDefault(); switch (ResultId) { case "": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yin).FirstOrDefault(); row[ItemNames.Length + 4] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yisi).FirstOrDefault(); row[ItemNames.Length + 5] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yang).FirstOrDefault(); break; case "1": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yin).FirstOrDefault(); break; case "0": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yisi).FirstOrDefault(); break; case "2": row[ItemNames.Length + 3] = list.Where(t => t.DeptName == DeptNames[i]).Select(t => t.Yang).FirstOrDefault(); break; default: break; } tabledisplay.Rows.Add(row); } //计算报表总条数 int row_count = 0 ; if (table.Rows.Count != 0) { //表格最后添加合计行 tabledisplay.Rows.Add(tabledisplay.NewRow()[1] = "合计"); for (int j = 2; j < tabledisplay.Columns.Count; j++) { int sum = 0; for (int i = 0; i < tabledisplay.Rows.Count - 1 ; i++) { sum += Convert.ToInt32(tabledisplay.Rows[i][j].ToString()); } //sum_column += sum; tabledisplay.Rows[tabledisplay.Rows.Count - 1][j] = sum; } row_count = tabledisplay.Rows.Count - 1; } else { row_count = 0 ; } _tableview.MyColumns = MyColumns; _tableview.BShowDetails = true; _tableview.Table = tabledisplay; }