Example #1
0
        public override void FillControls(T @object)
        {
            var controlSelector = new ControlSelector();
            var controlFiller   = new ControlFiller();
            var fieldFiller     = new ControlsFiller <T>(@object, controlFiller, controlSelector);
            var ca = ControlsAdded.ToList();

            fieldFiller.Fill(ca);
        }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public ControlSelectionWindowViewModel()
        {
            this.ControlSelectionInfo = new ControlSelectionInfoViewModel().AddTo(this);
            this.controlSelector      = new ControlSelector();
            this.controlSelector.Subscribe(nameof(this.controlSelector.SelectedHandle), () =>
            {
                var handle = this.controlSelector.SelectedHandle;
                if (handle == null)
                {
                    return;
                }
                var bounds = InteropHelper.GetWindowSize(handle.Value);

                // コントロール情報の更新
                this.ControlSelectionInfo.UpdateInfo(handle.Value, bounds);

                // ワールド座標に変換して選択範囲を設定する
                this.SelectedRegion = new Rect(
                    bounds.Left - this.screenOrigin.X,
                    bounds.Top - this.screenOrigin.Y,
                    bounds.Width,
                    bounds.Height);
            }).AddTo(this);

            // マウス座標変更イベントの購読
            this.Subscribe(nameof(this.MousePoint), () =>
            {
                this.controlSelector.Update(this.MousePoint);
                this.ControlSelectionInfo.Update(this.MousePoint);
            }).AddTo(this);

            // コントロール選択時の処理シーケンスの生成
            this.notifier = new Subject <IntPtr?>();
            this.notifier
            .Do(x => this.SelectedRegion = new Rect(0, 0, 0, 0))
            .Delay(TimeSpan.FromMilliseconds(100))
            .Subscribe(x => this.SelectControl(x))
            .AddTo(this);
        }