Ejemplo n.º 1
0
 private void LightControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue is LightViewModel newLvm)
     {
         viewModel = newLvm;
     }
 }
Ejemplo n.º 2
0
 public static void CreateLight()
 {
     if (_light == null)
     {
         _light = new LightViewModel();
     }
 }
Ejemplo n.º 3
0
        public LightingInfoDialog(LightViewModel lightViewModel)
        {
            InitializeComponent();

            DataContext = lightViewModel;

            BrightnessSlider.Value         = lightViewModel.BrightnessPercentage;
            BrightnessSlider.ValueChanged += BrightnessSlider_ValueChanged;
        }
Ejemplo n.º 4
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var viewmodel = new LightViewModel()
            {
                // FeedBacks = _feedBackRepository.GetAllFeedBacks().ToList(),
                Lights = _lightRepository.GetAllLights().ToList()
            };

            return(View(viewmodel));
        }
    public TrafficLightsViewModel(TrafficLightsSettings settings)
    {
        Lights = new List <LightViewModel>(settings.Lights.Count);

        foreach (var lightSettings in settings.Lights)
        {
            var lightModel = new LightViewModel(lightSettings, settings.DefaultColor);
            Lights.Add(lightModel);
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// Resets the state of the view model by passing in the parameters provided by the
        /// caller.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="Common.NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            defaultViewModel = (LightViewModel)this.DataContext;
            if (e.NavigationParameter is Light)
            {
                // Activated via selecting a trip in the main page's list of trips.
                DefaultViewModel.ShowLight((Light)e.NavigationParameter);
            }
            else if (e.NavigationParameter is LightVoiceCommand)
            {
                // look up destination, set trip.
                LightVoiceCommand voiceCommand = (LightVoiceCommand)e.NavigationParameter;
                DefaultViewModel.LoadLightFromStore(voiceCommand.room);

                // artificially populate the page backstack so we have something to
                // go back to to get to the main page.
                PageStackEntry backEntry = new PageStackEntry(typeof(View.LightListView), null, null);
                this.Frame.BackStack.Add(backEntry);
            }
            else if (e.NavigationParameter is string)
            {
                // We've been URI Activated, possibly by a user clicking on a tile in a Cortana session,
                // we should see an argument like destination=<Location>.
                // This should handle finding all of the destinations that match, but currently it only
                // finds the first one.
                string arguments = e.NavigationParameter as string;
                if (arguments != null)
                {
                    string[] args = arguments.Split('=');
                    if (args.Length == 2 && args[0].ToLowerInvariant() == "room")
                    {
                        DefaultViewModel.LoadLightFromStore(args[1]);

                        // artificially populate the page backstack so we have something to
                        // go back to to get to the main page.
                        PageStackEntry backEntry = new PageStackEntry(typeof(View.LightListView), null, null);
                        this.Frame.BackStack.Add(backEntry);
                    }
                }
            }
            else
            {
                DefaultViewModel.NewLight();
            }
        }
Ejemplo n.º 7
0
        public IActionResult Light([Bind("Light")] LightViewModel viewModel)
        {
            if (!string.IsNullOrEmpty(viewModel.Light))
            {
                TempData["Light"] = viewModel.Light;

                _redirectToCheckAnswers = (int)TempData["CheckAnswers"];

                if (_redirectToCheckAnswers == 4)
                {
                    return(RedirectToAction("CheckAnswers"));
                }

                return(RedirectToAction("Brightness"));
            }

            return(View("LightError", viewModel));
        }
        public static LightViewModel GetLightSettings(string settingName)
        {
            var    model       = new LightViewModel();
            string settingFile = ConfigurationManager.AppSettings["LightSettings"] ?? "";

            if (File.Exists(settingFile))
            {
                //read
                var xDoc = XDocument.Load(settingFile);
                if (xDoc != null)
                {
                    var lightDTOs = xDoc.Root.Element(settingName).Elements("Settings").Select(p => new LightDTO()
                    {
                        Channel   = p.Element("Channel").Value,
                        Intensity = p.Element("Intensity").Value,
                        OnOff     = p.Element("OnOff").Value,
                    }).ToList();
                    model.LightDTOs = new List <LightDTO>(lightDTOs);
                }
            }
            return(model);
        }
Ejemplo n.º 9
0
 public static void ClearLight()
 {
     _light.Cleanup();
     _light = null;
 }
Ejemplo n.º 10
0
 public void SetViewModel(LightViewModel viewModel)
 {
     this.viewModel = viewModel;
 }
Ejemplo n.º 11
0
 public static void CreateLight()
 {
     if (_light == null)
     {
         _light = new LightViewModel();
     }
 }
Ejemplo n.º 12
0
 public static void ClearLight()
 {
     _light.Cleanup();
     _light = null;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates the base camera view with the internal view
 /// </summary>
 /// <param name="dataContext">view model</param>
 /// <param name="internalView">camera type dependent view</param>
 public LightView(LightViewModel dataContext, UIElement internalView)
 {
     InitializeComponent();
     DataContext = dataContext;
     GroupItems.Children.Add(internalView);
 }