private void BuildFromNode(ISceneGraphNode node, TreeViewItem parentItem, SearchingScope search) { TreeViewItem item = null; switch (node) { case EntityNode entityNode: { item = new EntityItem(m_Session, entityNode.Entity, entityNode.Guid, entityNode); if (search.IsSearching) { if (search.Map.TryGetValue(entityNode.Entity, out _)) { parentItem.AddChild(item); } } else { parentItem.AddChild(item); } } break; } if (null == item) { return; } foreach (var child in node.Children) { BuildFromNode(child, string.IsNullOrEmpty(m_FilterString) ? item : parentItem, search); } }
protected override TreeViewItem BuildRoot() { // TODO:Remove m_CachedSceneItems.Clear(); using (var searching = new SearchingScope(IsSearching, m_HierarchySearchFilter)) { var root = new HierarchyItem { id = int.MaxValue, depth = -1, displayName = "Root" }; for (var i = 0; i < m_SceneManager.LoadedSceneCount; ++i) { var scene = m_SceneManager.GetLoadedSceneAtIndex(i); if (m_CachedSceneItems.TryGetValue(scene.SceneGuid, out var item)) { root.AddChild(item); } else { root.AddChild(LoadScene(scene, searching)); } } if (m_SceneManager.LoadedSceneCount == 0) { root.AddChild(new TreeViewItem(0, 0, "No scene loaded")); } ShouldReload = false; return(root); } }
private TreeViewItem LoadScene(Scene scene, SearchingScope search) { var graph = m_SceneManager.GetGraphForScene(scene); var item = new SceneItem(m_Session, graph); foreach (var node in graph.Roots) { BuildFromNode(node, item, search); } m_CachedSceneItems[scene.SceneGuid] = item; return(item); }
public string BuildeOnlySearchingScope(SearchingScope? scopreToFireChanging = null) { string format = "{0} ~ {1}"; scopreToFireChanging = scopreToFireChanging ?? this.SearchingScope; if (scopreToFireChanging == TinyMoneyManager.Component.SearchingScope.All) { return LocalizedStrings.GetLanguageInfoByKey("All"); } format = string.Format(format, this.StartDate.GetValueOrDefault().ToShortDateString(), this.EndDate.GetValueOrDefault().ToShortDateString()); if (scopreToFireChanging != TinyMoneyManager.Component.SearchingScope.Today) { return string.Format("{0}({1})", LocalizedStrings.GetLanguageInfoByKey(scopreToFireChanging.Value.ToString()), format); } if (scopreToFireChanging != TinyMoneyManager.Component.SearchingScope.Customize) { format = LocalizedStrings.GetLanguageInfoByKey(scopreToFireChanging.Value.ToString()) + "(" + System.DateTime.Now.Date.ToLongDateString() + ")"; } return format; }
/// <summary> /// Counts for settle amount for budget project. /// </summary> /// <param name="project">The project.</param> /// <param name="scope">The scope.</param> /// <returns></returns> public decimal CountForSettleAmountForBudgetProject(BudgetProject project, SearchingScope scope = SearchingScope.CurrentMonth) { if (project.BudgetItems == null || project.BudgetItems.Count == 0) { return 0.0m; } DetailsCondition dc = new DetailsCondition(); dc.SearchingScope = scope; var result = 0.0m; foreach (var category in project.BudgetItems) { result += CountSumOfBudgetItems(category, dc); } return result; }
/// <summary> /// Counts for last settle amount for category. The value is represent in global currency rate by the default currency type. /// </summary> /// <param name="budgetItem">The budget item.</param> /// <returns></returns> public decimal CountForLastSettleAmountForCategory(BudgetItem budgetItem, SearchingScope scope = SearchingScope.LastMonth) { DetailsCondition dc = new DetailsCondition(); dc.SearchingScope = scope; return CountSumOfBudgetItems(budgetItem, dc); }
/// <summary> /// Loads the budget monthly report. /// </summary> /// <param name="itemType">Type of the item.</param> /// <param name="searchingScope">The searching scope.</param> /// <returns></returns> public SummaryDetails LoadBudgetMonthlyReport(ItemType itemType, SearchingScope searchingScope) { var date = DateTime.Now.Date.GetFirstDayOfMonth().Date; var totalAmount = AccountBookDataContext.BudgetProjects.Where(p => p.ItemType == itemType ).Select(p => p.TotalAmount) .AsEnumerable().Sum(); return new SummaryDetails() { AccountItemType = itemType, TotalAmout = totalAmount, Date = date, Count = 1, Name = "{0}".FormatWith(date.ToString(LocalizedStrings.CultureName.DateTimeFormat.YearMonthPattern, LocalizedStrings.CultureName)), }; }
/// <summary> /// Initializes the start date and end date by search scope. /// </summary> /// <param name="calculatingContext">The calculating context.</param> /// <param name="scope">The scope.</param> /// <param name="startDateOffset">The start date offset.</param> /// <param name="endDateOffset">The end date offset.</param> private static void initializeStartDateAndEndDateBySearchScope(DetailsCondition calculatingContext, SearchingScope? scope = null, DateTime? startDateOffset = null, DateTime? endDateOffset = null) { if (startDateOffset == null) { startDateOffset = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1, 0, 0, 0); } if (endDateOffset == null) { endDateOffset = startDateOffset.Value.GetLastDayOfMonth(); } var offsetStartDate = startDateOffset.Value; var offsetEndDate = endDateOffset.Value; int startDay, startMonth, startYear; int endDay, endMonth, endYear; var isCustomized = AppSetting.Instance.BudgetStatsicSettings.BudgetStatsicMode == BudgetStatsicMode.BudgetStaticModeOfCustomized; var needToCalculateAgagin = true; if (startDateOffset == null && endDateOffset == null && (AppSetting.Instance.BudgetStatsicSettings.BudgetStatsicMode == BudgetStatsicMode.BudgetStaticModeOfCustomized)) { needToCalculateAgagin = false; offsetStartDate = AppSetting.Instance.BudgetStatsicSettings.StartDate; offsetEndDate = AppSetting.Instance.BudgetStatsicSettings.EndDate; } startDay = offsetStartDate.Day; startMonth = offsetStartDate.Month; startYear = offsetStartDate.Year; endDay = offsetEndDate.Day; endMonth = offsetEndDate.Month; endYear = offsetEndDate.Year; if (AppSetting.Instance.BudgetStatsicSettings.BudgetStatsicMode == BudgetStatsicMode.BudgetStaticModeOfCustomized) { needToCalculateAgagin = false; startDay = AppSetting.Instance.BudgetStatsicSettings.StartDate.Day; endDay = AppSetting.Instance.BudgetStatsicSettings.EndDate.Day; } if (scope == null && calculatingContext != null) { scope = calculatingContext.searchingScope; } else if (scope == null) { scope = SearchingScope.CurrentMonth; } var l_searchingScopr = scope; if (l_searchingScopr == TinyMoneyManager.Component.SearchingScope.LastMonth) { // ---> 2012.11.14.00.00 ---2012.12.14, // ---> 2012.12.13.59.59 ---2013.1.15. // 2012.11.15-2012.12.14 // 2012.12.15-2013.1.14 // 2013.1.15 - 2013.2.14. // --> if (startMonth == 1) { startMonth = 12; startYear = startYear - 1; } else { startMonth--; } if (endMonth == 1) { endMonth = 12; endYear = endYear - 1; } else { endMonth--; } var maxDayOfStartDate = new DateTime(startYear, startMonth, 1).GetLastDayOfMonth().Day; var maxDayOfEndDate = new DateTime(endYear, endMonth, 1).GetLastDayOfMonth().Day; if (maxDayOfEndDate < endDay || !isCustomized) { endDay = maxDayOfEndDate; } if (maxDayOfStartDate < startDay) { startDay = maxDayOfStartDate; } offsetStartDate = new System.DateTime(startYear, startMonth, startDay, 0, 0, 0); offsetEndDate = new System.DateTime(endYear, endMonth, endDay, 23, 59, 59); } else if (l_searchingScopr == Component.SearchingScope.NextMonth) { if (startMonth == 12) { startMonth = 1; startYear = startYear + 1; } else { startMonth++; } if (endMonth == 12) { endMonth = 1; endYear = endYear + 1; } else { endMonth++; } var maxDayOfStartDate = new DateTime(startYear, startMonth, 1).GetLastDayOfMonth().Day; var maxDayOfEndDate = new DateTime(endYear, endMonth, 1).GetLastDayOfMonth().Day; if (maxDayOfEndDate < endDay || !isCustomized) { endDay = maxDayOfEndDate; } if (maxDayOfStartDate < startDay) { startDay = maxDayOfStartDate; } offsetStartDate = new System.DateTime(startYear, startMonth, startDay, 0, 0, 0); offsetEndDate = new System.DateTime(endYear, endMonth, endDay, 23, 59, 59); } else if (l_searchingScopr == TinyMoneyManager.Component.SearchingScope.CurrentWeek) { offsetStartDate = DateTime.Now; offsetStartDate = offsetStartDate.GetDateTimeOfFisrtDayOfWeek(); offsetEndDate = offsetStartDate.AddDays(7.0).Date; } else if (l_searchingScopr == TinyMoneyManager.Component.SearchingScope.CurrentMonth) { if (needToCalculateAgagin) { offsetStartDate = System.DateTime.Now.Date.GetFirstDayOfMonth(); offsetEndDate = System.DateTime.Now.Date.GetLastDayOfMonth(); } else { var maxDayOfStartDate = new DateTime(startYear, startMonth, 1).GetLastDayOfMonth().Day; var maxDayOfEndDate = new DateTime(endYear, endMonth, 1).GetLastDayOfMonth().Day; if (maxDayOfEndDate < endDay || !isCustomized) { endDay = maxDayOfEndDate; } if (maxDayOfStartDate < startDay) { startDay = maxDayOfStartDate; } if (DateTime.Now.Day >= startDay) { // 2013.1.15 // 2013.2.14 offsetStartDate = new DateTime(startYear, startMonth, startDay); if (endMonth == 12) { endMonth = 1; endYear = endYear + 1; } offsetEndDate = new DateTime(endYear, endMonth, endDay); } else { // 2012.12.15, // 2013.1.14. if (endMonth == 1) { startMonth = 12; startYear = endYear - 1; } offsetStartDate = new DateTime(startYear, startMonth, startDay); offsetEndDate = new DateTime(endYear, endMonth, endDay); } } } else if (l_searchingScopr == TinyMoneyManager.Component.SearchingScope.CurrentYear) { offsetStartDate = new System.DateTime(System.DateTime.Now.Year, 1, 1, 0, 0, 0); offsetEndDate = new System.DateTime(System.DateTime.Now.Year, 12, 31, 23, 59, 59); } calculatingContext.StartDate = offsetStartDate; calculatingContext.EndDate = offsetEndDate; }
/// <summary> /// Res the calculate. /// </summary> /// <param name="searchingScope">The searching scope.</param> /// <param name="movingMonthDateOffset">The moving month date offset.</param> /// <returns></returns> public static DetailsCondition ReCalculate(SearchingScope searchingScope, DateTime movingMonthDateOffset) { var searchingContext = new DetailsCondition(); searchingContext.searchingScope = searchingScope; initializeStartDateAndEndDateBySearchScope(searchingContext, searchingScope, movingMonthDateOffset); return searchingContext; }
/// <summary> /// Res the calculate. /// </summary> /// <param name="searchingContext">The searching context.</param> /// <param name="movingMonthDateOffset">The moving month date offset.</param> /// <returns></returns> public static DetailsCondition ReCalculate(DetailsCondition searchingContext, SearchingScope scope, DateTime movingMonthStartDateOffset, DateTime movingMonthEndDateOffset) { initializeStartDateAndEndDateBySearchScope(searchingContext, scope, movingMonthStartDateOffset, movingMonthEndDateOffset); return searchingContext; }
void SearchDuringDate_SelectionChanged(object sender, SelectionChangedEventArgs e) { var index = SearchDuringDate.SelectedIndex; if (index == 4) seachingScope = Component.SearchingScope.LastMonth; else seachingScope = (Component.SearchingScope)index; }