Exemplo n.º 1
0
        private void InputDataChanged()
        {
            var images = ViewModelHelper.CreateReadOnlyDispatcherCollection(InputData.AttachedImages,
                                                                            b => new ImageDescriptionViewModel(InputData, b), DispatcherHelper.UIDispatcher);
            var imageListener = images.ListenCollectionChanged(_ =>
            {
                RaisePropertyChanged(() => IsImageAttached);
                RaisePropertyChanged(() => CanSaveToDraft);
                RaisePropertyChanged(() => CanAttachImage);
                UpdateTextCount();
            });

            Interlocked.Exchange(ref _images, images)?.Dispose();
            Interlocked.Exchange(ref _imageListener, imageListener)?.Dispose();
            RaisePropertyChanged(() => AttachedImages);
            RaisePropertyChanged(() => InputData);
            RaisePropertyChanged(() => InputText);
            RaisePropertyChanged(() => InReplyTo);
            RaisePropertyChanged(() => IsInReplyToEnabled);
            RaisePropertyChanged(() => DirectMessageTo);
            RaisePropertyChanged(() => IsDirectMessageEnabled);
            RaisePropertyChanged(() => IsBindHashtagEnabled);
            RaisePropertyChanged(() => IsImageAttached);
            RaisePropertyChanged(() => AttachedLocation);
            RaisePropertyChanged(() => IsLocationAttached);
            RaisePropertyChanged(() => IsAmending);
            RaisePropertyChanged(() => CanAmend);
            UpdateHashtagCandidates();
            UpdateTextCount();
        }
Exemplo n.º 2
0
        public void OnDispatcherTest()
        {
            using (var dispatcher = new TestDispatcherContext())
            {
                bool propertyChangedCalled   = false;
                bool collectionChangedCalled = false;

                Dispatcher.CurrentDispatcher.IsNot(dispatcher.Dispatcher);

                var source = new ObservableCollection <int>();
                var result = ViewModelHelper.CreateReadOnlyDispatcherCollection <int, int>(
                    source,
                    i => i * i,
                    dispatcher.Dispatcher);

                result.PropertyChanged += (sender, e) =>
                {
                    propertyChangedCalled = true;
                    Dispatcher.CurrentDispatcher.Is(dispatcher.Dispatcher);
                };

                result.CollectionChanged += (sender, e) =>
                {
                    collectionChangedCalled = true;
                    Dispatcher.CurrentDispatcher.Is(dispatcher.Dispatcher);
                };

                source.Add(1);

                propertyChangedCalled.Is(true);
                collectionChangedCalled.Is(true);
            }
        }
Exemplo n.º 3
0
 public MainWindowViewModel()
 {
     SourceItems = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         _model.SourceItems,
         (child) => new FileSystemViewModel(child),
         DispatcherHelper.UIDispatcher);
 }
Exemplo n.º 4
0
        public RelocatingSquadronsWindowViewModel(LandBase landBase)
        {
            this.Title = "配置転換中の航空機一覧";

            this.RelocatingSquadrons = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                landBase.RelocatingSquadrons,
                x => new RelocatingSquadronViewModel(x),
                DispatcherHelper.UIDispatcher);
        }
Exemplo n.º 5
0
        public SettingViewModel(NamingServiceManager manager)
        {
            _manager       = manager;
            NamingServices = ViewModelHelper.CreateReadOnlyDispatcherCollection <NamingServiceViewModel, NamingService>(
                _manager.NamingServices,
                ns => new NamingServiceViewModel(ns),
                DispatcherHelper.UIDispatcher);

            DataDirectory = Environment.ExpandEnvironmentVariables(Settings.Default.DataDirectory);
        }
Exemplo n.º 6
0
 public CategoryTreeItem()
 {
     _childrenro = ViewModelHelper.CreateReadOnlyDispatcherCollection <ServerCategoryTestData, CategoryTreeItem>(
         _children,
         prop => new CategoryTreeItem
     {
         _CategoryId    = prop.Id,
         Name           = prop.Name,
         HasChildServer = prop.IsChild.HasValue ? prop.IsChild.Value : false
     },
         DispatcherHelper.UIDispatcher);
 }
Exemplo n.º 7
0
		public TagTreeItem()
		{
			this._childrenro = ViewModelHelper.CreateReadOnlyDispatcherCollection<ServerTagTestData, TagTreeItem>(
				_children,
				prop => new TagTreeItem
				{
					Name = prop.Name,
					HasChildServer = prop.IsChild,
					_TagId = prop.Id
				},
				DispatcherHelper.UIDispatcher);
		}
Exemplo n.º 8
0
        public void ReloadPlugins()
        {
            this.AllPlugins = new List <PluginViewModel>(
                PluginHost.Instance.Plugins.Select(x => new PluginViewModel(x)));

            var collection = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Settings.Current.BlacklistedPlugins,
                x => new BlacklistedPluginViewModel(x),
                System.Windows.Application.Current.Dispatcher);

            this.CompositeDisposable.Add(collection);
            this.BlacklistedPlugins = collection;
        }
        public EditCorrectScoreWindowViewModel(IAppStore store, IAppActions actions)
        {
            this.Store   = store;
            this.Actions = actions;

            this.EnableAutoPropertyChangedEvent(store);
            this.EnableAutoCanExecuteChangedEvent(store);
            this.EnableValidation();

            this._startPosition = store.CorrectScoreStartPositionInAnalysisUnits.ToString();

            this.TempoSettings = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                store.TempoSettings, x => new TempoSettingViewModel(x), DispatcherHelper.UIDispatcher);
        }
Exemplo n.º 10
0
        void CreateReadOnlyTradeItemCollection()
        {
            if (TradeItems != null)
            {
                TradeItems.Dispose();
            }

            TradeItems = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                CurrentProduct.TradeItems,
                x =>
            {
                var vm = new TradeItemViewModel();
                vm.Initialize(x);
                return(vm);
            },
                DispatcherHelper.UIDispatcher);
        }
Exemplo n.º 11
0
        public TracelogViewModel()
        {
            TraceLogList = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Workspace.Instance.Traces,
                (m) => new SingleTraceViewModel(m),
                DispatcherHelper.UIDispatcher);
            CompositeDisposable.Add(TraceLogList);

            VisibilityList = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                Workspace.Instance.VisibleTraceTypes,
                (m) => new VisibleTraceTypeViewModel(m),
                DispatcherHelper.UIDispatcher
                );
            CompositeDisposable.Add(VisibilityList);
            CompositeDisposable.Add(SearchTextVM);
            CompositeDisposable.Add(DebugVM);
        }
Exemplo n.º 12
0
        public MainWindowViewModel()
        {
            var cm = Enum.GetValues(typeof(CardNumber)).Cast <CardNumber>().Select(e => new CardModel()
            {
                Number = e
            });

            CardModels = new ObservableCollection <CardModel>(cm);

            _Cards = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                CardModels,
                (m) => new CardViewModel(m.Number.ToString())
            {
            },
                DispatcherHelper.UIDispatcher);

            //CompositeDisposable.Add(CardModels);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 当クラスが利用するModelを指定して、当クラスのインスタンスを初期化します。
        /// </summary>
        /// <param name="model"></param>
        public FileSystemViewModel(FileSystemModel model)
        {
            _model = model;

            Childs = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                _model.Childs,
                (child) => new FileSystemViewModel(child),
                DispatcherHelper.UIDispatcher);

            Childs.CollectionChanged += (sender, e) => {
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
                {
                    foreach (FileSystemViewModel item in e.NewItems)
                    {
                        item.Parent = this;
                    }
                }
            };
        }
Exemplo n.º 14
0
        public RecordersViewModel(NamingServiceManager manager)
        {
            _manager   = manager;
            _recorders = new ObservableCollection <Recorder>();

            RecorderViewModels = ViewModelHelper.CreateReadOnlyDispatcherCollection <RecorderControlViewModel, Recorder>(
                _recorders,
                recorder => new RecorderControlViewModel(this, recorder),
                DispatcherHelper.UIDispatcher);

            NamingServiceTree = ViewModelHelper.CreateReadOnlyDispatcherCollection <TreeViewItemViewModel, TreeViewItemViewModel>(
                _manager.OutPortTree,
                item => item,
                DispatcherHelper.UIDispatcher);

            // NamingServiceManagerのIsUpdatingの状態が変わったら、UpdateTreeCommandの有効無効を切り替える
            Observable.FromEventPattern <PropertyChangedEventArgs>(_manager, "PropertyChanged")
            .Where(e => e.EventArgs.PropertyName == "IsUpdating")
            .Subscribe(_ => UpdateTreeCommand.RaiseCanExecuteChanged());
        }
Exemplo n.º 15
0
        //=====================================================================
        #region コンストラクタ・デストラクタ・Dispose
        //=====================================================================
        public MainWindowViewModel()
        {
            _LogInfos = ViewModelHelper.CreateReadOnlyDispatcherCollection <LogInfo, __LogInfoViewModel>(_LogInfo_Source, (p) => new __LogInfoViewModel(p), DispatcherHelper.UIDispatcher);
            _Ships    = ViewModelHelper.CreateReadOnlyDispatcherCollection <ShipData, ShipViewModel>(this._UserShip_Source, (p) => new ShipViewModel(p, this), DispatcherHelper.UIDispatcher);


            _LogInfo_Source.Add(new LogInfo
            {
                LogDate  = DateTime.Now,
                InfoType = "情報",
                Message  = "アプリケーションを開始しました。"
            });


            LoadApplicationSettingFile();


            Dictionary <string, string> apipath;

            {
                var inst = new ShipCsvLoader();
                this._ShipTable = inst.Load();
            }
            {
                var inst = new ApiPathCsvLoader();
                apipath = inst.Load();
            }


            this._Context       = new KcsRequestContext(apipath, _ApplicationSettings.BaseUrl, _ApplicationSettings.Referer);
            this._Context.Token = _ApplicationSettings.Token;

            this.AbTimer          = new Timer();
            this.AbTimer.Interval = 60000 * 1;
            this.AbTimer.Elapsed += AbTimer_Elapsed;
        }
Exemplo n.º 16
0
        public void LinkTest()
        {
            using (var dispatcher = new TestDispatcherContext())
            {
                var disposedCount = 0;

                //------------------Init
                var source = new ObservableCollection <int>()
                {
                    9, 8, 7
                };

                var result = ViewModelHelper.CreateReadOnlyDispatcherCollection <int, TestViewModel>(
                    source,
                    i => new TestViewModel(i * i, () => disposedCount++),
                    dispatcher.Dispatcher);

                result.Count().Is(3);
                result[0].Number.Is(81);
                result[1].Number.Is(64);
                result[2].Number.Is(49);

                //------------------Add
                source.Add(1);

                result.Count().Is(4);
                result[3].Number.Is(1);

                //------------------Add & Remove
                source.Add(3);
                source.Add(4);
                source.Add(5);
                source.Add(6);
                source.Remove(5);

                result.Count().Is(7);
                result[4].Number.Is(9);
                result[5].Number.Is(16);
                result[6].Number.Is(36);

                //------------------Replace
                source[2] = 10;

                result.Count().Is(7);
                result[2].Number.Is(100);

                //------------------Clear
                source.Clear();

                result.Any().Is(false);

                //------------------Dispose
                result.Dispose();

                source.Add(1);

                result.Any().Is(false);

                disposedCount.Is(9);
            }
        }
Exemplo n.º 17
0
 public LauncherCoreViewModel() : base(new LauncherCore())
 {
     Apps = ViewModelHelper.CreateReadOnlyDispatcherCollection(Model.Apps, (ai) => new AppInfoViewModel(ai), DispatcherHelper.UIDispatcher);
     CompositeDisposable.Add(() => Apps.Dispose());
 }