Пример #1
0
        public AnimationViewModel()
        {
            this.Timer = new DispatcherTimer(TimeSpan.FromMilliseconds(50), DispatcherPriority.Background, (o, e) => OnTimerTick(), Application.Current.Dispatcher)
            {
                IsEnabled = false
            };

            this.Frames                    = new ObservableCollection <WriteableBitmap>();
            this.CurrentFrameIndex         = Cell.Create(0);
            this.CurrentFrame              = Cell.Derived(this.CurrentFrameIndex, DeriveCurrentFrame);
            this.IsDoneRendering           = Cell.Create(false);
            this.MaximumFrameIndex         = Cell.Derived(() => this.Frames.Count - 1);
            this.Messages                  = new TextDocument();
            this.Frames.CollectionChanged += (sender, e) => OnFrameCollectionChanged();
            this.ToggleAnimation           = EnabledCommand.FromDelegate(OnToggleAnimation);
            this.ScaleToFill               = Cell.Create(true);
            this.ToggleScale               = EnabledCommand.CreateTogglingCommand(ScaleToFill);
            this.FullScreen                = Cell.Create(false);
            this.ToggleFullScreen          = EnabledCommand.CreateTogglingCommand(FullScreen);
            this.ExportFrame               = EnabledCommand.FromDelegate(OnExportFrame);
            this.ExportMovie               = CellCommand.FromDelegate(this.IsDoneRendering, OnExportMovie);
            this.CopyFrame                 = EnabledCommand.FromDelegate(OnCopyFrame);
            this.PreviousFrame             = EnabledCommand.FromDelegate(OnPreviousFrame);
            this.NextFrame                 = EnabledCommand.FromDelegate(OnNextFrame);
        }
Пример #2
0
        public MainViewModel()
        {
            this.Documents       = new ObservableCollection <DocumentViewModel>();
            this.CurrentDocument = Cell.Create <DocumentViewModel>(null);

            this.NewScriptCommand  = EnabledCommand.FromDelegate(OnNewScript);
            this.LoadScriptCommand = EnabledCommand.FromDelegate(OnLoadScript);
            this.LoadWifCommand    = EnabledCommand.FromDelegate(OnLoadWif);
            this.LoadCommand       = EnabledCommand.FromDelegate(OnLoad);
        }
Пример #3
0
 public DocumentViewModel(string contents, string path)
 {
     this.Source              = new TextDocument(contents);
     this.Path                = Cell.Create(path);
     this.ShortPath           = Cell.Derived(this.Path, DeriveShortPath);
     this.SaveScriptCommand   = EnabledCommand.FromDelegate(OnSaveScript);
     this.SaveScriptAsCommand = EnabledCommand.FromDelegate(OnSaveScriptAs);
     this.RenderScript        = EnabledCommand.FromDelegate(OnRenderScript);
     this.IsDirty             = Cell.Create(false);
     this.Source.Changed     += (s, e) => OnSourceChanged();
 }