Пример #1
0
        public RootViewModel(EngineContext engineContext, ProcessInfoRenderer processInfoRenderer)
        {
            if (engineContext == null)
                throw new ArgumentNullException("engineContext");

            if (engineContext.Scheduler == null)
                throw new InvalidOperationException("The provided EngineContext must have a Scheduler.");

            timer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1.0),
                IsEnabled = true,
            };
            timer.Tick += (s, e) => Increment++;
            timer.Start();

            this.processInfoRenderer = processInfoRenderer;

            EngineContext = engineContext;
            microThreadMonitoringManager = new MicroThreadMonitoringManager(EngineContext.Scheduler);

            SnapshotCommand = new AnonymousCommand(_ => TakeSnapshot());

            //PauseCommand = new AnonymousCommand(_ => EngineContext.Scheduler.PauseExecution());
            //ResumeCommand = new AnonymousCommand(_ => EngineContext.Scheduler.ResumeExecution());
            //NextFrameCommand = new AnonymousCommand(_ => EngineContext.Scheduler.NextExecutionFrame());

            SetupMicroThreadWatching();
            SetupScriptWatching();

            StartMonitoring();
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerViewModel"/> class.
 /// </summary>
 /// <param name="serviceProvider">A service provider that can provide a <see cref="IDispatcherService"/> to use for this view model.</param>
 public LoggerViewModel(IViewModelServiceProvider serviceProvider)
     : base(serviceProvider)
 {
     AddLoggerCommand = new AnonymousCommand<Logger>(serviceProvider, AddLogger);
     RemoveLoggerCommand = new AnonymousCommand<Logger>(serviceProvider, RemoveLogger);
     ClearLoggersCommand = new AnonymousCommand(serviceProvider, ClearLoggers);
     ClearMessagesCommand = new AsyncCommand(serviceProvider, ClearMessages);
     messages.CollectionChanged += MessagesCollectionChanged;
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoggerViewModel"/> class with multiple loggers.
 /// </summary>
 /// <param name="serviceProvider">A service provider that can provide a <see cref="Services.IDispatcherService"/> to use for this view model.</param>
 /// <param name="loggers">The collection of <see cref="Logger"/> to monitor.</param>
 public LoggerViewModel(IViewModelServiceProvider serviceProvider, IEnumerable<Logger> loggers)
     : this(serviceProvider)
 {
     if (loggers == null) throw new ArgumentNullException(nameof(loggers));
     foreach (var logger in loggers)
     {
         Loggers.Add(logger, new List<ILogMessage>());
         logger.MessageLogged += MessageLogged;
     }
     ClearMessagesCommand = new AnonymousCommand(serviceProvider, ClearMessages);
 }
Пример #4
0
        public RootViewModel(Window window)
        {
            optionsViewModel = new OptionsViewModel();
            optionsViewModel.OptionsChanged += LoadAssemblies;

            Options = optionsViewModel.Options;

            Sections = new ReadOnlyObservableCollection<SectionViewModel>(workingSections);

            CloseCommand = new AnonymousCommand(window.Close);
        }
Пример #5
0
        public OptionsViewModel()
        {
            Options = Options.Load() ?? new Options();

            XenkoPath = Options.XenkoPath;
            XenkoConfigFilename = Options.XenkoConfigFilename;

            CheckXenkoPath();
            CheckXenkoConfigFilename();

            BrowsePathCommand = new AnonymousCommand(BrowsePath);
            BrowseConfigFileCommand = new AnonymousCommand(BrowseConfigFile);
        }
Пример #6
0
        public ScriptMethodViewModel(ScriptEntry2 scriptEntry, ScriptTypeViewModel parent)
        {
            if (parent == null)
                throw new ArgumentNullException("parent");

            TypeParent = parent;
            AssemblyParent = TypeParent.Parent;

            this.scriptEntry = scriptEntry;

            RunScriptCommand = new AnonymousCommand(_ => OnRunScriptCommand());
            CloseMicroThreadView = new AnonymousCommand(_ => MicroThread = null);
        }
Пример #7
0
        public OptionsViewModel()
        {
            Options = Options.Load() ?? new Options();

            ParadoxPath = Options.ParadoxPath;
            ParadoxConfigFilename = Options.ParadoxConfigFilename;

            CheckParadoxPath();
            CheckParadoxConfigFilename();

            BrowsePathCommand = new AnonymousCommand(BrowsePath);
            BrowseConfigFileCommand = new AnonymousCommand(BrowseConfigFile);
        }
Пример #8
0
        protected CombinedObservableNode(ObservableViewModel ownerViewModel, string name, IEnumerable<SingleObservableNode> combinedNodes, Index index)
            : base(ownerViewModel, index)
        {
            // ReSharper disable once DoNotCallOverridableMethodsInConstructor
            DependentProperties.Add(nameof(Value), new[] { nameof(HasMultipleValues), nameof(IsPrimitive), nameof(HasList), nameof(HasDictionary) });
            this.combinedNodes = new List<SingleObservableNode>(combinedNodes);
            Name = name;
            DisplayName = this.combinedNodes.First().DisplayName;

            combinedNodeInitialValues = new List<object>();
            distinctCombinedNodeInitialValues = new HashSet<object>();

            bool isReadOnly = false;
            bool isVisible = false;
            bool nullOrder = false;

            foreach (var node in this.combinedNodes)
            {
                if (node.IsDestroyed)
                    throw new InvalidOperationException("One of the combined node is already disposed.");

                if (node.IsReadOnly)
                    isReadOnly = true;

                if (node.IsVisible)
                    isVisible = true;

                if (node.Order == null)
                    nullOrder = true;

                if (order == node.Order || (!nullOrder && order == null))
                    order = node.Order;

                combinedNodeInitialValues.Add(node.Value);
                distinctCombinedNodeInitialValues.Add(node.Value);
            }
            IsReadOnly = isReadOnly;
            IsVisible = isVisible;

            ResetInitialValues = new AnonymousCommand(ServiceProvider, () =>
            {
                using (Owner.BeginCombinedAction(Owner.FormatCombinedUpdateMessage(this, null), Path))
                {
                    CombinedNodes.Zip(combinedNodeInitialValues).ForEach(x => x.Item1.Value = x.Item2);
                    Refresh();
                }
            });
        }
        public ScriptManagerControl(EngineContext engineContext, Action terminateCommand)
        {
            InitializeComponent();

            if (engineContext == null)
                throw new ArgumentNullException("engineContext");

            if (terminateCommand != null)
                TerminateCommand = new AnonymousCommand(_ => terminateCommand());

            this.Loaded += (s, e) =>
            {
                scriptEditor.Initialize(engineContext);
                scriptMonitor.Initialize(engineContext);
            };

        }
Пример #10
0
        protected CombinedObservableNode(ObservableViewModel ownerViewModel, string name, IEnumerable<SingleObservableNode> combinedNodes, object index)
            : base(ownerViewModel, index)
        {
            this.combinedNodes = new List<SingleObservableNode>(combinedNodes);
            Name = name;
            DisplayName = this.combinedNodes.First().DisplayName;

            combinedNodeInitialValues = new List<object>();
            distinctCombinedNodeInitialValues = new HashSet<object>();

            bool isReadOnly = false;
            bool isVisible = false;
            bool nullOrder = false;

            foreach (var node in this.combinedNodes)
            {
                if (node.IsReadOnly)
                    isReadOnly = true;

                if (node.IsVisible)
                    isVisible = true;

                if (node.Order == null)
                    nullOrder = true;

                if (order == node.Order || (!nullOrder && order == null))
                    order = node.Order;

                combinedNodeInitialValues.Add(node.Value);
                distinctCombinedNodeInitialValues.Add(node.Value);
                node.PropertyChanged += NodePropertyChanged;
            }
            IsReadOnly = isReadOnly;
            IsVisible = isVisible;

            ResetInitialValues = new AnonymousCommand(ServiceProvider, () => { Owner.BeginCombinedAction(); CombinedNodes.Zip(combinedNodeInitialValues).ForEach(x => x.Item1.Value = x.Item2); Refresh(); Owner.EndCombinedAction(Owner.FormatCombinedUpdateMessage(this, null), Path, null); });
        }
Пример #11
0
 public void SetOptionsWindow(Window window)
 {
     CloseCommand = new AnonymousCommand(window.Close);
 }
Пример #12
0
 protected MessageDialogBase()
 {
     var serviceProvider = new ViewModelServiceProvider(new[] { new DispatcherService(Dispatcher) });
     ButtonCommand = new AnonymousCommand<int>(serviceProvider, ButtonClick);
 }