Ejemplo n.º 1
0
        /// <summary>
        /// Executes the add container command.
        /// </summary>
        private void ExecuteAddContainerCommand()
        {
            var newObject = new RHSStringTableTools.Model.Container();
            var viewModel = new ContainerEditViewModel(newObject, (Package)this.SelectedNode);

            var view = new ContainerEditView {
                DataContext = viewModel
            };

            view.ShowDialog();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ContainerEditViewModel"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="container">The container.</param>
        public ContainerEditViewModel(Container item, Package container = null)
        {
            this.Thing = item;
            this.Parent = container;
            this.Thing.Parent = container;

            var canOk = this.WhenAny(vm => vm.Name, vm => !string.IsNullOrWhiteSpace(vm.Value));
            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(this.OkCommandExecute);

            this.SetProperties();
        }
        /// <summary>
        /// Executes the add container command.
        /// </summary>
        private void ExecuteAddContainerCommand()
        {
            var newObject = new RHSStringTableTools.Model.Container();
            var viewModel = new ContainerEditViewModel(newObject, (Package)this.SelectedNode);

            var view = new ContainerEditView { DataContext = viewModel };

            view.ShowDialog();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyEditViewModel"/> class.
        /// </summary>
        /// <param name="item">
        /// The item.
        /// </param>
        /// <param name="container">
        /// The container.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        public KeyEditViewModel(Key item, Container container = null, int position = -1)
        {
            this.Templates = TemplateMaster.Instance.KeyTemplates;

            this.Thing = item;
            this.Thing.Parent = container;
            this.Parent = container;
            this.InsertAfter = position;

            var canOk = this.WhenAny(x => x.Id, y => y.Original, z => z.English, (x, y, z) => !string.IsNullOrWhiteSpace(x.Value) && !string.IsNullOrWhiteSpace(y.Value) && !string.IsNullOrWhiteSpace(z.Value));
            this.OkCommand = ReactiveCommand.Create(canOk);
            this.OkCommand.Subscribe(this.OkCommandExecute);

            this.WhenAnyValue(vm => vm.Original).Subscribe(_ => this.FillLanguages());
            this.WhenAnyValue(vm => vm.Russian).Subscribe(_ => this.Transliterate());
            this.WhenAny(vm => vm.SelectedTemplate, vm => vm.Value != null).Subscribe(_ => this.ApplyTemplate());

            this.SetProperties();
        }