aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/ExtensionMethods/TangoIOCExtensions.cs
blob: 827650f591b6bc8f2a95b663aa73e230a244b398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.DI;
using Tango.MachineStudio.Common;

public static class TangoIOCExtensions
{
    /// <summary>
    /// Gets the specified module <see cref="IStudioViewModel"/> view models.
    /// </summary>
    /// <param name="tangoIOC">The Tango IOC.</param>
    /// <param name="module">The module.</param>
    /// <returns></returns>
    public static IEnumerable<IStudioViewModel> GetModuleViewModels(this TangoIOC tangoIOC, IStudioModule module)
    {
        var viewModels = tangoIOC.GetAllInstancesByBase<IStudioViewModel>().Where(x => x != null && x.GetType().BaseType.GetGenericArguments().Length > 0 && x.GetType().BaseType.GetGenericArguments()[0] == module.GetType());
        return viewModels;
    }
}
class="p">, RoutedEventArgs e) { InvalidateGrid(); } protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); } protected override Size ArrangeOverride(Size arrangeSize) { return base.ArrangeOverride(arrangeSize); } private void InvalidateGrid() { RowDefinitions.Clear(); RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); int currentRow = 0; for (int i = 0; i < Children.Count; i++) { SetRow(Children[i], currentRow); if (i % 2 != 0) { SetColumn(Children[i], 1); (Children[i] as FrameworkElement).Margin = new Thickness(20, 0, 0, 0); currentRow++; RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) }); } (Children[i] as FrameworkElement).VerticalAlignment = VerticalAlignment.Bottom; } } } }