public DialogResult ShowDialog(Form form) { // Now that we implemented IMsoComponent, calling IVsUIShell.EnableModeless // causes more problems than it solves (ASURT 41876). // uishell.EnableModeless(0); // Site the Form if possible, to give access to AmbientProperties. ShowDialogContainer container = null; if (form.Site == null) { AmbientProperties ambient = new AmbientProperties(); ambient.Font = (Font)Styles["DialogFont"]; container = new ShowDialogContainer(ambient); container.Add(form); } DialogResult dlgResult = DialogResult.None; try { dlgResult = form.ShowDialog(GetDialogOwnerWindow()); } finally { if (container != null) { container.Remove(form); } } return(dlgResult); }
/// <devdoc> /// Override to GetService so we can route requests /// to the package's service provider. /// </devdoc> protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (serviceType == typeof(AmbientProperties)) { if (_ambientProperties == null) { IUIService uis = GetService(typeof(IUIService)) as IUIService; _ambientProperties = new AmbientProperties(); _ambientProperties.Font = (Font)uis.Styles["DialogFont"]; } return(_ambientProperties); } if (_provider != null) { object service = _provider.GetService(serviceType); if (service != null) { return(service); } } return(base.GetService(serviceType)); }
private void LoadDesigner() { //LoggingService.Info("Form Designer: BEGIN INITIALIZE"); DefaultServiceContainer parentProvider = new DefaultServiceContainer(); parentProvider.AddService(typeof(IUIService), new UIService()); parentProvider.AddService(typeof(IToolboxService), new ToolboxService()); parentProvider.AddService(typeof(IPropertyValueUIService), new PropertyValueUIService()); AmbientProperties serviceInstance = new AmbientProperties(); parentProvider.AddService(typeof(AmbientProperties), serviceInstance); parentProvider.AddService(typeof(IDesignerEventService), new FormsDesigner.Services.DesignerEventService()); this.designSurface = new System.ComponentModel.Design.DesignSurface(parentProvider); parentProvider.AddService(typeof(IMenuCommandService), new FormsDesigner.Services.MenuCommandService(this.p, this.designSurface)); parentProvider.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); DesignerLoader loader = this.loaderProvider.CreateLoader(this.generator); //加载XML内容 this.designSurface.BeginLoad(loader); this.generator.Attach(this); this.undoEngine = new FormsDesignerUndoEngine(this.Host); IComponentChangeService service = (IComponentChangeService) this.designSurface.GetService(typeof(IComponentChangeService)); service.ComponentChanged += delegate { this.viewContent.IsDirty = true; }; service.ComponentAdded += new ComponentEventHandler(this.ComponentListChanged); service.ComponentRemoved += new ComponentEventHandler(this.ComponentListChanged); service.ComponentRename += new ComponentRenameEventHandler(this.ComponentListChanged); this.Host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.TransactionClose); ISelectionService service2 = (ISelectionService) this.designSurface.GetService(typeof(ISelectionService)); service2.SelectionChanged += new EventHandler(this.SelectionChangedHandler); if (this.IsTabOrderMode) { this.tabOrderMode = false; this.ShowTabOrder(); } //LoggingService.Info("Form Designer: END INITIALIZE"); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Override to GetService so we can route requests to the package's service provider. /// </summary> // -------------------------------------------------------------------------------------------- protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } // --- Handle AmbinetProperties as special type. if (serviceType == typeof(AmbientProperties)) { if (_AmbientProperties == null) { var uis = GetService(typeof(IUIService)) as IUIService; _AmbientProperties = new AmbientProperties(); if (uis != null) { _AmbientProperties.Font = (Font)uis.Styles["DialogFont"]; } } return(_AmbientProperties); } // --- Route requests to the owner package's service provider. if (_ServiceProvider != null) { var service = _ServiceProvider.GetService(serviceType); if (service != null) { return(service); } } return(base.GetService(serviceType)); }
/// <devdoc> /// Override to GetService so we can route requests /// to the package's service provider. /// </devdoc> protected override object GetService(Type serviceType) { if (serviceType == null) { throw new ArgumentNullException("serviceType"); } if (_provider != null) { if (serviceType.IsEquivalentTo(typeof(AmbientProperties))) { if (_uis == null) { _uis = (IUIService)_provider.GetService(typeof(IUIService)); } if (_ambientProperties == null) { _ambientProperties = new AmbientProperties(); } if (_uis != null) { // update the _ambientProperties in case the styles have changed // since last time. _ambientProperties.Font = (Font)_uis.Styles["DialogFont"]; } return(_ambientProperties); } object service = _provider.GetService(serviceType); if (service != null) { return(service); } } return(base.GetService(serviceType)); }
public void Font_Set_GetReturnsExpected() { var property = new AmbientProperties { Font = SystemFonts.DefaultFont }; Assert.Equal(SystemFonts.DefaultFont, property.Font); }
public void Ctor_Default() { var property = new AmbientProperties(); Assert.Equal(Color.Empty, property.BackColor); Assert.Null(property.Cursor); Assert.Null(property.Font); Assert.Equal(Color.Empty, property.ForeColor); }
public void ForeColor_Set_GetReturnsExpected() { var property = new AmbientProperties { ForeColor = Color.Red }; Assert.Equal(Color.Red, property.ForeColor); }
public void Cursor_Set_GetReturnsExpected() { var cursor = new Cursor((IntPtr)1); var property = new AmbientProperties { Cursor = cursor }; Assert.Equal(cursor, property.Cursor); }
public void Font_Set_GetReturnsExpected(Font value) { var property = new AmbientProperties { Font = value }; Assert.Equal(value, property.Font); // Set same. property.Font = value; Assert.Equal(value, property.Font); }
public void ForeColor_Set_GetReturnsExpected(Color value) { var property = new AmbientProperties { ForeColor = value }; Assert.Equal(value, property.ForeColor); // Set same. property.ForeColor = value; Assert.Equal(value, property.ForeColor); }
public static int Main(string[] args) { NUnitForm.CommandLineOptions command = new NUnitForm.CommandLineOptions(); GuiOptions parser = new GuiOptions(args); if (parser.Validate() && !parser.help) { if (parser.cleanup) { DomainManager.DeleteShadowCopyPath(); return(0); } if (!parser.NoArgs) { if (parser.IsAssembly) { command.testFileName = parser.Assembly; } command.configName = parser.config; command.testName = parser.fixture; command.noload = parser.noload; command.autorun = parser.run; if (parser.lang != null) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(parser.lang); } if (parser.HasInclude) { command.categories = parser.include; command.exclude = false; } else if (parser.HasExclude) { command.categories = parser.exclude; command.exclude = true; } } // Add Standard Services to ServiceManager ServiceManager.Services.AddService(new SettingsService()); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); // Initialize Services ServiceManager.Services.InitializeServices(); // Create container in order to allow ambient properties // to be shared across all top-level forms. AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); NUnitForm form = new NUnitForm(command); c.Add(form); try { Application.Run(form); } finally { ServiceManager.Services.StopAllServices(); } } else { string message = parser.GetHelpText(); UserMessage.DisplayFailure(message, "Help Syntax"); return(2); } return(0); }
public static int Main(string[] args) { var options = new CommandLineOptions(args); if (options.ShowHelp) { // TODO: We would need to have a custom message box // in order to use a fixed font and display the options // so that the values all line up. MessageDisplay.Info(options.GetHelpText()); return(0); } if (!options.Validate()) { var NL = Environment.NewLine; var sb = new StringBuilder($"Error(s) in command line:{NL}"); foreach (string msg in options.ErrorMessages) { sb.Append($" {msg}{NL}"); } sb.Append($"{NL}{options.GetHelpText()}"); MessageDisplay.Error(sb.ToString()); return(2); } // Currently the InternalTraceLevel can only be set from the command-line. // We can't use user settings to provide a default because the settings // are an engine service and the engine have the internal trace level // set as part of its initialization. var traceLevel = options.InternalTraceLevel; // This initializes the trace setting for the GUI itself. InternalTrace.Initialize($"InternalTrace.{Process.GetCurrentProcess().Id}.gui.log", traceLevel); log.Info($"Starting TestCentric Runner - InternalTraceLevel = {traceLevel}"); // Create container in order to allow ambient properties // to be shared across all top-level forms. log.Info("Initializing AmbientProperties"); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); log.Info("Creating TestEngine"); ITestEngine testEngine = TestEngineActivator.CreateInstance(); testEngine.InternalTraceLevel = traceLevel; log.Info("Instantiating TestModel"); ITestModel model = new TestModel(testEngine); log.Info("Constructing Form"); TestCentricMainForm form = new TestCentricMainForm(model, options); c.Add(form); try { log.Info("Starting Gui Application"); Application.Run(form); log.Info("Application Exit"); } catch (Exception ex) { log.Error("Gui Application threw an excepion", ex); throw; } finally { log.Info("Exiting TestCentric Runner"); InternalTrace.Close(); testEngine.Dispose(); } return(0); }
void LoadDesigner() { LoggingService.Info("Form Designer: BEGIN INITIALIZE"); DefaultServiceContainer serviceContainer = new DefaultServiceContainer(); serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService); serviceContainer.AddService(typeof(IHelpService), new HelpService()); serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService()); serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), new DesignerResourceService(this.resourceStore)); AmbientProperties ambientProperties = new AmbientProperties(); serviceContainer.AddService(typeof(AmbientProperties), ambientProperties); this.typeResolutionService = new TypeResolutionService(this.PrimaryFileName); serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService); serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService()); serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); serviceContainer.AddService(typeof(ProjectResourceService), new ProjectResourceService(ParserService.GetParseInformation(this.DesignerCodeFile.FileName).MostRecentCompilationUnit.ProjectContent)); // Provide the ImageResourceEditor for all Image and Icon properties this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor)))); if (generator.CodeDomProvider != null) { serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider); } designSurface = CreateDesignSurface(serviceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesignerUnloading; serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this.Control, designSurface)); ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); this.loader = loaderProvider.CreateLoader(generator); designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } undoEngine = new FormsDesignerUndoEngine(Host); serviceContainer.AddService(typeof(UndoEngine), undoEngine); IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += ComponentChanged; componentChangeService.ComponentAdded += ComponentListChanged; componentChangeService.ComponentRemoved += ComponentListChanged; componentChangeService.ComponentRename += ComponentListChanged; this.Host.TransactionClosed += TransactionClose; ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; if (IsTabOrderMode) // fixes SD2-1015 { tabOrderMode = false; // let ShowTabOrder call the designer command again ShowTabOrder(); } UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("Form Designer: END INITIALIZE"); }
private void LoadDesigner(Stream stream) { LoggingService.Info("Form Designer: BEGIN INITIALIZE"); defaultServiceContainer = new DefaultServiceContainer(); defaultServiceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); defaultServiceContainer.AddService(typeof(IToolboxService), new ToolboxService()); defaultServiceContainer.AddService(typeof(IHelpService), new HelpService()); this.designSurface = CreateDesignSurface(defaultServiceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesingerUnloading; AmbientProperties ambientProperties = new AmbientProperties(); defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties); defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); defaultServiceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new MenuCommandService(panel, this.designSurface)); defaultServiceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); //need this to resolve the filename and manipulate //ReportSettings in ReportDefinitionDeserializer.LoadObjectFromXmlDocument //if the filename in ReportSettings is different from load location defaultServiceContainer.AddService(typeof(OpenedFile), base.PrimaryFile); DesignerOptionService dos = new System.Windows.Forms.Design.WindowsFormsDesignerOptionService(); dos.Options.Properties.Find("UseSmartTags", true).SetValue(dos, true); dos.Options.Properties.Find("ShowGrid", true).SetValue(dos, false); dos.Options.Properties.Find("UseSnapLines", true).SetValue(dos, true); defaultServiceContainer.AddService(typeof(DesignerOptionService), dos); this.loader = new ReportDesignerLoader(generator, stream); this.designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } defaultServiceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService()); ISelectionService selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; undoEngine = new ReportDesignerUndoEngine(Host); IComponentChangeService componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentAdded += OnComponentListChanged; componentChangeService.ComponentRemoved += OnComponentListChanged; componentChangeService.ComponentRename += OnComponentListChanged; this.Host.TransactionClosed += TransactionClose; UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("Form Designer: END INITIALIZE"); }
public ShowDialogContainer(AmbientProperties ambientProperties) { Debug.Assert(ambientProperties != null, "ambientProperties are null"); this.ambientProperties = ambientProperties; }
/* public void startNunitInSeparateAppDomain(string fileToLoad) * { * // var args = new[] { fileToLoad}; // (O2CorLib.dll) assembly that will be loaded and searched for Unit tests * var args = new string[] {}; * string exeToRun = Path.Combine(pathToNUnitBinFolder, "nunit-x86.exe"); * appDomain = AppDomainUtils.newAppDomain_ExecuteAssembly("nUnitExec", pathToNUnitBinFolder, exeToRun, args); * }*/ // ReSharper restore SuggestUseVarKeywordEvident /* public bool isAttached * { * get { return NUnitControl != null; } * }*/ /* public Control NUnitControl * { * get * { * if (nUnitRunnerDll == null) * loadNUnitDll(); * * //return null; * var label = new Label {Text = "aaaaaaaaaa"}; * return label; * } * }*/ // On this one lets not use var keywords (since that will make it easier to understand what is going on) // ReSharper disable SuggestUseVarKeywordEvident public Form getMainForm() { var nUnitGuiRunner = new O2ObjectFactory(NUnitGuiRunnerDll); var nUnitUtil = new O2ObjectFactory(nUnitUtilDll); var nUnitUikit = new O2ObjectFactory(nUnitUikitDll); // [code to implement] public static int Main(string[] args) // [code to implement] GuiOptions guiOptions = new GuiOptions(args); //var args = new[] { Config.getExecutingAssembly() }; // assembly that will be loaded and searched for Unit tests var args = new[] { nUnitUtilDll }; O2Object guiOptions = nUnitGuiRunner.ctor("GuiOptions", new[] { args }); // [code to implement] /* * ServiceManager.Services.AddService(new SettingsService()) * ServiceManager.Services.AddService(new DomainManager()); * ServiceManager.Services.AddService(new RecentFilesService()); * ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); * ServiceManager.Services.AddService(new AddinRegistry()); * ServiceManager.Services.AddService(new AddinManager()); * ServiceManager.Services.AddService(new TestAgency());*/ O2Object serviceManager_Services = nUnitUtil.staticTypeGetProperty("ServiceManager", "Services"); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("SettingsService") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("DomainManager") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("RecentFilesService") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("TestLoader", new[] { nUnitUikit.ctor("GuiTestEventDispatcher") }) }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("AddinRegistry") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("AddinManager") }); serviceManager_Services.call("AddService", new[] { nUnitUtil.ctor("TestAgency") }); // [code to implement] ServiceManager.Services.InitializeServices(); serviceManager_Services.call("InitializeServices"); // [code to implement] AppContainer container = new AppContainer(); O2Object container = nUnitUikit.ctor("AppContainer"); // [don't need to implement this one] AmbientProperties serviceInstance = new AmbientProperties(); var serviceInstance = new AmbientProperties(); // [code to implement] container.Services.AddService(typeof(AmbientProperties), serviceInstance); O2Object container_services = container.get("Services"); container_services.call("AddService", new object[] { typeof(AmbientProperties), serviceInstance }); // [code to implement] NUnitForm component = new NUnitForm(guiOptions); O2Object component = nUnitGuiRunner.ctor("NUnitForm", new[] { guiOptions }); // [code to implement] container.Add(component); container.call("Add", new object[] { component }); // [code to implement] new GuiAttachedConsole(); nUnitUikit.ctor("GuiAttachedConsole"); return((Form)component.Obj); /*return (form is Form) ? (Form) form.Obj : null; * if (form is Form) * return (Form) form.Obj; * else * return null; */ }
public static int Main(string[] args) { // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService(); InternalTrace.Initialize("nunit-gui_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); log.Info("Starting NUnit GUI"); GuiOptions guiOptions = new GuiOptions(args); GuiAttachedConsole attachedConsole = null; if (guiOptions.console) { log.Info("Creating attached console"); attachedConsole = new GuiAttachedConsole(); } if (guiOptions.help) { MessageDisplay.Display(guiOptions.GetHelpText()); return(0); } if (!guiOptions.Validate()) { string message = "Error in command line"; MessageDisplay.Error(message + Environment.NewLine + Environment.NewLine + guiOptions.GetHelpText()); log.Error(message); return(2); } if (guiOptions.cleanup) { log.Info("Performing cleanup of shadow copy cache"); DomainManager.DeleteShadowCopyPath(); return(0); } if (!guiOptions.NoArgs) { if (guiOptions.lang != null) { log.Info("Setting culture to " + guiOptions.lang); Thread.CurrentThread.CurrentUICulture = new CultureInfo(guiOptions.lang); } } try { // Add Standard Services to ServiceManager log.Info("Adding Services"); ServiceManager.Services.AddService(settingsService); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); // Initialize Services log.Info("Initializing Services"); ServiceManager.Services.InitializeServices(); } catch (Exception ex) { MessageDisplay.FatalError("Service initialization failed.", ex); log.Error("Service initialization failed", ex); return(2); } // Create container in order to allow ambient properties // to be shared across all top-level forms. log.Info("Initializing AmbientProperties"); AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); log.Info("Constructing Form"); NUnitForm form = new NUnitForm(guiOptions); c.Add(form); try { log.Info("Starting Gui Application"); Application.Run(form); log.Info("Application Exit"); } catch (Exception ex) { log.Error("Gui Application threw an excepion", ex); throw; } finally { log.Info("Stopping Services"); ServiceManager.Services.StopAllServices(); } if (attachedConsole != null) { Console.WriteLine("Press Enter to exit"); Console.ReadLine(); attachedConsole.Close(); } log.Info("Exiting NUnit GUI"); InternalTrace.Close(); return(0); }
void LoadDesigner(Stream stream) { LoggingService.Info("ReportDesigner LoadDesigner_Start"); panel = CreatePanel(); defaultServiceContainer = CreateAndInitServiceContainer(); LoggingService.Info("Create DesignSurface and add event's"); designSurface = CreateDesignSurface(defaultServiceContainer); SetDesignerEvents(); var ambientProperties = new AmbientProperties(); defaultServiceContainer.AddService(typeof(AmbientProperties), ambientProperties); defaultServiceContainer.AddService(typeof(ITypeResolutionService), new TypeResolutionService()); defaultServiceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); defaultServiceContainer.AddService(typeof(IMenuCommandService), new ICSharpCode.Reporting.Addin.Services.MenuCommandService(panel, designSurface)); defaultServiceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); defaultServiceContainer.AddService(typeof(OpenedFile), base.PrimaryFile); LoggingService.Info("Load DesignerOptionService"); var designerOptionService = CreateDesignerOptions(); defaultServiceContainer.AddService(typeof(DesignerOptionService), designerOptionService); LoggingService.Info("Create ReportDesignerLoader"); loader = new ReportDesignerLoader(generator, stream); designSurface.BeginLoad(this.loader); if (!designSurface.IsLoaded) { // throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); LoggingService.Error("designer not loaded"); } //------------- defaultServiceContainer.AddService(typeof(INameCreationService), new NameCreationService()); var selectionService = (ISelectionService)this.designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; undoEngine = new ReportDesignerUndoEngine(Host); var componentChangeService = (IComponentChangeService)this.designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += OnComponentChanged; componentChangeService.ComponentAdded += OnComponentListChanged; componentChangeService.ComponentRemoved += OnComponentListChanged; componentChangeService.ComponentRename += OnComponentListChanged; this.Host.TransactionClosed += TransactionClose; UpdatePropertyPad(); hasUnmergedChanges = false; LoggingService.Info("ReportDesigner LoadDesigner_End"); }
public static int Main(string[] args) { NTrace.Info("Starting NUnit GUI"); GuiOptions guiOptions = new GuiOptions(args); GuiAttachedConsole attachedConsole = null; if (guiOptions.console) { attachedConsole = new GuiAttachedConsole(); } if (!guiOptions.Validate() || guiOptions.help) { string message = guiOptions.GetHelpText(); UserMessage.DisplayFailure(message, "Help Syntax"); return(2); } if (guiOptions.cleanup) { DomainManager.DeleteShadowCopyPath(); return(0); } if (!guiOptions.NoArgs) { if (guiOptions.lang != null) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(guiOptions.lang); } } // Add Standard Services to ServiceManager ServiceManager.Services.AddService(new SettingsService()); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new RecentFilesService()); ServiceManager.Services.AddService(new TestLoader(new GuiTestEventDispatcher())); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); // Initialize Services ServiceManager.Services.InitializeServices(); // Create container in order to allow ambient properties // to be shared across all top-level forms. AppContainer c = new AppContainer(); AmbientProperties ambient = new AmbientProperties(); c.Services.AddService(typeof(AmbientProperties), ambient); NUnitForm form = new NUnitForm(guiOptions); c.Add(form); try { Application.Run(form); } finally { ServiceManager.Services.StopAllServices(); } if (attachedConsole != null) { Console.WriteLine("Press Enter to exit"); Console.ReadLine(); attachedConsole.Close(); } NTrace.Info("Exiting NUnit GUI"); return(0); }
public void LoadDesigner(string formFile) { UnloadDesigner(); DefaultServiceContainer serviceContainer = new DefaultServiceContainer(); serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService()); serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService); serviceContainer.AddService(typeof(IHelpService), new HelpService()); serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService()); AmbientProperties ambientProperties = new AmbientProperties(); serviceContainer.AddService(typeof(AmbientProperties), ambientProperties); this.typeResolutionService = new TypeResolutionService(); serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService); serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService()); serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService()); serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService()); designSurface = CreateDesignSurface(serviceContainer); designSurface.Loading += this.DesignerLoading; designSurface.Loaded += this.DesignerLoaded; designSurface.Flushed += this.DesignerFlushed; designSurface.Unloading += this.DesignerUnloading; designerResourceService = new DesignerResourceService(this);//roman// serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), designerResourceService); loader = new CodeDomHostLoader(this.Host, formFile, FileName); serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(Host)); ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(Host); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService); designSurface.BeginLoad(loader); if (!designSurface.IsLoaded) { throw new FormsDesignerLoadException(FormatLoadErrors(designSurface)); } undoEngine = new FormsDesignerUndoEngine(Host); serviceContainer.AddService(typeof(UndoEngine), undoEngine); IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService)); componentChangeService.ComponentChanged += ComponentChanged; componentChangeService.ComponentAdded += ComponentListChanged; componentChangeService.ComponentRemoved += ComponentListChanged; componentChangeService.ComponentRename += ComponentListChanged; this.Host.TransactionClosed += TransactionClose; ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService)); selectionService.SelectionChanged += SelectionChangedHandler; if (IsTabOrderMode) // fixes SD2-1015 { tabOrderMode = false; // let ShowTabOrder call the designer command again ShowTabOrder(); } UpdatePropertyPad(); hasUnmergedChanges = false; MakeDirty(); PropertyGrid grid = PropertyPad.Grid; var gridView = (Control)grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(grid); var edit = (Control)gridView.GetType().GetField("edit", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gridView); edit.KeyPress += PropertyPadEditorKeyPress; edit.ContextMenu = new ContextMenu(); }
// -------------------------------------------------------------------------------------------- /// <summary> /// Resets the AmbientProperties to null. /// </summary> // -------------------------------------------------------------------------------------------- public void ResetAmbientProperties() { _AmbientProperties = null; }