Ejemplo n.º 1
0
        // GET: Pivots/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Pivot irrigationUnit = db.Pivots.Find(id);

            if (irrigationUnit == null)
            {
                return(HttpNotFound());
            }

            PivotViewModel vm = new PivotViewModel();

            vm.IrrigationUnitId     = irrigationUnit.IrrigationUnitId;
            vm.ShortName            = irrigationUnit.ShortName;
            vm.Name                 = irrigationUnit.Name;
            vm.Bomb                 = new BombViewModel(irrigationUnit.Bomb);
            vm.Farm                 = irrigationUnit.Farm;
            vm.Position             = irrigationUnit.Position;
            vm.Latitude             = irrigationUnit.Position.Latitude;
            vm.Longitude            = irrigationUnit.Position.Longitude;
            vm.IrrigationEfficiency = irrigationUnit.IrrigationEfficiency;
            vm.IrrigationType       = irrigationUnit.IrrigationType;
            vm.PredeterminatedIrrigationQuantity = irrigationUnit.PredeterminatedIrrigationQuantity;
            vm.Surface = irrigationUnit.Surface;
            vm.Show    = irrigationUnit.Show;
            vm.Radius  = irrigationUnit.Radius;

            return(View("~/Views/Irrigation/Pivots/Details.cshtml", vm));
        }
Ejemplo n.º 2
0
        public MainPage()
        {
            var appView = ApplicationView.GetForCurrentView();

            appView.TitleBar.ButtonBackgroundColor = appView.TitleBar.InactiveBackgroundColor = appView.TitleBar.ButtonInactiveBackgroundColor = appView.TitleBar.BackgroundColor = "#2196f3".GetColor();
            //ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.Auto;
            ApplicationView.PreferredLaunchViewSize      = new Size(ScreenResolution.Width * 0.85, ScreenResolution.Height * 0.85);
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;

            //var titleBar = CoreApplication.GetCurrentView().TitleBar;

            InitializeComponent();

            Main      = this;
            PivotView = new PivotViewModel();

            HideButton = hideButton;

            DataContext = PivotView;

            if (Site.IsLogin)
            {
                PivotView.Add("主页", new HomePage());
            }
            //else
            //{
            //    Site.OnLogined += User_OnLogined;
            //    Site.Login();
            //}
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "IrrigationUnitId,ShortName,IrrigationType,IrrigationEfficiency,PredeterminatedIrrigationQuantity, Surface,FarmId, BombId, Latitude,Longitude, Show, Radius")] PivotViewModel pivotViewModel)
        {
            if (ModelState.IsValid)
            {
                Pivot irrigationUnit = new Pivot();



                long     positionId = GetPositionId(pivotViewModel.Latitude, pivotViewModel.Longitude);
                Position positionIU = new Position();
                //Not exist position
                if (positionId == 0)
                {
                    positionIU.Latitude     = pivotViewModel.Position.Latitude;
                    positionIU.Longitude    = pivotViewModel.Longitude;
                    positionIU.Name         = pivotViewModel.Farm.Name + " - " + pivotViewModel.Name + " - Unidad de riego";
                    irrigationUnit.Position = positionIU;
                }
                else
                {
                    irrigationUnit.PositionId = positionId;
                }

                Farm farm = db.Farms.Find(pivotViewModel.FarmId);
                if (farm == null)
                {
                    return(HttpNotFound());
                }

                irrigationUnit.ShortName            = pivotViewModel.ShortName;
                irrigationUnit.Name                 = farm.Name + " - " + pivotViewModel.ShortName;
                irrigationUnit.BombId               = pivotViewModel.BombId;
                irrigationUnit.FarmId               = pivotViewModel.FarmId;
                irrigationUnit.IrrigationEfficiency = pivotViewModel.IrrigationEfficiency;
                irrigationUnit.IrrigationType       = pivotViewModel.IrrigationType;
                irrigationUnit.PredeterminatedIrrigationQuantity = pivotViewModel.PredeterminatedIrrigationQuantity;
                irrigationUnit.Surface        = pivotViewModel.Surface;
                irrigationUnit.Show           = pivotViewModel.Show;
                irrigationUnit.Radius         = pivotViewModel.Radius;
                irrigationUnit.IrrigationType = Utils.IrrigationUnitType.Pivot;
                db.Pivots.Add(irrigationUnit);
                db.SaveChanges();
            }
            return(Redirect("/IrrigationUnit"));
            //var lList = db.IrrigationUnits.Include(f => f.Farm);
            //return View("~/Views/Irrigation/Pivot/Index.cshtml", lList.ToList());
        }
Ejemplo n.º 4
0
        public ActionResult Edit([Bind(Include = "IrrigationUnitId,ShortName,IrrigationType,IrrigationEfficiency,PredeterminatedIrrigationQuantity, Surface,FarmId, BombId, Latitude, Longitude, Show, Radius")] PivotViewModel pivotViewModel)
        {
            if (ModelState.IsValid)
            {
                Pivot lPivot = db.Pivots.Find(pivotViewModel.IrrigationUnitId);

                long     positionId = GetPositionId(pivotViewModel.Latitude, pivotViewModel.Longitude);
                Position lPosition  = new Position();
                //Not exist position
                if (positionId == 0)
                {
                    lPosition.Latitude  = pivotViewModel.Latitude;
                    lPosition.Longitude = pivotViewModel.Longitude;
                    lPosition.Name      = pivotViewModel.Farm.Name + " - " + pivotViewModel.Name + " - Unidad de riego";
                    lPivot.Position     = lPosition;
                }
                else
                {
                    lPivot.PositionId = positionId;
                }
                lPivot.ShortName            = pivotViewModel.ShortName;
                lPivot.BombId               = pivotViewModel.BombId;
                lPivot.FarmId               = pivotViewModel.FarmId;
                lPivot.IrrigationEfficiency = pivotViewModel.IrrigationEfficiency;
                lPivot.PredeterminatedIrrigationQuantity = pivotViewModel.PredeterminatedIrrigationQuantity;
                lPivot.Surface = pivotViewModel.Surface;
                lPivot.Show    = pivotViewModel.Show;
                lPivot.Radius  = pivotViewModel.Radius;
                // lPivot.IrrigationType = Utils.IrrigationUnitType.Sprinkler;
                db.Entry(lPivot).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Redirect("/IrrigationUnit"));
            //var lList = db.IrrigationUnits.Include(f => f.Farm);
            //return View("~/Views/Irrigation/IrrigationUnit/Index.cshtml", lList.ToList());
        }
Ejemplo n.º 5
0
        private static async void ClosePiovt(FrameworkElement sources)
        {
            try
            {
                PivotHeaderItem  item  = sources.GetParentControl <PivotHeaderItem>();
                PivotHeaderPanel panel = sources.GetParentControl <PivotHeaderPanel>();

                for (int i = 0; i < panel.Children.Count; i++)
                {
                    var child = panel.Children[i];
                    if (child == item)
                    {
                        PivotViewModel pivot = sources.GetParentControl <Pivot>().DataContext as PivotViewModel;
                        pivot.RemoveAt(i);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDialog messageDialog = new MessageDialog(ex.Message);
                await messageDialog.ShowAsync();
            }
        }
Ejemplo n.º 6
0
 public static void AddSelect(this PivotViewModel pivot, string head, object content)
 {
     MainPage.HideButton.Focus(FocusState.Pointer);
     pivot.Add(head, content);
 }