public void Add() { var instance = (IConveyor)Activator.CreateInstance(ConveyorsOptions[SelectedConveyorIndex]); instance.OnCrashChanged += Instance_OnCrashChanged; Conveyors.Add(instance); RaisePropertyChanged(nameof(Conveyors)); }
public void Stop(IConveyor conveyor) { int index = Conveyors.IndexOf(conveyor); Conveyors.Remove(conveyor); conveyor.Stop(); Conveyors.Insert(index, conveyor); RaisePropertyChanged(nameof(Conveyors)); }
public async void AddNewConveyor() { var conveyor = new Conveyor(); conveyor.AddMaterials += HandleAddMaterials; conveyor.Repair += HandleRepair; conveyor.Update += HandleUpdate; Conveyors.Add(conveyor); ConveyorAdded?.Invoke(conveyor); await Task.Run(conveyor.StartWorking); }
private void Instance_OnCrashChanged(IConveyor obj) { Application.Current.Dispatcher.Invoke( () => { int index = Conveyors.IndexOf(obj); Conveyors.Remove(obj); Conveyors.Insert(index, obj); RaisePropertyChanged(nameof(Conveyors)); }, System.Windows.Threading.DispatcherPriority.Send); }
private void Factory_OnSugarChanged(IConveyor conveyor) { Application.Current.Dispatcher.Invoke( () => { RaisePropertyChanged(nameof(Factory)); Messenger.Default.Send(new SugarTakenMessage { Conveyor = conveyor, ConveyorIndex = Conveyors.IndexOf(conveyor) }); }, System.Windows.Threading.DispatcherPriority.Send); }
void Convey_OnDataChanged(object sender, DataChangedEventArgs e) { if (e.State == null) return; string[] str = e.ItemName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); string ConveyID = str[0]; string ChangeName = str[1]; GetConveyor(ConveyID); if (ChangeName.IndexOf("TaskNo") >= 0) { object[] obj = ObjectUtil.GetObjects(e.State); string TaskNo = obj[0].ToString() + obj[1].ToString().PadLeft(4, '0') + obj[2].ToString().PadLeft(4, '0'); dicConvey[ConveyID].TaskNo = TaskNo; } else if (ChangeName.IndexOf("PalletCode") >= 0) dicConvey[ConveyID].PalletCode = e.State.ToString(); Conveyors.ConveyorInfo(dicConvey[ConveyID]); }
void Conveyor_OnDataChanged(object sender, DataChangedEventArgs e) { try { if (e.State == null) { return; } string txt = e.ItemName.Split('_')[0]; Conveyor conveyor = GetConveyorByID(txt); conveyor.value = e.State.ToString(); conveyor.ID = txt; Conveyors.ConveyorInfo(conveyor); } catch (Exception ex) { MCP.Logger.Error("输送线监控界面中Conveyor_OnDataChanged出现异常" + ex.Message); } }
private void ConveyorAdded(Conveyor conveyor) { Conveyors.Add(new ConveyorVm(Conveyors.Count, conveyor)); }
private void PaintConveyors(Graphics g) { Conveyors.ForEach(vm => { vm.Paint(g); }); }
private void HandleUpdate(Conveyor caller, ConveyorState state) { var pos = Conveyors.FindIndex(conveyor => conveyor == caller); UpdateView?.Invoke(pos, state, Loader.IsFree, Mechanic.IsFree); }
public void Delete(IConveyor conveyor) { conveyor.Stop(); Conveyors.Remove(conveyor); RaisePropertyChanged(nameof(Conveyors)); }
public void DeleteConveyor(IConveyor conveyor) { Conveyors.Remove(conveyor); conveyor.Stop(); }
public void AddConveyor(IConveyor conveyor) { Conveyors.Add(conveyor); conveyor.Start(this); }