aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModelLocator.cs
blob: 94b2f43411ce0bfd26b91315dc3314a0d369c7c8 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Tango.Core.DI;
using Tango.MachineStudio.Logging.Navigation;
using Tango.MachineStudio.Logging.ViewModels;

namespace Tango.MachineStudio.Logging
{
    /// <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<EventsViewVM>();
            TangoIOC.Default.Register<ApplicationLogsViewVM>();
            TangoIOC.Default.Register<EmbeddedLogsViewVM>();
            TangoIOC.Default.Register<HomeViewVM>();

            TangoIOC.Default.Unregister<LoggingNavigationManager>();
            TangoIOC.Default.Register<LoggingNavigationManager>(new LoggingNavigationManager());
        }

        public static EventsViewVM EventsViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<EventsViewVM>();
            }
        }

        public static ApplicationLogsViewVM ApplicationLogsViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<ApplicationLogsViewVM>();
            }
        }

        public static EmbeddedLogsViewVM EmbeddedLogsViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<EmbeddedLogsViewVM>();
            }
        }

        public static HomeViewVM HomeViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<HomeViewVM>();
            }
        }
    }
}
.ToSystemDrawing()).WorkingArea.ToWpf().TransformFromDevice(this); MaxHeight = workingArea.Height; MaxWidth = Math.Min(workingArea.Width, Math.Max(1000, workingArea.Width * 0.6)); } /// <summary> /// Gets/Sets whether the insight window should close automatically. /// The default value is true. /// </summary> public bool CloseAutomatically { get; set; } /// <inheritdoc/> protected override bool CloseOnFocusLost { get { return this.CloseAutomatically; } } void AttachEvents() { this.TextArea.Caret.PositionChanged += CaretPositionChanged; } /// <inheritdoc/> protected override void DetachEvents() { this.TextArea.Caret.PositionChanged -= CaretPositionChanged; base.DetachEvents(); } void CaretPositionChanged(object sender, EventArgs e) { if (this.CloseAutomatically) { int offset = this.TextArea.Caret.Offset; if (offset < this.StartOffset || offset > this.EndOffset) { Close(); } } } } /// <summary> /// TemplateSelector for InsightWindow to replace plain string content by a TextBlock with TextWrapping. /// </summary> internal sealed class InsightWindowTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (item is string) return (DataTemplate)((FrameworkElement)container).FindResource("TextBlockTemplate"); return null; } } }