protected void ProcessLicenseServiceResponse(IEnterKeyResponse response)
        {
            ILicenseService        service1 = this.Services.GetService <ILicenseService>();
            IMessageDisplayService service2 = this.Services.GetService <IMessageDisplayService>();

            this.IsLicensed = response.IsEnabled;
            if ((int)response.ErrorCode != -1073418160)
            {
                LicensingDialogHelper.ShowErrorMessageFromResponse((ILicenseSubServiceResponse)response, service2);
            }
            if (!response.IsEnabled)
            {
                if (service1.HasKey(response.KeySku) && service1.GetUnlicensedReason(response.KeySku) == UnlicensedReason.GraceTimeExpired)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Owner   = (Window)this,
                        Message = StringTable.LicensingYouNeedToActivate,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Exclamation
                    };
                    int num = (int)service2.ShowMessage(args);
                }
                else
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Owner   = (Window)this,
                        Message = StringTable.LicensingInvalidKeyMessage,
                        Button  = MessageBoxButton.OK,
                        Image   = MessageBoxImage.Hand
                    };
                    int num = (int)service2.ShowMessage(args);
                }
            }
            else if (this.ShouldActivate && service1.SkusFromFeature(ExpressionFeatureMapper.ActivationLicense).Contains(response.KeySku) && !response.IsActivated)
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Owner   = (Window)this,
                    Message = StringTable.LicensingEnterKeySucceededAndActivationFailed,
                    Image   = MessageBoxImage.Exclamation
                };
                int num = (int)service2.ShowMessage(args);
                LicensingDialogHelper.ShowActivationDialog(this.Services, (CommonDialogCreator) new ActivationDialogCreator(this.Services, ActivationWizardAction.ChooseActivationType));
            }
            else
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Owner   = (Window)this,
                    Message = StringTable.LicensingValidMessage
                };
                int num = (int)service2.ShowMessage(args);
            }
        }
Beispiel #2
0
        public static bool EnsureProductIsLicensed(IServices services, int nagAtDays)
        {
            services.GetService <ILicenseService>().WaitForValidLicenseInformation();
            IMessageDisplayService service = services.GetService <IMessageDisplayService>();
            bool flag;

            switch (LicensingDialogHelper.DialogToDisplay(services, nagAtDays))
            {
            case LicenseDialogPopup.NoDialog:
                flag = true;
                break;

            case LicenseDialogPopup.LicenseDialog:
                flag = LicensingDialogHelper.ShowLicensingDialog(services, (CommonDialogCreator) new LicensingDialogCreator(services));
                break;

            case LicenseDialogPopup.TrialExpiredDialog:
                flag = LicensingDialogHelper.ShowTrialExpiredDialog(services, (CommonDialogCreator) new TrialExpiredDialogCreator(services));
                break;

            case LicenseDialogPopup.ActivationGraceExpiredDialog:
                flag = LicensingDialogHelper.ShowActivationGraceExpiredDialog(services, (CommonDialogCreator) new ActivationGraceExpiredDialogCreator(services));
                break;

            case LicenseDialogPopup.ProductSkuNotInstalled:
                MessageBoxArgs args1 = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingProductSkuLicenseNotInstalledMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                if (service != null)
                {
                    int num1 = (int)service.ShowMessage(args1);
                }
                flag = false;
                break;

            default:
                MessageBoxArgs args2 = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingInitializationFailureMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                if (service != null)
                {
                    int num2 = (int)service.ShowMessage(args2);
                }
                flag = false;
                break;
            }
            return(flag);
        }
Beispiel #3
0
        public static void SaveLogAndPromptUser(ProjectUpgradeLogger upgradeLogger, IServiceProvider serviceProvider, string basePath, bool success)
        {
            if (upgradeLogger.IsEmpty)
            {
                return;
            }
            string str = UpgradeWizard.SafelyCreateLogFileWithFallback(upgradeLogger, basePath);

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            success = success & !upgradeLogger.HasErrors;
            if (!success)
            {
                IMessageDisplayService service        = (IMessageDisplayService)serviceProvider.GetService(typeof(IMessageDisplayService));
                MessageBoxArgs         messageBoxArg  = new MessageBoxArgs();
                CultureInfo            currentCulture = CultureInfo.CurrentCulture;
                string   upgradeErrorsMessage         = StringTable.UpgradeErrorsMessage;
                object[] objArray = new object[] { basePath };
                messageBoxArg.Message          = string.Format(currentCulture, upgradeErrorsMessage, objArray);
                messageBoxArg.HyperlinkMessage = StringTable.UpgradeErrorsLinkMessage;
                messageBoxArg.HyperlinkUri     = new Uri(str, UriKind.Absolute);
                messageBoxArg.Button           = MessageBoxButton.OK;
                messageBoxArg.Image            = MessageBoxImage.Hand;
                messageBoxArg.AutomationId     = "UpgradeWarningDialog";
                service.ShowMessage(messageBoxArg);
            }
        }
Beispiel #4
0
        protected override void PerformFinalActionsBeforeWatsonDump()
        {
            if (this.ExpressionInformationService == null)
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = StringTable.ApplicationUnrecoverableErrorDialogMessage,
                Button  = MessageBoxButton.YesNo,
                Image   = MessageBoxImage.Hand
            };
            MessageBoxResult       messageBoxResult = MessageBoxResult.No;
            IMessageDisplayService service1         = this.Services.GetService <IMessageDisplayService>();

            if (service1 != null)
            {
                messageBoxResult = service1.ShowMessage(args);
            }
            IProjectManager service2 = this.Services.GetService <IProjectManager>();
            IViewService    service3 = this.Services.GetService <IViewService>();

            if (service3 != null)
            {
                foreach (IView view in (IEnumerable <IView>)service3.Views)
                {
                    SilverlightSceneView silverlightSceneView = view as SilverlightSceneView;
                    if (silverlightSceneView != null)
                    {
                        silverlightSceneView.SuspendUpdatesForViewShutdown();
                    }
                }
            }
            if (service2 == null || service2.CurrentSolution == null)
            {
                return;
            }
            bool flag = false;

            foreach (IProject project in service2.CurrentSolution.Projects)
            {
                foreach (IProjectItem projectItem in (IEnumerable <IProjectItem>)project.Items)
                {
                    if (projectItem.IsDirty)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (!flag || messageBoxResult != MessageBoxResult.Yes)
            {
                return;
            }
            service2.CurrentSolution.Save(false);
        }
Beispiel #5
0
        public static bool EnsureSilverlightToolkitTypeAvailable(ITypeResolver typeResolver, ITypeId targetType, IMessageDisplayService messageDisplayService, string installHelperMessage, string upgradeHelperMessage)
        {
            bool flag = typeResolver.EnsureAssemblyReferenced("System.Windows.Controls.Toolkit");

            if (!flag)
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message          = installHelperMessage,
                    HyperlinkMessage = StringTable.SilverlightToolkitInstallHyperlinkMessage,
                    HyperlinkUri     = new Uri("http://go.microsoft.com/fwlink/?LinkId=183538", UriKind.Absolute),
                    Button           = MessageBoxButton.OK,
                    Image            = MessageBoxImage.Exclamation,
                    AutomationId     = "ToolkitNotInstalled"
                };
                int num = (int)messageDisplayService.ShowMessage(args);
            }
            else
            {
                flag = typeResolver.PlatformMetadata.IsSupported(typeResolver, targetType);
                if (!flag)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Message          = upgradeHelperMessage,
                        HyperlinkMessage = StringTable.SilverlightToolkitUpdateHyperlinkMessage,
                        HyperlinkUri     = new Uri("http://go.microsoft.com/fwlink/?LinkId=183538", UriKind.Absolute),
                        Button           = MessageBoxButton.OK,
                        Image            = MessageBoxImage.Exclamation,
                        AutomationId     = "ToolkitIncorrectVersion"
                    };
                    int num = (int)messageDisplayService.ShowMessage(args);
                }
            }
            return(flag);
        }
Beispiel #6
0
        private void ShowMefComposeError()
        {
            IConfigurationService        service1 = this.Services.GetService <IConfigurationService>();
            IMessageDisplayService       service2 = this.Services.GetService <IMessageDisplayService>();
            IMessageLoggingService       service3 = this.Services.GetService <IMessageLoggingService>();
            IExpressionMefHostingService service4 = this.Services.GetService <IExpressionMefHostingService>();

            if (this.mefExceptionToShow == null && Enumerable.Count <Exception>(service4.CompositionExceptions) <= 0)
            {
                return;
            }
            bool doNotAskAgain = service1 != null && (bool)service1["MEFHosting"].GetProperty("DoNotWarnAboutMefCompositionException", (object)false);

            if (!doNotAskAgain && service3 != null && (service4 != null && Enumerable.Count <Exception>(service4.CompositionExceptions) > 0))
            {
                foreach (Exception exception in service4.CompositionExceptions)
                {
                    service3.WriteLine(exception.Message);
                }
            }
            service4.ClearCompositionExceptions();
            if (!doNotAskAgain && service3 != null && (this.mefExceptionToShow != null && !string.IsNullOrEmpty(this.mefExceptionToShow.Message)))
            {
                service3.WriteLine(this.mefExceptionToShow.Message);
            }
            this.mefExceptionToShow = (Exception)null;
            if (doNotAskAgain || service2 == null)
            {
                return;
            }
            string         str  = Path.Combine(Path.GetDirectoryName(this.GetType().Module.FullyQualifiedName), "extensions");
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.MefCompositionException, new object[1]
                {
                    (object)str
                }),
                Button = MessageBoxButton.OK,
                Image  = MessageBoxImage.Exclamation
            };
            int num = (int)service2.ShowMessage(args, out doNotAskAgain);

            if (!doNotAskAgain || service1 == null)
            {
                return;
            }
            service1["MEFHosting"].SetProperty("DoNotWarnAboutMefCompositionException", (object)true);
        }
Beispiel #7
0
        internal static void ShowErrorMessageFromResponse(ILicenseSubServiceResponse response, IMessageDisplayService messageDisplayService)
        {
            string str = LicensingDialogHelper.ErrorMessageFromResponse(response);

            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            MessageBoxArgs args = new MessageBoxArgs()
            {
                Message = str,
                Button  = MessageBoxButton.OK,
                Image   = MessageBoxImage.Hand
            };
            int num = (int)messageDisplayService.ShowMessage(args);
        }
        public static bool PromptUserAndSaveDocument(IDocument document, bool saveAsOnFailure, IMessageDisplayService messageManager)
        {
            bool flag = false;

            if (document.IsDirty)
            {
                IDictionary <MessageChoice, string> dictionary = (IDictionary <MessageChoice, string>) new Dictionary <MessageChoice, string>()
                {
                    {
                        MessageChoice.Yes,
                        StringTable.SaveChangesYesResponse
                    },
                    {
                        MessageChoice.No,
                        StringTable.SaveChangesNoResponse
                    }
                };
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveChangesTo, new object[1]
                    {
                        (object)document.DocumentReference.DisplayName
                    }),
                    Button        = MessageBoxButton.YesNoCancel,
                    Image         = MessageBoxImage.Exclamation,
                    TextOverrides = dictionary
                };
                switch (messageManager.ShowMessage(args))
                {
                case MessageBoxResult.Yes:
                    flag = DocumentUtilities.SaveDocument(document, saveAsOnFailure, messageManager);
                    break;

                case MessageBoxResult.No:
                    flag = true;
                    break;
                }
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
Beispiel #9
0
        public static bool ShowLicensingDialog(IServices services, CommonDialogCreator licensingDialogCreator)
        {
            bool                  flag                = false;
            ILicenseService       service1            = services.GetService <ILicenseService>();
            ILicensingDialogQuery getInstance         = licensingDialogCreator.GetInstance;
            Guid                  mostPermissiveSkuId = service1.MostPermissiveSkuId;

            if (mostPermissiveSkuId != Guid.Empty)
            {
                if (service1.IsInGrace(mostPermissiveSkuId))
                {
                    getInstance.IsPermanentLicense = false;
                    getInstance.GraceDaysRemaining = (uint)Math.Floor((double)service1.GetRemainingGraceMinutes(mostPermissiveSkuId) / 1440.0);
                }
                else
                {
                    getInstance.IsStudioPermanentLicense = service1.FeaturesFromSku(service1.MostPermissiveSkuId).Contains(ExpressionFeatureMapper.StudioLicense);
                    getInstance.IsPermanentLicense       = !getInstance.IsStudioPermanentLicense && !service1.FeaturesFromSku(service1.MostPermissiveSkuId).Contains(ExpressionFeatureMapper.TrialLicense);
                }
                if (LicensingDialogHelper.ShowDialogWithMainWindowDisabled(services, getInstance) && getInstance.IsLicensed)
                {
                    flag = true;
                }
            }
            else
            {
                MessageBoxArgs args = new MessageBoxArgs()
                {
                    Message = StringTable.LicensingTrialKeyInstallationFailureMessage,
                    Button  = MessageBoxButton.OK,
                    Image   = MessageBoxImage.Hand
                };
                IMessageDisplayService service2 = services.GetService <IMessageDisplayService>();
                if (service2 != null)
                {
                    int num = (int)service2.ShowMessage(args);
                }
            }
            return(flag);
        }
Beispiel #10
0
        public static bool SaveDocument(IDocument document, bool saveAsOnFailure, bool forceSave, IMessageDisplayService messageManager)
        {
            bool flag = false;

            if (!forceSave)
            {
                if (!document.IsDirty)
                {
                    flag = true;
                    goto label_12;
                }
            }
            try
            {
                if (document.Container != null)
                {
                    document.Container.BeginCheckDocumentStatus(document);
                }
                FileAttributes fileAttributes = !PathHelper.FileExists(document.DocumentReference.Path) ? FileAttributes.Normal : File.GetAttributes(document.DocumentReference.Path);
                if ((fileAttributes & FileAttributes.ReadOnly) != (FileAttributes)0)
                {
                    MessageBoxArgs args = new MessageBoxArgs()
                    {
                        Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.OverwriteConfirmationMessage, new object[1]
                        {
                            (object)document.DocumentReference.DisplayName
                        }),
                        Button = MessageBoxButton.YesNoCancel,
                        Image  = MessageBoxImage.Exclamation
                    };
                    switch (messageManager.ShowMessage(args))
                    {
                    case MessageBoxResult.Yes:
                        File.SetAttributes(document.DocumentReference.Path, fileAttributes & ~FileAttributes.ReadOnly);
                        flag = document.Save();
                        break;

                    case MessageBoxResult.No:
                        flag = true;
                        break;
                    }
                }
                else
                {
                    flag = document.Save();
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                flag = false;
                messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2]
                {
                    (object)document.DocumentReference.DisplayName,
                    (object)ex.Message
                }));
                int num = saveAsOnFailure ? 1 : 0;
            }
            catch (IOException ex)
            {
                flag = false;
                messageManager.ShowError(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.SaveAccessError, new object[2]
                {
                    (object)document.DocumentReference.DisplayName,
                    (object)ex.Message
                }));
                int num = saveAsOnFailure ? 1 : 0;
            }
label_12:
            return(flag);
        }
Beispiel #11
0
 protected void ShowMessageBox(string message)
 {
     _messageDisplayService.ShowMessage(null, message);
 }