Exemple #1
0
        /// <summary>
        /// Go back to the previous openHAB widget
        /// </summary>
        /// <returns>The previous visted widget</returns>
        public static OpenHABWidget GoBack()
        {
            WidgetBackStack.Pop();
            _currentWidget = WidgetBackStack.Count == 0 ? null : WidgetBackStack.Peek();

            return(_currentWidget);
        }
Exemple #2
0
        private WidgetTypeEnum GetItemViewType(OpenHABWidget openHABWidget)
        {
            if (openHABWidget.Type.Equals("Switch"))
            {
                if (openHABWidget.Mappings != null && openHABWidget.Mappings.Any())
                {
                    return(WidgetTypeEnum.SectionSwitch);
                }

                if (openHABWidget.Item != null)
                {
                    if (openHABWidget.Item.Type != null)
                    {
                        // RollerShutterItem changed to RollerShutter in later builds of OH2
                        if ("RollershutterItem".Equals(openHABWidget.Item.Type) ||
                            "Rollershutter".Equals(openHABWidget.Item.Type) ||
                            "Rollershutter".Equals(openHABWidget.Item.GroupType))
                        {
                            return(WidgetTypeEnum.RollerShutter);
                        }

                        return(WidgetTypeEnum.Switch);
                    }

                    return(WidgetTypeEnum.Switch);
                }

                return(WidgetTypeEnum.Switch);
            }

            if (openHABWidget.Type.Equals("Video"))
            {
                if (openHABWidget.Encoding != null)
                {
                    if (openHABWidget.Encoding.Equals("mjpeg"))
                    {
                        return(WidgetTypeEnum.VideoMjpeg);
                    }

                    return(WidgetTypeEnum.Video);
                }

                return(WidgetTypeEnum.Video);
            }

            try
            {
                return(Enum <WidgetTypeEnum> .Parse(openHABWidget.Type));
            }
            catch (System.Exception ex)
            {
                return(WidgetTypeEnum.Generic);
            }

            return(WidgetTypeEnum.Generic);
        }
Exemple #3
0
        /// <summary>
        /// Navigates the backstack to the passed in target
        /// </summary>
        /// <param name="target">The openHAB widget to navigate to</param>
        public static void Navigate(OpenHABWidget target)
        {
            if (target == _currentWidget)
            {
                return;
            }

            WidgetBackStack.Push(target);
            _currentWidget = target;
        }
        /// <summary>
        /// Go back to the previous openHAB widget
        /// </summary>
        /// <returns>The previous visted widget</returns>
        public static OpenHABWidget GoBack()
        {
            OpenHABWidget backStackEntry = WidgetBackStack.LastOrDefault();

            WidgetBackStack.Remove(backStackEntry);

            _currentWidget = WidgetBackStack.Count == 0 ? null : backStackEntry;

            return(backStackEntry);
        }
Exemple #5
0
        private void OnWidgetClicked(OpenHABWidget widget)
        {
            SelectedWidget = widget;
            if (SelectedWidget.LinkedPage == null || !SelectedWidget.LinkedPage.Widgets.Any())
            {
                return;
            }

            WidgetNavigationService.Navigate(SelectedWidget);
            SetWidgetsOnScreen(SelectedWidget?.LinkedPage?.Widgets);
        }
Exemple #6
0
        /// <summary>
        /// Navigate backwards between linkedpages
        /// </summary>
        public void WidgetGoBack()
        {
            OpenHABWidget widget = WidgetNavigationService.GoBack();

            SetWidgetsOnScreen(widget != null ? widget.LinkedPage.Widgets : SelectedSitemap.Widgets);
        }
        private string GetItemViewType(OpenHABWidget openHABWidget)
        {
            if (openHABWidget.Type.Equals("Frame"))
            {
                return("frame");
            }

            if (openHABWidget.Type.Equals("Group"))
            {
                return("group");
            }

            if (openHABWidget.Type.Equals("Switch"))
            {
                if (openHABWidget.Mappings != null && openHABWidget.Mappings.Any())
                {
                    return("sectionswitch");
                }

                if (openHABWidget.Item != null)
                {
                    if (openHABWidget.Item.Type != null)
                    {
                        // RollerShutterItem changed to RollerShutter in later builds of OH2
                        if ("RollershutterItem".Equals(openHABWidget.Item.Type) ||
                            "Rollershutter".Equals(openHABWidget.Item.Type) ||
                            "Rollershutter".Equals(openHABWidget.Item.GroupType))
                        {
                            return("rollershutter");
                        }

                        return("switch");
                    }

                    return("switch");
                }

                return("switch");
            }

            if (openHABWidget.Type.Equals("Text"))
            {
                return("text");
            }

            if (openHABWidget.Type.Equals("Slider"))
            {
                return("slider");
            }

            if (openHABWidget.Type.Equals("Image"))
            {
                return("image");
            }

            if (openHABWidget.Type.Equals("Selection"))
            {
                return("selection");
            }

            if (openHABWidget.Type.Equals("Setpoint"))
            {
                return("setpoint");
            }

            if (openHABWidget.Type.Equals("Chart"))
            {
                return("chart");
            }

            if (openHABWidget.Type.Equals("Video"))
            {
                if (openHABWidget.Encoding != null)
                {
                    if (openHABWidget.Encoding.Equals("mjpeg"))
                    {
                        return("video_mjpeg");
                    }

                    return("video");
                }

                return("video");
            }

            if (openHABWidget.Type.Equals("Webview"))
            {
                return("web");
            }

            if (openHABWidget.Type.Equals("Colorpicker"))
            {
                return("color");
            }

            return("generic");
        }
 /// <summary>
 /// Clears and resets the widget navigation.
 /// </summary>
 public static void ClearWidgetNavigation()
 {
     _currentWidget = null;
     WidgetBackStack.Clear();
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WidgetClickedMessage"/> class.
 /// </summary>
 /// <param name="widget">The widget that was clicked.</param>
 public WidgetClickedMessage(OpenHABWidget widget)
 {
     Widget = widget;
 }