コード例 #1
0
 public ImageAssetEditor()
 {
     this._undoService         = ViewContainer.Resolve <IUndoService>();
     this.AddSpriteCommand     = new RelayCommand(this.AddSprite, () => this.Asset != null);
     this._removeSpriteCommand = new RelayCommand(this.RemoveSprite, () => this.Asset != null && this.SelectedSprite != null);
     this.InitializeComponent();
 }
コード例 #2
0
 public UndoManager(IUndoService undoService, int clientId)
 {
     _clientId    = clientId;
     _undoService = undoService;
     _undoService.ActiveStateChanged += _undoService_ActiveStateChanged;
     _undoService.StackChanged       += _undoService_StackChanged;
 }
コード例 #3
0
 public ComponentControl()
 {
     this._busyService        = ViewContainer.Instance.Resolve <IBusyService>();
     this._undoService        = ViewContainer.Instance.Resolve <IUndoService>();
     this._valueEditorService = ViewContainer.Instance.Resolve <IValueEditorService>();
     this.InitializeComponent();
 }
コード例 #4
0
ファイル: SheetFactory.cs プロジェクト: KingKnecht/AplayTest
 public SheetFactory(IUndoService undoService, IConnectionFactory connectionFactory, IBlockSymbolFactory blockSymbolFactory, IConnectorFactory connectorFactory)
 {
     _undoService        = undoService;
     _connectionFactory  = connectionFactory;
     _blockSymbolFactory = blockSymbolFactory;
     _connectorFactory   = connectorFactory;
 }
コード例 #5
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="collection">Collection to monitor</param>
        /// <param name="undoService">Undo service</param>
        public CollectionChangeUndoObserver(IList collection, IUndoService undoService)
        {
            if (collection == null)
            {
                throw new ArgumentNullException("collection");
            }
            if (undoService == null)
            {
                throw new ArgumentNullException("undoService");
            }

            var incc = collection as INotifyCollectionChanged;

            if (incc == null)
            {
                throw new ArgumentException("Collection must implement INotifyCollectionChanged.");
            }

            // Save off the data.
            _undoService = undoService;
            _collection  = new WeakReference(collection);

            // Add a listener to the collection.
            CollectionChangedEventManager.AddListener(incc, this);
        }
コード例 #6
0
        public ProjectViewModel(
            IAssetService assetService,
            IDialogService dialogService,
            IMonoGameService monoGameService,
            IProjectService projectService,
            ISceneService sceneService,
            Serializer serializer,
            IUndoService undoService)
        {
            this.AssetService     = assetService;
            this._dialogService   = dialogService;
            this._monoGameService = monoGameService;
            this.ProjectService   = projectService;
            this._sceneService    = sceneService;
            this._serializer      = serializer;
            this._undoService     = undoService;

            this.AddAssetCommand     = new RelayCommand(this.AddAsset);
            this._deleteAssetCommand = new RelayCommand(async() => await this.DeleteAsset(), () => this.AssetService.SelectedAsset?.Parent != null);
            this.OpenSceneCommand    = new RelayCommand <Asset>(this.OpenScene, asset => asset.Type == AssetType.Scene);

            this.AssetService.PropertyChanged   += this.AssetService_PropertyChanged;
            this.ProjectService.PropertyChanged += this.ProjectService_PropertyChanged;

            if (this.ProjectService.CurrentProject != null)
            {
                this.ProjectService.CurrentProject.PropertyChanged += this.CurrentProject_PropertyChanged;
            }
        }
コード例 #7
0
 public Connection(int id, IUndoService undoService, Action <Connection> onPrepareRemoveCallBack, Sheet sheet)
 {
     Id                               = id;
     _undoService                     = undoService;
     _onPrepareRemoveCallBack         = onPrepareRemoveCallBack;
     Sheet                            = sheet;
     _undoService.ActiveStateChanged += UndoServiceOnActiveStateChanged;
 }
コード例 #8
0
ファイル: TaskManager.cs プロジェクト: KingKnecht/AplayTest
 public TaskManager(Task[] tasks, IUndoService undoService)
 {
     _undoService = undoService;
     foreach (var task in tasks)
     {
         Tasks.Add(task);
     }
 }
コード例 #9
0
 public ModuleList()
 {
     this._dialogService       = ViewContainer.Instance.Resolve <IDialogService>();
     this._undoService         = ViewContainer.Instance.Resolve <IUndoService>();
     this._addModuleCommand    = new RelayCommand(this.AddModule);
     this._removeModuleCommand = new RelayCommand(this.RemoveModule, () => this.SelectedModule != null);
     InitializeComponent();
 }
コード例 #10
0
 /// <summary>
 /// Base constructor for segment view model factories derived from the <see cref="SegmentViewModelFactoryBase"/> class.
 /// </summary>
 /// <param name="scriptVideoContext">The runtime context of the <see cref="IScriptVideoService"/> instance.</param>
 /// <param name="undoService">The <see cref="IUndoService"/> instance providing undo/redo support.</param>
 /// <param name="undoChangeFactory">The <see cref="IChangeFactory"/> instance for undo <see cref="Change"/> creation.</param>
 /// <param name="rootUndoObject">The undo "root document" or "root object" for the view models this factory creates.</param>
 /// <param name="clipboardService">The <see cref="IClipboardService"/> instance providing access to the system clipboard.</param>
 protected SegmentViewModelFactoryBase(IScriptVideoContext scriptVideoContext, IUndoService undoService, IChangeFactory undoChangeFactory, object rootUndoObject, IClipboardService clipboardService)
 {
     _scriptVideoContext = scriptVideoContext;
     _undoService        = undoService;
     _undoChangeFactory  = undoChangeFactory;
     _rootUndoObject     = rootUndoObject;
     _clipboardService   = clipboardService;
 }
コード例 #11
0
ファイル: AssetService.cs プロジェクト: punker76/Macabre2D
 public AssetService(
     IDialogService dialogService,
     Serializer serializer,
     IUndoService undoService)
 {
     this._dialogService = dialogService;
     this._serializer    = serializer;
     this._undoService   = undoService;
 }
コード例 #12
0
 public SubUndoService(IUndoService undoService)
 {
     _undoService = undoService ?? throw new NullReferenceException();
     _undoService.StateRecorded     += UndoService_StateRecorded;
     _undoService.StateSet          += UndoService_StateSet;
     _undoService.ClearStackInvoked += UndoService_ClearStackInvoked;
     _undoService.CanRedoChanged    += UndoService_CanRedoChanged;
     _undoService.CanUndoChanged    += UndoService_CanUndoChanged;
 }
コード例 #13
0
 public Task(int id, bool isDone, string description, IUndoService undoService)
     : base()
 {
     Id           = id;
     IsDone       = isDone;
     _undoService = undoService;
     _undoService.ActiveStateChanged += _undoService_ActiveStateChanged;
     Description = description;
 }
コード例 #14
0
        public Connector(int id, IUndoService undoService, Action <Connector> onPrepareRemoveCallBack, Sheet sheet, Factories.IConnectionFactory connectionFactory)
        {
            Sheet                    = sheet;
            Id                       = id;
            _undoService             = undoService;
            _onPrepareRemoveCallBack = onPrepareRemoveCallBack;
            _connectionFactory       = connectionFactory;

            _undoService.ActiveStateChanged += UndoServiceOnActiveStateChanged;
        }
コード例 #15
0
 public void Setup()
 {
     _undoServiceForInt       = new UndoService <int>(GetIntState, SetIntState, 3);
     _individualUndoService   = new UndoService <int>(GetIntState, SetIntState, 3);
     _subUndoServiceForInt    = new UndoService <int>(GetIntState, SetIntState, 3);
     _subUndoServiceForString = new UndoService <string>(GetStringState, SetStringState, 3);
     IUndoService[] subservices = { _subUndoServiceForInt, _subUndoServiceForString };
     _aggregateService         = new UndoServiceAggregate(subservices);
     _canUndoChangedFiredCount = 0;
     _canRedoChangedFiredCount = 0;
 }
コード例 #16
0
ファイル: BlockSymbol.cs プロジェクト: KingKnecht/AplayTest
        public BlockSymbol(int id, IUndoService undoService, Factories.IConnectorFactory connectorFactory, Action <BlockSymbol> onPrepareRemoveCallBack, Sheet sheet)
            : this()
        {
            Sheet                    = sheet;
            Id                       = id;
            _undoService             = undoService;
            _connectorFactory        = connectorFactory;
            _onPrepareRemoveCallBack = onPrepareRemoveCallBack;

            _undoService.ActiveStateChanged += UndoServiceOnActiveStateChanged;
        }
コード例 #17
0
        public Sheet(int id, IUndoService undoService, Factories.IBlockSymbolFactory blockSymbolFactory,
                     Factories.IConnectionFactory connectionFactory,
                     Factories.IConnectorFactory connectorFactory)
        {
            Id                  = id;
            _undoService        = undoService;
            _blockSymbolFactory = blockSymbolFactory;
            _connectionFactory  = connectionFactory;
            _connectorFactory   = connectorFactory;

            _undoService.ActiveStateChanged += UndoServiceOnActiveStateChanged;
        }
コード例 #18
0
        private readonly IBallroomService _ballroomService;             // needed for undo

        public GuestsController(IGroupService groupService,
                                IPersonService personService,
                                IGuestAutoMapperService autoMapperService,
                                IUndoService undoService,
                                IBallroomService ballroomService)
        {
            _groupService      = groupService;
            _personService     = personService;
            _autoMapperService = autoMapperService;
            _undoService       = undoService;
            _ballroomService   = ballroomService;
        }
コード例 #19
0
 public BallroomController(IBallroomService ballroomService,
                           IBallroomAutoMapperService autoMapperService,
                           IUndoService undoService,
                           IGroupService guestService,
                           IPersonService personService)
 {
     _ballroomService   = ballroomService;
     _autoMapperService = autoMapperService;
     _undoService       = undoService;
     _groupService      = guestService;
     _personService     = personService;
 }
コード例 #20
0
        public UndoManager(IUndoService undoService, int clientId)
        {
            _clientId    = clientId;
            _undoService = undoService;
            _undoService.ActiveStateChanged += _undoService_ActiveStateChanged;
            _undoService.StackChanged       += _undoService_StackChanged;

            foreach (var historyEntry in _undoService.GetHistory(clientId))
            {
                History.Add(new HistoryEntry(historyEntry.Id, historyEntry.Description));
            }
        }
コード例 #21
0
        public ComponentHierarchy()
        {
            this._dialogService    = ViewContainer.Resolve <IDialogService>();
            this._monoGameService  = ViewContainer.Resolve <IMonoGameService>();
            this._componentService = ViewContainer.Resolve <IComponentService>();
            this._undoService      = ViewContainer.Resolve <IUndoService>();

            this._componentService.SelectionChanged += this.ComponentService_SelectionChanged;
            this._addComponentCommand    = new RelayCommand(this.AddComponent, () => this.SelectedItem != null);
            this._removeComponentCommand = new RelayCommand(this.RemoveComponent, () => this.SelectedItem != null && this.SelectedItem is ComponentWrapper);
            this.InitializeComponent();
        }
コード例 #22
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            IList source = GetListObject();

            if (source != null)
            {
                CollectionChangedEventManager.RemoveListener(source as INotifyCollectionChanged, this);
                _collection.Target = null;
            }

            _undoService = null;
        }
コード例 #23
0
        public Task(int id, ExternalChangeSet changeSet, IUndoService undoService)
        {
            _undoService = undoService;
            _undoService.ActiveStateChanged += _undoService_ActiveStateChanged;

            Id = id;

            foreach (var change in changeSet.Where(c => c.ItemId == id))
            {
                IsDone      = ((UndoObject)change.Undoable).IsDone;
                Description = ((UndoObject)change.Undoable).Description;
            }
        }
コード例 #24
0
 public ValueEditorService(
     IAssemblyService assemblyService,
     IDialogService dialogService,
     IProjectService projectService,
     ISceneService sceneService,
     IUndoService undoService)
 {
     this._assemblyService = assemblyService;
     this._dialogService   = dialogService;
     this._projectService  = projectService;
     this._sceneService    = sceneService;
     this._undoService     = undoService;
 }
コード例 #25
0
 public SpriteAnimationAssetEditor()
 {
     this._dialogService      = ViewContainer.Resolve <IDialogService>();
     this._projectService     = ViewContainer.Resolve <IProjectService>();
     this._undoService        = ViewContainer.Resolve <IUndoService>();
     this._addStepCommand     = new RelayCommand(this.AddStep, () => this.Asset != null);
     this._removeStepCommand  = new RelayCommand(this.RemoveStep, () => this.Asset != null && this.SelectedStep != null);
     this._moveDownCommand    = new RelayCommand(this.MoveDown, this.CanMoveDown);
     this._moveUpCommand      = new RelayCommand(this.MoveUp, this.CanMoveUp);
     this.ClearSpriteCommand  = new RelayCommand <SpriteAnimationStepWrapper>(this.ClearSprite);
     this.SelectSpriteCommand = new RelayCommand <SpriteAnimationStepWrapper>(this.SelectSprite);
     this.InitializeComponent();
 }
コード例 #26
0
        public MainWindow()
        {
            // Get the undo service
            _undoService = ServiceLocator.Instance.Resolve <IUndoService>();

            // Setup Undo/Redo key bindings.  This is not done automatically since the service is in Core.
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, (s, e) => _undoService.Undo(), (s, e) => e.CanExecute = _undoService.CanUndo));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, (s, e) => _undoService.Redo(), (s, e) => e.CanExecute = _undoService.CanRedo));

            Loaded   += MainWindowLoaded;
            Unloaded += MainWindowUnloaded;
            InitializeComponent();
        }
コード例 #27
0
        public ImageEditorViewModel(IUndoService undoService, IBuildService buildService, IPixelEventService pixelEventService)
        {
            this.UndoService       = undoService;
            this.BuildService      = buildService;
            this.PixelEventService = pixelEventService;

            // ***
            // ***
            // ***
            this.BuildService.BuildEvent += this.BuildService_BuildEvent;

            // ***
            // *** Group these property so that only one of them
            // *** can be true at any given time.
            // ***
            this.Group = new BooleanPropertyGroup
                         (
                (nameof(this.DrawIsChecked), (b) => { this.DrawIsChecked = b; }),
                (nameof(this.SandIsChecked), (b) => { this.SandIsChecked = b; }),
                (nameof(this.EraseIsChecked), (b) => { this.EraseIsChecked = b; }),
                (nameof(this.EraseColorIsChecked), (b) => { this.EraseColorIsChecked = b; }),
                (nameof(this.PickColorIsChecked), (b) => { this.PickColorIsChecked = b; })
                         );

            // ***
            // *** Wire up events for when the user interacts with the LED Matrix.
            // ***
            this.PixelEventService.PixelSelected += this.PixelMatrix_PixelSelected;

            // ***
            // *** Wire up the event to capture changes to the ColorMatrix.
            // ***
            this.ColorMatrix.PixelChanged      += this.ColorMatrix_PixelChanged;
            this.ColorMatrix.BackgroundChanged += this.ColorMatrix_BackgroundChanged;

            this.LoadCommand                   = new DelegateCommand(this.OnLoadCommand, this.OnEnableLoadCommand);
            this.SaveCommand                   = new DelegateCommand(this.OnSaveCommand, this.OnEnableSaveCommand);
            this.ClearCommand                  = new DelegateCommand(this.OnClearCommand, this.OnEnableClearCommand);
            this.RotateClockwiseCommand        = new DelegateCommand(this.OnRotateClockwiseCommand, this.OnEnableRotateClockwiseCommand);
            this.RotateCounterClockwiseCommand = new DelegateCommand(this.OnRotateCounterClockwiseCommand, this.OnEnableRotateCounterClockwiseCommand);
            this.FlipHorizontalCommand         = new DelegateCommand(this.OnFlipHorizontalCommand, this.OnEnableFlipHorizontalCommand);
            this.FlipVerticalCommand           = new DelegateCommand(this.OnFlipVerticalCommand, this.OnEnableFlipVerticalCommand);
            this.BuildCommand                  = new DelegateCommand(this.OnBuildCommand, this.OnEnableBuildCommand);
            this.RedoCommand                   = new DelegateCommand(this.OnRedoCommand, this.OnEnableRedoCommand);
            this.UndoCommand                   = new DelegateCommand(this.OnUndoCommand, this.OnEnableUndoCommand);
            this.CloseOutputCommand            = new DelegateCommand(this.OnCloseOutputCommand, this.OnEnableCloseOutputCommand);
        }
コード例 #28
0
 public ProjectManagerFactory(IProjectManagerService projectManagerService,
                              IUndoService undoService, //Todo: Inject a FactoryFactory here?
                              IUndoManagerCache undoManagerCache,
                              IConnectorFactory connectorFactory,
                              IConnectionFactory connectionFactory,
                              IBlockSymbolFactory blockSymbolFactory,
                              ISheetFactory sheetFactory)
 {
     _projectManagerService = projectManagerService;
     _undoService           = undoService;
     _undoManagerCache      = undoManagerCache;
     _connectorFactory      = connectorFactory;
     _connectionFactory     = connectionFactory;
     _blockSymbolFactory    = blockSymbolFactory;
     _sheetFactory          = sheetFactory;
     _aplayProjectsCache    = new AplayProjectsCache();
 }
コード例 #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="projectManagerService">Gets projects from some source i.e. DB</param>
        /// <param name="aplayProjectsCache">A cache of transformed projects. Contains Aplay-Projects. These projects must be the same over all ProjectManagers.</param>
        /// <param name="undoService">A service for undo/redo. Same for all clients.</param>
        /// <param name="undoManagerCache"></param>
        /// <param name="connectionFactory"></param>
        /// <param name="connectorFactory"></param>
        /// <param name="blockSymbolFactory"></param>
        /// <param name="sheetFactory"></param>
        public ProjectManager(IProjectManagerService projectManagerService,
                              IAplayProjectsCache aplayProjectsCache, IUndoService undoService,
                              IUndoManagerCache undoManagerCache,
                              Factories.IConnectionFactory connectionFactory, //Todo: A ProjectFactory is needed here instead of creating projects here directly.
                              Factories.IConnectorFactory connectorFactory,
                              Factories.IBlockSymbolFactory blockSymbolFactory,
                              Factories.ISheetFactory sheetFactory)
        {
            _projectManagerService = projectManagerService;
            _aplayProjectsCache    = aplayProjectsCache;
            _undoService           = undoService;
            _undoManagerCache      = undoManagerCache;
            _connectionFactory     = connectionFactory;
            _connectorFactory      = connectorFactory;
            _blockSymbolFactory    = blockSymbolFactory;
            _sheetFactory          = sheetFactory;


            //Subscribe for newly added, deleted projects from the service.
            var serviceUpdates = _projectManagerService.ProjectsDelta.Connect()
                                 .Filter(project => Filter(_searchString, project))
                                 .Transform(GetAplayProject)
                                 .Subscribe(changeSet =>
            {
                foreach (var change in changeSet)
                {
                    if (change.Reason == ChangeReason.Add)
                    {
                        Projects.Add(change.Current);
                    }
                    if (change.Reason == ChangeReason.Remove)
                    {
                        Projects.Remove(change.Current);
                    }
                }

                UpdateStates();
            });

            _cleanUp.Add(serviceUpdates);

            UpdateStates();
        }
コード例 #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCommand{T}"/> class.
        /// </summary>
        /// <param name="service">The undo service that owns this command.</param>
        /// <param name="desc">The description of the action.</param>
        /// <param name="undoAction">The undo action execute.</param>
        /// <param name="redoAction">The redo action to execute.</param>
        /// <param name="redoArgs">The arguments to pass to the redo functionality.</param>
        /// <param name="undoArgs">The arguments to pass to the undo functionality.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="service"/>, <paramref name="desc"/>, <paramref name="undoAction"/>, or the <paramref name="redoAction"/> parameter is <b>null</b>.</exception>
        /// <exception cref="ArgumentEmptyException">Thrown when the <paramref name="desc"/> parameter is empty.</exception>
        public UndoCommand(IUndoService service, string desc, Func <TU, CancellationToken, Task> undoAction, Func <TR, CancellationToken, Task> redoAction, TR redoArgs, TU undoArgs)
        {
            Service = service ?? throw new ArgumentNullException(nameof(service));

            if (desc == null)
            {
                throw new ArgumentNullException(nameof(desc));
            }

            if (string.IsNullOrWhiteSpace(desc))
            {
                throw new ArgumentEmptyException(nameof(desc));
            }

            Description = desc;
            _undoAction = undoAction ?? throw new ArgumentNullException(nameof(undoAction));
            _redoAction = redoAction ?? throw new ArgumentNullException(nameof(redoAction));
            _redoArgs   = redoArgs;
            _undoArgs   = undoArgs;
        }