Esempio n. 1
0
 public ETWControllerConfiguration(ETWController.ViewModel model)
 {
     BackupHost       = model.Host;
     BackupPortNumber = model.PortNumber;
     BackupWCFPort    = model.WCFPort;
     BackupForcedScreenshotIntervalinMs = model.ForcedScreenshotIntervalinMs;
     BackupKeepNNewestScreenShots       = model.KeepNNewestScreenShots;
     BackupTraceOpenCmdLine             = model.TraceOpenCmdLine;
     this.DataContext = model;
     Model            = model;
     InitializeComponent();
 }
Esempio n. 2
0
 public StatusMessages(ETWController.ViewModel model)
 {
     Model       = model;
     DataContext = Model;
     InitializeComponent();
     CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, SelectAll));
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, (a, b) => CopyCommand(a, b)));
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, (a, b) => Model.Commands["ClearStatusMessages"].Execute(null)));
     // Focus is needed to make copy command bindings work to put the context menu into the current visual tree by
     // setting as top level window the current window.
     // http://wpftutorial.net/Menus.html
     Focus();
 }
        public TraceControlViewModel(ETWController.ViewModel rootModel, bool isRemoteState)
        {
            RootModel      = rootModel;
            IsRemoteState  = isRemoteState;
            CommandOutputs = new ObservableCollection <string>();

            ShowCommand = new DelegateCommand((o) =>
            {
                if (OutputWindow == null)
                {
                    OutputWindow             = new OutputWindow();
                    OutputWindow.Title      += IsRemoteState ? " (Server)" : " (Local)";
                    OutputWindow.DataContext = this;
                    OutputWindow.Closed     += (a, b) => OutputWindow = null;
                }
                OutputWindow.Show();
                OutputWindow.Activate();
            });

            OpenTraceCommand = new DelegateCommand((o) =>
            {
                string outFile = RootModel.StopData.TraceFileName;
                if (outFile != null)
                {
                    var exe       = ExtractExecName(RootModel.TraceOpenCmdLine);
                    var options   = RootModel.TraceOpenCmdLine.Substring(exe.Length);
                    options       = Environment.ExpandEnvironmentVariables(options.Replace(TraceFileNameVariable, outFile));
                    var startInfo = new ProcessStartInfo(exe, options)
                    {
                        WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                    };
                    Process.Start(startInfo);
                    AddLogEntry(ETWController.ViewModel.CustomCommandPrefix + exe + options, new Tuple <int, string>(0, ""), CommandOutputs);
                }
            },
                                                   () => !IsRemoteState && RootModel.StopData != null && File.Exists(RootModel.StopData.TraceFileName)); // dynamically update the button enabled state if the output file does exist.
        }