示例#1
0
        internal static bool?ShowDialog(IServiceProvider services, ProjectSetViewModel projectSet, string dialogTitle, Func <bool> beforeAccept)
        {
            EditProjectSetDialog dialog = new EditProjectSetDialog();

            dialog.Title = dialogTitle;

            Package pkg = services.GetService <Package>();

            try
            {
                IInteractionService          isvc     = (IInteractionService)services.GetService <SInteractionService>();
                ProjectSetManagerUserOptions settings = isvc.GetSettings();
                settings.LoadSettingsFromStorage();

                dialog.Width  = settings.EditWindowWidth;
                dialog.Height = settings.EditWindowHeight;
                //dialog.Left = settings.EditWindowLeft;
                //dialog.Top = settings.EditWindowTop;
            }
            catch
            {
            }

            EditProjectSetViewModel viewModel = new EditProjectSetViewModel(services, projectSet);

            viewModel.CloseDialog += (s, e) =>
            {
                if (e.Result == true && (beforeAccept != null && beforeAccept() || beforeAccept == null) || e.Result != true)
                {
                    try
                    {
                        IInteractionService          isvc     = (IInteractionService)services.GetService <SInteractionService>();
                        ProjectSetManagerUserOptions settings = isvc.GetSettings();
                        settings.EditWindowWidth  = (int)dialog.ActualWidth;
                        settings.EditWindowHeight = (int)dialog.ActualHeight;
                        settings.EditWindowLeft   = (int)dialog.Left;
                        settings.EditWindowTop    = (int)dialog.Top;
                        settings.SaveSettingsToStorage();
                    }
                    catch
                    {
                    }

                    //winStates.SaveSettingsToStorage();
                    dialog.DialogResult = e.Result;
                    dialog.Close();
                }
            };

            dialog.DataContext = viewModel;
            return(dialog.ShowModal());
        }