public static void CreateNewWorkspace() { if (currentWorkspace != null) { AskToSaveCurrentWorkspaceAndSaveIt(); currentWorkspace = null; } var newWorkspace = new Workspace(); currentWorkspace = newWorkspace; WorkspaceChanged?.Invoke(null, new EventArgs()); SetHasChanges(true); }
public static void LoadWorkspace(string filePath) { using (Stream stream = new FileStream(filePath, FileMode.Open)) { XmlSerializer serializer = new XmlSerializer(typeof(StorageContainer)); var container = (StorageContainer)serializer.Deserialize(stream); Workspace workspace = new Workspace(); workspace.storageContainer = container; workspace.currentFilePath = filePath; currentWorkspace = workspace; WorkspaceChanged?.Invoke(null, new EventArgs()); SetHasChanges(false); } }
internal void RaiseEvents() { lock (_gate) { // this is a workaround for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/744145 // for preview 2. // // it is a workaround since we are calling event handler under a lock to make sure // we don't raise event concurrently // // we have this issue to track proper fix for preview 3 or later // https://github.com/dotnet/roslyn/issues/32551 // // issue we are working around is the fact this event can happen concurrently // if RegisteryText happens and then UnregisterText happens in perfect timing, // RegisterText got slightly delayed since it is async event, and UnregisterText happens // at the same time since it is a synchronous event, and they my happens in 2 different threads, // cause this event to be raised concurrently. // that can cause some listener to mess up its internal state like the issue linked above WorkspaceChanged?.Invoke(this, EventArgs.Empty); } }
private void Move(int nextIndex) { if (Current != null) { Current.Workspace.InteractionChanged -= WorkspaceInteractionChanged; } // Check limits due a remove push call if (nextIndex > _history.Count - 1) { nextIndex = _history.Count - 1; } if (nextIndex < 0) { nextIndex = 0; } CurrentIndex = nextIndex; Current = _history.ElementAt(CurrentIndex); Current.Workspace.InteractionChanged += WorkspaceInteractionChanged; WorkspaceChanged?.Invoke(this, Current); }
private void OnWorkspaceChanged() { cache.ClearCachedValues(); WorkspaceChanged?.Invoke(this, EventArgs.Empty); }
internal void RaiseEvents() { WorkspaceChanged?.Invoke(this, EventArgs.Empty); }