예제 #1
0
        /// <summary>Initializes a new instance of the <see cref="BrowserViewModel" /> class.</summary>
        /// <param name="mediator">The mediator.</param>
        public BrowserViewModel(IMessageMediator mediator)
        {
            _browserQueryViewerViewModel =
                TypeFactory.Default.CreateInstance <BrowserQueryViewerViewModel>();

            CurrentModel = _browserQueryViewerViewModel;

            mediator.Register <SimpleMessage>(this, OnMessageReceived);
        }
        protected override Task InitializeAsync()
        {
            _messageMediator.Register <ActivatedExplorerTabMessage>(this, OnActivatedExplorerTabMessageReceived);
            IsHideInstalledOptionEnabled = CheckIsHideInstalledOptionEnabled();

            ActiveFeeds = new ObservableCollection <INuGetSource>(GetActiveFeedsFromSettings());

            //"all" feed is default
            DefaultFeed = ActiveFeeds.FirstOrDefault(x => string.Equals(x.Name, Constants.CombinedSourceName));

            ObservedFeed = SetObservedFeed(ActiveFeeds, DefaultFeed);

            return(base.InitializeAsync());
        }
예제 #3
0
        public DeletemeWatcher(IPackageOperationNotificationService packageOperationNotificationService, IFileSystemService fileSystemService,
                               IDirectoryService directoryService, INuGetPackageManager nuGetPackageManager, IDefaultExtensibleProjectProvider projectProvider, IMessageMediator messageMediator)
            : base(packageOperationNotificationService)
        {
            Argument.IsNotNull(() => fileSystemService);
            Argument.IsNotNull(() => directoryService);
            Argument.IsNotNull(() => nuGetPackageManager);
            Argument.IsNotNull(() => projectProvider);
            Argument.IsNotNull(() => messageMediator);

            _fileSystemService   = fileSystemService;
            _directoryService    = directoryService;
            _nuGetPackageManager = nuGetPackageManager;

            messageMediator.Register <PackagingDeletemeMessage>(this, OnDeletemeMessageAsync);

            _defaultProject = projectProvider.GetDefaultProject();
        }
예제 #4
0
파일: MessageBase.cs 프로젝트: ziez/Catel
        /// <summary>
        /// Convenient helper method to subscribe to this Message type.
        /// <para/>
        /// Usage:
        /// <list type="bullet">
        ///         <item><description>MessageClass.Register(this, msg =&gt; Handler) if the handler has the signature void Handler(MessageClass message)</description></item>
        ///         <item><description>MessageClass.Register(this, msg =&gt; Handler(msg.Data)) if the handler has the signature void Handler(TData data)</description></item>
        ///     </list>
        /// </summary>
        /// <param name="recipient">The instance which registers to the messages. Is most cases this will be <c>this</c>.</param>
        /// <param name="handler">A delegate handling the incoming message. For example: msg =&gt; Handler(msg.Data).</param>
        /// <param name="tag">The optional Catel mediator tag to be used.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="handler"/> is <c>null</c>.</exception>
        public static void Register(object recipient, Action <TMessage> handler, object tag = null)
        {
            Argument.IsNotNull("handler", handler);

            _mediator.Register(recipient, handler, tag);
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Catel.Modules.ModuleBase`1" /> class.
 /// </summary>
 /// <param name="messageMediator">The message mediator.</param>
 public OxyPlotModule(IMessageMediator messageMediator)
     : base(Name)
 {
     messageMediator.Register(this, new Action <Tuple <ObservableCollection <int>, ObservableCollection <int> > >(OnPlot));
 }
예제 #6
0
 protected override async Task Initialize()
 {
     _messageMediator.Register <PropertyChangedMessage>(this, OnPropertyChangedMessageReceived);
     _messageMediator.Register <CommandExecutedMessage>(this, OnCommandExecutedMessageReceived);
 }
예제 #7
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();
        }
예제 #8
0
 public MainWindow()
 {
     InitializeComponent();
     _messageMediator.Register(this);
     DataContext = new MainViewModel();
 }