Exemple #1
0
        private void documentService_DocumentSaved(object sender, DocumentEventArgs e)
        {
            if (e.Kind != DocumentEventType.SavedAs || SourceControlService == null)
            {
                return;
            }

            if (SourceControlService.GetStatus(e.Document.Uri) == SourceControlStatus.NotControlled)
            {
                string message = "Add document ".Localize() + e.Document.Uri.AbsolutePath + " to version control?".Localize();
                var    result  = MessageBoxes.Show(message, " Add document to Version Control".Localize(), MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    SourceControlService.Add(e.Document.Uri);
                }
            }
        }
        private void documentService_DocumentSaved(object sender, DocumentEventArgs e)
        {
            if (e.Kind != DocumentEventType.SavedAs || SourceControlService == null)
            {
                return;
            }

            if (SourceControlService.GetStatus(e.Document.Uri) == SourceControlStatus.NotControlled)
            {
                string message = string.Format("Add document {0} to version control?".Localize(), e.Document.Uri.AbsolutePath);
                var    result  = MessageBoxes.Show(message, "Add Document to Version Control".Localize("this is the title of a dialog box that is asking a question"),
                                                   MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    SourceControlService.Add(e.Document.Uri);
                }
            }
        }
        /// <summary>
        /// Perform the Revert command</summary>
        /// <param name="doing">True to perform the Revert; false to test whether Revert can be done</param>
        /// <returns>True iff Revert can be done or was done</returns>
        protected virtual bool DoRevert(bool doing)
        {
            if (SourceControlService == null || SourceControlContext == null)
            {
                return(false);
            }

            foreach (IResource resource in SourceControlContext.Resources)
            {
                SourceControlStatus status = GetStatus(resource);
                if (status != SourceControlStatus.CheckedOut && status != SourceControlStatus.Added && status != SourceControlStatus.Deleted)
                {
                    return(false);
                }
            }

            if (doing)
            {
                // user must confirm revert
                var dialogResult = MessageBoxes.Show("All Changes will be lost. Do you want to proceed?".Localize(),
                                                     "Proceed with Revert?".Localize(),
                                                     MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (dialogResult == MessageBoxResult.Yes)
                {
                    foreach (IResource resource in SourceControlContext.Resources.ToArray())
                    {
                        SourceControlStatus status = GetStatus(resource);
                        if (status == SourceControlStatus.CheckedOut || status == SourceControlStatus.Added || status == SourceControlStatus.Deleted)
                        {
                            SourceControlService.Revert(resource.Uri);
                            Reload(resource);
                        }
                    }
                }
            }

            return(true);
        }