aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Updater/App.xaml.cs
blob: 6c3dce8680a43182dee36b7ced84e94426ff3f2a (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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace Tango.MachineStudio.Updater
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public static String[] StartupArgs { get; private set; }

        protected override void OnStartup(StartupEventArgs e)
        {
            StartupArgs = e.Args;
            base.OnStartup(e);
        }
    }
}
an> object _syncLock = new object(); /// <summary> /// Replaces the specified old element with the specified new element. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The observable collection.</param> /// <param name="oldElement">The old element.</param> /// <param name="newElement">The new element.</param> public static void Replace<T>(this ObservableCollection<T> collection, T oldElement, T newElement) { int index = collection.IndexOf(oldElement); collection.Remove(oldElement); collection.Insert(index, newElement); } /// <summary> /// Swaps the specified elements. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The observable collection.</param> /// <param name="element1">Element1.</param> /// <param name="element2">Element2.</param> public static void Swap<T>(this ObservableCollection<T> collection, T element1, T element2) { int index1 = collection.IndexOf(element1); int index2 = collection.IndexOf(element2); T tmp = collection[index1]; collection[index1] = collection[index2]; collection[index2] = tmp; } /// <summary> /// Removes the dragged element and inserts it after the dropped element position. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The collection.</param> /// <param name="dragged">The dragged element.</param> /// <param name="dropped">The dropped element.</param> public static void DragAndDrop<T>(this ObservableCollection<T> collection, T dragged, T dropped) { collection.Remove(dragged); collection.Insert(collection.IndexOf(dropped), dragged); } /// <summary> /// Enables cross thread operations on this collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The collection.</param> public static void EnableCrossThreadOperations<T>(this ObservableCollection<T> collection) { BindingOperations.EnableCollectionSynchronization(collection, _syncLock); } /// <summary> /// Creates a collection view from the observable collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The collection.</param> /// <returns></returns> public static ICollectionView ToCollectionView<T>(this ObservableCollection<T> collection) { return CollectionViewSource.GetDefaultView(collection); } }