public SetupVm(int setupId, PPItemCollection parent) : base(parent) { UOW = new Dal.SoheilEdmContext(); _id = setupId; reloadFromModel(); initializeCommands(); }
/// <summary> /// Creates an instance of BlockVm with the given model /// </summary> /// <remarks>commands must be set after creating a block</remarks> /// <param name="model"></param> /// <param name="parent"></param> public BlockVm(Soheil.Core.PP.PPItemBlock data, PPItemCollection parent) : base() { UOW = data.UOW; Parent = parent; _fullData = data; //this.ViewModeChanged += v => ShowTasks = v == PPViewMode.Report; load(); }
public NPTVm(PPItemCollection parent) : base() { Parent = parent; StartDateTimeChanged += newVal => { _suppress = true; StartDate = newVal.Date; StartTime = newVal.TimeOfDay; _suppress = false; }; initializeCommands(); }
/// <summary> /// Resets the timeline to Now, loads PPItems in range and loads Stations /// <para>This method is using _initialTimer so its body will be run with a 10ms delay</para> /// </summary> public void ResetTimeLine() { //exit if loaded once if (_initialTimer != null) return; _initialTimer = new System.Threading.Timer(new System.Threading.TimerCallback (t => Dispatcher.Invoke(() => { _suppressUpdateRange = true; //initialize DateTimes var currentDate = Arash.PersianDate.Today.ToDateTime(); var startDate = currentDate.GetNorooz(); //initialize Timeline components Days = new DayCollection(); Months = new MonthCollection(startDate); Months.SelectedMonthChanged += month => SelectedMonth = month; Hours = new HourCollection(); //initialize PPItems PPItems = new PPItemCollection(this); PPItems.Manager.DayColorsUpdated += (startingDate, colors) => { //refetch it, if selected month is changed after fetch if (SelectedMonth.Data != startingDate) { PPItems.Manager.InitMonth(SelectedMonth.Data); return; } //colorize days for (int i = 0; i < colors.Length; i++) { Days[i].Color = colors[i]; } }; PPItems.Manager.WorkTimeAdded += item => { var vms = Soheil.Core.ViewModels.OrganizationCalendar.WorkTimeRangeVm.CreateAuto(item); foreach (var vm in vms) { ShiftsAndBreaks.Add(vm); } }; PPItems.Manager.WorkTimesRemoved += () => { ShiftsAndBreaks.Clear(); }; PPItems.BlockAdded += vm => { initializeCommands(vm); }; PPItems.BlockRemoved += id => { if (SelectedBlock != null && SelectedBlock.Id == id) SelectedBlock = null; }; PPItems.NptAdded += vm => { initializeCommands(vm); }; PPItems.NptRemoved += id => { if (SelectedNPT != null && SelectedNPT.Id == id) SelectedNPT = null; }; //Initialize stations var stationModels = new DataServices.StationDataService().FixAndGetActives(); NumberOfStations = stationModels.Count(); foreach (var stationModel in stationModels) { PPItems.Add(new StationVm { Text = stationModel.Name }); } //Set advanced timeline components SelectedMonth = Months[(int)currentDate.GetPersianMonth() - 1]; HoursPassed = currentDate.Subtract(SelectedMonth.Data).TotalHours; if (currentDate.Year % 4 == 3) { HoursInYear = 8784; DaysInYear = 366; } else { HoursInYear = 8760; DaysInYear = 365; } //Loads PPItems _suppressUpdateRange = false; GoToNowCommand.Execute(null); })), null, _initialTimerInterval, System.Threading.Timeout.Infinite); }