private void FileWatcherServiceAttributeChangedEvent(object sender, SledFileWatcherServiceEventArgs e)
        {
            var sd = e.Document as SledDocument;
            if (sd == null)
                return;

            // Don't mess with hidden documents
            if (sd.Hidden)
                return;

            // Toggle readonly status of document
            sd.IsReadOnly = !sd.IsReadOnly;

            // If document is dirty and its now readonly then we have a problem
            // and need to bring up the readonly resolution form.
            if (!sd.IsReadOnly || !sd.Dirty)
                return;

            using (var form = new SledReadOnlyDocResolutionForm())
            {
                form.SledDocument = sd;
                form.TryOptionEvent += FormTryOptionEvent;
                form.ShowDialog(m_mainForm);
            }
        }
Example #2
0
        private void ModifiedFilesFormServiceFileReloaded(object sender, SledFileWatcherServiceEventArgs e)
        {
            if (m_breakpointsMoving.Count <= 0)
                return;

            try
            {
                foreach (var tempBpDetails in m_breakpointsMoving)
                {
                    SledProjectFilesBreakpointType breakpoint;
                    AddBreakpoint(
                        tempBpDetails.File,
                        tempBpDetails.Line,
                        tempBpDetails.Condition,
                        tempBpDetails.ConditionResult,
                        tempBpDetails.ConditionEnabled,
                        tempBpDetails.UseFunctionEnvironment,
                        out breakpoint);
                }
            }
            finally
            {
                m_breakpointsMoving.Clear();
            }

            // Write out any breakpoint changes
            m_projectService.SaveSettings();
        }
Example #3
0
        private void ModifiedFilesFormServiceFileReloading(object sender, SledFileWatcherServiceEventArgs e)
        {
            m_breakpointsMoving.Clear();

            // Try and track breakpoints

            if ((e.Document == null) ||
                (e.Document.SledProjectFile == null) ||
                (e.Document.SledProjectFile.Breakpoints.Count <= 0))
                return;

            using (var sd = SledDocument.CreateHidden(e.Document.Uri, null))
            {
                if (sd.Editor == null)
                    return;

                try
                {
                    sd.Read();
                }
                catch (Exception ex)
                {
                    SledOutDevice.OutLine(
                        SledMessageType.Error,
                        "{0}: Exception reading file for tracking breakpoints after external editor modification: {1}",
                        this, ex.Message);

                    return;
                }

                var breakpoints = e.Document.SledProjectFile.Breakpoints;
                var bpsToRemove = new List<SledProjectFilesBreakpointType>();

                foreach (var bp in breakpoints)
                {
                    var originalFileLineText = bp.LineText;
                    if (string.IsNullOrEmpty(originalFileLineText))
                        continue;

                    const int invalidLine = -1;
                    var foundLine = invalidLine;
                    var pos = bp.Line;

                    const int iterationThreshold = 128;
                    var iterations = 0;

                    // check down
                    for (; (pos < sd.Editor.DocumentLineCount) && (foundLine == invalidLine) && (iterations < iterationThreshold); ++pos)
                    {
                        var modifiedFileLineText = GetLineText(sd.Editor, pos);
                        if (string.Compare(originalFileLineText, modifiedFileLineText, true) == 0)
                            foundLine = pos;

                        iterations++;
                    }

                    // check up if not found down
                    if (foundLine == invalidLine)
                    {
                        pos = bp.Line - 1;
                        iterations = 0;

                        for (; (pos >= 1) && (foundLine == invalidLine) && (iterations < iterationThreshold); --pos)
                        {
                            var modifiedFileLineText = GetLineText(sd.Editor, pos);
                            if (string.Compare(originalFileLineText, modifiedFileLineText, true) == 0)
                                foundLine = pos;

                            iterations++;
                        }
                    }

                    if (foundLine != invalidLine)
                    {
                        if (bp.Line != foundLine)
                        {
                            var tempBp =
                                new TempBpDetails(
                                    bp.File,
                                    foundLine,
                                    bp.Condition,
                                    bp.ConditionResult,
                                    bp.ConditionEnabled,
                                    bp.UseFunctionEnvironment);

                            m_breakpointsMoving.Add(tempBp);
                            bpsToRemove.Add(bp);
                        }
                    }
                    else
                    {
                        bpsToRemove.Add(bp);
                    }
                }

                // Remove any breakpoints that moved or that we were unable to track
                foreach (var bp in bpsToRemove)
                    RemoveBreakpoint(bp.File, bp.Line);
            }
        }
 private void FileWatcherService_FileChangedEvent(object sender, SledFileWatcherServiceEventArgs e)
 {
     SledOutDevice.OutLine(SledMessageType.Info, "ISledFileWatcherService.FileChangedEvent");
 }
 private void ModifiedFilesFormIgnoreFileEvent(object sender, SledFileWatcherServiceEventArgs e)
 {
     FileIgnoring.Raise(this, e);
     FileIgnored.Raise(this, e);
 }
        private void ModifiedFilesFormReloadFileEvent(object sender, SledFileWatcherServiceEventArgs e)
        {
            FileReloading.Raise(this, e);

            var absPath = e.Document.Uri.LocalPath;
            m_documentService.Get.Close(e.Document);

            ISledDocument sd;
            m_documentService.Get.Open(new Uri(absPath), out sd);

            FileReloaded.Raise(this, new SledFileWatcherServiceEventArgs(sd));
        }
        private void FileWatcherServiceFileChangedEvent(object sender, SledFileWatcherServiceEventArgs e)
        {
            if (m_modifiedFilesForm == null)
            {
                m_modifiedFilesForm = new SledModifiedFilesForm();
                m_modifiedFilesForm.ReloadFileEvent += ModifiedFilesFormReloadFileEvent;
                m_modifiedFilesForm.IgnoreFileEvent += ModifiedFilesFormIgnoreFileEvent;
            }

            m_modifiedFilesForm.AddFile(e.Document);
            m_modifiedFilesForm.Show(m_mainForm);
        }