Beispiel #1
0
        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="NewDocumentItem"/> class.
        /// </summary>
        /// <param name="documentExtension">The <see cref="DocumentExtension"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="documentExtension"/> is <see langword="null"/>.
        /// </exception>
        public NewDocumentItem(DocumentExtension documentExtension)
        {
            if (documentExtension == null)
                throw new ArgumentNullException(nameof(documentExtension));

            _documentExtension = documentExtension;
            Command = new DelegateCommand<DocumentType>(OnNewDocument);
        }
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="RecentDocumentsItem"/> class.
        /// </summary>
        /// <param name="documentExtension">The <see cref="DocumentExtension"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="documentExtension"/> is <see langword="null"/>.
        /// </exception>
        public RecentDocumentsItem(DocumentExtension documentExtension)
        {
            if (documentExtension == null)
            {
                throw new ArgumentNullException(nameof(documentExtension));
            }

            _documentExtension = documentExtension;
            Command            = new DelegateCommand <string>(OnOpenRecentDocument);
        }
Beispiel #3
0
        protected Document(IEditorService editor, DocumentType documentType)
        {
            if (!WindowsHelper.IsInDesignMode)
            {
                if (editor == null)
                    throw new ArgumentNullException(nameof(editor));

                Editor = editor;
                _documentExtension = editor.Extensions.OfType<DocumentExtension>().FirstOrDefault().ThrowIfMissing();
            }

            if (documentType == null)
                throw new ArgumentNullException(nameof(documentType));

            DocumentType = documentType;
            _fileDialogFilter = DocumentHelper.GetFilterString(new[] { documentType });
            _fileDialogFilterIndex = 1;
            _viewModels = new ObservableCollection<DocumentViewModel>();
            ViewModels = new ReadOnlyObservableCollection<DocumentViewModel>(_viewModels);

            _documentExtension?.RegisterDocument(this);
        }
Beispiel #4
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="RecentDocumentsItem"/> class.
        /// </summary>
        /// <param name="documentExtension">The <see cref="DocumentExtension"/>.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="documentExtension"/> is <see langword="null"/>.
        /// </exception>
        public RecentDocumentsItem(DocumentExtension documentExtension)
        {
            if (documentExtension == null)
                throw new ArgumentNullException(nameof(documentExtension));

            _documentExtension = documentExtension;
            Command = new DelegateCommand<string>(OnOpenRecentDocument);
        }
Beispiel #5
0
        //--------------------------------------------------------------
        #region Properties & Events
        //--------------------------------------------------------------
        #endregion


        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------
        #endregion


        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        protected override void OnConfigure()
        {
            if (WindowsHelper.IsInDesignMode)
                return;

            Logger.Info("Configuring editor.");

#if !DEBUG
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Critical;
#endif

            _serviceContainer = new ServiceContainer();

            // Configure general services.
            _serviceContainer.Register(typeof(IWindowService), null, typeof(WindowManager));

            // Configure editor.
            _editor = new EditorViewModel(_serviceContainer)
            {
                ApplicationName = ApplicationName,
                ApplicationIcon = BitmapFrame.Create(new Uri("pack://application:,,,/DigitalRune.Editor;component/Resources/Raido.ico", UriKind.RelativeOrAbsolute))
            };
            // Core extensions
            _editor.Extensions.Add(new CommandExtension());
            _editor.Extensions.Add(new LayoutExtension());
            _editor.Extensions.Add(new AboutExtension());
            _editor.Extensions.Add(new OptionsExtension());
            _editor.Extensions.Add(new PrintExtension());
            _editor.Extensions.Add(new QuickLaunchExtension());
            _editor.Extensions.Add(new ThemeExtension());
            _editor.Extensions.Add(new StatusExtension());
            _editor.Extensions.Add(new SearchExtension());

            // Common tool windows.
            _editor.Extensions.Add(new OutputExtension());
            _editor.Extensions.Add(new ErrorExtension());
            _editor.Extensions.Add(new OutlineExtension());
            _editor.Extensions.Add(new PropertiesExtension());

            // Document extensions.
            _documentExtension = new DocumentExtension();
            _editor.Extensions.Add(_documentExtension);
            _editor.Extensions.Add(new TextExtension());
            _editor.Extensions.Add(new ShaderExtension());
            _editor.Extensions.Add(new TexturesExtension());
            _editor.Extensions.Add(new ModelsExtension());

            // Other extensions.
            _editor.Extensions.Add(new DiagnosticsExtension());
            _editor.Extensions.Add(new ColorExtension());
            _editor.Extensions.Add(new GameExtension());
            _editor.Extensions.Add(new TestExtension0());

            try
            {
                bool success = _editor.Initialize();
                if (!success)
                {
                    // The editor could not be configured or command line arguments caused the
                    // editor to shut down (e.g. if "--help" was specified).
                    Application.Shutdown(_editor.ExitCode);
                    return;
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, "Editor configuration failed.");

                _configurationFailed = true;
                Environment.ExitCode = ExitCodeConfigurationFailed;

                ExceptionHelper.ShowException(exception, ApplicationName, Email);
            }
        }