Exemplo n.º 1
0
        /// <summary>
        /// Performs refresh of documents' status</summary>
        /// <param name="doing">True iff doing the command</param>
        /// <returns>True iff any documents refreshed or can be refreshed</returns>
        protected virtual bool DoRefresh(bool doing)
        {
            if (SourceControlService == null || !SourceControlService.Enabled ||
                SourceControlContext == null)
            {
                return(false);
            }

            if (!doing)
            {
                foreach (IResource resource in SourceControlContext.Resources)
                {
                    return(true);
                }

                return(false);
            }

            var uris = new List <Uri>();

            foreach (IResource resource in SourceControlContext.Resources)
            {
                GetSourceControlledUri(resource, uris);
            }
            SourceControlService.RefreshStatus(uris);

            return(uris.Count > 0); // something to refresh?
        }
Exemplo n.º 2
0
        private void documentService_DocumentSaved(object sender, DocumentEventArgs e)
        {
            if (SourceControlService == null)
            {
                return;
            }

            if (RefreshStatusOnSave)
            {
                SourceControlService.RefreshStatus(e.Document.Uri);
            }

            if (e.Kind != DocumentEventType.SavedAs)
            {
                return;
            }


            if (SourceControlService.GetStatus(e.Document.Uri) == SourceControlStatus.NotControlled)
            {
                string       message = string.Format("Add document {0} to version control?".Localize(), e.Document.Uri.AbsolutePath);
                DialogResult result  = MessageBox.Show(GetDialogOwner(), message, "Add document to Version Control".Localize(), MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    SourceControlService.Add(e.Document.Uri);
                }
            }
        }