private ImageEditor(string filename, Size size, bool allowNoCrop, Rect?startRect) { _model = new CropModel { TargetWidth = size.Width, TargetHeight = size.Height }; DataContext = this; InitializeComponent(); Buttons = new[] { allowNoCrop?CreateExtraDialogButton(AppStrings.CropImage_Skip, new DelegateCommand(() => { Result = (BitmapSource)_image.ImageSource; ResultRect = new Int32Rect(0, 0, _image.Width, _image.Height); ResultRectRelative = new Rect(0d, 0d, 1d, 1d); Close(); }, () => !_image.IsBroken)) : null, CreateCloseDialogButton(UiStrings.Ok, true, false, MessageBoxResult.OK, new DelegateCommand(() => { var rect = new Int32Rect((int)_model.OffsetX, (int)_model.OffsetY, (int)_model.ImageWidth, (int)_model.ImageHeight); ResultRect = rect; ResultRectRelative = new Rect( (double)rect.X / _image.Width, (double)rect.Y / _image.Height, (double)rect.Width / _image.Width, (double)rect.Height / _image.Height); var cropped = new CroppedBitmap((BitmapSource)_image.ImageSource, rect); Result = cropped.Resize((int)_model.TargetWidth, (int)_model.TargetHeight); }, () => !_image.IsBroken)), CancelButton }; LoadImage(filename, startRect).Forget(); UpdateControlsToScale(); }
public override void Start() { base.Start(); TargetModel = GetComponent <CropModel>(); TargetController = GetComponent <CropController>(); LevelName = GameManager.Instance.LevelName; }
void Apply() { TargetModel = GetComponent <CropModel>(); TargetController = GetComponent <CropController>(); VariableName = name + LevelName + transform.position.x.ToString("F2") + transform.position.ToString("F2"); TargetController.Plot = GetPlot(transform.position); TargetModel.CurrentStage = DialogueLua.GetVariable(VariableName + "CurrentStage").asInt; TargetModel.CurrentStageGrowth = DialogueLua.GetVariable(VariableName + "CurrentStageGrowth").asInt; TargetModel.WateredToday = DialogueLua.GetVariable(VariableName + "WateredToday").asBool; TargetModel.CurrentlyWatered = DialogueLua.GetVariable(VariableName + "CurrentlyWatered").asBool; TargetModel.StageWaterLevel = DialogueLua.GetVariable(VariableName + "StageWaterLevel").asInt; TargetModel.StageSunLevel = DialogueLua.GetVariable(VariableName + "StageSunLevel").asInt; TargetModel.CurrentWilt = DialogueLua.GetVariable(VariableName + "CurrentWilt").asInt; TargetModel.Quality = DialogueLua.GetVariable(VariableName + "Quality").asFloat; TargetModel.TimeSinceWatered = DialogueLua.GetVariable(VariableName + "TimeSinceWatered").asInt; print("Plot: " + TargetController.Plot); TargetController.Plot.Crop = TargetController; TargetController.Load(); }
public ActionResult DeleteConfirmed(int id) { CropModel cropModel = db.CropModels.Find(id); db.CropModels.Remove(cropModel); db.SaveChanges(); return(RedirectToAction("Index")); }
void initialize() { crop = new CropModel(); soil = new SoilModel(); crop.initialize(); soil.initialize(); // set starting date & simulation config this.startdoy = 120; this.lastdoy = 330; }
public ActionResult Edit([Bind(Include = "Id,Name,CropTypeId")] CropModel cropModel) { if (ModelState.IsValid) { db.Entry(cropModel).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CropTypeId = new SelectList(db.CropTypeModels, "CropTypeId", "Type", cropModel.CropTypeId); return(View(cropModel)); }
public ActionResult Create([Bind(Include = "Id,Name,CropTypeId")] CropModel cropModel) { if (ModelState.IsValid) { db.CropModels.Add(cropModel); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CropTypeId = new SelectList(db.CropTypeModels, "CropTypeId", "Type", cropModel.CropTypeId); return(View(cropModel)); }
// GET: Crop/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropModel cropModel = db.CropModels.Find(id); if (cropModel == null) { return(HttpNotFound()); } return(View(cropModel)); }
public ActionResult CreateUpdateCrop(Int32 id) { var cropModel = new CropModel(); cropModel.CropStartDate = cropModel.CropEndDate = DateTime.Now; if (id > 0) { var crop = FarmManagementEntities.CropManagements.Single(x => x.Id == id); cropModel = crop.ToType <CropManagement, CropModel>(); } return(PartialView("CropPartial", cropModel)); }
public HydroService(ref DatabaseDriver databaseDriver) : base(ref databaseDriver) { accountModel = new AccountModel(ref databaseDriver); adminDeptModel = new AdminDeptModel(ref databaseDriver); cropModel = new CropModel(ref databaseDriver); dryEarthModel = new DryEarthModel(ref databaseDriver); irrigationAreaModel = new IrrigationAreaModel(ref databaseDriver); inflowPredictionModel = new InflowPredictionModel(ref databaseDriver); irrigationInstitutionModel = new IrrigationInstitutionModel(ref databaseDriver); roundOrderInfoModel = new RoundOrderInfoModel(ref databaseDriver); inflowHistoryModel = new InflowHistoryModel(ref databaseDriver); irrigationMethodModel = new IrrigationMethodModel(ref databaseDriver); }
// GET: Crop/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CropModel cropModel = db.CropModels.Find(id); if (cropModel == null) { return(HttpNotFound()); } ViewBag.CropTypeId = new SelectList(db.CropTypeModels, "CropTypeId", "Type", cropModel.CropTypeId); return(View(cropModel)); }
public void OnRecordPersistentData() { // print("RECORD"); TargetModel = GetComponent <CropModel>(); TargetController = GetComponent <CropController>(); VariableName = name + LevelName + transform.position.x.ToString("F2") + transform.position.ToString("F2"); DialogueLua.SetVariable(VariableName + "CurrentStage", TargetModel.CurrentStage); DialogueLua.SetVariable(VariableName + "CurrentStageGrowth", TargetModel.CurrentStageGrowth); DialogueLua.SetVariable(VariableName + "WateredToday", TargetModel.WateredToday); DialogueLua.SetVariable(VariableName + "CurrentlyWatered", TargetModel.CurrentlyWatered); DialogueLua.SetVariable(VariableName + "StageWaterLevel", TargetModel.StageWaterLevel); DialogueLua.SetVariable(VariableName + "StageSunLevel", TargetModel.StageSunLevel); DialogueLua.SetVariable(VariableName + "CurrentWilt", TargetModel.CurrentWilt); DialogueLua.SetVariable(VariableName + "Quality", TargetModel.Quality); DialogueLua.SetVariable(VariableName + "TimeSinceWatered", TargetModel.TimeSinceWatered); }
public ImageEditor(string filename, Size size) { _model = new CropModel { TargetWidth = size.Width, TargetHeight = size.Height }; DataContext = this; InitializeComponent(); Buttons = new[] { CreateExtraDialogButton(AppStrings.CropImage_Skip, () => { Result = _image; Close(); }), OkButton, CancelButton }; _image = new BitmapImage(); _image.BeginInit(); _image.UriSource = new Uri(filename); _image.EndInit(); OriginalImage.SetCurrentValue(Image.SourceProperty, _image); if (_image.IsDownloading) { _image.DownloadCompleted += Image_Loaded; } else { Image_Loaded(this, null); } Closing += (sender, args) => { if (MessageBoxResult != MessageBoxResult.OK) return; var rect = new Int32Rect((int) _model.OffsetX, (int) _model.OffsetY, (int) _model.ImageWidth, (int) _model.ImageHeight); var cropped = new CroppedBitmap(_image, rect); Result = cropped.Resize((int) _model.TargetWidth, (int) _model.TargetHeight); }; }
public ActionResult CreateUpdateCrop(CropModel cropModel) { if (!ModelState.IsValid) { return(ShowErrorMessage(GetModelErrors(ModelState))); } var crop = new CropManagement(); if (cropModel.Id > 0) { crop = FarmManagementEntities.CropManagements.Single(x => x.Id == cropModel.Id); } crop.FarmId = cropModel.FarmId; crop.AreaId = cropModel.AreaId; crop.CropName = cropModel.CropName; crop.CropDuration = cropModel.CropDuration; crop.CropStartDate = cropModel.CropStartDate; crop.CropEndDate = cropModel.CropEndDate; if (cropModel.Id == 0) { crop.InsertDate = DateTime.Now; FarmManagementEntities.CropManagements.Add(crop); } else { crop.UpdateDate = DateTime.Now; } FarmManagementEntities.SaveChanges(); var message = string.Format(Constant.SuccessMessage, cropModel.Id > 0 ? "updated" : "added"); return(ShowSuccessMessage(message)); }