aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModelLocator.cs
blob: 5f82984a46312937c1e9383aad3bb42f08eba600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Tango.Core.DI;
using Tango.MachineStudio.Developer.Navigation;
using Tango.MachineStudio.Developer.ViewModels;
using Tango.MachineStudio.Developer.Views;

namespace Tango.MachineStudio.Developer
{
    /// <summary>
    /// This class contains static references to all the view models in the
    /// application and provides an entry point for the bindings.
    /// </summary>
    public static class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        static ViewModelLocator()
        {
            TangoIOC.Default.Register<DeveloperNavigationManager, DeveloperNavigationManager>();
            TangoIOC.Default.Register<MainViewVM>();
        }

        public static MainViewVM MainViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<MainViewVM>();
            }
        }
    }
}
ss="w"> /// Gets the collection storing the read-only segments. /// </summary> public TextSegmentCollection<T> Segments { get { return segments; } } /// <summary> /// Creates a new TextSegmentReadOnlySectionProvider instance for the specified document. /// </summary> public TextSegmentReadOnlySectionProvider(TextDocument textDocument) { segments = new TextSegmentCollection<T>(textDocument); } /// <summary> /// Creates a new TextSegmentReadOnlySectionProvider instance using the specified TextSegmentCollection. /// </summary> public TextSegmentReadOnlySectionProvider(TextSegmentCollection<T> segments) { if (segments == null) throw new ArgumentNullException("segments"); this.segments = segments; } /// <summary> /// Gets whether insertion is possible at the specified offset. /// </summary> public virtual bool CanInsert(int offset) { foreach (TextSegment segment in segments.FindSegmentsContaining(offset)) { if (segment.StartOffset < offset && offset < segment.EndOffset) return false; } return true; } /// <summary> /// Gets the deletable segments inside the given segment. /// </summary> public virtual IEnumerable<ISegment> GetDeletableSegments(ISegment segment) { if (segment == null) throw new ArgumentNullException("segment"); int readonlyUntil = segment.Offset; foreach (TextSegment ts in segments.FindOverlappingSegments(segment)) { int start = ts.StartOffset; int end = start + ts.Length; if (start > readonlyUntil) { yield return new SimpleSegment(readonlyUntil, start - readonlyUntil); } if (end > readonlyUntil) { readonlyUntil = end; } } int endOffset = segment.EndOffset; if (readonlyUntil < endOffset) { yield return new SimpleSegment(readonlyUntil, endOffset - readonlyUntil); } } } }