public AsyncObservableCollection <T> ToCollection() { AsyncObservableCollection <T> newList = new AsyncObservableCollection <T>(); lock (SyncObject) { int index = 0; while (index < _list.Count) { newList.Add(_list[index]); index++; } } return(newList); }
public virtual void SetFieldAllowedValues(string propName, AllowedValue value) { if (FieldAllowedValues == null) { FieldAllowedValues = new Dictionary <string, AsyncObservableCollection <AllowedValue> >(); } if (!FieldAllowedValues.ContainsKey(propName)) { FieldAllowedValues.Add(propName, new AsyncObservableCollection <AllowedValue>()); } AsyncObservableCollection <AllowedValue> propValues = FieldAllowedValues[propName]; propValues.Add(value); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns an array of strings representing all the values in the specified enum /// type. /// </summary> //------------------------------------------------------------------------------------ public static AsyncObservableCollection <string> GetEnumValues <T>(bool excludeWildcardValues = false) { Array enumValues = typeof(T).GetEnumValues(); AsyncObservableCollection <string> values = new AsyncObservableCollection <string>(); foreach (T enumVal in enumValues) { string enumText = EnumToString <T>(enumVal); if (!excludeWildcardValues || (!enumText.StartsWith("<") && !enumText.StartsWith("aa"))) { values.Add(enumText); } } return(values); }
public AsyncObservableCollection <FileAttachment> GetAttachedFiles(StoreItem storeItem) { AsyncObservableCollection <FileAttachment> files = new AsyncObservableCollection <FileAttachment>(); DatastoreItem dsItem = storeItem.DSItem; OpenForRead(dsItem); foreach (ProductStudio.File file in dsItem.Files) { if (!IsInternalAttachedFile(file.FileName)) { files.Add(new FileAttachment(file)); } } return(files); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns the file names of all the attached files for this item. /// </summary> //------------------------------------------------------------------------------------ public AsyncObservableCollection <string> GetAttachedFileNames(StoreItem storeItem) { AsyncObservableCollection <string> filenames = new AsyncObservableCollection <string>(); DatastoreItem dsItem = storeItem.DSItem; OpenForRead(dsItem); foreach (ProductStudio.File file in dsItem.Files) { // Exclude internal-use-only attached files. if (!IsInternalAttachedFile(file.FileName)) { filenames.Add(file.FileName); } } return(filenames); }
public AsyncObservableCollection <string> GetAllBugAssignedToValues() { AsyncObservableCollection <string> assignedToValues = new AsyncObservableCollection <string>(); assignedToValues.Add(Constants.c_All); AsyncObservableCollection <PlannerBugItem> bugs = new AsyncObservableCollection <PlannerBugItem>(); foreach (PlannerBugItem bug in bugs) { if (!assignedToValues.Contains(bug.BugAssignedTo)) { assignedToValues.Add(bug.BugAssignedTo); } } return(assignedToValues); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns a list of all the allowed values for the given Product Studio field. This /// assumes that this property does not depend on the value of any other property for /// its state. /// </summary> //------------------------------------------------------------------------------------ public virtual AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(string propName, AllowedValue firstValue = null) { AsyncObservableCollection <AllowedValue> allowedValues = GetFieldAllowedValues(CreateDSItem(), propName); if (allowedValues.Count == 0) { if (FieldAllowedValues.ContainsKey(propName)) { allowedValues = FieldAllowedValues[propName]; } } if (firstValue != null) { allowedValues.Insert(0, firstValue); } return(allowedValues); }
public StoreItem() { m_id = 0; SyncLockItemProperties = new object(); SyncLockLocalProperties = new object(); ItemProperties = new Dictionary <string, ItemProperty>(); m_changedProperties = new AsyncObservableCollection <ItemProperty>(); ItemDocuments = new DocumentAttachmentCollection(this); ItemImages = new ImageAttachmentCollection(this); SelfList = new StoreItemCollection <StoreItem>(); SelfList.Add(this); AttachedFileNamesToCommit = null; UncommittedGuid = Guid.NewGuid(); PersistState = PersistStates.Dummy; IsInImmediateSave = false; CommitErrorState = CommitErrorStates.NoError; }
//------------------------------------------------------------------------------------ /// <summary> /// Returns a list of all the allowed values for the given Product Studio field, given /// the current state of the given item. /// </summary> //------------------------------------------------------------------------------------ private AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(DatastoreItem dsItem, string propName) { AsyncObservableCollection <AllowedValue> valueList = new AsyncObservableCollection <AllowedValue>(); if (dsItem != null) { ProductStudio.Field field = dsItem.Fields[propName]; ProductStudio.Values values = field.ValidValues; foreach (object value in values) { valueList.Add(new AllowedValue { Value = value }); } ResetDSItem(dsItem); } return(valueList); }
public static bool IsWorkDay(DateTime date, AsyncObservableCollection <OffTimeItem> offTimeItems) { if (IsWorkDay(date)) { if (offTimeItems.Count > 0) { foreach (OffTimeItem offTimeItem in offTimeItems) { if (date >= offTimeItem.StartDate && date <= offTimeItem.EndDate) { return(false); } } } return(true); } else { return(false); } }
//------------------------------------------------------------------------------------ /// <summary> /// GetNetWorkingHours - Returns the total number of working hours available between /// the two given days, taking into account weekends and company holidays. /// /// </summary> //------------------------------------------------------------------------------------ public static int GetNetWorkingHours(DateTime startDate, DateTime endDate, AsyncObservableCollection <OffTimeItem> offTimeItems) { int netWorkingDays = GetNetWorkingDays(startDate, endDate, offTimeItems); return(netWorkingDays * WorkHoursPerDay); }
public void RefreshAttachedFileInfo() { m_attachedFiles = null; NotifyPropertyChanged(() => AttachedFiles); NotifyPropertyChanged(() => AttachedFilesCount); }
void UpdateTimer_Tick(object sender, System.EventArgs e) { if (!CreateProductGroupOperationInProgress) { // Show ProductGroupEditor with a newly created product group if (ProductGroupStage == ProductGroupStages.ShowCreateProductGroupDialog) { CreateProductGroupOperationInProgress = true; ProductGroupStage = ProductGroupStages.CreateProductGroupDialogActive; if (NewProductGroupItem == null) { NewProductGroupItem = ScheduleStore.Instance.CreateStoreItem <ProductGroupItem>(ItemTypeID.ProductGroup); } //ProductGroupEditor dialog = new ProductGroupEditor(this, NewProductGroupItem); //dialog.ShowDialog(); //if (dialog.WelcomeState == PlannerNameSpace.WelcomeState.Ok) //{ // Planner.Instance.ItemRepository.DiscoverGroupMembers(NewProductGroupItem); //} } // Show ProductGroupEditor to edit an existing group else if (ProductGroupStage == ProductGroupStages.ShowEditProductGroupDialog) { CreateProductGroupOperationInProgress = true; ProductGroupStage = ProductGroupStages.EditProductGroupDialogActive; //ProductGroupEditor dialog = new ProductGroupEditor(this, SelectedProductGroupItem); //dialog.ShowDialog(); //if (dialog.WelcomeState == PlannerNameSpace.WelcomeState.Ok) //{ // SelectedProductGroupItem.BeginSaveImmediate(); // ExistingProductGroupAliasesChanged = dialog.AliasesChanged; // SelectedProductGroupItem.SaveImmediate(); //} //else //{ // CreateProductGroupOperationInProgress = false; //} } // The discovery of members for a new product group has completed else if (ProductGroupStage == ProductGroupStages.GroupMemberDiscoveryCompleted) { AsyncObservableCollection <MemberDescriptor> discoveredGroupMembers = Planner.Instance.ItemRepository.DiscoveredGroupMembers; //ConfirmNewProductGroupDialog dialog = new ConfirmNewProductGroupDialog(this, NewProductGroupItem, discoveredGroupMembers); //dialog.ShowDialog(); //if (dialog.DialogConfirmed) //{ // CreateProductGroupOperationInProgress = true; // NewProductGroupItem.HostItemStoreName = HostItemStore.Instance.StoreName; // NewProductGroupItem.SaveNewItem(); // ProductGroupStage = ProductGroupStages.CreatingProductGroupItem; // Planner.Instance.ItemRepository.CommitChanges(true); //} //else //{ // ProductGroupStage = ProductGroupStages.ShowCreateProductGroupDialog; // CreateProductGroupOperationInProgress = false; //} } // The commit of the new ProductGroupItem has completed. else if (ProductGroupStage == ProductGroupStages.CreatingProductGroupItemCompleted) { NewProductGroupItem.ParentProductGroupKey = NewProductGroupItem.StoreKey; EnsureProductGroupGridItems(); Planner.Instance.ItemRepository.CreateDiscoveredGroupMembers(NewProductGroupItem.StoreKey); } // The creation of previously discovered members for a new product group has completed. else if (ProductGroupStage == ProductGroupStages.CreateDiscoveredGroupMembersCompleted) { // Now commit all the newly discovered members CreateProductGroupOperationInProgress = true; ProductGroupStage = ProductGroupStages.CommittingDiscoveredGroupMembers; Planner.Instance.ItemRepository.CommitChanges(true); } // The creation of a new product group is fully completed else if (ProductGroupStage == ProductGroupStages.CommittingDiscoveredGroupMembersCompleted) { CreateProductGroupOperationInProgress = true; ProductGroupStage = ProductGroupStages.EndOfCycle; //NewProductGroupSuccessfulDialog dialog = new NewProductGroupSuccessfulDialog(this, NewProductGroupItem); //dialog.ShowDialog(); //if (dialog.SuccessResult == SuccessResult.Open) //{ // SelectedProductGroupItem = NewProductGroupItem; // WelcomeState = PlannerNameSpace.WelcomeState.Open; // Dialog.Close(); //} } else if (ProductGroupStage == ProductGroupStages.UpdateExistingProductGroupCompleted) { ProductGroupStage = ProductGroupStages.RebuildingProductGroupMembership; if (ExistingProductGroupAliasesChanged) { CreateProductGroupOperationInProgress = true; Planner.Instance.ItemRepository.RebuildProductGroupMembership(SelectedProductGroupItem); } else { ProductGroupStage = ProductGroupStages.EditProductGroupCompleted; } } else if (ProductGroupStage == ProductGroupStages.ProductGroupMembershipRebuildComplete) { CreateProductGroupOperationInProgress = true; Planner.Instance.ItemRepository.CommitChanges(true); } else if (ProductGroupStage == ProductGroupStages.EditProductGroupCompleted) { ProductGroupStage = ProductGroupStages.EndOfCycle; if (ExistingProductGroupAliasesChanged && SelectedProductGroupItem == Planner.Instance.ItemRepository.CurrentProductGroup && Planner.Instance.IsStartupComplete) { Result = DialogResult.Restart; Dialog.Close(); } } } }
public static T GetItem <T>(this AsyncObservableCollection <T> collection, int idx) { return(collection[idx]); }