示例#1
0
        /// <summary>
        /// Performs custom actions when a document's Dirty property changes</summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event args</param>
        protected virtual void OnDocumentDirtyChanged(object sender, EventArgs e)
        {
            IDocument document = sender as IDocument;

            if (SourceControlService == null || document == null || !document.Dirty || CheckoutOnEditBehavior == CheckoutOnEditBehavior.Never)
            {
                return;
            }

            if (SourceControlService.GetStatus(document.Uri) == SourceControlStatus.CheckedIn)
            {
                if (CheckoutOnEditBehavior == CheckoutOnEditBehavior.Always)
                {
                    TestCheckedIn(sender);
                    return;
                }

                var message = new StringBuilder();
                message.AppendLine("Check out this file to be able to save the changes?".Localize());
                message.AppendLine(document.Uri.LocalPath);

                DialogResult result = MessageBox.Show(
                    GetDialogOwner(),
                    message.ToString(),
                    "Check Out File".Localize(), MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    TestCheckedIn(sender);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Performs reconciliation of documents</summary>
        /// <param name="doing">True iff doing the command</param>
        /// <returns>True iff any documents reconciled or can be reconciled</returns>
        protected virtual bool DoReconcile(bool doing)
        {
            if (SourceControlService == null || 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)
            {
                uris.Add(resource.Uri);
            }

            var modifiled       = new List <Uri>();
            var localNotInDepot = new List <Uri>();

            using (new WaitCursor())
            {
                foreach (Uri uri in SourceControlService.GetModifiedFiles(uris))
                {
                    if (SourceControlService.GetStatus(uri) != SourceControlStatus.CheckedOut)
                    {
                        modifiled.Add(uri);
                    }
                }

                foreach (Uri uri in uris)
                {
                    if (!modifiled.Contains(uri))
                    {
                        if (SourceControlService.GetStatus(uri) == SourceControlStatus.FileDoesNotExist)
                        {
                            localNotInDepot.Add(uri);
                        }
                    }
                }
            }

            using (var form = new ReconcileForm(SourceControlService, modifiled, localNotInDepot))
            {
                if (m_mainForm != null)
                {
                    form.Icon = m_mainForm.Icon;
                }
                form.ShowDialog();
            }

            return(true);
        }
示例#3
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);
                }
            }
        }
        /// <summary>
        /// Handle document dirty changed event</summary>
        /// <param name="sender">Document registry</param>
        /// <param name="e">Event arguments</param>
        protected virtual void OnDocumentDirtyChanged(object sender, EventArgs e)
        {
            IDocument document = sender as IDocument;

            if (SourceControlService == null || document == null || !document.Dirty || CheckoutOnEditBehavior == CheckoutOnEditBehavior.Never)
            {
                return;
            }

            if (SourceControlService.GetStatus(document.Uri) == SourceControlStatus.CheckedIn)
            {
                if (CheckoutOnEditBehavior == CheckoutOnEditBehavior.Always)
                {
                    TestCheckedIn(sender);
                    return;
                }

                string message = string.Format("Check out the file\r\n\r\n{0}\r\n\r\nto be able to save the changes?".Localize(),
                                               document.Uri.LocalPath);

                var result = MessageBoxes.Show(message, "Check Out File".Localize("this is the title of a dialog box that is asking a question"),
                                               MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    TestCheckedIn(sender);
                }
            }
        }
        /// <summary>
        /// Get the source control status of an item</summary>
        /// <param name="resource">URI representing the path to item</param>
        /// <returns>Status of item</returns>
        protected virtual SourceControlStatus GetStatus(IResource resource)
        {
            Uri uri = resource.Uri;

            if (uri != null)
            {
                return(SourceControlService.GetStatus(new Uri(uri.LocalPath)));
            }

            return(SourceControlStatus.FileDoesNotExist);
        }
示例#6
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);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Tests if the resource is checked-in and needs checking out</summary>
        private void TestCheckedIn(object obj)
        {
            if (SourceControlService == null)
            {
                return;
            }
            IResource resource = obj.As <IResource>();

            if (resource == null)
            {
                return;
            }

            if (SourceControlService.GetStatus(resource.Uri) == SourceControlStatus.CheckedIn)
            {
                SourceControlService.CheckOut(resource.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);
                }
            }
        }