Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new service vertex.
        /// </summary>
        /// <param name="parentGraph"></param>
        /// <param name="service"></param>
        internal YodiiGraphVertex( YodiiGraph parentGraph, LabServiceInfo service )
            : this()
        {
            Debug.Assert( parentGraph != null );
            Debug.Assert( service != null );

            _isPlugin = false;
            _liveService = service;
            _parentGraph = parentGraph;

            _liveService.ServiceInfo.PropertyChanged += StaticInfo_PropertyChanged;
            _liveService.PropertyChanged += _labService_PropertyChanged;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new plugin vertex.
        /// </summary>
        /// <param name="parentGraph"></param>
        /// <param name="plugin"></param>
        internal YodiiGraphVertex( YodiiGraph parentGraph, LabPluginInfo plugin )
            : this()
        {
            Debug.Assert( parentGraph != null );
            Debug.Assert( plugin != null );

            _isPlugin = true;
            _livePlugin = plugin;
            _parentGraph = parentGraph;

            _livePlugin.PluginInfo.PropertyChanged += StaticInfo_PropertyChanged;
            _livePlugin.PropertyChanged += _labPlugin_PropertyChanged;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of this ViewModel.
        /// </summary>
        /// <param name="loadDefaultState">True if the default XML state should be loaded, false to start on an empty state.</param>
        public MainWindowViewModel( bool loadDefaultState = false )
        {
            _recentFiles = new CKObservableSortedArrayList<RecentFile>( ( a, b ) => DateTime.Compare( b.AccessTime, a.AccessTime ) );

            // Lab objects, live objects and static infos are managed in the LabStateManager.
            _labStateManager = new LabStateManager();
            _engine = _labStateManager.Engine;

            _labStateManager.Engine.PropertyChanged += Engine_PropertyChanged;
            _labStateManager.ServiceInfos.CollectionChanged += ServiceInfos_CollectionChanged;
            _labStateManager.PluginInfos.CollectionChanged += PluginInfos_CollectionChanged;
            _labStateManager.RunningPlugins.CollectionChanged += RunningPlugins_CollectionChanged;

            _engine.Configuration.Layers.CollectionChanged += Layers_CollectionChanged;

            _activityMonitor = new ActivityMonitor();

            _activityMonitor.OpenTrace().Send( "Hello world" );

            _graph = new YodiiGraph( _engine.Configuration, _labStateManager );

            _removeSelectedVertexCommand = new RelayCommand( RemoveSelectedVertexExecute, CanEditSelectedVertex );
            _toggleEngineCommand = new RelayCommand( ToggleEngineExecute );
            _openFileCommand = new RelayCommand( OpenFileExecute );
            _saveAsFileCommand = new RelayCommand( SaveAsFileExecute );
            _saveCommand = new RelayCommand( SaveExecute ); // Save is always available.e
            _reorderGraphLayoutCommand = new RelayCommand( ReorderGraphLayoutExecute );
            _createPluginCommand = new RelayCommand( CreatePluginExecute, CanEditItems );
            _createServiceCommand = new RelayCommand( CreateServiceExecute, CanEditItems );
            _openConfigurationEditorCommand = new RelayCommand( OpenConfigurationEditorExecute );
            _newFileCommand = new RelayCommand( NewFileExecute );
            _revokeAllCommandsCommand = new RelayCommand( RevokeAllCommandsExecute, CanRevokeAllCommands );
            _autoPositionCommand = new RelayCommand( AutoPositionExecute );

            LoadRecentFiles();

            // Appication is only available on WPF context.
            if( Application.Current != null )
            {
                _autosaveTimer = new DispatcherTimer( DispatcherPriority.Background, Application.Current.Dispatcher );
            }
            else
            {
                _autosaveTimer = new DispatcherTimer( DispatcherPriority.Background, Dispatcher.CurrentDispatcher );
            }

            _autosaveTimer.Interval = new TimeSpan( 0, 0, 5 );
            _autosaveTimer.Tick += AutosaveTick;

            // Autosave timer is started from outside, using StartAutosaveTimer().

            if( loadDefaultState ) LoadDefaultState();
        }