aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/ViewModelLocator.cs
blob: a7d08eb45b0e57d157e787e0f6acf7d681dfabd0 (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
using Tango.Core.DI;
using Tango.MachineStudio.Technician.ViewModels;

namespace Tango.MachineStudio.Technician
{
    /// <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<MachineTechViewVM>();
        }

        public static MachineTechViewVM MachineTechViewVM
        {
            get
            {
                return TangoIOC.Default.GetInstance<MachineTechViewVM>();
            }
        }
    }
}
p">, bool forceRedraw = true) { var bitmap = UIHelper.TakeSnapshot(element, new Size(element.ActualWidth, element.ActualHeight)); var parent = element.Parent; if (parent != null && forceRedraw) { UIHelper.RemoveChild(parent, element); element.UpdateLayout(); UIHelper.AddChild(parent, element); element.UpdateLayout(); } return bitmap; } /// <summary> /// Renders the element to a bitmap source of the specified size. /// </summary> /// <param name="element">The element.</param> /// <param name="width">The bitmap width.</param> /// <param name="height">The bitmap height.</param> /// <param name="forceRedraw">if set to <c>true</c> forces the redraw of the element and prevents a freezing effect.</param> /// <returns></returns> public static BitmapSource TakeSnapshot(this FrameworkElement element, int width, int height, bool forceRedraw = true) { var bitmap = UIHelper.TakeSnapshot(element, new Size(element.ActualWidth, element.ActualHeight)); TransformedBitmap resizedBitmap = new TransformedBitmap(bitmap, new ScaleTransform(width / bitmap.Width, height / bitmap.Height, 0, 0)); var parent = element.Parent; if (parent != null && forceRedraw) { UIHelper.RemoveChild(parent, element); element.UpdateLayout(); UIHelper.AddChild(parent, element); element.UpdateLayout(); } return resizedBitmap; } }