public MainViewModel(IEnumerable <IInputStream> streams, IEnumerable <ITextProcessor> processors, ILogService logger, IStreamService streamer, IOutputService outputHandler, IDialogService dialogHandler)
        {
            // fields and properties
            Streams                          = new ObservableCollection <IInputStream>(streams);
            Processors                       = new ObservableCollection <ITextProcessor>(processors);
            OrderByTextItemList              = new string[] { manualOrderingDescription, "TimeStamp", "Text" };
            StreamedItems                    = new ObservableCollection <TextItemViewModel>();
            StreamedItemsView                = new ListCollectionView(StreamedItems);
            outputService                    = outputHandler as OutputService;
            dialogService                    = dialogHandler;
            logService                       = logger;
            streamService                    = streamer;
            OrderByTextItem                  = OrderByTextItemList.FirstOrDefault();
            SelectedStream                   = Streams.FirstOrDefault();
            SelectedProcessor                = Processors.FirstOrDefault();
            StreamedItems.CollectionChanged += (s, e) => updateOutput();

            #region initialize services internal functions

            // set up the logger for binding
            IObservableLogger loggerWithEntries = null;
            if (logService != null && (loggerWithEntries = logService as IObservableLogger) != null)
            {
                LogEntries = new ListCollectionView(loggerWithEntries.Entries);
                loggerWithEntries.Entries.CollectionChanged += (s, e) => refreshLogCounters();
                refreshLogCounters();
            }

            // set the callback for the stream service
            (streamService as StreamService).ReceiveStreamText = streamedText =>
            {
                StreamedItems.Add(new TextItemViewModel(streamedText, outputService));
                CommandManager.InvalidateRequerySuggested();

                // NOTE:  updateOutput is called on the CollectionChanged event of StreamedItems
            };

            // set up output service
            outputService.RefreshAction = updateOutput;

            #endregion

            // commands
            StartCommand       = CreateCommand(startCommand_Execute, startCommand_CanExecute);
            StopCommand        = CreateCommand(stopCommand_Execute, stopCommand_CanExecute);
            SelectAllCommand   = CreateCommand(selectAllCommand_Execute, selectAllCommand_CanExecute);
            DeselectAllCommand = CreateCommand(deselectAllCommand_Execute, deselectAllCommand_CanExecute);
            DeleteCommand      = CreateCommand(deleteCommand_Execute, deleteCommand_CanExecute);
            MoveUpCommand      = CreateCommand(moveUpCommand_Execute, moveUpCommand_CanExecute);
            MoveDownCommand    = CreateCommand(moveDownCommand_Execute, moveDownCommand_CanExecute);
            CopyOutputCommand  = CreateCommand(copyOutputCommand_Execute, copyOutputCommand_CanExecute);
            HelpCommand        = CreateCommand(helpCommand_Execute);

            // enable the control used to select an input stream
            IsIdle        = true;
            loadCompleted = true;
            updateOutput();
            refreshStreamStateLabel();
        }
예제 #2
0
        public MainWindow(IObservableLogger <Log> logger)
        {
            InitializeComponent();
            this.logger = logger;
            DataContext = new MainWindowViewModel(logger);

            pleasanterSettingsPath = Environment.ExpandEnvironmentVariables(Properties.Settings.Default.PleasanterSettingsPath);
            SetDebugPleasanterSettingsPath();
        }
예제 #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            DispatcherUnhandledException += App_DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var logFilePath = "Logs\\Implem.SupportTools.log";

            if (File.Exists(SupportTools.Properties.Settings.Default.PleasanterSettingsPath))
            {
                var     json     = File.ReadAllText(SupportTools.Properties.Settings.Default.PleasanterSettingsPath);
                dynamic settings = JsonConvert.DeserializeObject(json);
                logFilePath = settings.logFilePath;
            }
            if (!Directory.Exists(Path.GetDirectoryName(logFilePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
            }
            Logger     = new Logger(logFilePath);
            MainWindow = new MainWindow(Logger);
            MainWindow.Show();
        }
 public MainWindowViewModel(IObservableLogger <Log> logger)
 {
     Logs = logger.Logs;
 }
예제 #5
0
 public MainWindow(IObservableLogger <Log> logger)
 {
     InitializeComponent();
     this.logger = logger;
     DataContext = new MainWindowViewModel(logger);
 }