本文整理汇总了C#中System.Windows.Documents.List.GroupBy方法的典型用法代码示例。如果您正苦于以下问题:C# List.GroupBy方法的具体用法?C# List.GroupBy怎么用?C# List.GroupBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.GroupBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XpsEditor
public XpsEditor(List<Annotation> annotations)
{
if (annotations == null)
{
throw new ArgumentNullException(nameof(annotations));
}
var byPages = annotations.GroupBy(a => a.PageNumber)
.Select(g => new
{
Number = g.Key ?? -1,
Annotations = g.ToArray()
})
.OrderBy(g => g.Number)
.ToList();
_commonAnnotations = _emptyAnnotations;
var commonAnnotations = byPages.FirstOrDefault(p => p.Number == -1);
if (commonAnnotations != null)
{
byPages.Remove(commonAnnotations);
_commonAnnotations = commonAnnotations.Annotations.Select(a => new AnnotationData(a)).ToArray();
}
_pageAnnotations = byPages.ToDictionary(p => p.Number, p => p.Annotations
.Select(a => new AnnotationData(a))
.ToArray());
}
示例2: OrgSelectEntity
public OrgSelectEntity(List<ExtOrgObj> selectedValue)
{
this.SelectedValue = selectedValue;
if (selectedValue != null && selectedValue.Count > 0)
{
IsMultipleType = selectedValue.GroupBy(item => item.ObjectType).Count() > 1;
}
}
示例3: LaunchWindow
public LaunchWindow()
{
string gameConfigurationFolder = "GameConfiguration";
string gameConfigurationsPath = Path.Combine(gameConfigurationFolder, "gameConfigs.json");
InitializeComponent();
if (!Directory.Exists(gameConfigurationFolder))
Directory.CreateDirectory(gameConfigurationFolder);
//Loading the last used configurations for hammer
RegistryKey rk = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Hammer\General");
var configs = new List<GameConfiguration>();
//try loading json
if (File.Exists(gameConfigurationsPath))
{
string jsonLoadText = File.ReadAllText(gameConfigurationsPath);
configs.AddRange(JsonConvert.DeserializeObject<List<GameConfiguration>>(jsonLoadText));
}
//try loading from registry
if (rk != null)
{
string BinFolder = (string)rk.GetValue("Directory");
string gameData = Path.Combine(BinFolder, "GameConfig.txt");
configs.AddRange(GameConfigurationParser.Parse(gameData));
}
//finalise config loading
if (configs.Any())
{
//remove duplicates
configs = configs.GroupBy(g => g.Name).Select(grp => grp.First()).ToList();
//save
string jsonSaveText = JsonConvert.SerializeObject(configs, Formatting.Indented);
File.WriteAllText(gameConfigurationsPath, jsonSaveText);
if (configs.Count == 1)
Launch(configs.First());
GameGrid.ItemsSource = configs;
}
else//oh noes
{
LaunchButton.IsEnabled = false;
WarningLabel.Content = "No Hammer configurations found. Cannot launch.";
}
}
示例4: OnInitialized
protected override void OnInitialized(EventArgs e)
{
base.OnInitialized(e);
List<KeyValuePair<string, string>> images=new List<KeyValuePair<string, string>>();
/* Get image file with allowed extensions and group them with their directory */
images=ProjectTools.RetrieveFiles(ChooseImageDialog.Extension);
IEnumerable<IGrouping<string, string>> grouping = images.GroupBy(image => image.Key, image => image.Value);
/* Set values for _data and bind to the ListBox */
foreach(IGrouping<string, string> group in grouping){
List<string> temp=new List<string>();
foreach(var name in group){
temp.Add(name);
}
_data.Add(new ImageData(group.Key + Path.DirectorySeparatorChar,temp));
}
Display.ItemsSource=_data;
Display.SelectionChanged+=delegate { Display.SelectedItem=null; };
}
示例5: NewForm
public NewForm()
{
InitializeComponent();
//Displays a SaveFileDialog so the user can save the xml template
// assigned to Save Button.
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Xml file|*.xml";
if (!string.IsNullOrEmpty(Utility.lastDir))
openFileDialog1.InitialDirectory = Utility.lastDir;
// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = openFileDialog1.ShowDialog();
// Get the selected file name and PARSE IT
if (result == true)
{
Utility.lastDir = openFileDialog1.File.FullName;
var list = new List<Element>();
var xElem = (XElement.Load(openFileDialog1.File.OpenRead())).Elements();
var serializer = new XmlSerializer(typeof(Element));
foreach (var item in xElem)
{
try
{
var test = (Element)serializer.Deserialize(item.CreateReader());
list.Add(test);
}
catch
{
throw;
}
}
List<List<Element>> groupings = list.GroupBy(x => x.Type)
.Select(x => x.ToList()).ToList();
foreach (var group in groupings)
{
string type = null;
StackPanel stackVerticalMain = new StackPanel();
stackVerticalMain.Orientation = Orientation.Vertical;
stackVerticalMain.Margin = new Thickness(10);
WrapPanel wpFirst = new WrapPanel();
wpFirst.Orientation = Orientation.Horizontal;
WrapPanel wpSecond = new WrapPanel();
wpSecond.Orientation = Orientation.Horizontal;
WrapPanel wpThird = new WrapPanel();
wpThird.Orientation = Orientation.Horizontal;
foreach (var element in group)
{
type = element.Type;
if (element.Combo.Count == 0)
{
if (element.IsMultiple == true)
{
Border brd = new Border();
brd.BorderThickness = new Thickness(1);
brd.Margin = new Thickness(5, 0, 0, 0);
brd.BorderBrush = new SolidColorBrush(Colors.Transparent);
brd.Background = new SolidColorBrush(Color.FromArgb(255, 34, 35, 37));
brd.Height = 150;
ScrollViewer sv = new ScrollViewer();
sv.BorderBrush = new SolidColorBrush(Colors.Transparent);
sv.Style = (Style)Helpers.FindResourceHelper.FindResource("ScrollViewerStyle1");
sv.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
sv.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
StackPanel stackVertical = new StackPanel();
stackVertical.Orientation = Orientation.Vertical;
stackVertical.Margin = new Thickness(10);
StackPanel stackHorizontal = new StackPanel();
stackHorizontal.Orientation = Orientation.Horizontal;
TextBlock textBlock = new TextBlock();
textBlock.Margin = new Thickness(5);
textBlock.Text = element.Display;
textBlock.Foreground = new SolidColorBrush(Color.FromArgb(255, 220, 220, 220));
stackHorizontal.Children.Add(textBlock);
Button btnAdd = new Button();
btnAdd.Content = "ADD";
btnAdd.Style = (Style)Helpers.FindResourceHelper.FindResource("InformButton");
btnAdd.Margin = new Thickness(80, 5, 5, 5);
btnAdd.Click -= new RoutedEventHandler(btnAdd_Click);
btnAdd.Click += new RoutedEventHandler(btnAdd_Click);
stackHorizontal.Children.Add(btnAdd);
stackVertical.Children.Add(stackHorizontal);
StackPanel hStack = new StackPanel();
hStack.Orientation = Orientation.Horizontal;
TextBox textbox = new TextBox();
textbox.Margin = new Thickness(5, 5, 5, 5);
textbox.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
textbox.Background = new SolidColorBrush(Color.FromArgb(255, 204, 204, 204));
textbox.Width = 200;
textbox.Height = 25;
hStack.Children.Add(textbox);
stackVertical.Children.Add(hStack);
sv.Content = stackVertical;
brd.Child = sv;
wpSecond.Children.Add(brd);
}
else
//.........这里部分代码省略.........
示例6: UPWR
//.........这里部分代码省略.........
int[] colData = new int[] { 4, 6, 7, 8, 9, 11, 13, 14 };
string[] colDx = new string[] { wSuite, wStatus, rStatus, rDate, dDate, wSummary, wProd, wCurRel };
for (int i = 0; i < colData.Length; i++) {
string undated = undate(oldRow[colData[i] - 1]);
if (undate(colDx[i]) != undated) {
if (undated != "") {
string ttemp = "Was: " + undated + Environment.NewLine + Environment.NewLine + "Now: " + colDx[i];
OldSheet.Range[getAlpha(colData[i]) + (insOffset + jets + 2), Type.Missing].Interior.ColorIndex = 6;
OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp;
} else {
string ttemp = colDx[i];
OldSheet.Cells[insOffset + jets + 2, colData[i]] = ttemp;
}
}
}
string xtemp = oldRow[9].Split(' ')[0];
OldSheet.Cells[insOffset + jets + 2, 10] = "Was: " + xtemp + Environment.NewLine + Environment.NewLine + "But it was not found" + Environment.NewLine + "Check dates, closure," + Environment.NewLine + "or linked status.";
OldSheet.Range["J" + (insOffset + jets + 2), Type.Missing].Interior.ColorIndex = 6;
OldSheet.Cells[insOffset + jets + 2, 2] = "Yes";
}
}
#endregion
int maxRf = OldSheet.UsedRange.Rows.Count;
object[,] arr = OldSheet.get_Range("C2:E" + maxRf).Value;
List<string> ProjectRow = new List<string>();
List<string> ProjectWR = new List<string>();
for (int i = 1; i < maxRf; i++) {
ProjectRow.Add(arr[i, 1].ToString());
ProjectWR.Add(arr[i, 3].ToString());
}
List<string> duplicatedWRs = ProjectWR.GroupBy(x => x)
.Where(group => group.Count() > 1)
.Select(group => group.Key).ToList();
if (duplicatedWRs.Count > 0) {
if (sheets.Count > 1) {
xlApp.DisplayAlerts = false;
OldBook.Sheets[2].Delete();
}
dpSheet = (Worksheet)sheets.Add(Type.Missing, sheets[1], Type.Missing, Type.Missing);
dpSheet.Name = "Updated Duplicate WRs";
int rowToPrint = 2;
dpSheet.Cells[1, 1] = "Duplicated" + Environment.NewLine + "WRs Found";
dpSheet.Cells[1, 2] = "Projects found linked";
dpSheet.Cells[1, 3] = "These WRs did NOT get updated correctly, and will require a manual review!";
foreach (string dWRx in duplicatedWRs) {
debug[3] = rowToPrint.ToString();
string ProjectsFound = "";
for (int i = 0; i < ProjectWR.Count; i++) {
if (dWRx == ProjectWR[i]) {
if (ProjectsFound == "") {
ProjectsFound += ProjectRow[i];
} else {
ProjectsFound += Environment.NewLine + ProjectRow[i];
}
}
}
//print this WR
dpSheet.Cells[rowToPrint, 1] = dWRx;
dpSheet.Cells[rowToPrint, 2] = ProjectsFound;
rowToPrint++;
}
dpSheet.get_Range("A:A", Type.Missing).EntireColumn.ColumnWidth = 16;
示例7: WRPR
//.........这里部分代码省略.........
rStatus = JItemsC[xWR].RequestedStatus;
rDate = JItemsC[xWR].RequestedDate;
dDate = JItemsC[xWR].DueDate;
wSummary = JItemsC[xWR].Summary;
wCurRel = JItemsC[xWR].CurrentRelease;
wIT = JItemsC[xWR].IssueType;
wStatus = JItemsC[xWR].Resolution + Environment.NewLine + JItemsC[xWR].Status;
wProd = JItemsC[xWR].Product;
wDesc = JItemsC[xWR].Description;
} string cdate = DT.createdDate.Month + "-" + DT.createdDate.Day + "-" + DT.createdDate.Year;
string[] newLine = { dtNow, "No", DT.Project, wSuite, DT.WR, wStatus, rStatus, rDate, dDate, cdate, wSummary, "'" + wDesc, wProd, wCurRel, DT.IV, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate };
//string[] newLine = { dtNow, "No", DT.Project, wSuite, DT.WR, wStatus, rStatus, rDate, dDate, cdate, wSummary, wDesc, wProd, wCurRel, DT.IV, DT.IVseverity, DT.NeedByEvent, DT.NeedByDate };//DEBUG ONLY
object[,] xlNewLine = new object[1, newLine.Length];
for (int i = 0; i < newLine.Length; i++) {
xlNewLine[0, i] = newLine[i];
}
xlR = dataSheet.Range["A" + rowCount, getAlpha(newLine.Length) + rowCount];
xlR.Value2 = xlNewLine;
rowCount++;
Dispatcher.Invoke((System.Action)delegate() {
pBar.Value += iJ;
});
}//end of magic
#region findDuplicates
int maxRf = dataSheet.UsedRange.Rows.Count;
object[,] arr = dataSheet.get_Range("C2:E" + maxRf).Value;
List<string> ProjectRow = new List<string>();
List<string> ProjectWR = new List<string>();
for (int i = 1; i < maxRf; i++) {
ProjectRow.Add(arr[i, 1].ToString());
ProjectWR.Add(arr[i, 3].ToString());
}
List<string> duplicatedWRs = ProjectWR.GroupBy(x => x)
.Where(group => group.Count() > 1)
.Select(group => group.Key).ToList();
if (duplicatedWRs.Count > 0) {
Excel.Worksheet dpSheet = (Worksheet)sheets.Add(Type.Missing, sheets[1], Type.Missing, Type.Missing);
dpSheet.Name = "Duplicated WRs";
int rowToPrint = 2;
dpSheet.Cells[1, 1] = "Duplicated" + Environment.NewLine + "WRs Found";
dpSheet.Cells[1, 2] = "Projects found linked";
foreach (string dWRx in duplicatedWRs) {
debug[3] = rowToPrint.ToString();
string ProjectsFound = "";
for (int i = 0; i < ProjectWR.Count; i++) {
if (dWRx == ProjectWR[i]) {
if (ProjectsFound == "") {
ProjectsFound += ProjectRow[i];
} else {
ProjectsFound += Environment.NewLine + ProjectRow[i];
}
}
}
//print this WR
dpSheet.Cells[rowToPrint, 1] = dWRx;
dpSheet.Cells[rowToPrint, 2] = ProjectsFound;
rowToPrint++;
}
dpSheet.get_Range("A:A", Type.Missing).EntireColumn.ColumnWidth = 16;
dpSheet.get_Range("B:B", Type.Missing).EntireColumn.ColumnWidth = 32;
dpSheet.get_Range("A:B", Type.Missing).EntireColumn.VerticalAlignment = XlVAlign.xlVAlignCenter;
dpSheet.get_Range("A:B", Type.Missing).EntireColumn.HorizontalAlignment = XlHAlign.xlHAlignCenter;
dpSheet.get_Range("A1", "B1").Cells.Font.Bold = true;
dpSheet.Select();
示例8: Menu_RedownloadItemAssets
private void Menu_RedownloadItemAssets(object sender, RoutedEventArgs e)
{
string sMessageBoxText = L10n.Message("The existing Skill Item assets will be deleted and new assets will be downloaded.")
+ "\n\n" + L10n.Message("Do you want to continue?");
var rsltMessageBox = Popup.Ask(sMessageBoxText, MessageBoxImage.Warning);
string appDataPath = AppData.GetFolder(true);
switch (rsltMessageBox)
{
case MessageBoxResult.Yes:
if (Directory.Exists(Path.Combine(appDataPath, "Data")))
{
try
{
if (Directory.Exists(Path.Combine(appDataPath, "DataBackup")))
Directory.Delete("DataBackup", true);
Directory.Move(Path.Combine(appDataPath, "Data"), Path.Combine(appDataPath, "DataBackup"));
var bases = new List<ItemBase>();
var images = new List<Tuple<string, string>>();
StartLoadingWindow();
UpdateLoadingWindow(0, 3);
ItemAssetDownloader.ExtractJewelry(bases, images);
UpdateLoadingWindow(1, 3);
ItemAssetDownloader.ExtractArmors(bases, images);
UpdateLoadingWindow(2, 3);
ItemAssetDownloader.ExtractWeapons(bases, images);
UpdateLoadingWindow(3, 3);
new System.Xml.Linq.XElement("ItemBaseList", bases.Select(b => b.Serialize())).Save(Path.Combine(AppData.GetFolder(@"Data\Equipment"), "Itemlist.xml"));
var imgroups = images.GroupBy(t => t.Item2).ToArray();
UpdateLoadingWindow(0, imgroups.Length);
var dir = AppData.GetFolder(@"Data\Equipment\Assets");
using (var client = new WebClient())
{
for (int i = 0; i < imgroups.Length; i++)
{
using (var ms = new MemoryStream(client.DownloadData(imgroups[i].Key)))
{
PngBitmapDecoder dec = new PngBitmapDecoder(ms, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
var image = dec.Frames[0];
var cropped = new CroppedBitmap(image, new Int32Rect(4, 4, image.PixelWidth - 8, image.PixelHeight - 8));
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(cropped));
using (var m = new MemoryStream())
{
encoder.Save(m);
foreach (var item in imgroups[i])
{
using (var f = File.Create(Path.Combine(dir, item.Item1 + ".png")))
{
m.Seek(0, SeekOrigin.Begin);
m.CopyTo(f);
}
}
}
UpdateLoadingWindow(i + 1, imgroups.Length);
}
}
}
foreach (var file in new DirectoryInfo(Path.Combine(appDataPath, @"DataBackup")).GetFiles())
file.CopyTo(Path.Combine(Path.Combine(appDataPath, @"Data"), file.Name));
File.Copy(Path.Combine(AppData.GetFolder(@"DataBackup\Equipment"), "Affixlist.xml"), Path.Combine(AppData.GetFolder(@"Data\Equipment"), "Affixlist.xml"));
Directory.Move(Path.Combine(appDataPath, @"DataBackup\Assets"), Path.Combine(appDataPath, @"Data\Assets"));
if (Directory.Exists(Path.Combine(appDataPath, "DataBackup")))
Directory.Delete(Path.Combine(appDataPath, "DataBackup"), true);
CloseLoadingWindow();
}
catch (Exception ex)
{
if (Directory.Exists(Path.Combine(appDataPath, "Data")))
Directory.Delete(Path.Combine(appDataPath, "Data"), true);
try
{
CloseLoadingWindow();
}
catch (Exception)
{
//Nothing
}
Directory.Move(Path.Combine(appDataPath, "DataBackup"), Path.Combine(appDataPath, "Data"));
Popup.Error(L10n.Message("Error while downloading assets."));
}
}
break;
//.........这里部分代码省略.........
示例9: BindData
private void BindData()
{
List<EmployeeContributions> employees = new List<EmployeeContributions>();
// get list item values into a strongly typed class
foreach (ListItem li in _employees)
{
employees.Add(new EmployeeContributions
{
Name = li["Title"].ToString(),
TeamName = li["Team"].ToString(),
Contributions = Convert.ToDecimal(li["Contribution_x0020__x0028_in_x00"])
});
}
// use linq to group employees on team name and then total team contributions
List<TeamContributions> teams = employees
.GroupBy(e => e.TeamName)
.Select(t => new TeamContributions
{
Name = t.Key,
Contributions = t.Sum(e => e.Contributions)
}).ToList();
chart.DataContext = teams; // must be on UI thread
}
示例10: GetBlockedCellsSprtEdgeMap
/// <summary>
/// This returns all the unique edge triangles of the cells passed in (each face of the cell cube has two triangles), and which
/// cells share each of those triangles
/// </summary>
private static Tuple<ITriangle, int[]>[] GetBlockedCellsSprtEdgeMap(Rectangle3DIndexedMapped[] cells)
{
if (cells.Length == 0)
{
return new Tuple<ITriangle, int[]>[0];
}
// Get the triangles for each cell
List<Tuple<int, Tuple<int, int, int>>> trianglesPerCell = new List<Tuple<int, Tuple<int, int, int>>>();
for (int cntr = 0; cntr < cells.Length; cntr++)
{
Tuple<int, int, int>[] trianglesOrdered = cells[cntr].GetEdgeTriangles().Select(o =>
{
int[] indices = o.IndexArray.OrderBy(p => p).ToArray(); // sorting them so they can be easily compared to other cell's triangles
return Tuple.Create(indices[0], indices[1], indices[2]);
}).
ToArray();
trianglesPerCell.AddRange(trianglesOrdered.Select(o => Tuple.Create(cntr, o)));
}
Point3D[] points = cells[0].AllPoints;
// Now group by triangle
var retVal = trianglesPerCell.GroupBy(o => o.Item2).
Select(o =>
{
ITriangle triangle = new TriangleIndexed(o.Key.Item1, o.Key.Item2, o.Key.Item3, points);
int[] correspondingCells = o.Select(p => p.Item1).Distinct().ToArray();
return Tuple.Create(triangle, correspondingCells);
}).
ToArray();
// Exit Function
return retVal;
}
示例11: btnSalesReport_Click
private void btnSalesReport_Click(object sender, RoutedEventArgs e)
{
const int PAD = 10;
string summary = "";
summary += string.Format(SALES_REPORT_FORM_HEADER, mReceipts[0].Date.ToShortDateString());
List<SalesItem> allItems = new List<SalesItem>();
mReceipts.ForEach(r =>
{
allItems.AddRange(r.SalesItems);
});
var x = allItems
.GroupBy(i => i.Item)
.Select(i => i.First());
var sortedItems = (from i in x
orderby i.Department, i.Category, i.Item
select i);
//StreamWriter csvFile = new StreamWriter(mCurrentReceiptLogFile + @".csv");
//csvFile.WriteLine("Dept,Category,Code,Name,Price,Sold,Total");
//foreach (var i in sortedItems)
//{
// double total = (from si in allItems
// where si.Item.Equals(i.Item)
// select si.Price).Sum();
// csvFile.WriteLine("{0},{1},{2},{3},{4},{5},{6}",
// i.Department,
// i.Category,
// i.Item,
// i.ItemDetail,
// i.Price,
// allItems.Count(si => si.Item.Equals(i.Item)),
// total);
//}
//csvFile.Flush();
//csvFile.Close();
double grandTotal = (from i in allItems
select i.Price).Sum();
double totalBeer = (from i in allItems
where (i.Category.Equals(Categories.BEERS))
select i.Price).Sum();
int beerCount = allItems.Count(i => i.Category.Equals(Categories.BEERS));
double totalDraft = (from i in allItems
where (i.Category.Equals(Categories.DRAFT))
select i.Price).Sum();
int draftCount = allItems.Count(i => i.Category.Equals(Categories.DRAFT));
double totalSodas = (from i in allItems
where (i.Category.Equals(Categories.SODAS) || i.Category.Equals(Categories.W_WHAT))
select i.Price).Sum();
int sodasCount = allItems.Count(i => (i.Category.Equals(Categories.SODAS) || i.Category.Equals(Categories.W_WHAT)));
double totalWine = (from i in allItems
where (i.Category.Equals(Categories.WINE))
select i.Price).Sum();
int wineCount = allItems.Count(i => i.Category.Equals(Categories.WINE));
double totalCigs = (from i in allItems
where (i.Category.Equals(Categories.CIG))
select i.Price).Sum();
int cigCount = allItems.Count(i => i.Category.Equals(Categories.CIG));
double totalSnackFoodDress = (from i in allItems
where (i.Category.Equals(Categories.SNACKS)
|| i.Category.Equals(Categories.FOOD)
|| i.Category.Equals(Categories.DRESS))
select i.Price).Sum();
int sfdCount = allItems.Count(i => i.Category.Equals(Categories.SNACKS)
|| i.Category.Equals(Categories.FOOD)
|| i.Category.Equals(Categories.DRESS));
double totalLiquor = (from i in allItems
where (i.Category.Equals(Categories.LIQUOR) ||
i.Category.Equals(Categories.CORDIA) ||
i.Category.Equals(Categories.HOUSE) ||
i.Category.Equals(Categories.C_SHOT) ||
i.Category.Equals(Categories.SHOTS) ||
i.Category.Equals(Categories.DRINKS) ||
i.Category.Equals(Categories.TINI) ||
(i.Category.Equals(Categories.MISC) && i.Department.Equals(Departments.DELI)))
select i.Price).Sum();
int liquorCount = allItems.Count(i => i.Category.Equals(Categories.LIQUOR) ||
i.Category.Equals(Categories.CORDIA) ||
i.Category.Equals(Categories.HOUSE) ||
i.Category.Equals(Categories.C_SHOT) ||
i.Category.Equals(Categories.SHOTS) ||
i.Category.Equals(Categories.DRINKS) ||
i.Category.Equals(Categories.TINI) ||
(i.Category.Equals(Categories.MISC) && i.Department.Equals(Departments.DELI)));
//.........这里部分代码省略.........
示例12: btnGenera_Click
private void btnGenera_Click(object sender, RoutedEventArgs e)
{
int anno = 0;
try
{
anno = int.Parse(txtboxAnno.Text);
}
catch (FormatException ex)
{
MessageBox.Show("L'anno dev'essere un numero intero", "Formato anno errato", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
int mese = mesi[cbxMese.Text];
DateTime arrivoDa = new DateTime(anno, mese, 1);
DateTime arrivoA = arrivoDa.AddMonths(1).AddDays(-1);
//prendi tutti i pagamenti emessi in questo mese
allPagamenti = dag.cercaPagamentiByData(arrivoDa, arrivoA);
if (allPagamenti.Count == 0)
{
MessageBox.Show("Non ci sono pagamenti registrati nel mese selezionato", "Nessun pagamento", MessageBoxButton.OK, MessageBoxImage.Information);
return;
}
btnPrint.IsEnabled = true;
var pageqcom = new PagamentiComparer();
//cerca pagamenti duplicati
var pagdups = allPagamenti.GroupBy(i => i, pageqcom)
.Where(g => g.Count() > 1)
.Select(g => g.Key).ToList<Pagamento>();
if (pagdups.Count > 0)
{
var plist = new List<Pagamento>();
foreach (var p in allPagamenti)
{
if (pagdups.Contains(p, pageqcom))
plist.Add(p);
}
pagamentiDup = new ObservableCollection<Pagamento>(plist);
//allPagamenti.Intersect<Pagamento>(pagdups, pageqcom).ToList<Pagamento>());
dataGridPagamentiDup.DataContext = pagamentiDup;
}
//cerca pagamenti a importo nullo
var pagnull = (from p in allPagamenti
where p.Totale == 0
select p).ToList<Pagamento>();
if (pagnull.Count > 0)
{
pagamentiNull = new ObservableCollection<Pagamento>(pagnull);
dataGridPagamentiNulli.DataContext = pagamentiNull;
}
//verifica progressivi mancanti
checkProgressiviMancanti(allPagamenti);
}
示例13: ViewRelation
public void ViewRelation(int max, RelationIndexType type, out List<ItemRelationViewData> list)
{
if (comunityDic == null)
{
CreateComunityDic();
}
foreach (var item in comunityDic.Values.Where(n => n.Selected == false))
{
item.NewBrush(Colors.Transparent, 1);
}
var selectedList = AllComunity.Where(n => n.Selected == true);
List<ItemRelation> relationList = new List<ItemRelation>();
foreach (var item in selectedList)
{
relationList.AddRange(item.Relations.Where(n => selectedList.Where(m => m.Id == n.ItemId).Any() == false));
}
var d = relationList.GroupBy(n => n.ItemId).Select(n => new { n.Key, a = n.Aggregate(1.0, (m, l) => l.GetIndex(type) * m) });
int half = max / 2;
int count = 0;
foreach (var item in d.OrderByDescending(n => n.a).Where(n => comunityDic.ContainsKey(n.Key) == true).Take(max))
{
if (count > half)
{
comunityDic[item.Key].NewBrush(Colors.Orange, 0.2);
}
else
{
comunityDic[item.Key].NewBrush(Colors.Orange, 0.6);
}
count++;
}
int i = 1;
list = new List<ItemRelationViewData>();
foreach (var item in d.OrderByDescending(n => n.a))
{
if (comunityDic.ContainsKey(item.Key))
{
var c = comunityDic[item.Key];
if (type == RelationIndexType.確信度)
{
list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 確信度 = item.a.ToString("F3"), });
}
else
{
list.Add(new ItemRelationViewData() { Rank = i, Name = c.Name, 補正確信度 = item.a.ToString("F3") });
}
i++;
}
}
//foreach (var item in comunity.Relations.OrderByDescending(n => n.GetIndex(type)).Take(max))
//{
// if (comunityDic.ContainsKey(item.ItemId))
// {
// if (count > half)
// {
// comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.2);
// }
// else
// {
// comunityDic[item.ItemId].NewBrush(Colors.Orange, 0.6);
// }
// count++;
// }
//}
}
示例14: SetMandatoryMappingColumns
internal void SetMandatoryMappingColumns(List<ColumnMetaInfo> _mandatoryColumns)
{
bmRequiredFields = _mandatoryColumns.GroupBy(f => f.columnName).Select(g=>g.First()).ToList();
}
示例15: printListsScreen
//used with displayAllSessionsOnViewer()
private void printListsScreen(List<string> list, ListBox listToPrint, TextBox listTotal)
{
var q1 = list.GroupBy(x => x)
.Select(g => new { Value = g.Key, Count = g.Count() })
.OrderByDescending(x => x.Count);
foreach (var x in q1) { listToPrint.Items.Add(x.Value + ": " + x.Count); }
listTotal.Text = list.Count().ToString();
}