private bool InRecycleBin(Point point) { Point originRecycleBin = RecycleBin.TranslatePoint(new Point(0, 0), Workbench); Rect recycleBinRect = new Rect(0, 0, originRecycleBin.X + RecycleBin.ActualWidth, originRecycleBin.Y + RecycleBin.ActualHeight); return(recycleBinRect.Contains(point)); }
private void AssignToObservableCollection(List <object> newCollection) { // Create a list of new items. List <CollectionItem> items = new List <CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin <CollectionItem> bin = new RecycleBin <CollectionItem>()) { foreach (object oldItem in _collection) { bin.AddObject(new CollectionItem(_collection, oldItem, true)); } // Add new objects to the list. if (newCollection != null) { foreach (object obj in newCollection) { items.Add(bin.Extract(new CollectionItem(_collection, obj, false))); } } // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } }
private void DocumentDescriptorCleanup(DateTime checkDate) { var list = RecycleBin.Slots .Where(x => x.DeletedAt < checkDate && x.Id.StreamId.StartsWith("DocumentDescriptor_")) .Take(200) .ToArray(); foreach (var slot in list) { Logger.InfoFormat("Deleting slot {0} because it is in recyclebin and was deleted at {1}", slot.Id.StreamId, slot.DeletedAt); var blobIds = (BlobId[])slot.Data["files"]; foreach (var blobId in blobIds.Distinct()) { Logger.InfoFormat("....deleting file {0}", blobId); BlobStore.Delete(blobId); } RecycleBin.Purge(slot.Id); Logger.InfoFormat("....deleting stream {0}.{1}", slot.Id.BucketId, slot.Id.StreamId); Store.Advanced.DeleteStream(slot.Id.BucketId, slot.Id.StreamId); Logger.InfoFormat("Slot {0} deleted", slot.Id.StreamId); } }
public static string GenerateRecycleItemsByJson() { try { List <Dictionary <string, string> > RecycleItemList = new List <Dictionary <string, string> >(); foreach (ShellItem Item in RecycleBin.GetItems()) { try { if (!Item.IsLink) { Dictionary <string, string> PropertyDic = new Dictionary <string, string> { { "OriginPath", Item.Name }, { "ActualPath", Item.FileSystemPath }, { "CreateTime", Convert.ToString(((System.Runtime.InteropServices.ComTypes.FILETIME)Item.Properties[Ole32.PROPERTYKEY.System.DateCreated]).ToDateTime().ToBinary()) } }; RecycleItemList.Add(PropertyDic); } } finally { Item.Dispose(); } } return(JsonConvert.SerializeObject(RecycleItemList)); } catch { return(string.Empty); } }
public double GetSize_RecycleBin() { double size = 0; size = RecycleBin.GetSizeRecycleBin(); return(size); }
public static IEnumerable <T> RecycleCollection <T>(IList collection, IEnumerable <T> source) { // Recycle the collection of items. List <Placeholder <T> > newItems = new List <Placeholder <T> >(collection.Count); using (var recycleBin = new RecycleBin <Placeholder <T> >()) { foreach (T item in collection) { recycleBin.AddObject(new Placeholder <T>(collection, item, true)); } // Extract each item from the recycle bin. foreach (T item in source) { newItems.Add(recycleBin.Extract(new Placeholder <T>(collection, item, false))); } } for (int index = 0; index < newItems.Count; index++) { newItems[index].EnsureInCollectionAt(index); } return(newItems.Select(placeholder => placeholder.Item)); }
public void EmptyTrashcan(RecycleBin.RecycleBinType type) { //validate against the app type! switch (type) { case RecycleBin.RecycleBinType.Content: if (!AuthorizeRequest(DefaultApps.content.ToString())) { return; } break; case RecycleBin.RecycleBinType.Media: if (!AuthorizeRequest(DefaultApps.media.ToString())) { return; } break; default: throw new ArgumentOutOfRangeException("type"); } //TODO: This will never work in LB scenarios Application["trashcanEmptyLeft"] = RecycleBin.Count(type).ToString(); emptyTrashCanDo(type); }
public void CL_WorkItemTracking_RecycleBin_GetDeletedItems_Success() { // arrange RecycleBin recycleBin = new RecycleBin(_configuration); WorkItems workItems = new WorkItems(_configuration); WorkItem item = null; int[] ids = new int[2]; // act ////create workitems, delete them, get from bin item = workItems.CreateWorkItem(_configuration.Project); workItems.DeleteWorkItem(Convert.ToInt32(item.Id)); ids[0] = Convert.ToInt32(item.Id); item = workItems.CreateWorkItem(_configuration.Project); workItems.DeleteWorkItem(Convert.ToInt32(item.Id)); ids[1] = Convert.ToInt32(item.Id); var list = recycleBin.GetDeletedItems(_configuration.Project); //assert Assert.IsNotNull(list); Assert.IsTrue(list.Count >= 2); }
private void OnUpdateCollection() { // Get the source collection from the wrapped object. IEnumerable <T> sourceCollection = _getMethod(); // Create a list of new items. List <CollectionItem <T> > items = new List <CollectionItem <T> >(); // Dump all previous items into a recycle bin. using (RecycleBin <CollectionItem <T> > bin = new RecycleBin <CollectionItem <T> >()) { foreach (T oldItem in _collection) { bin.AddObject(new CollectionItem <T>(_collection, oldItem, true)); } // Add new objects to the list. if (sourceCollection != null) { foreach (T obj in sourceCollection) { items.Add(bin.Extract(new CollectionItem <T>(_collection, obj, false))); } } // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem <T> item in items) { item.EnsureInCollection(index); ++index; } }
public static bool Restore(string OriginPath) { try { using (ShellItem SourceItem = RecycleBin.GetItemFromOriginalPath(OriginPath)) { Directory.CreateDirectory(Path.GetDirectoryName(SourceItem.Name)); if (File.Exists(SourceItem.FileSystemPath)) { File.Move(SourceItem.FileSystemPath, StorageController.GenerateUniquePath(SourceItem.Name)); } else if (Directory.Exists(SourceItem.FileSystemPath)) { Directory.Move(SourceItem.FileSystemPath, StorageController.GenerateUniquePath(SourceItem.Name)); } string ExtraInfoPath = Path.Combine(Path.GetDirectoryName(SourceItem.FileSystemPath), Path.GetFileName(SourceItem.FileSystemPath).Replace("$R", "$I")); if (File.Exists(ExtraInfoPath)) { File.Delete(ExtraInfoPath); } } return(true); } catch { return(false); } }
public T[] GetRecycledObject(int count) { if (!Enabled) { return(null); } if (RecycleBin.Count == 0 || RecycleBin.Count < count) { return(null); } T[] r = new T[count]; int i = 0; foreach (var k in RecycleBin.Keys) { r[i++] = k; if (i >= count) { break; } } for (i = 0; i < count; i++) { RecycleBin.Remove(r[i]); } return(r); }
public void WorkItemTracking_RecycleBin_RestoreMultipleItems_Success() { // arrange WorkItems workItemsRequest = new WorkItems(_configuration); RecycleBin recyclebinRequest = new RecycleBin(_configuration); WorkItemPatchResponse.WorkItem createResponse; string[] ids = new string[3]; // act createResponse = workItemsRequest.CreateWorkItem(_configuration.Project); ids[0] = createResponse.id.ToString(); createResponse = workItemsRequest.CreateWorkItem(_configuration.Project); ids[1] = createResponse.id.ToString(); createResponse = workItemsRequest.CreateWorkItem(_configuration.Project); ids[2] = createResponse.id.ToString(); foreach (var id in ids) { var deleteResponse = workItemsRequest.DeleteWorkItem(id); } var respond = recyclebinRequest.RestoreMultipleItems(ids); //assert Assert.AreEqual(HttpStatusCode.OK, createResponse.HttpStatusCode); workItemsRequest = null; recyclebinRequest = null; }
void UpdateRecycleBinAndCleanSelected() { var newRecycleBin = RecycleBin.Where(file => SelectedList.Any(sfile => sfile.Id == file.Id) == false); RecycleBin = new ObservableCollection <FileCommon>(newRecycleBin); Notify(nameof(RecycleBin)); SelectedList.Clear(); }
public RecycleBinContainsFilesState(RecycleBin recycleBin, string name, Bitmap expandedIcon, Bitmap collapsedIcon, Color foregroundColor, Color backgroundColor) : base(name, expandedIcon, collapsedIcon, foregroundColor, backgroundColor) { this.recycleBin = recycleBin; this.recycleBin.StateChanged += new EventHandler(recycleBin_StateChanged); }
public void EmptyTrashcan(cms.businesslogic.RecycleBin.RecycleBinType type) { if (BasePage.ValidateUserContextID(BasePage.umbracoUserContextID)) { Application["trashcanEmptyLeft"] = RecycleBin.Count(type).ToString(); emptyTrashCanDo(type); } }
public static string GenerateRecycleItemsByJson() { try { List <Dictionary <string, string> > RecycleItemList = new List <Dictionary <string, string> >(); foreach (ShellItem Item in RecycleBin.GetItems()) { try { Dictionary <string, string> PropertyDic = new Dictionary <string, string> { { "ActualPath", Item.FileSystemPath } }; if (Path.HasExtension(Item.FileSystemPath)) { PropertyDic.Add("StorageType", Enum.GetName(typeof(StorageItemTypes), StorageItemTypes.File)); if (Path.HasExtension(Item.Name)) { PropertyDic.Add("OriginPath", Item.Name); } else { PropertyDic.Add("OriginPath", Item.Name + Item.FileInfo.Extension); } } else { PropertyDic.Add("OriginPath", Item.Name); PropertyDic.Add("StorageType", Enum.GetName(typeof(StorageItemTypes), StorageItemTypes.Folder)); } if (Item.Properties.TryGetValue(Ole32.PROPERTYKEY.System.Recycle.DateDeleted, out object DeleteFileTime)) { PropertyDic.Add("DeleteTime", Convert.ToString(((FILETIME)DeleteFileTime).ToInt64())); } else { PropertyDic.Add("DeleteTime", Convert.ToString(DateTimeOffset.MaxValue.ToFileTime())); } RecycleItemList.Add(PropertyDic); } finally { Item.Dispose(); } } return(JsonSerializer.Serialize(RecycleItemList)); } catch { return(string.Empty); } }
private void UpdateItems() { ++_updating; try { if (GetItems != null) { // Use the adapter if the check state event is not defined. GetObjectCheckStateDelegate getItemCheckState = GetItemCheckState; if (getItemCheckState == null) { getItemCheckState = new GetObjectCheckStateDelegate(AdaptGetItemCheckState); } SetObjectCheckStateDelegate setItemCheckState = SetItemCheckState; if (setItemCheckState == null) { setItemCheckState = new SetObjectCheckStateDelegate(AdaptSetItemCheckState); } // Recycle the collection of items. ArrayList newItems = new ArrayList(base.Items.Count); using (var recycleBin = new RecycleBin <CheckedListBoxItem>()) { foreach (CheckedListBoxItem item in base.Items) { recycleBin.AddObject(item); } // Extract each item from the recycle bin. foreach (object item in GetItems()) { newItems.Add(recycleBin.Extract( new CheckedListBoxItem(item, GetItemText, getItemCheckState, setItemCheckState))); } } // Replace the items in the control. base.BeginUpdate(); try { // Make sure the same tag is selected. CheckedListBoxItem selectedItem = (CheckedListBoxItem)base.SelectedItem; object selectedTag = selectedItem == null ? null : selectedItem.Tag; base.Items.Clear(); base.Items.AddRange(newItems.ToArray()); base.SelectedIndex = IndexOfTag(selectedTag); } finally { base.EndUpdate(); } } } finally { --_updating; } }
protected internal override void PublishChanges() { _publishingChanges = true; try { if (_sourceCollection == null) { if (_collection != null) { _collection = null; _collectionChangedFromUIEventHandlerSubscribed = false; FirePropertyChanged(); } return; } if (_collection == null) { _collection = new ObservableCollection <object>(); _collection.CollectionChanged += _collectionChangedFromUIEventHandler; _collectionChangedFromUIEventHandlerSubscribed = true; FirePropertyChanged(); } // Create a list of new items. List <CollectionItem> items = new List <CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin <CollectionItem> bin = new RecycleBin <CollectionItem>()) { foreach (object oldItem in _collection) { bin.AddObject(new CollectionItem(_collection, oldItem, true)); } // Add new objects to the list. if (_sourceCollection != null) { foreach (object obj in _sourceCollection) { items.Add(bin.Extract(new CollectionItem(_collection, WrapValue(obj), false))); } } // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } } finally { _publishingChanges = false; } }
public bool DeleteFile() { if (CanDeleteFile) { RecycleBin.DeleteFileOrFolder(Path); return(true); } return(false); }
void OnDisable() { //// remove all slots with items //foreach(ItemSlotDropHandler inventorySlot in GetComponentsInChildren<ItemSlotDropHandler>()) //{ // Destroy(inventorySlot.gameObject); //} RecycleBin.RecycleChildrenOf(inventoryItemsGrid.gameObject); }
protected Context() { this.compositionBin = new RecycleBin<Composition>(item => item.Delete()); this.textureBin = new RecycleBin<Texture>(item => item.Delete()); this.textureDeleteBin = new WasteBin<Texture>(item => item.Delete()); this.depthBin = new WasteBin<Depth>(item => item.Delete()); this.frameBufferBin = new WasteBin<FrameBuffer>(item => item.Delete()); this.programBin = new WasteBin<Program>(item => item.Delete()); this.shaderBin = new WasteBin<Shader>(item => item.Delete()); }
public void Initialize(RecycleBin recycleBin) { this.recycleBin = recycleBin; HookupEvents(); SetupListView(); //RecycleBinEntry[] entries = recycleBin.GetEntryList(); recycleBinList.SetObjects(recycleBin.EntryTable); //recycleBinList.DataSource = recycleBin.EntryTable; }
private void EmptyRecycleBin() { ProgressManager progress = new ProgressManager(); Progress.Steps.Add(new SteppedProgressManagerStep(progress, 0.0f, S._("Emptying recycle bin..."))); RecycleBin.Empty(EmptyRecycleBinOptions.NoConfirmation | EmptyRecycleBinOptions.NoProgressUI | EmptyRecycleBinOptions.NoSound); }
public void UpdateNow() { if (_provider.IsCollection) { _depValue.OnGet(); // Create a list of new items. List <CollectionItem> items = new List <CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin <CollectionItem> bin = new RecycleBin <CollectionItem>()) { foreach (object oldItem in _collection) { bin.AddObject(new CollectionItem(_collection, oldItem, true)); } // Add new objects to the list. if (_sourceCollection != null) { foreach (object obj in _sourceCollection) { items.Add(bin.Extract(new CollectionItem(_collection, WrapValue(obj), false))); } } _sourceCollection = null; // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } } else { object oldValue = _value; _depValue.OnGet(); object newValue = _value; if (_initialized) { if ((!Object.Equals(newValue, oldValue))) { _wrapper.FirePropertyChanged(_propertyInfo.Name); } } else { _initialized = true; } } }
protected override void UpdateValue() { // Get the source collection from the wrapped object. IEnumerable source = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject) as IEnumerable; if (source == null) { _collection = null; return; } List <object> sourceCollection = source.OfType <object>().ToList(); // Delay the update to the observable collection so that we don't record dependencies on // properties used in the items template. XAML will invoke the item template synchronously // as we add items to the observable collection, thus causing other view model property // getters to fire. _delay = delegate { if (_collection == null) { _collection = new ObservableCollection <object>(); FirePropertyChanged(); } // Create a list of new items. List <CollectionItem> items = new List <CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin <CollectionItem> bin = new RecycleBin <CollectionItem>()) { foreach (object oldItem in _collection) { bin.AddObject(new CollectionItem(_collection, oldItem, true)); } // Add new objects to the list. if (sourceCollection != null) { foreach (object obj in sourceCollection) { items.Add(bin.Extract(new CollectionItem(_collection, TranslateOutgoingValue(obj), false))); } } // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } }; }
private void Start() { img = GetComponent <Image>(); img.fillAmount = 0; Debug.Log("Progress Handler::"); recycleBin = PoolManager.Instance.GetRecycleBin("Balls"); Debug.Log("RecycleBin -> " + recycleBin?.GetType().Name); //if (recycleBin != null) // recycleBin.OnAddressablesLoading += RecycleBin_OnAddressablesLoading; }
public void DelRestoreFolderTest() { const string dir = @"C:\Temp\Fonts\"; RecycleBin.DeleteToRecycleBin(dir); Assert.That(RecycleBin.Count, Is.GreaterThan(0L)); TestContext.WriteLine($"cnt={RecycleBin.Count}; sz={RecycleBin.Size}"); RecycleBin.RestoreAll(); Assert.That(RecycleBin.Count, Is.EqualTo(0L)); Assert.IsTrue(Directory.Exists(dir)); }
public static string GenerateRecycleItemsByJson() { try { List <Dictionary <string, string> > RecycleItemList = new List <Dictionary <string, string> >(); foreach (ShellItem Item in RecycleBin.GetItems()) { try { Dictionary <string, string> PropertyDic = new Dictionary <string, string> { { "ActualPath", Item.FileSystemPath }, { "DeleteTime", (Item.IShellItem as Shell32.IShellItem2).GetFileTime(Ole32.PROPERTYKEY.System.Recycle.DateDeleted).ToInt64().ToString() } }; if (File.Exists(Item.FileSystemPath)) { PropertyDic.Add("StorageType", Enum.GetName(typeof(StorageItemTypes), StorageItemTypes.File)); if (Path.HasExtension(Item.Name)) { PropertyDic.Add("OriginPath", Item.Name); } else { PropertyDic.Add("OriginPath", Item.Name + Item.FileInfo.Extension); } } else if (Directory.Exists(Item.FileSystemPath)) { PropertyDic.Add("OriginPath", Item.Name); PropertyDic.Add("StorageType", Enum.GetName(typeof(StorageItemTypes), StorageItemTypes.Folder)); } else { continue; } RecycleItemList.Add(PropertyDic); } finally { Item.Dispose(); } } return(JsonSerializer.Serialize(RecycleItemList)); } catch { return(string.Empty); } }
public void Analyze() { list_size_of_data.Add(GetSize_TempFolder()); list_size_of_data.Add(GetSize_TmpInternetFiles()); list_size_of_data.Add(GetSize_TempWindows()); list_size_of_data.Add(GetSize_PrefetchData()); list_size_of_data.Add(GetSize_RecentItems()); list_size_of_data.Add(GetSize_Cookies()); list_size_of_data.Add(GetSize_InternetHistory()); list_size_of_data.Add(GetSize_WinError()); list_size_of_data.Add(RecycleBin.GetSizeRecycleBin()); }
public static bool EmptyRecycleBin() { try { RecycleBin.Empty(); return(true); } catch { return(false); } }
public void WorkItemTracking_RecycleBin_GetDeletedItems_Success() { // arrange RecycleBin request = new RecycleBin(_configuration); // act GetItemsFromRecycleBinResponse.WorkItems response = request.GetDeletedItems(_configuration.Project); //assert Assert.AreEqual(HttpStatusCode.OK, response.HttpStatusCode); request = null; }
private void AssignToObservableCollection(List<object> newCollection) { // Create a list of new items. List<CollectionItem> items = new List<CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin<CollectionItem> bin = new RecycleBin<CollectionItem>()) { foreach (object oldItem in _collection) bin.AddObject(new CollectionItem(_collection, oldItem, true)); // Add new objects to the list. if (newCollection != null) foreach (object obj in newCollection) items.Add(bin.Extract(new CollectionItem(_collection, obj, false))); // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } }
// Runs when the object if first instantiated, because this object will occur once through the game, // these values are the beginning of game values // Note: Values should be updated at the EndTurn State void Start() { //TODO: Damien: Replace Tile stuff later // Clear the tile dictionary TileDictionary.Clean(); // Set the dimensions and generate/add the tiles TileManager.SetDimensions(64, 20, 16); TileManager.GenerateAndAddTiles(); // Get HUD elements guiPlayerName = GameObject.Find("CurrentPlayer/PlayerNamePanel/PlayerName").GetComponent<Text>(); guiTurnText = GameObject.Find("CurrentPlayer/TurnPhasePanel/TurnPhase").GetComponent<Text>(); guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>(); guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>(); actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>(); actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>(); acceptPanel = GameObject.Find("Accept"); pauseMenu = GameObject.Find ("PauseMenu"); instructionsSet = GameObject.Find ("Instructions"); imageParent = GameObject.Find("AllPlayers/ImageOrganizer"); textParent = GameObject.Find("AllPlayers/TextOrganizer"); inventory = GameObject.Find("PlayerInventory").GetComponent<PlayerInventory>(); allyInventory = GameObject.Find("AllyInventory").GetComponent<AllyInventory>(); recycleInventory = GameObject.Find("RecycleBin").GetComponent<RecycleBin>(); allyTable = GameObject.Find("Allies").GetComponent<AllyTable>(); GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false); actionButtonActive = true; isPaused = false; instructionsProgress = 1; // Disable the other panels by default acceptPanel.SetActive(false); pauseMenu.SetActive (false); inventory.gameObject.SetActive(false); allyInventory.gameObject.SetActive(false); recycleInventory.gameObject.SetActive(false); allyTable.gameObject.SetActive(false); // Running the end stuff defaults to true canRunEndStuff = true; // The movement class is not initialised isMovementInitialized = false; // The ally window are closed by default isAlliesOpen = false; // Get the number of players guiNumOfPlayers = GameMaster.Instance.NumPlayers; // Set the turn guiPlayerTurn = GameMaster.Instance.Turn; // Set starting values guiDiceDistVal = 0; // The player is not an AI by default isPlayerAI = false; // Create a die die = new Die(); // Reseed the random number generator die.Reseed(Environment.TickCount); // Get movement and map event components guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> (); guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> (); // There isn't a map event in the beginning mapEventResultString = string.Empty; // Initialise other things after Start() runs canInitAfterStart = true; // Set the state to the BeginTurn state gamePlayState = GamePlayState.BeginTurn; }
private void UpdateItems() { ++_updating; try { if ( GetItems != null ) { // Use the adapter if the check state event is not defined. GetObjectCheckStateDelegate getItemCheckState = GetItemCheckState; if ( getItemCheckState == null ) getItemCheckState = new GetObjectCheckStateDelegate( AdaptGetItemCheckState ); SetObjectCheckStateDelegate setItemCheckState = SetItemCheckState; if ( setItemCheckState == null ) setItemCheckState = new SetObjectCheckStateDelegate( AdaptSetItemCheckState ); // Recycle the collection of items. ArrayList newItems = new ArrayList( base.Items.Count ); using (var recycleBin = new RecycleBin<CheckedListBoxItem>()) { foreach (CheckedListBoxItem item in base.Items) recycleBin.AddObject(item); // Extract each item from the recycle bin. foreach ( object item in GetItems() ) { newItems.Add( recycleBin.Extract( new CheckedListBoxItem( item, GetItemText, getItemCheckState, setItemCheckState ) ) ); } } // Replace the items in the control. base.BeginUpdate(); try { // Make sure the same tag is selected. CheckedListBoxItem selectedItem = (CheckedListBoxItem)base.SelectedItem; object selectedTag = selectedItem == null ? null : selectedItem.Tag; base.Items.Clear(); base.Items.AddRange( newItems.ToArray() ); base.SelectedIndex = IndexOfTag( selectedTag ); } finally { base.EndUpdate(); } } } finally { --_updating; } }
// Runs when the object if first instantiated, because this object will occur once through the game, // these values are the beginning of game values // Note: Values should be updated at the EndTurn State void Start() { // Get the reference to the tile manager tileManager = GameObject.Find("TileManager").GetComponent<TileManager>(); // Generate the map tileManager.GenerateMap(); // Get HUD elements CurrentPlayer = GameObject.Find ("Canvas/CurrentPlayer"); AllPlayers = GameObject.Find("Canvas/AllPlayers"); BKG = GameObject.Find ("Canvas/Background"); guiPlayerName = GameObject.Find("CurrentPlayer/PlayerNamePanel/PlayerName").GetComponent<Text>(); guiTurnText = GameObject.Find("CurrentPlayer/TurnPhasePanel/TurnPhase").GetComponent<Text>(); guiGold = GameObject.Find("CurrentPlayer/WeightGold/Gold").GetComponent<Text>(); guiWeight = GameObject.Find("CurrentPlayer/WeightGold/Weight").GetComponent<Text>(); actionButton = GameObject.Find("CurrentPlayer/ActionButton").GetComponent<Button>(); actionButtonText = GameObject.Find("CurrentPlayer/ActionButton").GetComponentInChildren<Text>(); acceptPanel = GameObject.Find("Accept"); pauseMenu = GameObject.Find ("PauseMenu"); instructionsSet = GameObject.Find ("Instructions"); audioSet = GameObject.Find ("Options"); imageParent = GameObject.Find("AllPlayers/ImageOrganizer"); textParent = GameObject.Find("AllPlayers/TextOrganizer"); inventory = GameObject.Find("PlayerInventory").GetComponent<PlayerInventory>(); allyInventory = GameObject.Find("AllyInventory").GetComponent<AllyInventory>(); recycleInventory = GameObject.Find("RecycleBin").GetComponent<RecycleBin>(); allyTable = GameObject.Find("Allies").GetComponent<AllyTable>(); GameObject.Find ("Canvas").transform.Find ("Instructions").gameObject.SetActive (false); HUDToggle = true; actionButtonActive = true; isPaused = false; instructionsProgress = 1; // Disable the other panels by default acceptPanel.SetActive(false); pauseMenu.SetActive (false); audioSet.SetActive (false); inventory.gameObject.SetActive(false); allyInventory.gameObject.SetActive(false); recycleInventory.gameObject.SetActive(false); allyTable.gameObject.SetActive(false); // Running the end stuff defaults to true canRunEndStuff = true; // The movement class is not initialised isMovementInitialized = false; // The ally window are closed by default isAlliesOpen = false; // Get the number of players guiNumOfPlayers = GameMaster.Instance.NumPlayers; // Set the turn guiPlayerTurn = GameMaster.Instance.Turn; // Set starting values guiDiceDistVal = 0; movementCooldown = 0.0f; // The player is not an AI by default isPlayerAI = false; // Create a die die = new Die(); // Get movement and map event components guiMovement = GameObject.Find("Canvas").GetComponent<GUIMovement> (); guiMapEvent = GameObject.Find("Canvas").GetComponent<MapEvent> (); // There isn't a map event in the beginning mapEventResultString = string.Empty; // Initialise other things after Start() runs canInitAfterStart = true; // Set the state to the BeginTurn state gamePlayState = GamePlayState.BeginTurn; }
private void OnUpdateCollection() { // Get the source collection from the wrapped object. IEnumerable source = ClassProperty.GetObjectValue(ObjectInstance.WrappedObject) as IEnumerable; List<object> sourceCollection = source.OfType<object>().ToList(); // Delay the update to the observable collection so that we don't record dependencies on // properties used in the items template. XAML will invoke the item template synchronously // as we add items to the observable collection, thus causing other view model property // getters to fire. _delay = delegate { // Create a list of new items. List<CollectionItem> items = new List<CollectionItem>(); // Dump all previous items into a recycle bin. using (RecycleBin<CollectionItem> bin = new RecycleBin<CollectionItem>()) { foreach (object oldItem in _collection) bin.AddObject(new CollectionItem(_collection, oldItem, true)); // Add new objects to the list. if (sourceCollection != null) foreach (object obj in sourceCollection) items.Add(bin.Extract(new CollectionItem(_collection, TranslateOutgoingValue(obj), false))); // All deleted items are removed from the collection at this point. } // Ensure that all items are added to the list. int index = 0; foreach (CollectionItem item in items) { item.EnsureInCollection(index); ++index; } }; }