Esempio n. 1
0
        private void DuplicateImpl()
        {
            var duplicate = new ApplicationLink
            {
                DefaultUserName = SelectedLink.DefaultUserName,
                Parameters      = SelectedLink.Parameters,
                Path            = SelectedLink.Path,
                Title           = SelectedLink.Title + " (copy)"
            };

            ApplicationLinks.Insert(ApplicationLinks.IndexOf(SelectedLink), duplicate);
            SelectedLink = duplicate;

            EditImpl();
        }
Esempio n. 2
0
        public MainWindowViewModel()
        {
            Add = ReactiveCommand.Create();
            (Add as ReactiveCommand <object>).Subscribe(_ => AddImpl());

            Browse = ReactiveCommand.Create();
            (Browse as ReactiveCommand <object>).Subscribe(_ => BrowseImpl());

            Edit = ReactiveCommand.Create(this.WhenAny(x => x.SelectedLink, t => t.Value != null));
            (Edit as ReactiveCommand <object>).Subscribe(_ => EditImpl());

            CancelEdit = ReactiveCommand.Create();
            (CancelEdit as ReactiveCommand <object>).Subscribe(_ => { IsEditing = false; });

            Delete = ReactiveCommand.Create(this.WhenAny(x => x.SelectedLink, t => t.Value != null));
            (Delete as ReactiveCommand <object>).Subscribe(_ => DeleteImpl());

            Connect = ReactiveCommand.Create(this.WhenAny(x => x.SelectedLink, t => t.Value != null));
            (Connect as ReactiveCommand <object>).Subscribe(_ => ConnectImpl());

            Duplicate = ReactiveCommand.Create(this.WhenAny(x => x.SelectedLink, t => t.Value != null));
            (Duplicate as ReactiveCommand <object>).Subscribe(_ => DuplicateImpl());

            SaveItem = ReactiveCommand.Create(this.WhenAny(
                                                  x => x.InEditPath,
                                                  y => y.InEditTitle,
                                                  (p, t) =>
                                                  string.IsNullOrWhiteSpace(t.Value) == false &&
                                                  string.IsNullOrWhiteSpace(p.Value) == false &&
                                                  File.Exists(p.Value)));

            (SaveItem as ReactiveCommand <object>).Subscribe(_ => SaveItemImpl());

            using (ApplicationLinks.SuppressChangeNotifications())
            {
                LoadApplicationLinks();
            }

            ApplicationLinks.ChangeTrackingEnabled = true;
            ApplicationLinks.Changed.Select(_ => Unit.Default)
            .Merge(ApplicationLinks.ItemChanged.Select(_ => Unit.Default))
            .Throttle(TimeSpan.FromSeconds(1))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(async _ => await SaveApplicationLinks());
        }
Esempio n. 3
0
        private void SaveItemImpl()
        {
            if (IsAddMode)
            {
                var newLink = new ApplicationLink
                {
                    Title           = InEditTitle,
                    Path            = InEditPath,
                    Parameters      = InEditParameters,
                    DefaultUserName = InEditUserName
                };
                ApplicationLinks.Add(newLink);
            }
            else
            {
                SelectedLink.Title           = InEditTitle;
                SelectedLink.Path            = InEditPath;
                SelectedLink.Parameters      = InEditParameters;
                SelectedLink.DefaultUserName = InEditUserName;
            }

            IsEditing = false;
        }
Esempio n. 4
0
 private void DeleteImpl()
 {
     ApplicationLinks.Remove(SelectedLink);
 }