public MainWindowVM() { ControllerAddress = new PropertyVM <string>("N/A"); _controllerClient.IsWorkingChanged += OnIsWorkingChanged; _controllerSelector.StartBroadcasting(); _controllerSelector.ControllerSelected += async(s, e) => { _controllerClient.Address = _controllerSelector.SelectedControllerAddress; ControllerAddress.Value = _controllerClient.Address; await ConfigurationTab.RefreshAsync(); Dialog = null; }; _controllerSelector.SelectionCanceled += (s, e) => { Application.Current.Shutdown(); }; HomeTab = new HomeTabVM(_controllerClient); ConfigurationTab = new ConfigurationTabVM(_controllerClient, _unhandledExceptionPresenter); HealthTab = new HealthTabVM(_controllerClient); Dialog = _controllerSelector; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (_isEditing) { facade.GetPropertyBySysNo(_editingSysNo, (obj, args) => { PropertyVM vm = new PropertyVM(); vm.SysNo = args.Result.SysNo.Value; vm.PropertyName = args.Result.PropertyName.Content; vm.Status = Convert.ToInt32(args.Result.Status).ToString(); this.DataContext = vm; if (args.Result.Status == PropertyStatus.Active) { dplistPropertyStatus.SelectedIndex = 0; } else { dplistPropertyStatus.SelectedIndex = 1; } }); } else { this.DataContext = new PropertyVM(); dplistPropertyStatus.SelectedIndex = 0; } }
private void btnSave_Click(object sender, RoutedEventArgs e) { PropertyVM vm = this.DataContext as PropertyVM; vm.SysNo = Convert.ToInt32(_editingSysNo); if (vm.SysNo > 0) { facade.UpdateProperty(vm, (obj, args) => { if (args.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert(ResPropertyMaintain.Info_SaveSuccessfully); CloseDialog(DialogResultType.OK); }); } else { facade.CreateProperty(vm, (obj, args) => { if (args.FaultsHandle()) { return; } CPApplication.Current.CurrentPage.Context.Window.Alert(ResPropertyMaintain.Info_SaveSuccessfully); CloseDialog(DialogResultType.OK); }); } }
internal MainWindow(PropertyVM property) { InitializeComponent(); propertyVM = property; propertyVM.SelectedIndex = 0; propertyVM.SelectedController.SelectedZoneIndex = 0; DataContext = propertyVM; }
private PropertyInfo CovertVMtoEntity(PropertyVM data) { PropertyInfo msg = new PropertyInfo(); msg.SysNo = data.SysNo; msg.PropertyName = new LanguageContent(data.PropertyName); msg.Status = data.Status == "有效" ? PropertyStatus.Active : PropertyStatus.DeActive; return(msg); }
public App() { //StartupUri = new Uri("/SprinklerConfig;component/MainWindow.xaml", UriKind.Relative); var sprinklerRepository = new SprinklerRepository(); var propertyVM = new PropertyVM(sprinklerRepository); var w = new MainWindow(propertyVM); //var w = new TestWindow(propertyVM); w.Show(); }
public List <PropertyVM> ConvertCategoryPropertyListToPropertyVMList(IEnumerable <CategoryProperty> categoryPropertyList) { var propertyVMList = new List <PropertyVM>(); categoryPropertyList.ForEach(categoryProperty => { var propertyVM = new PropertyVM(); if (categoryProperty.Property.SysNo.HasValue) { propertyVM.SysNo = categoryProperty.Property.SysNo.Value; propertyVM.PropertyName = categoryProperty.Property.PropertyName.Content; } propertyVMList.Add(propertyVM); }); return(propertyVMList); }
public WeatherStationTabVM(ControllerClient controllerClient) { if (controllerClient == null) { throw new ArgumentNullException(nameof(controllerClient)); } _controllerClient = controllerClient; ApiKey = new PropertyVM <string>(string.Empty); Latitude = new PropertyVM <string>(string.Empty); Longitude = new PropertyVM <string>(string.Empty); RefreshCommand = new AsyncDelegateCommand(Refresh); SaveCommand = new AsyncDelegateCommand(Save); }
public void PropVM_SelectedIndexBoundariesAreRespected(int selectedIndex, bool shouldThrow) { // arrange var controllers = new Controller[] { new Controller { Name = "First" }, new Controller { Name = "Second" } }; var sprinklerRepoMock = new Mock <ISprinklerRepository>(); sprinklerRepoMock.Setup(sr => sr.GetControllers()).Returns(controllers); var subject = new PropertyVM(sprinklerRepoMock.Object); // act Action test = () => { subject.SelectedIndex = selectedIndex; }; // assert if (shouldThrow) { Assert.ThrowsException <IndexOutOfRangeException>(test); } else { test(); if (selectedIndex == -1) { Assert.AreEqual(null, subject.SelectedController); } else { Assert.AreEqual(controllers[selectedIndex], subject.SelectedController.Controller); } } }
public HealthTabVM(ControllerClient controllerClient) { if (controllerClient == null) { throw new ArgumentNullException(nameof(controllerClient)); } TraceItems = new SelectableObservableCollection <TraceItem>(); _controllerClient = controllerClient; _traceItemReceiverClient = new TraceItemReceiverClient(); _traceItemReceiverClient.TraceItemReceived += EnlistTraceItem; _traceItemReceiverClient.Start(); ClearCommand = new DelegateCommand(Clear); AutoScroll = new PropertyVM <bool>(true); ShowVerboseMessages = new PropertyVM <bool>(true); ShowInformations = new PropertyVM <bool>(true); ShowWarnings = new PropertyVM <bool>(true); ShowErrors = new PropertyVM <bool>(true); }
/// <summary> /// 编辑属性 /// </summary> /// <param name="data"></param> /// <param name="callback"></param> public void UpdateProperty(PropertyVM data, EventHandler <RestClientEventArgs <PropertyInfo> > callback) { string relativeUrl = "/IMService/Property/UpdateProperty"; restClient.Update <PropertyInfo>(relativeUrl, CovertVMtoEntity(data), callback); }
public PropertyView() { InitializeComponent(); DataContext = new PropertyVM(); }
public ActionResult Create(PropertyVM mod) { if (ModelState.IsValid) { try { if (mod.SocietyID <= 0) { tblSociety soc = new tblSociety { CityID = mod.CityID, Society = mod.OtherSociety, Status = true }; db.tblSocieties.Add(soc); db.SaveChanges(); mod.SocietyID = soc.SocietyID; } tblProperty tbl = new tblProperty { CityID = mod.CityID, Description = mod.Description, IsFeatured = mod.IsFeatured, LandArea = mod.LandArea, Price = mod.Price, PropertyTitle = mod.PropertyTitle, Purpose = mod.Purpose, SocietyID = mod.SocietyID, Status = "H", TransDate = DateTime.Now.AddHours(12), TypeID = mod.TypeID, UOMID = mod.UOMID, UserID = bl.GetUserID(System.Web.HttpContext.Current), Block = mod.Block, ContactNo = mod.ContactNo, Estate = mod.Estate, IsDealer = mod.IsDealer, Owner = mod.Owner, PlotNo = mod.PlotNo }; db.tblProperties.Add(tbl); db.SaveChanges(); var coun = Request.Files.Count; for (int i = 0; i < coun; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetExtension(file.FileName); tblImage img = new tblImage { PropertyID = tbl.PropertyID, ImagePath = fileName, Status = true }; db.tblImages.Add(img); db.SaveChanges(); var path = Path.Combine(Server.MapPath("~/Images/"), img.ImageID + fileName); file.SaveAs(path); } } return(RedirectToAction("Create")); } catch (Exception) { } } return(View(mod)); }
public ActionResult Edit(PropertyVM mod) { if (ModelState.IsValid) { try { var mo = db.tblProperties.Find(mod.PropertyID); if (mod.SocietyID <= 0) { tblSociety soc = new tblSociety { CityID = mod.CityID, Society = mod.OtherSociety, Status = true }; db.tblSocieties.Add(soc); db.SaveChanges(); mod.SocietyID = soc.SocietyID; } //tblProperty tbl = new tblProperty //{ mo.CityID = mod.CityID; mo.Description = mod.Description; //IsFeatured = mod.IsFeatured; mo.LandArea = mod.LandArea; mo.Price = mod.Price; mo.PropertyTitle = mod.PropertyTitle; mo.Purpose = mod.Purpose; mo.SocietyID = mod.SocietyID; //mo.Status = "H"; //TransDate = DateTime.Now; mo.TypeID = mod.TypeID; mo.UOMID = mod.UOMID; mo.UserID = bl.GetUserID(System.Web.HttpContext.Current); mo.Block = mod.Block; mo.ContactNo = mod.ContactNo; mo.Estate = mod.Estate; mo.IsDealer = mod.IsDealer; mo.Owner = mod.Owner; mo.PlotNo = mod.PlotNo; //}; //db.tblProperties.Add(tbl); db.SaveChanges(); var coun = Request.Files.Count; for (int i = 0; i < coun; i++) { var file = Request.Files[i]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetExtension(file.FileName); tblImage img = new tblImage { PropertyID = mod.PropertyID, ImagePath = fileName, Status = true }; db.tblImages.Add(img); db.SaveChanges(); var path = Path.Combine(Server.MapPath("~/Images/"), img.ImageID + fileName); file.SaveAs(path); //return Json(new { Message = fileName }); } } return(RedirectToAction("Properties", new { ID = mod.Purpose })); } catch (Exception) { } } return(View(mod)); }