Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataGridModule" /> class.
        /// </summary>
        public DataGridModule(IOrchestraService orchestraService)
            : base(Name)
        {
            Argument.IsNotNull(() => orchestraService);

            _orchestraService = orchestraService;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrowserViewModel" /> class.
 /// </summary>
 /// <param name="title">The title.</param>
 /// <param name="messageService">The message service.</param>
 /// <param name="orchestraService">The orchestra service.</param>
 /// <param name="messageMediator">The message mediator.</param>
 public BrowserViewModel(string title, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator)
     : this(messageService, orchestraService, messageMediator)
 {
     if (!string.IsNullOrWhiteSpace(title))
     {
         Title = title;
     }
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BrowserViewModel"/> class.
        /// </summary>
        public BrowserViewModel()
        {
            GoBack       = new Command(OnGoBackExecute, OnGoBackCanExecute);
            GoForward    = new Command(OnGoForwardExecute, OnGoForwardCanExecute);
            Browse       = new Command(OnBrowseExecute, OnBrowseCanExecute);
            Test         = new Command(OnTestExecute);
            CloseBrowser = new Command(OnCloseBrowserExecute);

            Title = "Browser";

            _orchestraService = ServiceLocator.ResolveType <IOrchestraService>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PropertiesViewModel"/> class.
        /// </summary>
        public PropertiesViewModel(IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager)
        {
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => messageMediator);

            _messageService   = messageService;
            _orchestraService = orchestraService;
            _messageMediator  = messageMediator;

            Title = "Properties";

            // Comands
            DocMapSelectedCommand = new Command(OnDocMapSelectedCommandExecute, OnDocMapSelectedCommandCanExecute);
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BrowserViewModel" /> class.
        /// </summary>
        /// <param name="messageService">The message service.</param>
        /// <param name="orchestraService">The orchestra service.</param>
        /// <param name="messageMediator">The message mediator.</param>
        public BrowserViewModel(IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator)
        {
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => messageMediator);

            _messageService   = messageService;
            _orchestraService = orchestraService;
            _messageMediator  = messageMediator;

            GoBack       = new Command(OnGoBackExecute, OnGoBackCanExecute);
            GoForward    = new Command(OnGoForwardExecute, OnGoForwardCanExecute);
            Browse       = new Command(OnBrowseExecute, OnBrowseCanExecute);
            Test         = new Command(OnTestExecute);
            CloseBrowser = new Command(OnCloseBrowserExecute);

            Title = "Browser";
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContextualViewModelManager" /> class.
 /// </summary>
 /// <param name="orchestraService">The <see cref="IOrchestraService">orchestra service</see>.</param>
 /// <param name="viewModelFactory">The <see cref="IViewModelFactory">orchestra service</see>..</param>
 public ContextualViewModelManager(IOrchestraService orchestraService, IViewModelFactory viewModelFactory)
 {
     _orchestraService = orchestraService;
     _viewModelFactory = viewModelFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertiesViewModel"/> class.
 /// </summary>
 /// <param name="title">The title.</param>
 /// <param name="messageService">The message service.</param>
 /// <param name="orchestraService">The orchestra service.</param>
 /// <param name="messageMediator">The message mediator.</param>
 /// <param name="contextualViewModelManager">The contextual view model manager.</param>
 public PropertiesViewModel(string title, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager)
     : this(messageService, orchestraService, messageMediator, contextualViewModelManager)
 {
     Title = title;
 }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditorViewModel" /> class.
        /// </summary>
        /// <param name="messageService">The message service.</param>
        /// <param name="orchestraService">The orchestra service.</param>
        /// <param name="messageMediator">The message mediator.</param>
        /// <param name="contextualViewModelManager">The contextual view model manager.</param>
        /// <param name="textEditorModule">The Main Module Class.</param>
        /// <param name="processService">The process service.</param>
        public TextEditorViewModel(TextEditorModule textEditorModule, IMessageService messageService, IOrchestraService orchestraService,
                                   IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager, IProcessService processService)
        {
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => orchestraService);
            Argument.IsNotNull(() => messageMediator);
            Argument.IsNotNull(() => processService);

            Document = new TextDocument();

            _messageService             = messageService;
            _orchestraService           = orchestraService;
            _messageMediator            = messageMediator;
            _contextualViewModelManager = contextualViewModelManager;
            _textEditorModule           = textEditorModule;
            _processService             = processService;

            #region TextEditor related
            TextOptions = new TextEditorOptions()
            {
                ShowSpaces = true
            };

            // Set Highlightning to C#
            HighlightDef = HighlightingManager.Instance.GetDefinition("C#");
            //SelectedLanguage = "C#";
            IsDirtyDoc      = false;
            IsReadOnly      = false;
            ShowLineNumbers = true;
            WordWrap        = false;

            // Comands
            ShowLineNumbersCommand = new Command(OnShowLineNumbersCommandExecute);
            WordWrapCommand        = new Command(OnWordWrapCommandExecute);
            EndLineCommand         = new Command(OnEndLineCommandExecute);
            ShowSpacesCommand      = new Command(OnShowSpacesCommandExecute);

            SaveAsCommand = new Command(OnSaveAsCommandExecute, OnSaveAsCommandCanExecute);
            SaveCommand   = new Command(OnSaveCommandExecute, OnSaveCommandCanExecute);
            CloseDocument = new Command(OnCloseDocumentExecute);
            UpdateCommand = new Command(OnUpdateCommandExecute, OnUpdateCommandCanExecute);

            DocumentMapOpenCommand = new Command(OnDocumentMapOpenExecute);

            ScriptCSCommand = new Command(OnScriptCSCommandExecute, OnScriptCSCommandCanExecute);
            #endregion

            #region Document related

            Title = FileName;
            #endregion

            string directory = Catel.IO.Path.GetApplicationDataDirectory("Orchestra.TextEditor");

            // Set the path and Load the default Document Map Settings
            _path = Path.Combine(directory, "mapsettings.txt");
            if (File.Exists(_path))
            {
                _regextPattern = File.ReadAllText(_path);
            }
            else
            {
                // Set the default value
                _regextPattern = "^.*\b(private|public|sealed|protected|virtual|internal)\b.*$";
            }

            messageMediator.Register <string>(this, OnDocMapRegexChange);

            // Invalidate the current viewmodel
            ViewModelActivated();
        }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextEditorViewModel" /> class.
 /// Main TextEdtior Class is passed by reference to this Class
 /// </summary>
 /// <param name="title">The title.</param>
 /// <param name="messageService">The message service.</param>
 /// <param name="orchestraService">The orchestra service.</param>
 /// <param name="messageMediator">The message mediator.</param>
 /// <param name="contextualViewModelManager">The contextual view model manager.</param>
 /// <param name="textEditorModule">The Main Module Class.</param>
 /// <param name="processService">The process service.</param>
 public TextEditorViewModel(string title, TextEditorModule textEditorModule, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager, IProcessService processService)
     : this(textEditorModule, messageService, orchestraService, messageMediator, contextualViewModelManager, processService)
 {
     if (!string.IsNullOrWhiteSpace(title))
     {
         Title = title;
     }
     _textEditorModule = textEditorModule;
     // Set Highlightning to C#
     this.HighlightDef = HighlightingManager.Instance.GetDefinition("C#");
     //this._isDirty = false;
     this.IsReadOnly      = false;
     this.ShowLineNumbers = true;
     this.WordWrap        = false;
 }
Пример #10
0
        /// <summary>
        /// Initializes the ribbon.
        /// <para />
        /// Use this method to hook up views to ribbon items.
        /// </summary>
        /// <param name="ribbonService">The ribbon service.</param>
        protected override void InitializeRibbon(IRibbonService ribbonService)
        {
            LoadResourceDictionary();

            orchestraService = GetService <IOrchestraService>();

            // Module specific
            var typeFactory = TypeFactory.Default;

            //ribbonService.RegisterRibbonItem(new RibbonButton(HomeRibbonTabName, ModuleName, "Open", new Command(() => NewDocumentCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png" });
            ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.HomeRibbonTabName, ModuleName, "Open", new Command(() =>
            {
                var textEditorViewModel = typeFactory.CreateInstance <TextEditorViewModel>();
                orchestraService.ShowDocument(textEditorViewModel);
            }))
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png"
            });

            // View specific
            #region File Buttons

            // View specific
            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "File", "New", new Command(() => NewDocumentCommand.Execute(null)))
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_New32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "File", "Open", new Command(() => OpenDocumentCommand.Execute(null)))
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Open32.png"
            },
                ModuleName);

            //ribbonService.RegisterContextualRibbonItem<TextEditorView>(
            //   new RibbonButton(Name, "File", "Open", "OpenDocumentCommand") { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Open32.png" },
            //   ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "File", "Save", "SaveCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_Save32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "File", "SaveAs", "SaveAsCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/File_SaveAs32.png"
            },
                ModuleName);

            //ribbonService.RegisterContextualRibbonItem<TextEditorView>(
            //  new RibbonButton(Name, "File", "CloseMe", new Command(() => CloseDocumentCommand.Execute(null)))
            //  {
            //      ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/action_close.png",
            //      ToolTip = new RibbonToolTip { Title = "Close (Ctrl+X)", Text = "Closes the file." }
            //  },
            //ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "File", "CloseMe", "CloseDocument")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/action_close.png",
                ToolTip   = new RibbonToolTip {
                    Title = "Close (Ctrl+X)", Text = "Closes the file."
                }
            },
                ModuleName);
            #endregion

            #region Edit Buttons

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Edit", "Copy", ApplicationCommands.Copy)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Copy32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Edit", "Cut", ApplicationCommands.Cut)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Cut32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Edit", "Paste", ApplicationCommands.Paste)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Paste32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Edit", "Delete", ApplicationCommands.Delete)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Delete32.png"
            },
                ModuleName);

            #endregion

            #region Undo / Redo Buttons

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Undo", "Undo", ApplicationCommands.Undo)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Undo32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Undo", "Redo", ApplicationCommands.Redo)
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Redo32.png"
            },
                ModuleName);

            #endregion

            #region Text Editor Buttons
            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Text Editor", "WordWrap", "WordWrapCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png"
            },
                ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Text Editor", "LineNumbers", "ShowLineNumbersCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/Edit_Numbers32.png"
            },
                ModuleName);
            #endregion

            #region ScriptCS  Buttons
            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Run ScriptCS", "ScriptCS", "ScriptCSCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/cs_32.png"
            },
                ModuleName);

            #endregion

            //ribbonService.RegisterContextualRibbonItem<TextEditorView>(
            // new RibbonButton(Name, "Document", "Map", new Command(() => ShowDocumentMapCommand.Execute(null))) { ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/ShowWordWrap32.png" },
            // ModuleName);

            ribbonService.RegisterContextualRibbonItem <TextEditorView>(
                new RibbonButton(Name, "Document", "Map", "DocumentMapOpenCommand")
            {
                ItemImage = "/Orchestra.Modules.TextEditor;component/Resources/Images/App/ShowWordWrap32.png"
            },
                ModuleName);

            #region TextEditor Module

            // Language selection combobox
            //ribbonService.RegisterContextualRibbonItem<TextEditorView>(new RibbonComboBox(Name, "Languages")
            //{
            //    ItemsSource = "SyntaxHighlighting",
            //    SelectedItem = "SelectedLanguage",
            //    Layout = new RibbonItemLayout { Width = 100 },
            //    Style = Application.Current.Resources["SelectedSitesComboBoxStyle"] as Style
            //}, ModuleName);

            // Find the template to show as dynamic content. TODO: Refactor, make more elegant.
            var template = Application.Current.Resources["TestTemplate"] as DataTemplate;


            ribbonService.RegisterRibbonItem(new RibbonButton(OrchestraResources.ViewRibbonTabName, ModuleName, "TextEditor properties", new Command(() =>
            {
                orchestraService.ShowDocumentIfHidden <PropertiesViewModel>();
            }))
            {
                ItemImage = "/rchestra.Modules.TextEditor;component/Resources/Images/App/Edit_WordWrap32.png"
            });

            #endregion

            var dockingSettings = new DockingSettings();
            dockingSettings.DockLocation = DockLocation.Right;
            dockingSettings.Width        = 225;

            // Demo: register contextual view related to browserview
            var contextualViewModelManager = GetService <IContextualViewModelManager>();
            contextualViewModelManager.RegisterContextualView <TextEditorViewModel, PropertiesViewModel>("Document Map", DockLocation.Right);

            // Open blank document during application start
            var currenttextEditorViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <TextEditorViewModel>("Orchestra", this);
            //orchestraViewModel.Url = "http://www.github.com/Orcomp/Orchestra";
            orchestraService.ShowDocument(currenttextEditorViewModel, "New Document");
        }