public void SectionEditCommand_Execute()
        {
            if (RentLivingEdit == null)
            {
                return;
            }
            if (SectionsSelectedItem == null)
            {
                return;
            }

            if (RentLivingEdit.Ownership == Ownerships.Unit)
            {
                SectionsSelectedItem.IsOwnershipTypeUnit = true;
            }
            else if (RentLivingEdit.Ownership == Ownerships.All)
            {
                SectionsSelectedItem.IsOwnershipTypeUnit = false;
            }

            OpenRentLivingRoomWindowEventArgs ag = new OpenRentLivingRoomWindowEventArgs();

            ag.Id = SectionsSelectedItem.RentLivingRoomId;
            ag.RentLivingRoomObject = SectionsSelectedItem;
            ag.RentLivingRooms      = RentLivingEdit.RentLivingRooms;


            OpenRentLivingRoomWindow?.Invoke(this, ag);
        }
        public void SectionNewCommand_Execute()
        {
            if (RentLivingEdit == null)
            {
                return;
            }

            // RentLivingRoom Newオブジェクトを用意
            RentLivingRoom rlsection = new RentLivingRoom(RentLivingEdit.RentId, _id, Guid.NewGuid().ToString());

            rlsection.IsNew = true;
            if (RentLivingEdit.Ownership == Ownerships.Unit)
            {
                rlsection.IsOwnershipTypeUnit = true;
            }
            else if (RentLivingEdit.Ownership == Ownerships.All)
            {
                rlsection.IsOwnershipTypeUnit = false;
            }

            OpenRentLivingRoomWindowEventArgs ag = new OpenRentLivingRoomWindowEventArgs();

            ag.Id = rlsection.RentLivingRoomId;
            ag.RentLivingRoomObject = rlsection;
            ag.RentLivingRooms      = RentLivingEdit.RentLivingRooms;

            OpenRentLivingRoomWindow?.Invoke(this, ag);
        }
示例#3
0
        // 部屋編集画面の表示
        public void OpenRentLivingRoomWindow(OpenRentLivingRoomWindowEventArgs arg)
        {
            if (arg == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(arg.Id))
            {
                return;
            }

            if (arg.RentLivingRoomObject == null)
            {
                return;
            }

            string id = arg.Id;

            App app = App.Current as App;

            foreach (var w in app.WindowList)
            {
                if (!(w is RentLivingRoomWindow))
                {
                    continue;
                }

                if ((w as RentLivingRoomWindow).DataContext == null)
                {
                    continue;
                }

                if (!((w as RentLivingRoomWindow).DataContext is RentLivingRoomViewModel))
                {
                    continue;
                }

                if (id == ((w as RentLivingRoomWindow).DataContext as RentLivingRoomViewModel).Id)
                {
                    //w.Activate();

                    if ((w as RentLivingRoomWindow).WindowState == WindowState.Minimized || (w as Window).Visibility == Visibility.Hidden)
                    {
                        //w.Show();
                        (w as RentLivingRoomWindow).Visibility  = Visibility.Visible;
                        (w as RentLivingRoomWindow).WindowState = WindowState.Normal;
                    }

                    (w as RentLivingRoomWindow).Activate();
                    //(w as EditorWindow).Topmost = true;
                    //(w as EditorWindow).Topmost = false;
                    (w as RentLivingRoomWindow).Focus();

                    return;
                }
            }

            // Create new window.

            if (arg.RentLivingRoomObject is RentLivingRoom)
            {
                // Windowを生成
                var win = new RentLivingRoomWindow();
                // VMをセット
                win.DataContext = new RentLivingRoomViewModel(id);

                var vm = (win.DataContext as RentLivingRoomViewModel);
                // VMにデータを渡す
                vm.RentLivingRoomEdit = arg.RentLivingRoomObject;
                vm.RentLivingRooms    = arg.RentLivingRooms;

                // 画像編集画面からの変更通知を受け取る
                vm.RentLivingIsDirty += () => OnRentLivingIsDirty();

                // Windowリストへ追加。
                app.WindowList.Add(win);

                // モーダルで編集画面を開く
                win.Owner = this;
                //win.Show();
                win.ShowDialog();

                //win.ShowInTaskbar = true;
                //win.ShowActivated = true;
                //win.Visibility = Visibility.Visible;
                //win.Activate();
            }
        }