public SourceExplorerHierarchyControllerFactory( ISynchronizationContextProvider synchronizationContextProvider, IFileSystemTreeSource fileSystemTreeSource, IVisualStudioPackageProvider visualStudioPackageProvider, IVsGlyphService vsGlyphService, IImageSourceFactory imageSourceFactory, IOpenDocumentHelper openDocumentHelper, IFileSystem fileSystem, IClipboard clipboard, IWindowsExplorer windowsExplorer, IUIRequestProcessor uiRequestProcessor, IEventBus eventBus, IGlobalSettingsProvider globalSettingsProvider, IDelayedOperationProcessor delayedOperationProcessor, IUIThread uiThread) { _synchronizationContextProvider = synchronizationContextProvider; _fileSystemTreeSource = fileSystemTreeSource; _visualStudioPackageProvider = visualStudioPackageProvider; _vsGlyphService = vsGlyphService; _imageSourceFactory = imageSourceFactory; _openDocumentHelper = openDocumentHelper; _fileSystem = fileSystem; _clipboard = clipboard; _windowsExplorer = windowsExplorer; _uiRequestProcessor = uiRequestProcessor; _eventBus = eventBus; _globalSettingsProvider = globalSettingsProvider; _delayedOperationProcessor = delayedOperationProcessor; _uiThread = uiThread; }
public SoundManager(GameDataManager gameData, AudioManager audio, IUIThread ui) { data = gameData; this.audio = audio; soundCache = new LRUCache <string, LoadedSound>(64, OnLoadSound); this.ui = ui; }
public SourceExplorerHierarchyControllerFactory( ISynchronizationContextProvider synchronizationContextProvider, IFileSystemTreeSource fileSystemTreeSource, IVisualStudioPackageProvider visualStudioPackageProvider, IVsGlyphService vsGlyphService, IImageSourceFactory imageSourceFactory, IOpenDocumentHelper openDocumentHelper, IFileSystem fileSystem, IClipboard clipboard, IWindowsExplorer windowsExplorer, IUIRequestProcessor uiRequestProcessor, IEventBus eventBus, IGlobalSettingsProvider globalSettingsProvider, IDelayedOperationProcessor delayedOperationProcessor, IUIThread uiThread) { _synchronizationContextProvider = synchronizationContextProvider; _fileSystemTreeSource = fileSystemTreeSource; _visualStudioPackageProvider = visualStudioPackageProvider; _vsGlyphService = vsGlyphService; _imageSourceFactory = imageSourceFactory; _openDocumentHelper = openDocumentHelper; _fileSystem = fileSystem; _clipboard = clipboard; _windowsExplorer = windowsExplorer; _uiRequestProcessor = uiRequestProcessor; _eventBus = eventBus; _globalSettingsProvider = globalSettingsProvider; _delayedOperationProcessor = delayedOperationProcessor; _uiThread = uiThread; }
/// <summary> /// Default constructor for runtime behavior that can't be mocked. /// </summary> public MessageBoxService(IVsUIShell uiShell, IUIThread uiThread) { Guard.NotNull(() => uiShell, uiShell); Guard.NotNull(() => uiThread, uiThread); this.uiShell = uiShell; this.uiThread = uiThread; }
/// <summary> /// Default constructor for runtime behavior that can't be mocked. /// </summary> public MessageBoxService(IVsUIShell uiShell, IUIThread uiThread) { Guard.NotNull(() => uiShell, uiShell); Guard.NotNull(() => uiThread, uiThread); this.uiShell = uiShell; this.uiThread = uiThread; }
public static IVsHierarchy GetSelectedHierarchy(this IVsMonitorSelection monitorSelection, IUIThread uiThread) { var hierarchyPtr = IntPtr.Zero; var selectionContainer = IntPtr.Zero; return uiThread.Invoke(() => { try { // Get the current project hierarchy, project item, and selection container for the current selection // If the selection spans multiple hierarchies, hierarchyPtr is Zero. // So fast path is for non-zero result (most common case of single active project/item). uint itemid; IVsMultiItemSelect multiItemSelect = null; ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer)); // There may be no selection at all. if (itemid == VSConstants.VSITEMID_NIL) return null; if (itemid == VSConstants.VSITEMID_ROOT) { // The root selection could be the solution itself, so no project is active. if (hierarchyPtr == IntPtr.Zero) return null; else return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); } // We may have a single item selection, so we can safely pick its owning project/hierarchy. if (itemid != VSConstants.VSITEMID_SELECTION) return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); // Otherwise, this is a multiple item selection within the same hierarchy, // we select he hierarchy. uint numberOfSelectedItems; int isSingleHierarchyInt; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt)); var isSingleHierarchy = (isSingleHierarchyInt != 0); if (isSingleHierarchy) return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); return null; } finally { if (hierarchyPtr != IntPtr.Zero) { Marshal.Release(hierarchyPtr); } if (selectionContainer != IntPtr.Zero) { Marshal.Release(selectionContainer); } } }); }
public VsHierarchyAggregate( IServiceProvider serviceProvider, IVsGlyphService vsGlyphService, IUIThread uiThread) { _serviceProvider = serviceProvider; _vsGlyphService = vsGlyphService; _uiThread = uiThread; _version = 1; }
public AudioManager(IUIThread uithread) { Music = new MusicPlayer(this); this.UIThread = uithread; Thread AudioThread = new Thread(new ThreadStart(UpdateThread)); AudioThread.Name = "Audio"; AudioThread.Start(); }
public VsHierarchyAggregate( IServiceProvider serviceProvider, IVsGlyphService vsGlyphService, IUIThread uiThread) { _serviceProvider = serviceProvider; _vsGlyphService = vsGlyphService; _uiThread = uiThread; _version = 1; }
public GLGraphicsFactory(Dictionary <string, ITexture> textures, IContainer resolver, IGLUtils glUtils, IGraphicsBackend graphics, IBitmapLoader bitmapLoader, IUIThread uiThread) { this._uiThread = uiThread; this._textures = textures; this._resolver = resolver; this._resources = resolver.Resolve <IResourceLoader>(); this._bitmapLoader = bitmapLoader; this._spriteSheetLoader = new SpriteSheetLoader(_resources, _bitmapLoader, addAnimationFrame, loadImage, graphics); AGSGameSettings.CurrentSkin = new AGSBlueSkin(this, glUtils).CreateSkin(); }
/// <summary> /// Specifies the UI thread to use. /// May only set once at most. /// </summary> /// <param name="thread">The <see cref="IUIThread"/> to use.</param> public static void Set(IUIThread thread) { if (thread.NullReference()) { throw Exc.Null(nameof(thread)); } var previousValue = Interlocked.CompareExchange(ref uiThread, thread, comparand: null); if (previousValue.NotNullReference()) { throw new InvalidOperationException("UI already initialized!").StoreFileLine(); } }
/// <summary> /// Initializes a new instance of the <see cref="SolutionNodeFactory"/> class. /// </summary> /// <param name="serviceLocator">The service locator.</param> /// <param name="childNodeFactory">The factory for nodes, used to construct child nodes automatically.</param> /// <param name="looseNodeFactory">The explorer node factory used to create "loose" nodes from solution explorer.</param> /// <param name="solutionEvents">The solution events.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> /// <param name="uiThread">The UI thread.</param> public SolutionNodeFactory( IServiceLocator serviceLocator, [Named(DefaultHierarchyFactory.RegisterKey)] Lazy <ITreeNodeFactory <IVsSolutionHierarchyNode> > childNodeFactory, ISolutionExplorerNodeFactory looseNodeFactory, ISolutionEvents solutionEvents, IAdapterService adapter, IUIThread uiThread) { this.locator = serviceLocator; this.childNodeFactory = childNodeFactory; this.looseNodeFactory = looseNodeFactory; this.solutionEvents = solutionEvents; this.adapter = adapter; this.uiThread = uiThread; }
public AudioManager(IUIThread uithread) { UIThread = uithread; audioThreadId = Thread.CurrentThread.ManagedThreadId; initTask = Task.Run(() => { Platform.RegisterDllMap(typeof(AudioManager).Assembly); Music = new MusicPlayer(this); //Init context dev = Alc.alcOpenDevice(null); ctx = Alc.alcCreateContext(dev, IntPtr.Zero); Alc.alcMakeContextCurrent(ctx); for (int i = 0; i < MAX_SOURCES; i++) { freeSources.Enqueue(Al.GenSource()); } for (int i = 0; i < MAX_STREAM_BUFFERS; i++) { Buffers.Enqueue(Al.GenBuffer()); } Instances = new InstanceInfo[MAX_INSTANCES]; for (int i = 0; i < MAX_INSTANCES; i++) { Instances[i].Source = uint.MaxValue; freeInstances.Enqueue((uint)i); } uint musicSource; for (int i = 0; i < 2; i++) { while (!freeSources.TryDequeue(out musicSource)) { } streamingSources.Enqueue(musicSource); } FLLog.Debug("Audio", "Audio initialised"); Al.alListenerf(Al.AL_GAIN, ALUtils.ClampVolume(ALUtils.LinearToAlGain(_masterVolume))); Ready = true; }); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="childNodeFactory">The factory for child nodes.</param> /// <param name="looseNodeFactory">The explorer node factory used to create "loose" nodes from solution explorer.</param> /// <param name="locator">The service locator.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> /// <param name="solutionEvents">The solution events.</param> /// <param name="uiThread">The UI thread.</param> public SolutionNode( IVsSolutionHierarchyNode hierarchyNode, // This is the regular node factory for trees, that receives a lazy // pointer to the parent tree node. ITreeNodeFactory <IVsSolutionHierarchyNode> childNodeFactory, // This factory is used to create "loose" nodes from solution explorer ISolutionExplorerNodeFactory looseNodeFactory, IServiceLocator locator, IAdapterService adapter, ISolutionEvents solutionEvents, // Retrieving current selection must be done on the UI thread. IUIThread uiThread) : base(SolutionNodeKind.Solution, hierarchyNode, null, childNodeFactory, adapter) { this.Solution = new Lazy <EnvDTE.Solution>(() => hierarchyNode.ServiceProvider.GetService <EnvDTE.DTE>().Solution); this.nodeFactory = childNodeFactory; this.explorerNodeFactory = looseNodeFactory; this.events = solutionEvents; this.selection = new Lazy <IVsMonitorSelection>(() => locator.GetService <SVsShellMonitorSelection, IVsMonitorSelection>()); this.uiThread = uiThread; }
public GameClient(IUIThread mainThread, GameSession session) { this.mainThread = mainThread; Session = session; }
public SoundManager(AudioManager audio, IUIThread ui) { this.audio = audio; soundCache = new LRUCache <string, LoadedSound>(64, OnLoadSound); this.ui = ui; }
public static IEnumerable <Tuple <IVsHierarchy, uint> > GetSelection(this IVsMonitorSelection monitorSelection, IUIThread uiThread, IVsHierarchy solution) { var hierarchyPtr = IntPtr.Zero; var selectionContainer = IntPtr.Zero; return(uiThread.Invoke(() => { try { // Get the current project hierarchy, project item, and selection container for the current selection // If the selection spans multiple hierarchies, hierarchyPtr is Zero uint itemid; IVsMultiItemSelect multiItemSelect = null; ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer)); if (itemid == VSConstants.VSITEMID_NIL) { return Enumerable.Empty <Tuple <IVsHierarchy, uint> >(); } if (itemid == VSConstants.VSITEMID_ROOT) { if (hierarchyPtr == IntPtr.Zero) { return new[] { Tuple.Create(solution, VSConstants.VSITEMID_ROOT) } } ; else { return new[] { Tuple.Create( (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)), VSConstants.VSITEMID_ROOT) } }; } if (itemid != VSConstants.VSITEMID_SELECTION) { return new[] { Tuple.Create( (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)), itemid) } } ; // This is a multiple item selection. uint numberOfSelectedItems; int isSingleHierarchyInt; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt)); var isSingleHierarchy = (isSingleHierarchyInt != 0); var vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems]; var flags = (isSingleHierarchy) ? (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs : 0; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(flags, numberOfSelectedItems, vsItemSelections)); return vsItemSelections.Where(sel => sel.pHier != null) // NOTE: we can return lazy results here, since // the GetSelectedItems has already returned in the UI thread // the array of results. We're just delaying the creation of the tuples // in case they aren't all needed. .Select(sel => Tuple.Create(sel.pHier, sel.itemid)); } finally { if (hierarchyPtr != IntPtr.Zero) { Marshal.Release(hierarchyPtr); } if (selectionContainer != IntPtr.Zero) { Marshal.Release(selectionContainer); } } })); }
public VsHierarchy(System.IServiceProvider serviceProvider, IVsGlyphService vsGlyphService, IUIThread uiThread) { _serviceProvider = serviceProvider; _vsGlyphService = vsGlyphService; _threadId = uiThread.ManagedThreadId; _logger = new VsHierarchyLogger(this); }
public SynchronizationContextProvider(IUIThread uiThread) { _context = new SynchronizationContextDelegate(SynchronizationContext.Current); _threadId = uiThread.ManagedThreadId; }
public AudioManager(IUIThread uithread) { Music = new MusicPlayer(this); this.UIThread = uithread; new Thread(new ThreadStart(UpdateThread)).Start(); }
public static IVsHierarchy GetSelectedHierarchy(this IVsMonitorSelection monitorSelection, IUIThread uiThread) { var hierarchyPtr = IntPtr.Zero; var selectionContainer = IntPtr.Zero; return(uiThread.Invoke(() => { try { // Get the current project hierarchy, project item, and selection container for the current selection // If the selection spans multiple hierarchies, hierarchyPtr is Zero. // So fast path is for non-zero result (most common case of single active project/item). uint itemid; IVsMultiItemSelect multiItemSelect = null; ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer)); // There may be no selection at all. if (itemid == VSConstants.VSITEMID_NIL) { return null; } if (itemid == VSConstants.VSITEMID_ROOT) { // The root selection could be the solution itself, so no project is active. if (hierarchyPtr == IntPtr.Zero) { return null; } else { return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); } } // We may have a single item selection, so we can safely pick its owning project/hierarchy. if (itemid != VSConstants.VSITEMID_SELECTION) { return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); } // Otherwise, this is a multiple item selection within the same hierarchy, // we select he hierarchy. uint numberOfSelectedItems; int isSingleHierarchyInt; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt)); var isSingleHierarchy = (isSingleHierarchyInt != 0); if (isSingleHierarchy) { return (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)); } return null; } finally { if (hierarchyPtr != IntPtr.Zero) { Marshal.Release(hierarchyPtr); } if (selectionContainer != IntPtr.Zero) { Marshal.Release(selectionContainer); } } })); }
public DialogWindowFactory(Lazy <IDevEnv> devEnv, IVsUIShell uiShell, IUIThread uiThread) { this.devEnv = devEnv; this.uiShell = uiShell; this.uiThread = uiThread; }
public VsHierarchy(System.IServiceProvider serviceProvider, IVsGlyphService vsGlyphService, IUIThread uiThread) { _serviceProvider = serviceProvider; _vsGlyphService = vsGlyphService; _threadId = uiThread.ManagedThreadId; _logger = new VsHierarchyLogger(this); }
public MainViewModel(SpeechRecognizer speechRecognizer, IUIThread uiThread) { this.speechRecognizer = speechRecognizer ?? throw new ArgumentNullException(nameof(speechRecognizer)); this.uiThread = uiThread ?? throw new ArgumentNullException(nameof(uiThread)); this.RecognitionResults = new ObservableCollection <RecognitionResult>(); }
public static IEnumerable<Tuple<IVsHierarchy, uint>> GetSelection(this IVsMonitorSelection monitorSelection, IUIThread uiThread, IVsHierarchy solution) { var hierarchyPtr = IntPtr.Zero; var selectionContainer = IntPtr.Zero; return uiThread.Invoke(() => { try { // Get the current project hierarchy, project item, and selection container for the current selection // If the selection spans multiple hierarchies, hierarchyPtr is Zero uint itemid; IVsMultiItemSelect multiItemSelect = null; ErrorHandler.ThrowOnFailure(monitorSelection.GetCurrentSelection(out hierarchyPtr, out itemid, out multiItemSelect, out selectionContainer)); if (itemid == VSConstants.VSITEMID_NIL) return Enumerable.Empty<Tuple<IVsHierarchy, uint>>(); if (itemid == VSConstants.VSITEMID_ROOT) { if (hierarchyPtr == IntPtr.Zero) return new[] { Tuple.Create(solution, VSConstants.VSITEMID_ROOT) }; else return new[] { Tuple.Create( (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)), VSConstants.VSITEMID_ROOT) }; } if (itemid != VSConstants.VSITEMID_SELECTION) return new[] { Tuple.Create( (IVsHierarchy)Marshal.GetTypedObjectForIUnknown(hierarchyPtr, typeof(IVsHierarchy)), itemid) }; // This is a multiple item selection. uint numberOfSelectedItems; int isSingleHierarchyInt; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectionInfo(out numberOfSelectedItems, out isSingleHierarchyInt)); var isSingleHierarchy = (isSingleHierarchyInt != 0); var vsItemSelections = new VSITEMSELECTION[numberOfSelectedItems]; var flags = (isSingleHierarchy) ? (uint)__VSGSIFLAGS.GSI_fOmitHierPtrs : 0; ErrorHandler.ThrowOnFailure(multiItemSelect.GetSelectedItems(flags, numberOfSelectedItems, vsItemSelections)); return vsItemSelections.Where(sel => sel.pHier != null) // NOTE: we can return lazy results here, since // the GetSelectedItems has already returned in the UI thread // the array of results. We're just delaying the creation of the tuples // in case they aren't all needed. .Select(sel => Tuple.Create(sel.pHier, sel.itemid)); } finally { if (hierarchyPtr != IntPtr.Zero) { Marshal.Release(hierarchyPtr); } if (selectionContainer != IntPtr.Zero) { Marshal.Release(selectionContainer); } } }); }
public SynchronizationContextProvider(IUIThread uiThread) { _context = new SynchronizationContextDelegate(SynchronizationContext.Current); _threadId = uiThread.ManagedThreadId; }
public GameNetClient(IUIThread mainThread) { this.mainThread = mainThread; }
public static void MustNotBeCalledFromUIThread(this IUIThread self, string message = "Invalid cross-thread call") { Debug.Assert(self is IMockUIThread || self.InvokeRequired, message); }