aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Dialogs/JobCreationViewVM.cs
blob: e2176c6afbf1111cfbfa54209c0a1f3b46505801 (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
60
61
62
63
64
65
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Enumerations;
using Tango.SharedUI;

namespace Tango.PPC.Jobs.Dialogs
{
    /// <summary>
    /// Represents the a job type picker view model
    /// </summary>
    /// <seealso cref="Tango.SharedUI.DialogViewVM" />
    public class JobCreationViewVM : DialogViewVM
    {
        /// <summary>
        /// Gets or sets the supported job types.
        /// </summary>
        public List<JobTypes> SupportedJobTypes { get; set; }

        private JobTypes _selectedJobType;
        /// <summary>
        /// Gets or sets the type of the selected job.
        /// </summary>
        public JobTypes SelectedJobType
        {
            get { return _selectedJobType; }
            set
            {
                _selectedJobType = value;
                RaisePropertyChangedAuto();
            }
        }

        /// <summary>
        /// Gets or sets the supported color spaces.
        /// </summary>
        public List<ColorSpaces> SupportedColorSpaces { get; set; }

        private ColorSpaces _selectedColorSpace;
        /// <summary>
        /// Gets or sets the selected color space.
        /// </summary>
        public ColorSpaces SelectedColorSpace
        {
            get { return _selectedColorSpace; }
            set
            {
                _selectedColorSpace = value;
                RaisePropertyChangedAuto();
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="JobCreationViewVM"/> class.
        /// </summary>
        /// <param name="supportedJobTypes">The supported job types.</param>
        /// <param name="supportedColorSpaces">The supported color spaces</param>
        public JobCreationViewVM(List<JobTypes> supportedJobTypes,List<ColorSpaces> supportedColorSpaces) : base()
        {
            SupportedJobTypes = supportedJobTypes;
            SupportedColorSpaces = supportedColorSpaces;
        }
    }
}
>using Tango.Settings; namespace Tango.BL { /// <summary> /// Exposes method for retrieving observable collections of observable entities. /// </summary> /// <seealso cref="Tango.Core.ExtendedObject" /> [Obsolete("ObservablesEntitiesAdapter should not be used. Use ObservablesStaticCollections instead!")] public partial class ObservablesEntitiesAdapter : ExtendedObject { public event Action Initialized; private Dispatcher _dispatcher; private static object _syncLock; private static ObservablesEntitiesAdapter _instance; /// <summary> /// Gets the singleton instance. /// </summary> public static ObservablesEntitiesAdapter Instance { get { if (_instance == null) { _instance = new ObservablesEntitiesAdapter(); } return _instance; } } /// <summary> /// Gets the DB context. /// </summary> public ObservablesContext Context { get; private set; } /// <summary> /// Performs an implicit conversion from <see cref="ObservablesEntitiesAdapter"/> to <see cref="DbContext"/>. /// </summary> /// <param name="instance">The instance.</param> /// <returns> /// The result of the conversion. /// </returns> public static implicit operator DbContext(ObservablesEntitiesAdapter instance) { return instance.Context; } /// <summary> /// Prevents a default instance of the <see cref="ObservablesEntitiesAdapter"/> class from being created. /// </summary> private ObservablesEntitiesAdapter() { Context = ObservablesContext.CreateDefault(); Context.Configuration.LazyLoadingEnabled = true; } /// <summary> /// Initializes this instance. /// </summary> public void Initialize() { Invalidate(true); Initialized?.Invoke(); } /// <summary> /// Saves the current changes to database. /// </summary> public void SaveChanges() { try { Context.SaveChanges(); } catch (Exception ex) { throw ex; } finally { Invalidate(); } } /// <summary> /// Invokes the specified action on the adapter synchronization context. /// </summary> /// <param name="action">The action.</param> public void Invoke(Action action) { _dispatcher.Invoke(() => { action(); }); } /// <summary> /// Invalidates the adapter and reloads the database. /// </summary> /// <param name="initializing">if set to <c>true</c> [initializing].</param> public void Invalidate(bool initializing = false) { try { _syncLock = new object(); Organizations = Context.Organizations.ToObservableCollection(); Machines = Context.Machines.ToObservableCollection(); MachineVersions = Context.MachineVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); Addresses = Context.Addresses.ToList().OrderBy(x => x.AddressString).ToObservableCollection(); Contacts = Context.Contacts.ToList().OrderBy(x => x.FullName).ToObservableCollection(); Roles = Context.Roles.ToList().OrderBy(x => x.Name).ToObservableCollection(); Permissions = Context.Permissions.ToList().OrderBy(x => x.Name).ToObservableCollection(); UsersRoles = Context.UsersRoles.ToObservableCollection(); Users = Context.Users.Where(x => !x.Deleted).ToList().OrderBy(x => x.Contact.FullName).ToObservableCollection(); foreach (var role in Roles) { role.RolesPermissions = role.RolesPermissions.ToSynchronizedObservableCollection(); } Configurations = Context.Configurations.ToList().OrderBy(x => x.LastUpdated).ToObservableCollection(); foreach (var config in Configurations) { //config.IdsPacks = config.IdsPacks.ToObservableCollection2(); } ApplicationOsVersions = Context.ApplicationOsVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); ApplicationFirmwareVersions = Context.ApplicationFirmwareVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); ApplicationDisplayPanelVersions = Context.ApplicationDisplayPanelVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); EmbeddedFirmwareVersions = Context.EmbeddedFirmwareVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); HardwareVersions = Context.HardwareVersions.ToList().OrderBy(x => x.Version).ToObservableCollection(); IdsPacks = Context.IdsPacks.ToObservableCollection(); DispenserTypes = Context.DispenserTypes.ToObservableCollection(); LiquidTypes = Context.LiquidTypes.ToObservableCollection(); CartridgeTypes = Context.CartridgeTypes.ToObservableCollection(); MidTankTypes = Context.MidTankTypes.ToObservableCollection(); SpoolTypes = Context.SpoolTypes.ToObservableCollection(); EventTypes = Context.EventTypes.ToObservableCollection(); MediaMaterials = Context.MediaMaterials.ToObservableCollection(); MediaPurposes = Context.MediaPurposes.ToObservableCollection(); MediaConditions = Context.MediaConditions.ToObservableCollection(); LinearMassDensityUnits = Context.LinearMassDensityUnits.ToObservableCollection(); FiberShapes = Context.FiberShapes.ToObservableCollection(); FiberSynths = Context.FiberSynths.ToObservableCollection(); Rmls = Context.Rmls.ToObservableCollection(); LiquidTypesRmls = Context.LiquidTypesRmls.ToObservableCollection(); Ccts = Context.Ccts.ToObservableCollection(); Cats = Context.Cats.ToObservableCollection(); ProcessParametersTables = Context.ProcessParametersTables.ToObservableCollection(); ProcessParametersTablesGroups = Context.ProcessParametersTablesGroups.ToObservableCollection(); foreach (var group in ProcessParametersTablesGroups) { group.ProcessParametersTables = group.ProcessParametersTables.OrderBy(x => x.TableIndex).ToSynchronizedObservableCollection(); } WindingMethods = Context.WindingMethods.ToObservableCollection(); TechMonitors = Context.TechMonitors.ToObservableCollection(); TechDispensers = Context.TechDispensers.ToObservableCollection(); TechValves = Context.TechValves.ToObservableCollection(); TechIos = Context.TechIos.ToObservableCollection(); TechControllers = Context.TechControllers.ToObservableCollection(); IdsPackFormulas = Context.IdsPackFormulas.ToObservableCollection(); ColorSpaces = Context.ColorSpaces.ToObservableCollection(); HardwareDancerTypes = Context.HardwareDancerTypes.ToObservableCollection(); HardwareDancers = Context.HardwareDancers.ToObservableCollection(); HardwareMotorTypes = Context.HardwareMotorTypes.ToObservableCollection(); HardwareMotors = Context.HardwareMotors.ToObservableCollection(); HardwarePidControlTypes = Context.HardwarePidControlTypes.ToObservableCollection(); HardwarePidControls = Context.HardwarePidControls.ToObservableCollection(); HardwareWinderTypes = Context.HardwareWinderTypes.ToObservableCollection(); HardwareWinders = Context.HardwareWinders.ToObservableCollection(); HardwareSpeedSensorTypes = Context.HardwareSpeedSensorTypes.ToObservableCollection(); HardwareSpeedSensors = Context.HardwareSpeedSensors.ToObservableCollection(); HardwareBlowerTypes = Context.HardwareBlowerTypes.ToObservableCollection(); HardwareBlowers = Context.HardwareBlowers.ToObservableCollection(); HardwareBreakSensorTypes = Context.HardwareBreakSensorTypes.ToObservableCollection(); HardwareBreakSensors = Context.HardwareBreakSensors.ToObservableCollection(); Customers = Context.Customers.ToObservableCollection(); _dispatcher = Application.Current.Dispatcher; _dispatcher.Invoke(() => { InitCollectionSources(); }); } catch (Exception ex) { throw LogManager.Default.Log(ex, "Error on observables entities adapter initialization."); } } /// <summary> /// Creates a collection view from the specified observable collection. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection">The collection.</param> /// <returns></returns> private ICollectionView CreateCollectionView<T>(ObservableCollection<T> collection) { var view = CollectionViewSource.GetDefaultView(collection); return view; } } }