public DeviceRoleViewModel(DeviceRole deviceRole) { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <DeviceRole>(); var dtos = AuthorizationDevices.Select(x => new ListBoxItem { ID = x.DeviceID, DisplayName = x.Name, IsSelected = deviceRole.HasDeviceAuthorization(x.DeviceID) }); DeviceDtos = new ObservableCollection <SelectableItem>(dtos); CurrentDeviceRole = deviceRole; if (deviceRole.DeviceRoleID != 0) { Name = deviceRole.RoleName; if (deviceRole.DeviceRolePermissions.Any()) { var firstPermission = deviceRole.DeviceRolePermissions.First(); SelectedTimezone = Timezones.FirstOrDefault(x => x.TimeZoneID == firstPermission.AllowedAccessTimeZoneID); SelectedPermissionAction = (int)firstPermission.PermissionAction; } } else { SelectedTimezone = Timezones.FirstOrDefault(); SelectedPermissionAction = PermissionActionDict.FirstOrDefault().ItemID.Value; } Title = (deviceRole.DeviceRoleID == 0) ? "新增设备角色" : "修改设备角色"; }
public TimeGroupViewModel(TimeGroup timeGroup) { ViewModelAttachment = new ViewModelAttachment <TimeGroup>(); SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); TimeSegmentDtos = new ObservableCollection <SelectableItem>(); foreach (var timeSegment in AllTimeSegments) { TimeSegmentDtos.Add(new ListBoxItem { ID = timeSegment.TimeSegmentID, DisplayName = timeSegment.TimeSegmentName, IsSelected = false }); } CurrentTimeGroup = timeGroup; if (timeGroup.TimeGroupID != 0) { TimeGroupID = timeGroup.TimeGroupID; Name = timeGroup.TimeGroupName; Code = timeGroup.TimeGroupCode; foreach (var timeSegment in timeGroup.TimeSegments) { TimeSegmentDtos.First(t => t.ID == timeSegment.TimeSegmentID).IsSelected = true; } } }
public SysRoleViewModel() { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <SysRole>(); TreeViewSource = BuildTreeViewSource(); }
public FloorViewModel() { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <Floor>(); InitDoorListBox(); }
public MoveUserViewModel(User userInfo) { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <User>(); CurrentUser = userInfo; CurrentDepartment = AuthorizationDepartments.First(x => x.DepartmentID == userInfo.DepartmentID); }
public UserAuthMngtViewModel(User currentUser) { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); CurrentUser = currentUser; ViewModelAttachment = new ViewModelAttachment <User>(); UserDeviceAuthViewModels = new ObservableCollection <UserDeviceAuthViewModel>(CreateUserDeviceAuthViewModels()); }
public DeviceViewModel() { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <DeviceController>(); DoorViewModels = new ObservableCollection <DeviceDoorViewModel>(); HeadReadingViewModels = new ObservableCollection <DeviceHeadReadingViewModel>(); }
public UserViewModel(User userInfo) { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); UploadImageCmd = new RelayCommand <string>(UploadImage); DepartmentChangedCmd = new RelayCommand(ProcessDepartmentChangedCmd); CurrentUser = userInfo; DepartmentInfo = new Department(); UserID = userInfo.UserID; IsAddMode = userInfo.UserID == 0; StartDate = DateTime.Now; Birthday = DateTime.Now; UserType = UserType.Employee; ViewModelAttachment = new ViewModelAttachment <User>(); Avator = _userAvatorService.GetAvator(_userAvatorService.DefaultAvatorFileName); Title = IsAddMode ? "新增人员" : "修改人员"; if (!IsAddMode) //Edit mode { UserType = userInfo.Type; UserCode = userInfo.UserCode; Name = userInfo.Name; Status = userInfo.Status == GeneralStatus.Enabled; StartDate = userInfo.StartDate; EndDate = userInfo.EndDate; Phone = userInfo.Phone; Avator = _userAvatorService.GetAvator(userInfo.Photo); DepartmentInfo = AuthorizationDepartments.FirstOrDefault(d => d.DepartmentID == userInfo.DepartmentID); CurrentDepartmentName = DepartmentInfo.Name; Gender = userInfo.Gender; LastName = userInfo.UserPropertyInfo.FirstName; FirstName = userInfo.UserPropertyInfo.FirstName; Nationality = userInfo.UserPropertyInfo.Nationality; NativePlace = userInfo.UserPropertyInfo.NativePlace; Birthday = userInfo.UserPropertyInfo.Birthday; Marriage = userInfo.UserPropertyInfo.Marriage; PoliticalStatus = (userInfo.UserPropertyInfo.PoliticalStatus != null) ? (PoliticalStatus)userInfo.UserPropertyInfo.PoliticalStatus : PoliticalStatus.Unknown; Degree = (userInfo.UserPropertyInfo.Degree != null) ? (DegreeStatus)userInfo.UserPropertyInfo.Degree : DegreeStatus.Unknown; HomeNumber = userInfo.UserPropertyInfo.HomeNumber; EnglishName = userInfo.UserPropertyInfo.EnglishName; Company = userInfo.UserPropertyInfo.Company; TechnicalTitle = userInfo.UserPropertyInfo.TechnicalTitle; TechnicalLevel = userInfo.UserPropertyInfo.TechnicalLevel; IDType = userInfo.UserPropertyInfo.IDType; IDNumber = userInfo.UserPropertyInfo.IDNumber; SocialNumber = userInfo.UserPropertyInfo.SocialNumber; Email = userInfo.UserPropertyInfo.Email; Address = userInfo.UserPropertyInfo.Address; Postcode = userInfo.UserPropertyInfo.Postcode; Remark = userInfo.UserPropertyInfo.Remark; } DeviceRoleListBoxSource = GetDeviceRoleListBoxSource(); }
public SysOperatorViewModel() { ViewModelAttachment = new ViewModelAttachment <SysOperator>(); SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); SysOperatorRoleItems = new ObservableCollection <ComboBoxItem>(); SysPermissionProvider.GetInstance().AllSysRoles.ForEach(r => SysOperatorRoleItems.Add(new ComboBoxItem() { ID = r.RoleID, DisplayName = r.RoleName })); }
protected override bool InstallToViewModel(ref ModViewModelAddArgs a) { GameObject gameObject; if (this.isMesh && !a.isMesh) { return(base.InstallToViewModel(ref a)); } if (!this.isMesh && a.isMesh) { return(base.InstallToViewModel(ref a)); } if (a.vm == null) { Debug.Log("Viewmodel null for item attachment..."); } if (this.attachObjectVM != null) { WeaponModRep weaponModRep = (WeaponModRep)a.modRep; if (!a.isMesh) { gameObject = this.GetSocketByName(a.vm, this.attachSocketName).InstantiateAsChild(this.attachObjectVM, true); } else { Socket socketByName = this.GetSocketByName(a.vm, this.attachSocketName); gameObject = UnityEngine.Object.Instantiate(this.attachObjectVM, socketByName.offset, Quaternion.Euler(socketByName.eulerRotate)) as GameObject; gameObject.transform.parent = socketByName.parent; gameObject.transform.localPosition = socketByName.offset; gameObject.transform.localEulerAngles = socketByName.eulerRotate; } gameObject.name = this.attachObjectVM.name; weaponModRep.SetAttached(gameObject, true); ViewModelAttachment component = gameObject.GetComponent <ViewModelAttachment>(); if (component) { if (this.socketOverrideName != string.Empty && component is VMAttachmentSocketOverride) { VMAttachmentSocketOverride vMAttachmentSocketOverride = (VMAttachmentSocketOverride)component; this.SetSocketByname(a.vm, this.socketOverrideName, vMAttachmentSocketOverride.socketOverride); if (this.modifyZoomOffset) { a.vm.punchScalar = this.punchScalar; a.vm.zoomOffset.z = this.zoomOffsetZ; } } component.viewModel = a.vm; } } return(true); }
public TimeZoneViewModel(RldModel.TimeZone timeZone) { ViewModelAttachment = new ViewModelAttachment <RldModel.TimeZone>(); SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); CurrentTimeZone = timeZone; if (timeZone.TimeZoneID != 0) { ID = timeZone.TimeZoneID; Name = timeZone.TimeZoneName; Code = timeZone.TimeZoneCode; } Title = (timeZone.TimeZoneID == 0) ? "新增时间区" : "修改时间区"; TimeGroupAssociationsDtos = InitTimeZoneGroupDtos(); }
protected override void UninstallFromViewModel(ref ModViewModelRemoveArgs a) { if (this.attachObjectVM != null) { WeaponModRep weaponModRep = (WeaponModRep)a.modRep; GameObject gameObject = weaponModRep.attached; ViewModelAttachment component = gameObject.GetComponent <ViewModelAttachment>(); if (component) { component.viewModel = null; } Socket socketByName = this.GetSocketByName(a.vm, this.attachSocketName); if (socketByName.attachParent == null) { Transform transforms = socketByName.parent; } if (gameObject) { weaponModRep.SetAttached(null, true); UnityEngine.Object.Destroy(gameObject.gameObject); } } }
public DeviceGroupViewModel() { SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); ViewModelAttachment = new ViewModelAttachment <DeviceGroup>(); }
public TimeSegmentViewModel() { ViewModelAttachment = new ViewModelAttachment <TimeSegment>(); SaveCmd = new RelayCommand(Save); CancelCmd = new RelayCommand(() => Close("")); }