コード例 #1
0
        private void StartLifeCycle(Window window, ViewModelBase viewModel, Pipe pipe)
        {
            viewModel.OnPreInit();

            window.DataContext = viewModel;
            window.Loaded     += (s, e) => viewModel.OnLoaded();
            window.Closing    += (s, e) => e.Cancel = !viewModel.OnFinishing();
            var  conf   = WindowStateSaver.ConfigureWindow(View.OriginalString, window, viewModel);
            bool closed = false;

            window.Closed += (s, e) =>
            {
                closed = true;
                conf.Snapshot();
                viewModel.OnFinished();
            };
            viewModel.FinishRequest += window.Close;
            viewModel.Pipe           = pipe;

            viewModel.OnInit();

            if (closed)
            {
                return;
            }

            if (pipe.IsDialog)
            {
                window.ShowDialog();
            }
            else
            {
                window.Show();
            }
        }
コード例 #2
0
        // on show each window
        public static WindowStateSaver ConfigureWindow(string windowKey, Window window, ISaverData data)
        {
            var settings = new WindowStateSaver(windowKey, window, data);

            settings.Configure();
            return(settings);
        }