private void MetadataButton_ContextMenuOpening(object sender, ContextMenuEventArgs e) { if (e != null) { e.Handled = true; } ButtonBase button = sender as ButtonBase; if ((button != null) && button.IsEnabled) { button.ContextMenu = null; IMetadataViewService metadataViewService = ToolsUIApplication.Instance.RootServiceProvider.GetService(typeof(IMetadataViewService)) as IMetadataViewService; if (metadataViewService != null) { IEnumerable <MetadataView> metadataViews = metadataViewService.GetMetadataViews(Window.GetWindow(button)); if (metadataViews.Count() > 0) { button.Focus(); button.ContextMenu = new ContextMenu() { DataContext = button.CommandParameter, ItemContainerStyle = Resources["MetadataViewSelectorMenuItemStyle"] as Style, ItemsSource = metadataViews, PlacementTarget = button, IsOpen = true, }; } } } }
public MetadataView(IServiceProvider serviceProvider) { DebugHelper.AssertUIThread(); // Give the metadata view a unique title when first added by the user IMetadataViewService metadataViewService = null; if (serviceProvider != null) { metadataViewService = serviceProvider.GetService(typeof(IMetadataViewService)) as IMetadataViewService; } if (metadataViewService != null) { Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { DebugHelper.AssertUIThread(); if (this.setTitle) { this.setTitle = false; this.Title = metadataViewService.GetUniqueTitle(this); } })); } }
public object CreateView(string registeredViewName, IServiceProvider serviceProvider) { object value = null; switch (registeredViewName) { case "TargetConnectionView": value = TargetConnectionView.CreateView(serviceProvider); break; case "TargetRecordableStreamsView": value = TargetRecordableStreamsView.CreateView(serviceProvider); break; case "PlaybackableStreamsView": value = PlaybackableStreamsView.CreateView(serviceProvider); break; case "TargetMonitorableStreamsView": value = TargetMonitorableStreamsView.CreateView(serviceProvider); break; case "Image2DVisualizationView": value = Image2DVisualizationView.CreateView(serviceProvider, EventType.Monitor); break; case "Image3DVisualizationView": value = Image3DVisualizationView.CreateView(serviceProvider, EventType.Monitor); break; case "InspectionImage2DVisualizationView": value = Image2DVisualizationView.CreateView(serviceProvider, EventType.Inspection); break; case "InspectionImage3DVisualizationView": value = Image3DVisualizationView.CreateView(serviceProvider, EventType.Inspection); break; case "Image2DPropertyView": value = Image2DPropertyView.CreateView(serviceProvider); break; case "MetadataView": if (serviceProvider != null) { IMetadataViewService metadataViewService = serviceProvider.GetService(typeof(IMetadataViewService)) as IMetadataViewService; if (metadataViewService != null) { value = metadataViewService.CreateView(serviceProvider); } } break; } return(value); }
public MainWindow(string[] args) { InitializeWindow(); InitializeComponent(); IServiceProvider serviceProvider = ToolsUIApplication.Instance.RootServiceProvider; if (serviceProvider != null) { this.loggingService = serviceProvider.GetService(typeof(ILoggingService)) as ILoggingService; this.notificationService = serviceProvider.GetService(typeof(IUserNotificationService)) as IUserNotificationService; this.kstudioService = serviceProvider.GetService(typeof(IKStudioService)) as IKStudioService; this.metadataViewService = serviceProvider.GetService(typeof(IMetadataViewService)) as IMetadataViewService; this.pluginService = serviceProvider.GetService(typeof(IPluginService)) as IPluginService; } if (this.kstudioService != null) { MultiBinding titleBinding = new MultiBinding { Converter = new TitleConverter { NoFileString = Strings.WindowTitle_NoFile, ReadOnlyFileFormat = Strings.WindowTitle_ReadOnlyFileFormat, WritableFileFormat = Strings.WindowTitle_WritableFileFormat, }, FallbackValue = ToolsUIApplication.Instance.AppTitle, }; titleBinding.Bindings.Add(new Binding { Source = this.kstudioService, Path = new PropertyPath("RecordingFilePath"), }); titleBinding.Bindings.Add(new Binding { Source = this.kstudioService, Path = new PropertyPath("PlaybackFilePath"), }); titleBinding.Bindings.Add(new Binding { Source = this.kstudioService, Path = new PropertyPath("IsPlaybackFileReadOnly"), }); this.SetBinding(Window.TitleProperty, titleBinding); this.kstudioService.PlaybackOpened += (s, e) => { DebugHelper.AssertUIThread(); if (!this.suppressAutoSwitch) { this.SwitchToView("PlaybackableStreamsView"); } }; this.kstudioService.Busy += (s, e) => { DebugHelper.AssertUIThread(); if (e != null) { this.IsEnabled = !e.IsBusy; } }; } if ((args != null) && (this.kstudioService != null)) { if (args.Length > 1) { bool connect = false; bool readOnly = false; string fileName = null; for (int i = 1; i < args.Length; ++i) { string arg = args[i]; if ((arg.Length > 1) && (arg[0] == '-')) { char ch = Char.ToUpperInvariant(arg[1]); switch (ch) { case 'R': readOnly = true; break; } } else { fileName = args[i]; } } string error = null; string targetAlias = null; IPAddress targetAddress = null; targetAlias = Environment.MachineName; targetAddress = IPAddress.Loopback; this.Loaded += (s, e) => { Dispatcher.BeginInvoke(new Action(() => { if (error == null) { if (connect) { if (targetAddress != null) { using (WaitCursor waitCursor = new WaitCursor(this)) { if (!this.kstudioService.ConnectToTarget(targetAddress, targetAlias)) { fileName = null; } } } } if (fileName != null) { error = String.Format(CultureInfo.CurrentCulture, Strings.Arg_Error_InvalidFileName, fileName); if (fileName.Length > 2) { using (WaitCursor waitCursor = new WaitCursor(this)) { this.OpenFile(fileName, readOnly); error = null; } } } } if (error != null) { if (this.notificationService != null) { this.notificationService.ShowMessageBox(error, MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK); } else if (this.loggingService != null) { this.loggingService.LogLine(error); } } CommandManager.InvalidateRequerySuggested(); } )); }; } } }