Example #1
0
        void ResourceTree_OnCancel(ResourceTreeView.State state)
        {
            Common.Storage.Version resource = null;

            // If the resource of the state exists then cancel it
            // This happens when a translation is not required - non CreateResourceJob
            if ((resource = ResourceTree.GetResourceFromTree(state.Resource.Guid)) != null)
            {
                _workMaster.CancelJobForResource(resource);
                return;
            }

            if (IdTranslation.ContainsValue(state.Resource.Guid))
            {
                Guid oldGuid = Guid.Empty;

                lock (IdTranslation)
                {
                    Dictionary <Guid, Guid> .Enumerator en = IdTranslation.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (en.Current.Value == state.Resource.Guid)
                        {
                            oldGuid = en.Current.Key;
                            break;
                        }
                    }
                }

                resource = ResourceTree.GetResourceFromTree(oldGuid);
                _workMaster.CancelJobForResource(resource);
                return;
            }

            throw new InvalidOperationException("Could not locate resource.");
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TVIState"/> class.
 /// </summary>
 /// <param name="resource">The <see cref="Common.Storage.Version"/>.</param>
 public State(Common.Storage.Version resource)
 {
     _eventFlags = EventFlagType.None;
     _status = StatusType.None;
     _direction = DirectionType.None;
     _resource = resource;
 }