Example #1
0
        public MainView()
        {
            InitializeComponent();
            if (!mvvmContext1.IsDesignMode)
            {
                InitializeBindings();
            }

            Version version = Assembly.GetEntryAssembly().GetName().Version;

            this.Text += $" {version.ToString()}";

            this.engine      = new DiagnosticEngine();
            this.engine.Log += UpdateLog;

            IHighlightingDefinition asmGiHighlightingDefinition;

            using (TextReader s = new StringReader(Resources.SyntaxHighlightingIL))
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    asmGiHighlightingDefinition = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            teEditor = new TextEditor();
            teEditor.Options.ConvertTabsToSpaces = true;
            teEditor.Options.IndentationSize     = 3;
            teEditor.ShowLineNumbers             = true;
            teEditor.FontFamily         = new FontFamily("Consolas");
            teEditor.FontSize           = 12.0;
            teEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#");
            teEditor.Text      = Resources.Samples_Sample0;
            elementHost1.Child = teEditor;

            teIL = new TextEditor();
            teIL.ShowLineNumbers    = true;
            teIL.FontFamily         = new FontFamily("Consolas");
            teIL.FontSize           = 12.0;
            teIL.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("C#");
            elementHostIL.Child     = teIL;

            teASM = new TextEditor();
            teASM.ShowLineNumbers    = true;
            teASM.FontFamily         = new FontFamily("Consolas");
            teASM.FontSize           = 12.0;
            teASM.SyntaxHighlighting = asmGiHighlightingDefinition;
            var contextMenu = new System.Windows.Controls.ContextMenu();
            var menuItem1   = new System.Windows.Controls.MenuItem();

            menuItem1.Header = "Resolve method...";
            menuItem1.Click += MenuItem1OnClick;
            contextMenu.Items.Add(menuItem1);
            teASM.ContextMenu    = contextMenu;
            elementHostASM.Child = teASM;

            ThreadPool.QueueUserWorkItem(ThreadCallback);
            timer1.Interval = interval;
            timer1.Start();
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IApplicationService applicationService, IFileService fileService)
        {
            // Services
            this.fileService        = fileService;
            this.applicationService = applicationService;

            // Initial state
            this.scriptArgument   = "<Argument>";
            this.state            = MainViewModelState.Idle;
            this.mainAssembly     = Assembly.GetEntryAssembly();
            this.AssemblyPlatform = Environment.Is64BitProcess
                ? DiagnosticAssembyPlatform.x64
                : DiagnosticAssembyPlatform.x86;
            this.engine      = new DiagnosticEngine();
            this.engine.Log += UpdateLog;

            // Commands
            this.RunScriptCommand        = new RelayCommand(RunScript, CanRunScript);
            this.ExitCommand             = new RelayCommand(Exit);
            this.LoadExperimentCommand   = new RelayCommand(LoadExperiment);
            this.SaveExperimentCommand   = new RelayCommand(SaveExperiment, CanSaveExperiment);
            this.SaveExperimentAsCommand = new RelayCommand(SaveExperimentAs);
            this.GCDataClickCommand      = new RelayCommand <ChartPoint>(GCDataClick);

            // Self-register messages
            Messenger.Default.Register <PropertyChangedMessage <string> >(
                this, (e) =>
            {
                if (e.PropertyName == nameof(ScriptText))
                {
                    this.RunScriptCommand?.RaiseCanExecuteChanged();
                }
            });
            Messenger.Default.Register <PropertyChangedMessage <MainViewModelState> >(
                this, (e) =>
            {
                this.RunScriptCommand?.RaiseCanExecuteChanged();
            });
            Messenger.Default.Register <PropertyChangedMessage <IExperimentFile> >(
                this, e =>
            {
                this.SaveExperimentCommand?.RaiseCanExecuteChanged();
                RaisePropertyChanged(nameof(Title));
            });

            // LiveCharts customization
            this.mapper = Mappers.Xy <DateViewModel>()
                          .X(dayModel => dayModel.DateTime.Ticks)
                          .Y(dayModel => dayModel.Value);

            this.GraphDataGC      = new SeriesCollection();
            this.GCSections       = new SectionsCollection();
            this.GCSectionsLabels = new VisualElementsCollection();
        }