コード例 #1
0
        public BoardPage(OWBoard board) : base()
        {
            Board = board;

            //board.StartLogging();
            InitializeComponent();
            BindingContext = board;

            AppVersionLabel.Text = $"{AppInfo.VersionString} (build {AppInfo.BuildString})";

            ImperialSwitch.IsToggled = !App.Current.MetricDisplay;


            Board.Init();
            // I really don't like this.
            _ = Board.SubscribeToBLE();

            App.Current.OWBLE.BoardDisconnected += OWBLE_BoardDisconnected;
            App.Current.OWBLE.BoardReconnecting += OWBLE_BoardReconnecting;
            App.Current.OWBLE.BoardReconnected  += OWBLE_BoardReconnected;

            // Shift title to the right.
            var titleLabel = GetTitleLabel();

            titleLabel.HorizontalOptions = LayoutOptions.End;
            titleLabel.Padding           = new Thickness(0, 0, 16, 0);


            var settingsToolbarItem = new CustomToolbarItem()
            {
                Position        = CustomToolbarItemPosition.Left,
                IconImageSource = "burger_menu",
                Command         = new Command(() =>
                {
                    PopupNavigation.Instance.PushAsync(SettingsPopupPage);
                }),
            };

            CustomToolbarItems.Add(settingsToolbarItem);
        }
コード例 #2
0
        public BoardListPage() : base()
        {
            InitializeComponent();
            BindingContext = this;

            _scanningView = new Grid()
            {
                HorizontalOptions = LayoutOptions.End,
                ColumnDefinitions = new ColumnDefinitionCollection()
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(26, GridUnitType.Absolute)
                    },
                },
                ColumnSpacing = 18,
            };
            _scanningView.BindingContext = App.Current.OWBLE;
            _scanningView.SetBinding(Grid.IsVisibleProperty, "IsScanning");

            var scanningLabel = new Label()
            {
                Text              = "Scanning...",
                TextColor         = Color.Black,
                FontFamily        = "SairaExtraCondensed-SemiBold",
                FontSize          = 24,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End,
            };

            var scanningActivityIndicator = new ActivityIndicator()
            {
                WidthRequest      = 26,
                HeightRequest     = 26,
                Color             = Color.Black,
                IsRunning         = true,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End,
            };

            Grid.SetColumn(scanningLabel, 0);
            Grid.SetColumn(scanningActivityIndicator, 1);

            _scanningView.Children.Add(scanningLabel);
            _scanningView.Children.Add(scanningActivityIndicator);

            var scanningToolbarItem = new CustomToolbarItem();

            scanningToolbarItem.Content = _scanningView;
            CustomToolbarItems.Add(scanningToolbarItem);

#if DEBUG
            var popupPage = new Rg.Plugins.Popup.Pages.PopupPage();

            // Secret debug menu.
            var debugToolbarItem = new CustomToolbarItem()
            {
                Position        = CustomToolbarItemPosition.Left,
                IconImageSource = "burger_menu",
                Command         = new Command(() =>
                {
                    var debugMenu = new Popup.DebugBoardListPageSettingPopup();

                    PopupNavigation.Instance.PushAsync(debugMenu);
                }),
            };
            CustomToolbarItems.Add(debugToolbarItem);
#endif

            /*
             #if DEBUG
             * var rand = new Random();
             * Boards.Add(new MockOWBoard($"ow{rand.Next(111111, 999999)}", OWBoardType.V1));
             * Boards.Add(new MockOWBoard($"ow{rand.Next(111111, 999999)}", OWBoardType.Plus));
             * Boards.Add(new MockOWBoard($"ow{rand.Next(111111, 999999)}", OWBoardType.XR));
             * Boards.Add(new MockOWBoard($"ow{rand.Next(111111, 999999)}", OWBoardType.Pint));
             * Boards.Add(new MockOWBoard($"ow{rand.Next(111111, 999999)}", OWBoardType.Unknown));
             #endif
             */
        }
コード例 #3
0
ファイル: FormData.cs プロジェクト: yshulin/C1-CMS-Foundation
        /// <exclude />
        public XElement Serialize()
        {
            using (new ThreadCultureScope(CultureInfo.InvariantCulture))
            {
                IXmlSerializer xmlSerializer = new XmlSerializer(new IValueXmlSerializer[] {
                    new SystemPrimitivValueXmlSerializer(),
                    new SystemCollectionValueXmlSerializer(),
                    new SystemTypesValueXmlSerializer(),
                    new CompositeCollectionValueXmlSerializer(),
                    new DataFieldDescriptorValueXmlSerializer(),
                    new DataTypeDescriptorValueXmlSerializer(),
                    new NamedFunctionCallValueXmlSerializer(),
                    new SerializerHandlerValueXmlSerializer(),
                    new SystemSerializableValueXmlSerializer()
                });


                XElement containerLabelElement = new XElement("ContainerLabel");
                if (this.ContainerLabel != null)
                {
                    containerLabelElement.Add(new XAttribute("value", this.ContainerLabel));
                }


                XElement formDefinitionElement = new XElement("FormDefinition");
                if (this.FormDefinition != null)
                {
                    formDefinitionElement.Add(new XAttribute("value", this.FormDefinition));
                }
                else
                {
                    using (XmlReader xmlReader = this.FormMarkupProvider.GetReader())
                    {
                        xmlReader.MoveToContent();
                        XElement  element  = (XElement)XDocument.ReadFrom(xmlReader);
                        XDocument document = new XDocument(element);
                        string    content  = document.GetDocumentAsString();
                        formDefinitionElement.Add(new XAttribute("value", content));
                    }
                }

                XElement customToolBarItems = null;
                if (CustomToolbarItems != null && CustomToolbarItems.Count > 0)
                {
                    customToolBarItems = new XElement(nameof(CustomToolbarItems),
                                                      CustomToolbarItems.Select(tuple => new XElement("item",
                                                                                                      new XAttribute("id", tuple.Item1.ToString()),
                                                                                                      new XAttribute("markup", tuple.Item2.ToString()),
                                                                                                      new XAttribute("priority", (int)tuple.Item3)))
                                                      .OfType <object>()
                                                      .ToArray());
                }

                XElement containerTypeElement = xmlSerializer.Serialize(typeof(IFlowUiContainerType), this.ContainerType);


                Dictionary <string, object> selectedBindings =
                    (from kvp in this.Bindings
                     where (kvp.Value != null &&
                            kvp.Value.GetType() != typeof(System.EventHandler)) ||
                     kvp.Value == null
                     select kvp).ToDictionary(f => f.Key, f => f.Value);
                XElement bindingsElement = xmlSerializer.Serialize(typeof(Dictionary <string, object>), selectedBindings);

                XElement bindingsValidationRulesElement = xmlSerializer.Serialize(typeof(Dictionary <string, List <ClientValidationRule> >), this.BindingsValidationRules);

                XElement excludedEventsElement = xmlSerializer.Serialize(typeof(List <string>), ExcludedEvents);

                var formDataElement = new XElement("FormData",
                                                   containerLabelElement,
                                                   formDefinitionElement,
                                                   customToolBarItems,
                                                   new XElement("ContainerType", containerTypeElement),
                                                   new XElement("Bindings", bindingsElement),
                                                   new XElement("BindingsValidationRules", bindingsValidationRulesElement)
                                                   );

                if (excludedEventsElement != null)
                {
                    formDataElement.Add(new XElement("ExcludedEvents", excludedEventsElement));
                }

                if (this.EventHandleFilterType != null)
                {
                    formDataElement.Add(new XElement("EventHandleFilterType", new XAttribute("type", TypeManager.SerializeType(this.EventHandleFilterType))));
                }

                return(formDataElement);
            }
        }