private void ApplySortOrder( ref List<PhoneBookSearchResult> results, Library.Enums.SearchType type ) { switch (type) { case Library.Enums.SearchType.Department: results = results.OrderBy( o => o.Department ).ThenBy( o => o.FullName ).ToList(); break; case Library.Enums.SearchType.PhoneNumber: case Library.Enums.SearchType.Name: default: results = results.OrderBy( o => o.FullName ).ToList(); break; } }
private void DetalleOrden() { try { List<Clases.DetalleOrdenViewModel> detalle = new List<Clases.DetalleOrdenViewModel>(); foreach (Core.Venta.DetalleOrden item in this.orden.DetalleProducto) { detalle.Add( new Clases.DetalleOrdenViewModel(this.conexion) { DescripcionProducto = item.Producto.Descripcion, PrecioProducto = Funcion.FormatoDecimal(item.Producto.PrecioVenta), Cantidad = item.Cantidad, Imagen = item.Producto.Imagen } ); } this.dtgDetalleVenta.ItemsSource = detalle.OrderBy(x => x.DescripcionProducto); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SetGridData(List<Product> products) { Products = products; InitializeFilters(); _GridViewResult.Clear(); _GridViewResult.AddRange((from p in products.OrderBy(o => o.ProductCategory) select new ProductGridViewModel(p))); foreach (ProductGridViewModel m in _GridViewResult) { ProductsGrid.Items.Add(m); } }
// funkcja odpowiedzialna za ładowanie danych do elementów GUI private async void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { try { if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) return; db = ViewLogic.dbContext; StocktakingViewModel.Stocktaking.SelectedTab = Tab.Devs; if (db == null || loadUI == false) return; System.Windows.Data.CollectionViewSource deviceRecordViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["deviceRecordViewSource"]; await db.sprzet.LoadAsync(); List<sprzet> sprzety = db.sprzet.Local.ToList(); List<DeviceRecord> rekordy = new List<DeviceRecord>(); foreach (sprzet s in sprzety) { rekordy.Add(new DeviceRecord(s)); } deviceRecordViewSource.Source = rekordy.OrderBy(r => r.id); System.Windows.Data.CollectionViewSource sprzet_typViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["sprzet_typViewSource"]; await db.sprzet_typ.LoadAsync(); sprzet_typViewSource.Source = db.sprzet_typ.Local.ToBindingList(); System.Windows.Data.CollectionViewSource roomRecordViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["roomRecordViewSource"]; await db.sala.LoadAsync(); List<sala> sale = db.sala.Local.ToList(); List<RoomRecord> rekordyS = new List<RoomRecord>(); foreach (sala s in sale) { rekordyS.Add(new RoomRecord(s)); } roomRecordViewSource.Source = rekordyS.OrderBy(r => r.id); System.Windows.Data.CollectionViewSource zakladViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["zakladViewSource"]; await db.zaklad.LoadAsync(); zakladViewSource.Source = db.zaklad.Local.ToList(); loadUI = false; } catch (Exception) { ViewLogic.Blad("Wystapił bład w UserControl_IsVisibleChanged!"); } }
public void LoadHand(List<Kaart> kaarten) { StackPanelHand.Children.Clear(); foreach (Kaart k in kaarten.OrderBy(o => o.Soort.ID).ThenBy(o => o.Nummer)) { Bitmap bmp = (Bitmap)Properties.Resources.ResourceManager.GetObject(k.Soort.Naam.ToUpper() + "_" + k.Nummer); System.Windows.Controls.Image img = new System.Windows.Controls.Image(); img.Source = Bitmap2BitmapImage(bmp); img.Tag = k; img.MouseUp += img_MouseUp; StackPanelHand.Children.Add(img); } }
public static TimeData[] BuildTimeReport(DateTime fromDate, DateTime toDate, SortOrder so) { TimeData[] entries = TimeDataInterface.GetEntries(fromDate, toDate, so); try { bool countCalls = App.Settings.manuallyTrackRvs; if (!countCalls) return entries; RvPreviousVisitData[] calls = RvPreviousVisitsDataInterface.GetCallsByDate(fromDate, toDate); if (calls != null) { var entriesMore = new List<TimeData>(entries); foreach (var c in calls) { bool found = false; foreach (var e in entries) { if (e.Date.Date != c.Date.Date) continue; // Check for call data which happened on the same date as another service day // If it did, add the values, otherwise continue e.Magazines += c.Magazines; e.Books += c.Books; e.Brochures += c.Brochures; e.Tracts += c.Tracts; e.ReturnVisits += RvPreviousVisitsDataInterface.IsInitialCall(c) ? 0 : 1; found = true; break; } if (!found) { // We found a call, but no service time was recorded on this date entriesMore.Add(new TimeData() { Magazines = c.Magazines, Books = c.Books, Brochures = c.Brochures, Tracts = c.Tracts, Date = c.Date, ReturnVisits = RvPreviousVisitsDataInterface.IsInitialCall(c) ? 0 : 1 }); } } entries = entriesMore.OrderBy(s => s.Date).ToArray(); } return entries; } catch { return entries; } }
private void client_ExecuteAsyncCompleted(RestResponse response) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response.Content); List<Account> data = new List<Account>(); var nodes = from e in doc.DocumentNode.DescendantNodes() where e.Name == "li" && e.Attributes.Contains("class") == true && e.Attributes["class"].Value == "account" select e; foreach (HtmlNode node in nodes) { Account a = new Account(); a.Name = (from e in node.DescendantNodes() where e.Name == "span" && e.Attributes.Contains("class") == true && e.Attributes["class"].Value == "nickname" select e).First().InnerText; a.Balance = (from e in node.DescendantNodes() where e.Name == "span" && e.Attributes.Contains("class") == true && e.Attributes["class"].Value == "balance" select e).First().InnerText; a.LastUpdated = (from e in node.DescendantNodes() where e.Name == "span" && e.Attributes.Contains("class") == true && e.Attributes["class"].Value == "last-updated" select e).First().InnerText; data.Add(a); } this.listBox1.ItemsSource = data.OrderBy(i => i.Name); double total = 0.00; foreach (Account a in data) { total += Convert.ToDouble(a.Balance.Replace("$", "").Replace("–", "-")); } this.textBlock1.Text = String.Format("{0:c}", total); this.ToggleProgressBar(); }
void PopulateGrid() { ParticipantResults = new List<ParticipantResult>(); foreach (Participant p in Participants) { // todo: make this less dependant on `Places` if (Places.ContainsKey(p.Id)) ParticipantResults.Add(new ParticipantResult(p, Places[p.Id])); else ParticipantResults.Add(new ParticipantResult(p)); } ParticipantResults = ParticipantResults.OrderBy(p => p.LastName).ToList(); dataGridResults.ItemsSource = ParticipantResults; }
internal static ToolBarPositionInfo CalculateToolBarPositionInfo(RadToolBar sourceToolBar, RadToolBarTray tray, Point mousePosition) { var band = CalculateBand(sourceToolBar, tray, mousePosition); List<RadToolBar> toolBars = new List<RadToolBar>(); foreach (RadToolBar toolBar in tray.Items) { if (toolBar != sourceToolBar && toolBar.Band == band.Band) { toolBars.Add(toolBar); } } toolBars = toolBars.OrderBy(tb => tb.BandIndex).ToList(); int bandIndex = CalculateBandIndex(tray.Orientation, sourceToolBar, toolBars, mousePosition); return new ToolBarPositionInfo(band.Band, band.NewBand, bandIndex, toolBars); }
private void GetJournalsByCropIdCompleted(List<JournalModel> journals) { List<JournalModel> journalsWithImage = new List<JournalModel>(); foreach (JournalModel jm in journals) { byte[] photoByte = jm.Photo; if (photoByte != null) { using (MemoryStream ms = new MemoryStream(photoByte)) { BitmapImage bmpImage = new BitmapImage(); bmpImage.SetSource(ms); jm.BitmapPhoto = bmpImage; } } journalsWithImage.Add(jm); } journalListBox.ItemsSource = journalsWithImage.OrderBy(x => x.DateEntered).ToList(); }
public void RandomLayout() { foreach (var item in ClusterTable.LayerGroup) { List<Models.Comunity> comunityList = new List<Models.Comunity>(); List<Models.Layer> layerList = new List<Models.Layer>(); foreach (var layer in item.Items) { layerList.Add(layer); comunityList.AddRange(layer.Comunities); layer.Comunities.Clear(); } int c = 0; foreach (var comunity in comunityList.OrderBy(n=>new Guid())) { layerList[c % layerList.Count].Comunities.Add(comunity); c++; } } }
private void GenerateColumns(DataGrid dataGrid, List<RowViewModel> rows, List<RuleViewModel> rules) { if (dataGrid == null || rows.Count == 0) return; var nameColumn = dataGrid.Columns.First(); dataGrid.Columns.Clear(); dataGrid.Columns.Add(nameColumn); var sortedRules = rules.OrderBy(cur => cur.Index); foreach(var rule in sortedRules) { dataGrid.Columns.Add(new DataGridTemplateColumn { Header = rule, HeaderTemplateSelector = RuleSelectorHeaderTemplateSelector.Instance, CellTemplateSelector = DTReadOnlyCellTemplateSelector.Instance, MinWidth = 70 }); } }
/* ALL CHECKED */ private void allChecked(object sender, RoutedEventArgs e) { if (salesList != null) { inStockFilter.IsChecked = false; dairyFilter.IsChecked = false; bakeryFilter.IsChecked = false; meatFilter.IsChecked = false; produceFilter.IsChecked = false; salesList = initResults; if (sortAZ.IsSelected) { salesList = salesList.OrderBy(Items => Items.name).ToList(); } if (sortZA.IsSelected) { salesList = salesList.OrderBy(Items => Items.name).Reverse().ToList(); } if (sortLoHi.IsSelected) { salesList = salesList.OrderBy(Items => Items.price).ToList(); } if (sortHiLo.IsSelected) { salesList = salesList.OrderBy(Items => Items.price).Reverse().ToList(); } if (sortLoc.IsSelected) { salesList = salesList.OrderBy(Items => Items.location).ToList(); } salesListBox.ItemsSource = salesList; } }
//metoda uruchamiajaca sie wtedy gdy zostanie zmieniona widocznosc zakladki oraz gdy //uzytkownik przejdzie na ta zakladke //ladowane tutaj sa rekordy do gridow oraz inne typy do comboboxa private async void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { try { if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) return; db = ViewLogic.dbContext; StocktakingViewModel.Stocktaking.SelectedTab = Tab.UsrAcc; if (db == null || loadUI == false) return; System.Windows.Data.CollectionViewSource userRecordViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("userRecordViewSource"))); List<UserRecord> rekordy = new List<UserRecord>(); await db.konto.LoadAsync();//operacja asynchroniczna List<konto> konta = db.konto.Local.ToList(); foreach (konto k in konta) { rekordy.Add(new UserRecord(k)); } userRecordViewSource.Source = rekordy.OrderBy(r => r.id); System.Windows.Data.CollectionViewSource konto_typViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("konto_typViewSource"))); await db.konto_typ.LoadAsync();//operacja asynchroniczna konto_typViewSource.Source = db.konto_typ.Local.ToBindingList().OrderBy(t => t.id); typComboBox.ItemsSource = db.konto_typ.Local.ToList().OrderBy(t => t.id); System.Windows.Data.CollectionViewSource pracownikViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("pracownikViewSource"))); pracownikViewSource.Source = await db.pracownik.Where(p => p.konto.Count == 0).ToListAsync();//operacja asnychroniczna loadUI = false; } catch (Exception) { ViewLogic.Blad("Wystapił bład w UserControl_IsVisibleChanged!"); } }
/// <summary> /// Populates the layout radio buttons from disk. /// </summary> private void PopulateLayoutRadioButtonsFromDisk() { List<RadioButton> radioButtonList = new List<RadioButton>(); var rockConfig = RockConfig.Load(); List<string> filenameList = Directory.GetFiles( ".", "*.dplx" ).ToList(); foreach ( var fileName in filenameList ) { DplxFile dplxFile = new DplxFile( fileName ); DocumentLayout documentLayout = new DocumentLayout( dplxFile ); RadioButton radLayout = new RadioButton(); if ( !string.IsNullOrWhiteSpace( documentLayout.Title ) ) { radLayout.Content = documentLayout.Title.Trim(); } else { radLayout.Content = fileName; } radLayout.Tag = fileName; radLayout.IsChecked = rockConfig.LayoutFile == fileName; radioButtonList.Add( radLayout ); } if ( !radioButtonList.Any( a => a.IsChecked ?? false ) ) { if ( radioButtonList.FirstOrDefault() != null ) { radioButtonList.First().IsChecked = true; } } lstLayouts.Items.Clear(); foreach ( var item in radioButtonList.OrderBy( a => a.Content ) ) { lstLayouts.Items.Add( item ); } }
private void SetupCultures() { var cultureDataDict = CultureInfo.GetCultures(CultureTypes.AllCultures) .OrderBy(c => c.Name) .Select(c => new CultureData { CultureInfo = c, SubCultures = new List<CultureData>() }) .ToDictionary(c => c.CultureInfo.Name); var rootCultures = new List<CultureData>(); foreach (var cd in cultureDataDict.Values) { if (cd.CultureInfo.Parent.LCID == 127) { rootCultures.Add(cd); } else { CultureData parentCultureData; if (cultureDataDict.TryGetValue(cd.CultureInfo.Parent.Name, out parentCultureData)) { parentCultureData.SubCultures.Add(cd); } else { throw new ParentCultureException( "unexpected error - parent culture not found"); } } } this.DataContext = rootCultures.OrderBy(cd => cd.CultureInfo.EnglishName); }
void LoadCitiesBase() { var path = AppDomain.CurrentDomain.BaseDirectory; var root = Path.GetPathRoot(path); bool fileExists = false; if (File.Exists(Path.Combine(path, JsonFileName))) { fileExists = true; } else { while (path != "" && path != root) { path = Directory.GetParent(path).ToString(); if (File.Exists(Path.Combine(path, JsonFileName))) { fileExists = true; break; } } } if (fileExists) { var resultList = new List<string>(); using (var reader = new StreamReader(Path.Combine(path, JsonFileName))) { string line = ""; JavaScriptSerializer js = new JavaScriptSerializer(); while (( line = reader.ReadLine() ) != null) { var dict = js.Deserialize<Dictionary<string, string>>(line); if (dict.ContainsKey("city")) { resultList.Add(dict["city"]); } } } resultList = resultList.ConvertAll(x => x.ToLower()); _locations = resultList.OrderBy(x => x).ToArray(); } else { MessageBox.Show(JsonFileName + " not found"); } }
private void dockControl_ViewChanged(object sender, EventArgs e) { var list = new List<C1MenuItem>(); foreach (var nestedTabControl in dockControl.NestedItems) { var tabControl = nestedTabControl; // must be fresh each loop iteration because of the delegate if (tabControl == MainArea) continue; foreach (var item in tabControl.Items) { var tabItem = (C1DockTabItem)item; // must be fresh each loop iteration because of the delegate var menuItem = new C1MenuItem(); menuItem.Header = tabItem.Header; menuItem.Click += delegate { switch (tabControl.DockMode) { case DockMode.Hidden: tabControl.DockMode = DockMode.Docked; break; case DockMode.Sliding: tabControl.SlideOpen(); break; } tabItem.IsSelected = true; }; list.Add(menuItem); } } ViewMenuItem.Items.Clear(); foreach (var menuItem in list.OrderBy(mi => mi.Header)) { ViewMenuItem.Items.Add(menuItem); } }
private void MouseWheel_Handler(object sender, MouseWheelEventArgs e) { double delta = (e.Delta/(120*0.5)); zoom -= delta; starSystemList = starSystemCollection.UpdateStarSystemList(currentSystem.id, -zoom, zoom); starList = starSystemCollection.BuildStarList(starSystemList); starList.OrderBy(order => order.projectPoint.Z); RenderStars(); UpdateRender(); }
public void ReorderViews() { // get all children var children = new List<DynamicBlockView>(); foreach (var elem in StackPanel.Children) children.Add((DynamicBlockView)elem); // order by index children = children.OrderBy(x => x.Model.Index).ToList(); // clear the panel StackPanel.Children.Clear(); // re-insert in correct order foreach (var elem in children) StackPanel.Children.Add(elem); }
//creates the page private void createPage(List<Airport> airports) { this.AllAirlines = new List<Airline>(); this.SelectedAirports = new ObservableCollection<AirportMVVM>(); this.RoutesRanges = new List<FilterValue>() { new FilterValue("0",0,0),new FilterValue("1-9",1,9), new FilterValue("10-24",10,24),new FilterValue("25+",25,int.MaxValue) }; this.OperatingRanges = new List<FilterValue>() { new FilterValue("0", 0, 0), new FilterValue("1-5", 1, 5), new FilterValue("6+", 5, int.MaxValue) }; Airline dummyAirline = new Airline(new AirlineProfile("All Airlines", "99", "Blue", "", false, 1900, 1900), Airline.AirlineMentality.Safe, Airline.AirlineFocus.Domestic, Airline.AirlineLicense.Domestic, Route.RouteType.Passenger); dummyAirline.Profile.addLogo(new AirlineLogo(AppSettings.getDataPath() + "\\graphics\\airlinelogos\\default.png")); this.AllAirlines.Add(dummyAirline); foreach (Airline airline in Airlines.GetAllAirlines().Where(a => a != GameObject.GetInstance().HumanAirline).OrderBy(a=>a.Profile.Name)) this.AllAirlines.Add(airline); this.AllAirports = new List<AirportMVVM>(); foreach (Airport airport in airports.OrderBy(a=>a.Profile.Name)) this.AllAirports.Add(new AirportMVVM(airport)); AirlinerType dummyAircraft = new AirlinerCargoType(new Manufacturer("Dummy", "", null,false), "All Aircrafts", "", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, AirlinerType.BodyType.Single_Aisle, AirlinerType.TypeRange.Regional, AirlinerType.EngineType.Jet, new Period<DateTime>(DateTime.Now,DateTime.Now), 0,false); this.HumanAircrafts = new List<AirlinerType>(); this.HumanAircrafts.Add(dummyAircraft); foreach (AirlinerType type in GameObject.GetInstance().HumanAirline.Fleet.Select(f => f.Airliner.Type).Distinct()) this.HumanAircrafts.Add(type); InitializeComponent(); TabControl tab_main = UIHelpers.FindChild<TabControl>(this.Tag as Page, "tabMenu"); if (tab_main != null) { var matchingItem = tab_main.Items.Cast<TabItem>() .Where(item => item.Tag.ToString() == "Airports") .FirstOrDefault(); //matchingItem.IsSelected = true; tab_main.SelectedItem = matchingItem; } }
//shows the list of used airliners for sale private void showUsedAirliners() { lbUsedAirliners.Items.Clear(); var lAirliners = new List<Airliner>(airliners.FindAll(a => a.Type.TypeAirliner == airlinerType)); if (sortDescending) lAirliners = lAirliners.OrderByDescending(sortCriteriaUsed).ThenBy(a => a.TailNumber).ToList(); else lAirliners = lAirliners.OrderBy(sortCriteriaUsed).ThenBy(a => a.TailNumber).ToList(); foreach (Airliner airliner in lAirliners) lbUsedAirliners.Items.Add(airliner); }
/// <summary> /// 绑定组织架构节点 /// </summary> private void BindCompany() { try { treeOrganization.Items.Clear(); allCompanys = Application.Current.Resources["ORGTREESYSCompanyInfo" + Perm + Entity] as List<T_HR_COMPANY>; allDepartments = Application.Current.Resources["ORGTREESYSDepartmentInfo" + Perm + Entity] as List<T_HR_DEPARTMENT>; if (allCompanys == null) { loadbar.Stop(); return; } //根据传值不同去不同的信息 if (IsOrganizationHistory) { allCompanys = allCompanys.Where(s => s.EDITSTATE != "0").ToList(); allCompanys = allCompanys.OrderBy(s => s.SORTINDEX).ToList(); if (allDepartments != null) { allDepartments = allDepartments.Where(s => s.EDITSTATE != "0").ToList(); allDepartments = allDepartments.OrderBy(s => s.SORTINDEX).ToList(); } } else { allCompanys = allCompanys.Where(s => s.EDITSTATE == "1").ToList(); allCompanys = allCompanys.OrderBy(s => s.SORTINDEX).ToList(); if (allDepartments != null) { allDepartments = allDepartments.Where(s => s.EDITSTATE == "1").ToList(); allDepartments = allDepartments.OrderBy(s => s.SORTINDEX).ToList(); } } List<T_HR_COMPANY> TopCompany = new List<T_HR_COMPANY>(); foreach (T_HR_COMPANY tmpOrg in allCompanys) { //如果当前公司没有父机构的ID,则为顶级公司 if (string.IsNullOrWhiteSpace(tmpOrg.FATHERID)) { TreeViewItem item = new TreeViewItem(); SolidColorBrush brush = new SolidColorBrush(); //没生效的为红色 if (tmpOrg.EDITSTATE != ((int)EditStates.Actived).ToString()) { brush.Color = Colors.Red; item.Foreground = brush; } else { brush.Color = Colors.Black; item.Foreground = brush; } item.Header = tmpOrg.CNAME; // item.Header = tmpOrg.BRIEFNAME; item.HeaderTemplate = treeViewItemTemplate; item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style; ToolTipService.SetToolTip(item, "公司"); ExtOrgObj obj = new ExtOrgObj(); obj.ObjectInstance = tmpOrg; item.DataContext = obj; //标记为公司 item.Tag = OrgTreeItemTypes.Company; treeOrganization.Items.Add(item); TopCompany.Add(tmpOrg); } else { //查询当前公司是否在公司集合内有父公司存在 var ent = from c in allCompanys where c.COMPANYID == tmpOrg.FATHERID && tmpOrg.FATHERTYPE == "0" select c; var ent2 = from c in allDepartments where tmpOrg.FATHERTYPE == "1" && tmpOrg.FATHERID == c.DEPARTMENTID select c; //如果不存在,则为顶级公司 if (ent.Count() == 0 && ent2.Count() == 0) { TreeViewItem item = new TreeViewItem(); SolidColorBrush brush = new SolidColorBrush(); if (tmpOrg.EDITSTATE != ((int)EditStates.Actived).ToString()) { brush.Color = Colors.Red; item.Foreground = brush; } else { brush.Color = Colors.Black; item.Foreground = brush; } item.Header = tmpOrg.CNAME; //item.Header = tmpOrg.BRIEFNAME; item.HeaderTemplate = treeViewItemTemplate; ; item.Style = Application.Current.Resources["TreeViewItemStyle"] as Style; ToolTipService.SetToolTip(item, "公司"); ExtOrgObj obj = new ExtOrgObj(); obj.ObjectInstance = tmpOrg; item.DataContext = obj; //标记为公司 item.Tag = OrgTreeItemTypes.Company; treeOrganization.Items.Add(item); TopCompany.Add(tmpOrg); } } } //开始递归 foreach (var topComp in TopCompany) { TreeViewItem parentItem = GetParentItem(OrgTreeItemTypes.Company, topComp.COMPANYID); List<T_HR_COMPANY> lsCompany = (from ent in allCompanys where ent.FATHERTYPE == "0" && ent.FATHERID == topComp.COMPANYID select ent).ToList(); List<T_HR_DEPARTMENT> lsDepartment = (from ent in allDepartments where ent.FATHERID == topComp.COMPANYID && ent.FATHERTYPE == "0" select ent).ToList(); AddOrgNode(lsCompany, lsDepartment, parentItem); } } catch (Exception ex) { string ss = ex.ToString(); } }
private void loadPrograms() { ProgrammeHelper client = new ProgrammeHelper(); try { List<Program> progList = client.ViewProgram(eventDay_.DayID).ToList<Program>(); DateTime curr = eventDay_.StartDateTime; DateTime end = eventDay_.EndDateTime; List<Program> newprogList = new List<Program>(); while (curr.CompareTo(end) < 0) { for (int i = 0; i < progList.Count; i++) { if (progList[i].StartDateTime.CompareTo(curr) == 0) { newprogList.Add(progList[i]); curr = progList[i].EndDateTime; goto next; } } Program p = new Program(); p.Name = ""; p.StartDateTime = curr; p.EndDateTime = curr.AddMinutes(30); newprogList.Add(p); curr = curr.AddMinutes(30); next: continue; } lstProgram.ItemsSource = newprogList.OrderBy(x => x.StartDateTime) .ThenBy(x => x.EndDateTime).ToList<Program>(); lstProgram.SelectedIndex = -1; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { client.Close(); } }
private void LoadFilters() { this.Filters = new FilterCollection(); this.Filters.Add(new Filter { Name = "Users", Caption = "Users" }); this.Filters.Add(new Filter { Name = "Projects", Caption = "Projects" }); List<string> names; names = new List<string>(); // load users foreach (var userName in this.Hours.Select(row => row.User.Name).Distinct().Where(userName => !names.Contains(userName))) { names.Add(userName); } foreach (var userName in this.Invoices.Select(row => row.Task.AssignedTo.Name).Distinct().Where(userName => !names.Contains(userName))) { names.Add(userName); } foreach (var name in names.OrderBy(row => row)) { this.LoadFilter("Users", name); } names = new List<string>(); // load projects foreach (var projectName in this.Hours.Select(row => row.Project.Name).Distinct().Where(projectName => !names.Contains(projectName))) { names.Add(projectName); } foreach (var projectName in this.Invoices.Select(row => row.Project.Name).Distinct().Where(projectName => !names.Contains(projectName))) { names.Add(projectName); } foreach (var name in names.OrderBy(row => row)) { this.LoadFilter("Projects", name); } if (this.FiltersChanged != null) { this.FiltersChanged(this, new EventArgs()); } this.ApplyFilters(); }
public static void Sort(this DataGrid dg, Type cTypeOfElement, string sFieldName, bool bBackward) { System.Reflection.PropertyInfo cHeader = (System.Reflection.PropertyInfo)cTypeOfElement.GetMember(sFieldName)[0]; List<ObjectForSort> aOFS = new List<ObjectForSort>(); foreach (object oOFS in dg.ItemsSource) aOFS.Add(new ObjectForSort() { o = oOFS, oValue = cHeader.GetValue(oOFS, null) }); if (bBackward) dg.ItemsSource = aOFS.OrderByDescending(o => o.oValue).Select(o => o.o).ToList(); else dg.ItemsSource = aOFS.OrderBy(o => o.oValue).Select(o => o.o).ToList(); }
public IList<ImportValidationResultInfo> ValidateAndSave(List<PricingImport> entities) { int batchSize = Convert.ToInt32(0.2 * entities.Count); var productPricingImports = entities.OrderBy(p => p.ProductCode).Batch(batchSize).Select(x => x.ToList()).ToList(); #region Contruct Items var taskArray = new Task<IEnumerable<ProductPricing>>[productPricingImports.Count]; var results = new List<ProductPricing>(); try { for (int i = 0; i < taskArray.Length; i++) { var current = productPricingImports.FirstOrDefault(); if (current != null && current.Any()) { //taskArray[i] = Task<IEnumerable<ProductPricing>>.Factory.StartNew(() => ConstructDomainEntities(current)); ConstructDomainEntities(current); productPricingImports.Remove(current); } } foreach (var result in taskArray.Select(n => n.Result).ToList()) { results.AddRange(result); } } catch (AggregateException ex) { } #endregion #region Validate var validationResults = new List<ImportValidationResultInfo>(); if (results.Any()) { batchSize = Convert.ToInt32(0.2 * results.Count); var products = results.OrderBy(p => p.CurrentEffectiveDate).Batch(batchSize).Select(x => x.ToList()).ToList(); var validationTaskArray = new Task<ImportValidationResultInfo[]>[products.Count]; try { for (int i = 0; i < validationTaskArray.Length; i++) { var current = products.FirstOrDefault(); if (current != null && current.Any()) { validationTaskArray[i] = Task<ImportValidationResultInfo[]>.Factory.StartNew(() => ValidatePricings(current)); products.Remove(current); } } foreach (var result in validationTaskArray.Select(n => n.Result).ToList()) { validationResults.AddRange(result); } } catch (AggregateException ex) { } } #endregion #region Save valid Items var validatedPricings = validationResults.Where(n => n.IsValid).Select(n => (ProductPricing)n.Entity).ToList(); if (validatedPricings.Any()) { batchSize = Convert.ToInt32(0.2 * validatedPricings.Count); var products = validatedPricings.OrderBy(p => p.CurrentEffectiveDate).Batch(batchSize).Select(x => x.ToList()).ToList(); var saveTasksArray = new Task<Guid[]>[products.Count]; try { for (int i = 0; i < saveTasksArray.Length; i++) { var current = products.FirstOrDefault(); if (current != null && current.Any()) { saveTasksArray[i] = Task<Guid[]>.Factory.StartNew(() => SaveProductPricings(current)); products.Remove(current); } } var savedResults = new List<Guid>(); foreach (var result in saveTasksArray.Select(n => n.Result).ToList()) { savedResults.AddRange(result); } } catch (AggregateException ex) { } } #endregion return validationResults.Where(p => !p.IsValid).ToList(); }
protected override IReportData FillData(DateTime startTime, DateTime endTime, PeriodTypeValues period) { string header = PeriodTypes.GetString(period) + " raport produkcji z "; switch (period) { case PeriodTypeValues.Daily: { header += "dnia " + startTime.ToShortDateString(); break; } case PeriodTypeValues.Monthly: { header += "miesiąca " + startTime.Month.ToString(); break; } case PeriodTypeValues.Custom: { header += "okresu od: " + startTime.ToShortDateString() + " do: " + endTime.ToShortDateString(); break; } } ProductionReportData result = new ProductionReportData() {Header = header}; using (IReportsService service = ServiceFactory.GetReportsService()) { List<DeliveryNoteReportPackage> deliveryNoteReportPackageList = service.GetDeliveryNoteReportPackageListByDateTime(startTime, endTime); var groups = deliveryNoteReportPackageList.GroupBy(x => (x.Recipe != null) ? x.Recipe.Id : 0).AsEnumerable(); double amountAllElements = 0; List<ProductionReportSubData> productionReportSubDatas = new List<ProductionReportSubData>(); foreach (var group in groups) { if (group.Count() <= 0) break; if (group.FirstOrDefault() == null) break; string recipeCode = "0"; string recipeName = "NotDefined"; if (group.FirstOrDefault().Recipe != null) { recipeName = group.FirstOrDefault().Recipe.Name; recipeCode = group.FirstOrDefault().Recipe.Code; } double amountOfElement = 0; foreach (var elementGroup in group) { if (elementGroup != null && elementGroup.DeliveryNote != null && !elementGroup.DeliveryNote.IsDeactive && !elementGroup.DeliveryNote.IsDeleted) { amountOfElement += elementGroup.DeliveryNote.Amount ?? 0; } } amountAllElements += amountOfElement; productionReportSubDatas.Add(new ProductionReportSubData() {RecipeCode = recipeCode, RecipeName = recipeName, Amount = amountOfElement.ToString()}); Debug.WriteLine("Code: " + recipeCode + " Nazwa recepty: " + recipeName + ", GroupKey:" + group.Key + ", GroupCount: " + group.Count() + ", Ilość: " + amountOfElement + " m3"); } result.Items = productionReportSubDatas.OrderBy(x => x.RecipeCode).ToList(); result.Sum = amountAllElements.ToString(); } return result; }
private void FetchSubCategories() { const int pagesToCheckForSubCategories = 200; var categoriesContents = new List<CategoriesContent>(); string urlToFetch = cmbCategories.SelectedValue.ToString(); prgCategory.Maximum = pagesToCheckForSubCategories; prgCategory.Value = 1; string retrievedHTML = RetrieveData(urlToFetch); categoriesContents.AddRange(FetchSelectedCategoryContent(retrievedHTML)); for (int i = 2; i < pagesToCheckForSubCategories; i++)//Checks the no of pages where from different individual star celebrity names can be found. { string url = urlToFetch + "?order=n&page=" + i; retrievedHTML = RetrieveData(url); prgCategory.Value = i; categoriesContents.AddRange(FetchSelectedCategoryContent(retrievedHTML)); } var categoriesContentsToBind = new List<CategoriesContent>(); foreach (var categoriesContent in categoriesContents) { var content = categoriesContent; if (categoriesContentsToBind.Where(i => i.Name == content.Name).ToList().Count == 0) { var webSite = new WebSite(); webSite.AddSubCategoriesCategories(categoriesContent.Name, categoriesContent.URL); categoriesContentsToBind.Add(categoriesContent); } } cmbSubCategories.ItemsSource = categoriesContentsToBind.OrderBy(val => val.Name).ToList(); }
private void RepUI_C_tile_PreviewMouseDown(object sender, MouseButtonEventArgs e) { reports.IsEnabled = true; reports.Visibility = Visibility.Visible; //sample adding data on tables List<User> items = new List<User>(); items.Add(new User() { Date = new DateTime(2005, 8, 20), Time = new DateTime(1, 1, 1, 11, 00, 00), userName = "******", Event = "dsasfgjdsfjdsakfsafdk" }); items.Add(new User() { Date = new DateTime(2012, 8, 23), Time = new DateTime(1, 1, 1, 11, 30, 00), userName = "******", Event = "dsasfgjdsfjdsakfsafdsaddk" }); items.Add(new User() { Date = new DateTime(2013, 8, 10), Time = new DateTime(1, 1, 1, 11, 02, 00), userName = "******", Event = "dsasdsadsadsadfgjdsfjdsakfsafdsaddk" }); items.Add(new User() { Date = new DateTime(2015, 8, 30), Time = new DateTime(1, 1, 1, 11, 50, 00), userName = "******", Event = "aaaaaaadsasdsadsadsadfgjdsfjdsakfsafdsaddk" }); //reports.ItemsSource = items; reports.ItemsSource = items.OrderBy(item => item.Date).ToArray(); AnimationSet.Completed += (object s, EventArgs ex) => { AnimationSet.Add(tiles_grid, AnimationKind.TranslateY, AnimationFactory.Create(AnimationType.DoubleAnimation, -150.0, TimeSpan.FromMilliseconds(300), TimeSpan.FromMilliseconds(0))); AnimationSet.Add(close_btn, AnimationKind.Opacity, AnimationFactory.Create(AnimationType.DoubleAnimation, 100.0, TimeSpan.FromMilliseconds(100000), TimeSpan.FromMilliseconds(0))); AnimationSet.Add(reports, AnimationKind.Opacity, AnimationFactory.Create(AnimationType.DoubleAnimation, 100.0, TimeSpan.FromMilliseconds(100000), TimeSpan.FromMilliseconds(500))); AnimationSet.Run(); }; AnimationSet.Add(property_lbl, AnimationKind.TranslateY, AnimationFactory.Create(AnimationType.DoubleAnimation, -50.0, TimeSpan.FromMilliseconds(300), TimeSpan.FromMilliseconds(0))); AnimationSet.Run(); RepUI_C_tile.Background= new SolidColorBrush(Color.FromArgb(80,54,102,180)); RepUI_W_tile.Background = new SolidColorBrush(Color.FromArgb(80, 67, 178, 226)); RepUI_M_tile.Background = new SolidColorBrush(Color.FromArgb(80, 67, 178, 226)); RepUI_Y_tile.Background = new SolidColorBrush(Color.FromArgb(80, 67, 178, 226)); RepUI_D_tile.Background = new SolidColorBrush(Color.FromArgb(80, 67, 178, 226)); close_btn.IsEnabled = true; MessageBox.Show("I dont know what to put here.", "No Idea", MessageBoxButton.OK, MessageBoxImage.Information); }