示例#1
0
        private static bool ConfirmDownload(Version releaseVersion)
        {
            var question = string.Format("A new version ({0}) has been released.{1}{1}Do you want to download and install it?", releaseVersion, Environment.NewLine);
            var result   = QuestionBox.Show(question, false);

            return(result == MessageBoxResult.Yes);
        }
示例#2
0
        private void ImportResources(string fileName, IResourceFileReader resourceFileReader)
        {
            var workingDirectory = Path.GetDirectoryName(fileName);
            var documentName     = resourceFileReader.GetDocumentName(fileName);

            if (IsDocumentOpen)
            {
                var fileMatchesDocument = string.Equals(Document.Name, documentName, StringComparison.CurrentCultureIgnoreCase);
                if (fileMatchesDocument == false)
                {
                    var closeConfirmation = QuestionBox.Show(Strings.ResourceFileLoad_CloseConfirmation);

                    switch (closeConfirmation)
                    {
                    case MessageBoxResult.Yes:
                        // Load resources in a new document
                        if (CloseDocument())
                        {
                            break;
                        }

                        // User chose not to close current document -> cancel
                        return;

                    case MessageBoxResult.No:
                        // Load resources in opened document
                        break;

                    case MessageBoxResult.Cancel:
                        // Do not load resources
                        return;

                    default:
                        throw new InvalidOperationException();
                    }
                }
            }

            var document = Document ?? CreateNewDocument(workingDirectory, documentName);

            resourceFileReader.LoadResources(document, fileName);

            Document           = document;
            IsDocumentModified = true;
        }
示例#3
0
        /// <summary>
        /// Closes the current document.
        /// </summary>
        /// <returns>True if the document was closed, otherwise false.</returns>
        public bool CloseDocument()
        {
            if (IsDocumentOpen)
            {
                if (IsDocumentModified)
                {
                    var closeConfirmation = QuestionBox.Show("Save changes to current document?");

                    switch (closeConfirmation)
                    {
                    case MessageBoxResult.Yes:
                        SaveDocument();
                        break;

                    case MessageBoxResult.Cancel:
                        return(false);
                    }
                }

                Document = null;
            }

            return(true);
        }