public void Import_OptIn_AllowRecomposition() { var container = new CompositionContainer(); var importer = new Class_OptIn_AllowRecompositionImports(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(importer); var valueKey = batch.AddExportedValue("Value", 21); container.Compose(batch); // Initial compose Value should be 21 Assert.Equal(21, importer.Value); // Recompose Value to be 42 batch = new CompositionBatch(); batch.RemovePart(valueKey); batch.AddExportedValue("Value", 42); container.Compose(batch); Assert.Equal(42, importer.Value); }
//[ImportMany(typeof(IFormExstension), AllowRecomposition = true)] //public List<IFormExstension> FormExtensions { get; set; } public void LoadExtensions() { string path = Application.StartupPath + @"\Extensions"; if(Directory.Exists(path)) { var catalog = new AggregateCatalog( new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog(path)); var batch = new CompositionBatch(); batch.AddPart(this); _container = new CompositionContainer(catalog); try { _container.Compose(batch); } catch (CompositionException compositionException) { MessageBox.Show(compositionException.ToString()); } } }
private void LoadPlugins() { try { var catalog = new DirectoryCatalog(@".\", "*.plg.dll"); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); container.Compose(batch); } catch (Exception ee) { var li = new LogItem { App = "Apteka.Interfaces", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "PluginManager.LoadPlugins" }; CLogJson.Write(li); } }
[ActiveIssue(25498, TestPlatforms.AnyUnix)] // System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. public void ImportCompletedChildDoesnotNeedParentContainer() { var cat = CatalogFactory.CreateDefaultAttributed(); var parent = new CompositionContainer(cat); CompositionBatch parentBatch = new CompositionBatch(); CompositionBatch childBatch = new CompositionBatch(); parentBatch.AddExportedValue <ICompositionService>(parent); parent.Compose(parentBatch); var child = new CompositionContainer(parent); var parentImporter = new MyNotifyImportImporter(parent); var childImporter = new MyNotifyImportImporter(child); parentBatch = new CompositionBatch(); parentBatch.AddPart(parentImporter); childBatch.AddParts(childImporter, new MyNotifyImportExporter()); child.Compose(childBatch); Assert.Equal(0, parentImporter.ImportCompletedCallCount); Assert.Equal(1, childImporter.ImportCompletedCallCount); // Parent will become bound at this point. MyNotifyImportExporter parentExporter = parent.GetExportedValue <MyNotifyImportExporter>("MyNotifyImportExporter"); parent.Compose(parentBatch); Assert.Equal(1, parentImporter.ImportCompletedCallCount); Assert.Equal(1, parentExporter.ImportCompletedCallCount); MyNotifyImportExporter childExporter = child.GetExportedValue <MyNotifyImportExporter>("MyNotifyImportExporter"); Assert.Equal(1, childExporter.ImportCompletedCallCount); }
static void CreateSharedMain() { // Create a type catalog with the types of components we want in the application TypeCatalog catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(ErrorDialogService) // displays errors to the user in a message box ); StandardEditCommands.UseSystemClipboard = true; CompositionContainer sharedContainer = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); m_toolMainForm = new ToolMainForm() { Text = "Diagram Editor Main".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; // Add the main Form instance to the container batch.AddPart(m_toolMainForm); sharedContainer.Compose(batch); sharedContainer.InitializeAll(); m_SharedComponents.Add(sharedContainer.GetExportedValue <SettingsService>()); m_SharedComponents.Add(sharedContainer.GetExportedValue <UnhandledExceptionService>()); m_SharedComponents.Add(sharedContainer.GetExportedValue <IFileDialogService>()); m_SharedComponents.Add(sharedContainer.GetExportedValue <ErrorDialogService>()); m_SharedContainer = sharedContainer; }
public void Load() { try { DirectoryCatalog catalog_plugin = new DirectoryCatalog(Path.Combine(Environment.CurrentDirectory, gatewayPath)); CompositionContainer container = new CompositionContainer(catalog_plugin); CompositionBatch bath = new CompositionBatch(); bath.AddPart(this); container.Compose(bath); string[] hows = new string[plugins.Length]; int i = 0; foreach (var plugin in plugins) { hows[i] = plugin.How; i++; } Config.Hows = string.Join(",", hows); } catch (Exception ex) { throw new Exception($"Errors.ERROR_LOADING_GATEWAY, ex: {ex.Message}"); } }
/// <summary> /// 卸载插件 /// </summary> /// <param name="plugin"></param> /// <returns></returns> private bool UnLoadPlugin(IPlugin plugin) { bool isSuccess = false; try { var batch = new CompositionBatch(); var part = AttributedModelServices.CreatePart(plugin); //var part = batch.AddExportedValue<IPlugin>(plugin); //var part2 = _container.GetExportedValues<IPlugin>().First(); //Lazy<IPlugin> part3 = _container.GetExport<IPlugin>(); //IPlugin tmp = part3.Value; //batch.RemovePart(part); batch.AddPart(part); _container.Compose(batch); //_container.ReleaseExport(part3); isSuccess = true; } catch { isSuccess = false; } return(isSuccess); }
/// <summary> /// Will satisfy the imports on a part based on a <see cref="CompositionContainer"/> /// registered with the <see cref="CompositionHost"/>. By default if no <see cref="CompositionContainer"/> /// is registered the first time this is called it will be initialized to a catalog /// that contains all the assemblies loaded by the initial application XAP. /// </summary> /// <param name="part"> /// Part with imports that need to be satisfied. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="instance"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="instance"/> contains <see cref="ExportAttribute"/>s applied on its type. /// </exception> /// <exception cref="ChangeRejectedException"> /// One or more of the imports on the object instance could not be satisfied. /// </exception> /// <exception cref="CompositionException"> /// One or more of the imports on the object instance caused an error while composing. /// </exception> public static void SatisfyImports(ComposablePart part) { if (part == null) { throw new ArgumentNullException("part"); } var batch = new CompositionBatch(); batch.AddPart(part); if (part.ExportDefinitions.Any()) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.ArgumentException_TypeHasExports, part.ToString()), "part"); } CompositionContainer container = null; // Ignoring return value because we don't need to know if we created it or not CompositionHost.TryGetOrCreateContainer(_createContainer, out container); container.Compose(batch); }
public void DualContainers() { var container1 = new CompositionContainer(); TypeDescriptorServices dat1 = new TypeDescriptorServices(); CompositionBatch batch = new CompositionBatch(); batch.AddPart(dat1); container1.Compose(batch); MetadataStore.AddAttribute( typeof(DynamicMetadataTestClass), (type, attributes) => Enumerable.Concat( attributes, new Attribute[] { new TypeConverterAttribute(typeof(DynamicMetadataTestClassConverter)) } ), container1 ); var container2 = new CompositionContainer(); CompositionBatch batch2 = new CompositionBatch(); TypeDescriptorServices dat2 = new TypeDescriptorServices(); batch2.AddPart(dat2); container2.Compose(batch2); DynamicMetadataTestClass val = DynamicMetadataTestClass.Get("42"); var attached1 = dat1.GetConverter(val.GetType()); Assert.IsTrue(attached1.CanConvertFrom(typeof(string)), "The new type converter for DynamicMetadataTestClass should support round tripping"); var attached2 = dat2.GetConverter(val.GetType()); Assert.IsFalse(attached2.CanConvertFrom(typeof(string)), "The default type converter for DynamicMetadataTestClass shouldn't support round tripping"); }
public void LoadExtensions() { string path = Application.StartupPath + @"\Extensions"; if (Directory.Exists(path)) { var catalog = new AggregateCatalog( new AssemblyCatalog(Assembly.GetExecutingAssembly()), new DirectoryCatalog(path)); var batch = new CompositionBatch(); batch.AddPart(this); _container = new CompositionContainer(catalog); try { _container.Compose(batch); } catch (CompositionException compositionException) { MessageBox.Show(compositionException.ToString()); } } }
private bool Compose() { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); catalog.Catalogs.Add(new AssemblyCatalog(typeof(IEmailService).Assembly)); _container = new CompositionContainer(catalog); CompositionBatch batch = new CompositionBatch(); batch.AddPart(this); try { _container.Compose(batch); } catch (CompositionException compositionException) { MessageBox.Show(compositionException.ToString()); Shutdown(1); return(false); } return(true); }
public PluginManagerSI() { try { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); var catalog = new DirectoryCatalog(@".\", "*.plg.dll"); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); container.Compose(batch); PlgItem?.Initialize(null); } catch (ReflectionTypeLoadException ee) { var li = new LogItem { App = "wsDataBaseSync", Stacktrace = ee.GetStackTrace(5), Message = ee.GetAllMessages(), Method = "PluginManagerSI" }; CLogJson.Write(li); } }
private bool Compose() { var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly())); catalog.Catalogs.Add(new DirectoryCatalog("AddIns")); _container = new CompositionContainer(catalog); CompositionBatch batch = new CompositionBatch(); batch.AddPart(this); batch.AddExportedValue <CompositionContainer>(_container); try { _container.Compose(batch); } catch (CompositionException compositionException) { MessageBox.Show(compositionException.ToString()); Shutdown(1); } return(true); }
private void AddToFavorites() { Debug.Assert(NavigationService != null); Debug.Assert(Container != null); string fullPath = System.IO.Path.Combine(NavigationService.CurrentPath, NavigationService.SelectedItem); IFavoriteItem favItem = null; if (Directory.Exists(fullPath)) { favItem = new FavoriteDirectoryItem(fullPath); } else if (File.Exists(fullPath)) { favItem = new FavoriteFileItem(fullPath); } if (favItem != null) { CompositionBatch batch = new CompositionBatch(); batch.AddPart(favItem); Container.Compose(batch); } }
/// <summary> /// Composes: load the available plugins. /// </summary> public void Compose() { GlobalPlugins = new List <IGlobalPlugin>(); DataHandlerPlugins = new List <IDataHandlerPlugin>(); try { var directoryCatalogs = pluginsDirectories.Select(d => new DirectoryCatalog(d)); var catalog = new AggregateCatalog(directoryCatalogs.ToArray()); var container = new CompositionContainer(catalog); var batch = new CompositionBatch(); batch.AddPart(this); container.Compose(batch); } catch (Exception ex) { var debugException = ex; This.Logger.Error("Could not load plugins.", ex); } }
public void ParentedContainerSimpleCompose() { var container = ContainerFactory.Create(); var importPart = PartFactory.CreateImporter("value1", "value2"); CompositionBatch batch = new CompositionBatch(); batch.AddExportedValue("value1", "Parent"); var childContainer = new CompositionContainer(container); CompositionBatch childBatch = new CompositionBatch(); childBatch.AddExportedValue("value2", "Child"); childBatch.AddPart(importPart); Assert.Equal(0, importPart.ImportSatisfiedCount); container.Compose(batch); childContainer.Compose(childBatch); Assert.Equal(2, importPart.ImportSatisfiedCount); Assert.Equal("Parent", importPart.GetImport("value1")); Assert.Equal("Child", importPart.GetImport("value2")); }
public void PhaseTest() { CompositionContainer container = ContainerFactory.Create(); CompositionBatch batch = new CompositionBatch(); var part = new OrderingTestComposablePart(); part.AddImport("Import1", ImportCardinality.ExactlyOne, true, false); part.AddExport("Export1", 1); part.CallOrder.Enqueue("Import:Import1"); part.CallOrder.Enqueue("OnComposed"); batch.AddExportedValue("Import1", 20); batch.AddPart(part); container.Compose(batch); // Export shouldn't be called until it is pulled on by someone. var export = container.GetExport <object>("Export1"); part.CallOrder.Enqueue("Export:Export1"); Assert.AreEqual(1, export.Value); Assert.IsTrue(part.CallOrder.Count == 0); }
public void Rejection_DefendPromisesOnceMade() { var container = ContainerFactory.CreateWithAttributedCatalog(typeof(Needy)); var addBatch = new CompositionBatch(); var removeBatch = new CompositionBatch(); var addedPart = addBatch.AddPart(new NoImportPart()); removeBatch.RemovePart(addedPart); // Add then remove should be fine as long as exports aren't used yet. container.Compose(addBatch); container.Compose(removeBatch); // Add the dependencies container.Compose(addBatch); // Retrieve needy which uses an export from addedPart var export = container.GetExportedValue <Needy>(); // Should not be able to remove the addedPart because someone depends on it. ExceptionAssert.Throws <ChangeRejectedException>(() => container.Compose(removeBatch)); }
static void Main() { //// important to call these before creating application host //Application.EnableVisualStyles(); //Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 //// Set up localization support early on, so that user-readable strings will be localized //// during the initialization phase below. Use XML files that are embedded resources. //Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; //Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); //// Enable metadata driven property editing for the DOM //DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator<CustomTypeDescriptorNodeAdapter>()); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); using ( var catalog = new TypeCatalog( /* Standard ATF stuff */ typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter. typeof(Outputs), // passes messages to all log writers typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(DocumentRegistry), // central document registry with change notification typeof(FileDialogService), // standard Windows file dialogs typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(StandardFileExitCommand), // standard File exit menu command typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(ContextRegistry), // central context registry with change notification typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(PaletteService), // global palette, for drag/drop instancing typeof(PropertyEditor), // property grid for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, typeof(SchemaLoader), typeof(PaletteClient), // component which adds items to palette typeof(Editor) // tree list view editor component )) { using (var container = new CompositionContainer(catalog)) { var toolStripContainer = new ToolStripContainer(); toolStripContainer.Dock = DockStyle.Fill; using (var mainForm = new MainForm(toolStripContainer)) { mainForm.Text = "SceneEditor".Localize(); mainForm.Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)); var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Tree-List-Editor-Sample".Localize())); container.Compose(batch); container.InitializeAll(); //// Set the switch level for the Atf TraceSource instance so everything is traced. //Outputs.TraceSource.Switch.Level = SourceLevels.All; //// a very verbose data display that includes callstacks //Outputs.TraceSource.Listeners["Default"].TraceOutputOptions = // TraceOptions.Callstack | TraceOptions.DateTime | // TraceOptions.ProcessId | TraceOptions.ThreadId | // TraceOptions.Timestamp; Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); } } } }
static void Main() { // important to call these before creating application host Application.EnableVisualStyles(); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(SettingsServiceCommands), // Setting service commands typeof(FileDialogService), // proivdes standard Windows file dialogs, to let the user open and close files. Used by SkinService. typeof(SkinService), // allows for customization of an application’s appearance by using inheritable properties that can be applied at run-time typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(StandardFileExitCommand), // standard File exit menu command typeof(HelpAboutCommand), // Help -> About command typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(ContextRegistry), // component that tracks application contexts; needed for context menu // add target info plugins and TargetEnumerationService typeof(Deci4pTargetProvider), // provides information about development devices available via Deci4p typeof(TcpIpTargetProvider), // provides information about development devices available via TCP/IP typeof(TargetCommands), // commands to operate on currently selected targets. typeof(TargetEnumerationService) // queries and enumerates target objects, consuming target providers created by the application ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); var mainForm = new MainForm(new ToolStripContainer()) { Text = "ATF TargetManager Sample".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; // Add the main Form instance to the container batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Target-Manager-Sample".Localize())); container.Compose(batch); var controlHostService = container.GetExportedValue <ControlHostService>(); controlHostService.RegisteredCommands = ControlHostService.CommandRegister.None; // turn off standard window commands for simpele & single window UI // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main(string[] args) { // important to call these before creating application host Application.EnableVisualStyles(); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(SettingsServiceCommands), // Setting service commands typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(ContextRegistry), // central context registry with change notification typeof(StandardFileExitCommand), // standard File exit menu command typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands //typeof(StandardLockCommands), // standard Edit menu lock/unlock commands typeof(HelpAboutCommand), // Help -> About command typeof(PaletteService), // global palette, for drag/drop instancing typeof(HistoryLister), // visual list of undo/redo stack typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All typeof(Outputs), // passes messages to all log writers typeof(ErrorDialogService), // displays errors to the user in a message box typeof(HelpAboutCommand), // custom command component to display Help/About dialog typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(Editor), // editor which manages event sequence documents typeof(DomTypes), // defines the DOM's metadata for this sample app typeof(PaletteClient), // component which adds items to palette typeof(EventListEditor), // adds drag/drop and context menu to event sequence ListViews typeof(ResourceListEditor), // adds "slave" resources ListView control, drag/drop and context menu typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form and add it to the composition container var batch = new CompositionBatch(); var toolStripContainer = new ToolStripContainer(); var mainForm = new MainForm(toolStripContainer) { Text = "Simple DOM, No XML, Editor Sample".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Simple-DOM-No-XML-Editor-Sample".Localize())); // Compose the MEF container container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main() { // important to call these before creating application host Application.EnableVisualStyles(); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); using ( var catalog = new TypeCatalog( /* Standard ATF stuff */ typeof(SettingsService), // persistent settings and user preferences dialog typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter. typeof(Outputs), // passes messages to all log writers typeof(StandardFileExitCommand), // standard File exit menu command typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(UserFeedbackService), // displaying a dialog box that allows the user to submit a bug report to SHIP typeof(VersionUpdateService), // updates to latest version on SHIP typeof(ContextRegistry), // central context registry with change notification typeof(PropertyEditor), // property grid for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All /* Different styles of TreeListView */ typeof(List), // list view editor component typeof(CheckedList), // checked list view editor component typeof(VirtualList), // virtual list view editor component typeof(TreeList), // tree list view editor component typeof(CheckedTreeList), // checked tree list view editor component /* Use the TreeListView as a normal Control */ typeof(RawTreeListView), // tree list view editor for hierarchical file system component typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service )) { using (var container = new CompositionContainer(catalog)) { using (var mainForm = new MainForm()) { mainForm.Text = "TreeListView Sample".Localize(); mainForm.Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)); var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Tree-List-Editor-Sample".Localize())); container.Compose(batch); container.InitializeAll(); // Set the switch level for the Atf TraceSource instance so everything is traced. Outputs.TraceSource.Switch.Level = SourceLevels.All; // a very verbose data display that includes callstacks Outputs.TraceSource.Listeners["Default"].TraceOutputOptions = TraceOptions.Callstack | TraceOptions.DateTime | TraceOptions.ProcessId | TraceOptions.ThreadId | TraceOptions.Timestamp; Application.Run(mainForm); } } } }
static void Main(string[] args) { // important to call these before creating application host Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands typeof(FileDialogService), // standard Windows file dialogs typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(Outputs), // service that provides static methods for writing to IOutputWriter objects. typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter. typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(StandardFileExitCommand), // standard File exit menu command typeof(HelpAboutCommand), // Help -> About command typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(ContextRegistry), // central context registry with change notification typeof(DocumentRegistry), // central document registry with change notification typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(Editor), // code editor component typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService), // provides facilities to run an automated script using the .NET remoting service typeof(PerforceService), // Perforce plugin typeof(SourceControlCommands), // source control commmands to interact with Perforce plugin typeof(SourceControlContext) // source control context component ); var container = new CompositionContainer(catalog); var toolStripContainer = new ToolStripContainer(); toolStripContainer.Dock = DockStyle.Fill; var mainForm = new MainForm(toolStripContainer); var image = GdiUtil.GetImage("CodeEditor.Resources.File_edit.ico"); mainForm.Icon = GdiUtil.CreateIcon(image, 32, true); mainForm.Text = "Code Editor".Localize(); var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Code-Editor-Sample".Localize())); container.Compose(batch); // To make the tab commands (e.g., "Copy Full Path", "Open Containing Folder") available, we have to change // the default behavior to work with this sample app's unusual Editor. In most cases, an editor like this // would implement IDocumentClient and this customization of DefaultTabCommands wouldn't be necessary. var tabCommands = container.GetExportedValue <DefaultTabCommands>(); tabCommands.IsDocumentControl = controlInfo => controlInfo.Client is Editor; // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); container.Dispose(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), typeof(SkinService), typeof(StandardFileExitCommand), // standard File exit menu command typeof(StandardEditHistoryCommands), // tracks document changes and updates main form title typeof(HelpAboutCommand), // Help -> About command typeof(ContextRegistry), // central context registry with change notification typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor typeof(SettingsService), typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService), // provides facilities to run an automated script using the .NET remoting service typeof(SchemaLoader), // component that loads XML schema and sets up types typeof(Editor) // component that manages UI documents ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form // Configure the main Form with a ToolStripContainer so the CommandService can // generate toolbars. var toolStripContainer = new ToolStripContainer(); toolStripContainer.Dock = DockStyle.Fill; var mainForm = new MainForm(toolStripContainer) { Text = "DOM Property Editor".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; // Add the main Form instance to the container var batch = new CompositionBatch(); batch.AddPart(mainForm); // batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-DOM-Tree-Editor-Sample".Localize())); container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); var propEditor = container.GetExportedValue <PropertyEditor>(); propEditor.PropertyGrid.PropertySorting = Sce.Atf.Controls.PropertyEditing.PropertySorting.Categorized; // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main() { // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Register the embedded image resources so that they will be available for all users of ResourceUtil, // such as the PaletteService. ResourceUtil.Register(typeof(Resources)); // enable metadata driven property editing DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(LiveConnectService), // allows easy interop between apps on same router subnet typeof(Outputs), // passes messages to all IOutputWriter components typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(StandardFileExitCommand), // standard File exit menu command typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(ContextRegistry), // central context registry with change notification typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(RenameCommand), // allows for renaming of multiple selected objects //StandardPrintCommands does not currently work with Direct2D //typeof(StandardPrintCommands), // standard File menu print commands typeof(PaletteService), // global palette, for drag/drop instancing typeof(HistoryLister), // visual list of undo/redo stack typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All typeof(PerformanceMonitor), // displays the frame rate and memory usage typeof(FileWatcherService), // service to watch for changes to files typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(SkinService), // allows for customization of an application’s appearance by using inheritable properties that can be applied at run-time // Client-specific plug-ins typeof(TimelineEditor), // timeline editor component typeof(TimelineCommands), // defines Timeline-specific commands typeof(HelpAboutCommand), // Help -> About command // Testing related typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service ); var container = new CompositionContainer(catalog); var toolStripContainer = new ToolStripContainer(); toolStripContainer.Dock = DockStyle.Fill; var mainForm = new MainForm(toolStripContainer) { Text = "Timeline Editor Sample".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Timeline-Editor-Sample".Localize())); container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); container.Dispose(); }
static void Main(string[] args) { // This startup sequence is based on the "Circuit editor" sample in the Sony ATF repo // We want to take advantage of the ATF implementations whereever they exist, but we'll // remove the parts that are specific to that circuit editor sample app. // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // early engine initialization var engineDevice = new GUILayer.EngineDevice(); GC.KeepAlive(engineDevice); var attach0 = new ShaderPatcherLayer.LibraryAttachMarker(engineDevice); GC.KeepAlive(attach0); XLEBridgeUtils.Utils.AttachLibrary(engineDevice); var logRedirect = new XLEBridgeUtils.LoggingRedirect(); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog // typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands // typeof(AtfUsageLogger), // logs computer info to an ATF server // typeof(CrashLogger), // logs unhandled exceptions to an ATF server // typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(HelpAboutCommand), // Help -> About command typeof(ContextRegistry), // central context registry with change notification typeof(StandardFileExitCommand), // standard File exit menu command // typeof(StandardEditCommands), // standard Edit menu commands for copy/paste // typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(StandardLayoutCommands), // standard Format menu layout commands typeof(StandardViewCommands), // standard View menu commands // typeof(PaletteService), // global palette, for drag/drop instancing typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All typeof(HistoryLister), // visual list of undo/redo stack typeof(PrototypeLister), // editable palette of instantiable item groups typeof(LayerLister), // editable tree view of layers typeof(Outputs), // passes messages to all log writers // typeof(ErrorDialogService), // displays errors to the user in a message box typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter. typeof(DomRecorder), // records and displays changes to the DOM for diagnostic purposes typeof(Editor), // editor which manages circuit documents and controls // typeof(SchemaLoader), // loads circuit schema and extends types // typeof(GroupingCommands), // circuit group/ungroup commands typeof(DiagramControlRegistry), // circuit controls management // typeof(LayeringCommands), // "Add Layer" command // typeof(GraphViewCommands), // zooming with presets typeof(PerformanceMonitor), // displays the frame rate and memory usage typeof(DefaultTabCommands), // provides the default commands related to document tab Controls // typeof(ModulePlugin), // component that defines circuit module types // typeof(TemplateLister), // template library for subgraph referencing or instancing // typeof(TemplatingCommands), // commands for promoting/demoting graph elements to/from template library //typeof(TemplatingSupervisor), // templated instances copy-on-edit support(optionally) typeof(AnnotatingCommands), // annotating commands // typeof(CircuitTestCommands), // circuit tester commands typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService), // provides facilities to run an automated script using the .NET remoting service typeof(SkinService), typeof(ShaderPatcherLayer.Manager), typeof(ShaderFragmentArchive.Archive), typeof(Controls.DiagramControl), typeof(Controls.ShaderFragmentArchiveControl), typeof(Controls.DiagramLister), typeof(NodeEditorCore.ShaderFragmentArchiveModel), typeof(NodeEditorCore.ModelConversion), typeof(NodeEditorCore.ShaderFragmentNodeCreator), typeof(NodeEditorCore.DiagramDocument), typeof(ControlsLibraryExt.Commands.CommonCommands), typeof(ControlsLibraryExt.Material.MaterialInspector), typeof(ControlsLibraryExt.Material.MaterialSchemaLoader), typeof(ControlsLibraryExt.ModelView.ActiveModelView), typeof(ActiveMaterialContext), typeof(DiagramCommands) ); // enable use of the system clipboard StandardEditCommands.UseSystemClipboard = true; // Set up the MEF container with these components var container = new CompositionContainer(catalog); // This is bit wierd, but we're going to add the container to itself. // This will create a tight circular dependency, of course // It's also not ideal by the core DI pattern. // But it's useful for us, because we want to use the same container to construct // objects (and also to retrieve global instances). container.ComposeExportedValue <ExportProvider>(container); container.ComposeExportedValue <CompositionContainer>(container); // Configure the main Form var batch = new CompositionBatch(); var mainForm = new MainForm(new ToolStripContainer()) { Text = Application.ProductName //, // Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; // Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle); // Add the main Form instance, etc., to the container batch.AddPart(mainForm); // batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Circuit-Editor-Sample".Localize())); container.Compose(batch); // We need to attach compilers for models, etc engineDevice.AttachDefaultCompilers(); container.InitializeAll(); // if there is a model filename on the command line, we will load it into our viewer if (args != null && args.Length > 0) { var a = args[0]; if (string.Equals(System.IO.Path.GetExtension(a), ".dae", StringComparison.OrdinalIgnoreCase)) { // Insert a delegate to be executed after the AutoDocumentService has run. That is attached // to the "Loaded" event in the main form, also -- so this should occur afterwards // This way we can pop our window to the top, after the auto load documents appear mainForm.Loaded += delegate(object o, EventArgs eventArgs) { var modelView = container.GetExport <ControlsLibraryExt.ModelView.ActiveModelView>().Value; if (modelView != null) { modelView.LoadFromCommandLine(a); var hostService = container.GetExport <IControlHostService>().Value; if (hostService != null) { hostService.Show(modelView.Control); } // unfortunately we can't suppress the autoload documents stuff from here! } }; } } Application.Run(mainForm); container.Dispose(); mainForm.Dispose(); logRedirect.Dispose(); engineDevice.PrepareForShutdown(); XLEBridgeUtils.Utils.DetachLibrary(); attach0.Dispose(); engineDevice.Dispose(); }
static void Main() { // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(SettingsServiceCommands), // Setting service commands typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands //typeof(AtfUsageLogger), // logs computer info to an ATF server //typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification //typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(HelpAboutCommand), // Help -> About command typeof(ContextRegistry), // central context registry with change notification typeof(StandardFileExitCommand), // standard File exit menu command typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(StandardLayoutCommands), // standard Format menu layout commands typeof(StandardViewCommands), // standard View menu commands //StandardPrintCommands does not currently work with Direct2D //typeof(StandardPrintCommands), // standard File menu print commands typeof(PaletteService), // global palette, for drag/drop instancing typeof(MyPropertyEditor), // property grid for editing selected objects; uses tooltips to show property descriptions //typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, typeof(DomNodeRefDictionary), // Reference dictionary typeof(HistoryLister), // visual list of undo/redo stack typeof(PrototypeLister), // editable palette of instantiable item groups typeof(LayerLister), // editable tree view of layers typeof(Outputs), // passes messages to all log writers // typeof(ErrorDialogService), // displays errors to the user in a message box typeof(OutputService), // rich text box for displaying error and warning messages. Implements IOutputWriter. typeof(DomRecorder), // records and displays changes to the DOM for diagnostic purposes typeof(VisualScriptEditor), // editor which manages circuit documents and controls typeof(VisualScriptTypeManager), // loads circuit schema and extends types typeof(GroupingCommands), // circuit group/ungroup commands typeof(CircuitControlRegistry), // circuit controls management typeof(LayeringCommands), // "Add Layer" command typeof(GraphViewCommands), // zooming with presets //typeof(PerformanceMonitor), // displays the frame rate and memory usage typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(ScriptNodeDefinitionManager), // component that defines circuit module types typeof(TemplateLister), // template library for subgraph referencing or instancing typeof(TemplatingCommands), // commands for promoting/demoting graph elements to/from template library //typeof(TemplatingSupervisor), // templated instances copy-on-edit support(optionally) typeof(AnnotatingCommands), // annotating commands typeof(DynamicPropertyCommands), // context commands for user-defined properties in the property editors typeof(ExpressionCommands), // typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service ); // enable use of the system clipboard StandardEditCommands.UseSystemClipboard = true; // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); var mainForm = new MainForm(new ToolStripContainer()) { Text = Application.ProductName, Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle); // Add the main Form instance, etc., to the container batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Circuit-Editor-Sample".Localize())); container.Compose(batch); // Add a customized category comparer to the object palette. var paletteService = container.GetExportedValue <PaletteService>(); paletteService.CategoryComparer = new CategoryComparer(); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main(string[] arg) { Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture; // For testing localization //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); ShowBitNess(); ISledCrashReporter crashReporter = null; ISledUsageStatistics usageStatistics = null; try { // Try and create crash reporter crashReporter = SledLibCrashReportNetWrapper.TryCreateCrashReporter(); // Try and create usage statistics usageStatistics = SledLibCrashReportNetWrapper.TryCreateUsageStatistics(); // Create 'master' catalog to hold all // other catalogs we might create var aggregateCatalog = new AggregateCatalog(); // Add 'standard/default' parts to 'master' catalog aggregateCatalog.Catalogs.Add( new TypeCatalog( /* ATF related services */ typeof(SettingsService), typeof(StatusService), typeof(CommandService), typeof(ControlHostService), typeof(UnhandledExceptionService), typeof(UserFeedbackService), typeof(OutputService), typeof(Outputs), typeof(FileDialogService), typeof(DocumentRegistry), typeof(ContextRegistry), typeof(StandardFileExitCommand), typeof(RecentDocumentCommands), typeof(StandardEditCommands), typeof(StandardEditHistoryCommands), typeof(TabbedControlSelector), typeof(DefaultTabCommands), typeof(WindowLayoutService), typeof(WindowLayoutServiceCommands), typeof(SkinService), /* SLED related services */ typeof(SledOutDevice), typeof(SledAboutService), typeof(SledAboutDocumentService), typeof(SledGotoService), typeof(SledTitleBarTextService), typeof(SledDocumentService), typeof(SledProjectService), typeof(SledProjectWatcherService), typeof(SledModifiedProjectFormService), typeof(SledProjectFileGathererService), typeof(SledLanguageParserService), typeof(SledProjectFilesTreeEditor), typeof(SledProjectFilesDiskViewEditor), typeof(SledProjectFileFinderService), typeof(SledProjectFilesUtilityService), typeof(SledProjectFileAdderService), typeof(SledBreakpointService), typeof(SledBreakpointEditor), typeof(SledNetworkPluginService), typeof(SledLanguagePluginService), typeof(SledTargetService), typeof(SledFindAndReplaceService), typeof(SledFindAndReplaceService.SledFindResultsEditor1), typeof(SledFindAndReplaceService.SledFindResultsEditor2), typeof(SledDebugService), typeof(SledDebugScriptCacheService), typeof(SledDebugBreakpointService), typeof(SledDebugFileService), typeof(SledDebugHeartbeatService), typeof(SledDebugNegotiationTimeoutService), typeof(SledDebugFlashWindowService), typeof(SledFileWatcherService), typeof(SledModifiedFilesFormService), typeof(SledFileExtensionService), typeof(SledSyntaxCheckerService), typeof(SledSyntaxErrorsEditor), typeof(SledTtyService), typeof(SledDebugFreezeService), typeof(SledSourceControlService), typeof(SledSharedSchemaLoader) )); // Create directory information service var directoryInfoService = new SledDirectoryInfoService(); // Create dynamic plugin service var dynamicPluginService = new SledDynamicPluginService(); // Grab all dynamically loaded plugins // from the "SLED\Plugins" directory var dynamicAssemblies = dynamicPluginService.GetDynamicAssemblies(directoryInfoService); // Add dynamically obtained assemblies to // the master catalog AddAssembliesToMasterCatalog(aggregateCatalog, dynamicAssemblies); // Add 'master' catalog to container using (var container = new CompositionContainer(aggregateCatalog)) { // Create tool strip container using (var toolStripContainer = new ToolStripContainer()) { toolStripContainer.Dock = DockStyle.Fill; // Grab SledShared.dll for resource loading var assem = Assembly.GetAssembly(typeof(SledShared)); // Create main form & set up some properties var mainForm = new MainForm(toolStripContainer) { AllowDrop = true, Text = Resources.Resource.SLED, Icon = GdiUtil.GetIcon( assem, SledShared.IconPathBase + ".Sled.ico") }; // Load all the icons and images SLED will need SledShared.RegisterImages(); directoryInfoService.MainForm = mainForm; // Create batch and add any manual parts var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(directoryInfoService); batch.AddPart(dynamicPluginService); SetupDebugEventFiringWatching(batch); container.Compose(batch); // Set this one time SledServiceReferenceCompositionContainer.SetCompositionContainer(container); // Initialize all IInitializable interfaces try { try { foreach (var initializable in container.GetExportedValues <IInitializable>()) { initializable.Initialize(); } } catch (CompositionException ex) { foreach (var error in ex.Errors) { MessageBox.Show(error.Description, MefCompositionExceptionText); } throw; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), ExceptionDetailsText); Environment.Exit(-1); } // Send usage data to the server now that everything is loaded if (usageStatistics != null) { usageStatistics.PhoneHome(); } SledOutDevice.OutBreak(); // Notify directoryInfoService.LoadingFinished(); // Let ATF's UnhandledExceptionService know about our ICrashLogger if (crashReporter != null) { var unhandledExceptionService = SledServiceInstance.TryGet <UnhandledExceptionService>(); if (unhandledExceptionService != null) { unhandledExceptionService.CrashLogger = crashReporter; } } // Show main form finally Application.Run(mainForm); } } } finally { // // Cleanup // if (crashReporter != null) { crashReporter.Dispose(); } if (usageStatistics != null) { usageStatistics.Dispose(); } } }
static void Main() { // important to call these before creating application host Application.EnableVisualStyles(); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(AtfUsageLogger), // logs computer info to an ATF server #if !DEBUG typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save #endif typeof(DomExplorer), //Debug view the DOM typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable Ctrl+tab selection of documents and controls within the app typeof(ContextRegistry), // central context registry with change notification typeof(StandardFileExitCommand), // standard File exit menu command typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(HelpAboutCommand), // Help -> About command typeof(PropertyEditor), // property grid for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor typeof(Outputs), // passes messages to all log writers typeof(ErrorDialogService), // displays errors to the user a in message box typeof(HelpAboutCommand), // custom command component to display Help/About dialog typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService), // provides facilities to run an automated script using the .NET remoting service //Worldsmith stuff typeof(SchemaLoader), //Loads the schema typeof(Project.DotaVPKService), //Handles the VPK stuff, including reading from the VPK and building the DOM node //UI Elements typeof(ProjectTreeLister), typeof(UnitTreeLister), typeof(TextEditing.TextEditor), typeof(DotaVPKTreeLister), typeof(KeyValueEditor), // typeof(UnitPropertyEditor), //Commands typeof(ProjectCommands), typeof(TreeListCommands), typeof(KeyValueCommands) ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); var toolStripContainer = new ToolStripContainer(); var mainForm = new MainForm(toolStripContainer) { Text = "Worldsmith".Localize(), Icon = GdiUtil.CreateIcon(WorldsmithATF.Properties.Resources.WSIcon32) }; // Add the main Form instance to the container batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("http://www.worldsmith.net".Localize())); container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main() { // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Register the embedded image resources so that they will be available for all users of ResourceUtil, // such as the PaletteService. ResourceUtil.Register(typeof(Resources)); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(WindowLayoutService), // multiple window layout support typeof(WindowLayoutServiceCommands), // window layout commands typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(SkinService), typeof(DocumentRegistry), // central document registry with change notification typeof(FileDialogService), // standard Windows file dialogs typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(StandardFileExitCommand), // standard File exit menu command typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(HelpAboutCommand), // Help -> About command typeof(ContextRegistry), // central context registry with change notification typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(PaletteService), // global palette, for drag/drop instancing typeof(HistoryLister), // visual list of undo/redo stack typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All typeof(CurveEditor), // edits curves using the CurveEditingControl typeof(SchemaLoader), // component that loads XML schema and sets up types typeof(Editor), // component that manages UI documents typeof(PaletteClient), // component that adds UI types to palette typeof(TreeLister), // component that displays the UI in a tree control typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(DomExplorer), // component that gives diagnostic view of DOM typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form with a ToolStripContainer so the CommandService can // generate toolbars. var toolStripContainer = new ToolStripContainer(); toolStripContainer.Dock = DockStyle.Fill; var mainForm = new MainForm(toolStripContainer) { Text = "Dom Tree Editor".Localize(), Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; // Add the main Form instance to the container var batch = new CompositionBatch(); batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-DOM-Tree-Editor-Sample".Localize())); container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Example of programmatic layout creation: { var windowLayoutService = container.GetExportedValue <IWindowLayoutService>(); var dockStateProvider = container.GetExportedValue <IDockStateProvider>(); // Load custom XML and add it to the Window Layout Service int layoutNum = 0; Assembly assembly = Assembly.GetExecutingAssembly(); foreach (string resourceName in assembly.GetManifestResourceNames()) { if (resourceName.Contains("Layout") && resourceName.EndsWith(".xml")) { var xmlDoc = new XmlDocument(); xmlDoc.Load(assembly.GetManifestResourceStream(resourceName)); layoutNum++; windowLayoutService.SetOrAddLayout(dockStateProvider, "Programmatic Layout " + layoutNum, xmlDoc.InnerXml); } } } // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
static void Main() { // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 //Engine engine = new Engine(); //engine.StartEngine(); // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog //typeof(StatusService), // status bar at bottom of main Form typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(VS2CMakeContext), typeof(DomNodeRefDictionary), typeof(VS2CMakeImport), typeof(VS2CMakeGenerateCMake), typeof(Outputs), // passes messages to all log writers typeof(ErrorDialogService), // displays errors to the user in a message box typeof(ConsoleOutputWriter) ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); var mainForm = new ConsoleMainForm() { Text = Application.ProductName, }; // Add the main Form instance, etc., to the container batch.AddPart(mainForm); container.Compose(batch); container.InitializeAll(); mainForm.Run(); mainForm.Close(); // Give components a chance to clean up. container.Dispose(); //engine.StopEngine(); }