Exemplo n.º 1
0
        private void ExecuteShowMainViews(object o)
        {
            MainW mainW = ViewManager.GetValue(typeof(MainW)) as MainW;
            Type  type;

            getView(o, mainW, out type);
            ViewBase mainV = ViewManager.GetValue(type) as ViewBase;

            if (((ViewModelBase)mainV.DataContext).IsGoodInit)
            {
                //현재 화면일 경우
                if (this.viewStack.Last != null && this.viewStack.Last.Value.Equals(mainV))
                {
                    MessageBoxResult messageBoxResult = MessageBox.Show("현재 창을 닫으시겠습니까?\n저장하지 않은 정보는 사라집니다.", "경고",
                                                                        MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);

                    if (messageBoxResult.Equals(MessageBoxResult.Yes))
                    {
                        this.MenuColor[mainV.MenuIndex] = UNACTIVE_COLOR;

                        mainW.mainStage.Children.Remove(mainV);
                        this.viewStack.RemoveLast();
                        ViewManager.RemoveValue(type);
                        ViewModelManager.RemoveValue(mainV.DataContext.GetType());

                        if (this.viewStack.Last != null)
                        {
                            ViewBase oldView = this.viewStack.Last.Value;

                            this.MenuColor[oldView.MenuIndex] = CURRENT_ACTIVE_COLOR;
                            oldView.Visibility = Visibility.Visible;
                        }
                    }
                }
                //과거 화면일 경우
                else if (this.viewStack.Contains(mainV))
                {
                    ViewBase oldView = this.viewStack.Last.Value;

                    this.MenuColor[oldView.MenuIndex] = ACTIVE_COLOR;
                    oldView.Visibility = Visibility.Collapsed;

                    this.viewStack.Remove(mainV);
                    this.viewStack.AddLast(mainV);

                    this.MenuColor[mainV.MenuIndex] = CURRENT_ACTIVE_COLOR;
                    mainV.Visibility = Visibility.Collapsed;
                }
                //처음 켜는 경우
                else
                {
                    if (this.viewStack.Last != null)
                    {
                        ViewBase oldView = this.viewStack.Last.Value;

                        this.MenuColor[oldView.MenuIndex] = ACTIVE_COLOR;
                        oldView.Visibility = Visibility.Collapsed;
                    }
                    this.viewStack.AddLast(mainV);

                    mainW.mainStage.Children.Add(mainV);
                    this.MenuColor[mainV.MenuIndex] = CURRENT_ACTIVE_COLOR;
                }

                if (this.viewStack.Last != null)
                {
                    ViewBase newView = this.viewStack.Last.Value;
                    this.Title = newView.Title;
                    DoubleAnimation show = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1));
                    Storyboard.SetTarget(show, newView);
                    Storyboard.SetTargetProperty(show, new PropertyPath(UserControl.OpacityProperty));
                    Storyboard sb = new Storyboard();
                    sb.Children.Add(show);
                    sb.Begin();
                }
                else
                {
                    this.Title = DEFAULT_TITLE;
                }
            }
        }