Beispiel #1
0
        public TextBox(FleuxControlPage settingsPage)
        {
            _settingsPage = settingsPage;
            _text = "";
            MultiLine = false;

            Style = new TextStyle(MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeNormal,
                          MetroTheme.PhoneTextBoxFontBrush);

            TapHandler += point => OnTap();
        }
        public ScreenAppointment(Size _size, bool _white)
        {
            this.Size = _size;
            _listAppointment.Clear(); _indexAppointment = 0;
            _typeColorIcon = "white";
            if (!_white) _typeColorIcon = "black";

            var _style = new TextStyle(_fontName, _fontSize.ToLogic(), _fontColor);
            var _height = FleuxApplication.DummyDrawingGraphics.Style(_style).CalculateMultilineTextHeight("0", 100);

            this.AddElement(_textLocation = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset,_height * 0),
                Size = new Size(this.Size.Width - leftOffset - rightOffset,_height),
                Style = _style,
            });

            this.AddElement(_textSubject = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset, _height * 1),
                Size = new Size(this.Size.Width - leftOffset - rightOffset, _height),
                Style = _style,
            });

            this.AddElement(_textTime = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset, _height * 2),
                Size = new Size(this.Size.Width - leftOffset - rightOffset - 100, _height),
                Style = _style,
            });

            this.AddElement(_textCount = new TextElementAdvanced("")
            {
                Location = new Point(this.Size.Width - 100 + 60, _height * 2),
                Size = new Size(100 - 60, _height),
                Style = _style,
            });

            this.Size = new Size(_size.Width, _height * 3);
        }
Beispiel #3
0
        public HOBDTheme()
        {
            PhoneTextBlockBase = new TextStyle(
                this.PhoneFontFamilyNormal,
                this.PhoneFontSizeSmall,
                this.PhoneTextBoxBrush,
                this.PhoneHorizontalMargin);

            PhoneTextNormalStyle = new TextStyle(
                this.PhoneFontFamilyNormal,
                this.PhoneFontSizeNormal,
                this.PhoneForegroundBrush);

            PhoneTextTitle1Style =  new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeExtraExtraLarge,
                this.PhoneForegroundBrush);

            PhoneTextTitle2Style = new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeLarge,
                this.PhoneForegroundBrush);

            PhoneTextTitle3Style = new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeMedium,
                this.PhoneForegroundBrush);

            PhoneTextLargeStyle = new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeLarge,
                this.PhoneForegroundBrush);

            PhoneTextExtraLargeStyle = new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeExtraLarge,
                this.PhoneForegroundBrush);

            PhoneTextGroupHeaderStyle = new TextStyle(
                this.PhoneFontFamilySemiLight,
                this.PhoneFontSizeLarge,
                this.PhoneSubtleBrush);

            PhoneTextSmallStyle = new TextStyle(
                this.PhoneFontFamilyNormal,
                this.PhoneFontSizeSmall,
                this.PhoneSubtleBrush);

            PhoneTextContrastStyle = new TextStyle(
                this.PhoneFontFamilySemiBold,
                this.PhoneFontSizeNormal,
                this.PhoneContrastForegroundBrush);

            PhoneTextAccentStyle = new TextStyle(
                this.PhoneFontFamilySemiBold,
                this.PhoneFontSizeNormal,
                this.PhoneAccentBrush);

            PhoneTextPageTitleStyle = new TextStyle(this.PhoneFontFamilyLight, PhoneFontSizeExtraExtraLarge, this.PhoneSubtleBrush);

            PhoneTextPageSubTitleStyle = new TextStyle(this.PhoneFontFamilyLight, this.PhoneFontSizeLarge, this.PhoneForegroundBrush);

            PhoneTextPanoramaTitleStyle = new TextStyle(this.PhoneFontFamilyLight, 65, this.PhoneSubtleBrush);

            PhoneTextPanoramaSubTitleStyle = new TextStyle(this.PhoneFontFamilyLight, PhoneFontSizeExtraLarge, this.PhoneSubtleBrush);

            PhoneTextPanoramaSectionTitleStyle = new TextStyle(this.PhoneFontFamilyLight, this.PhoneFontSizeExtraLarge, this.PhoneForegroundBrush);

            PhoneTextStatusStyle = new TextStyle(this.PhoneFontFamilyLight, this.PhoneFontSizeSmall, this.PhoneSubtleBrush);

            PhoneTextSensorDescrStyle = new TextStyle(this.PhoneFontFamilyLight, this.PhoneFontSizeSmall, Color.FromArgb( unchecked( (int)0xC0A09090 )));
        }
Beispiel #4
0
        public static HOBDTheme LoadTheme(string file)
        {
            HOBDTheme theme = new HOBDTheme();

            theme.File = file;

            XmlReaderSettings xrs = new XmlReaderSettings();
            xrs.IgnoreWhitespace = true;
            xrs.IgnoreComments = true;

            try{
            XmlReader reader = XmlReader.Create(file, xrs);

            reader.ReadToDescendant("theme");

            theme.Name = reader.GetAttribute("name");
            theme.Background = reader.GetAttribute("background");

            reader.ReadStartElement("theme");

            while(true){
                if (reader.NodeType != XmlNodeType.Element){
                    if (!reader.Read())
                        break;
                    continue;
                }
                string name;
                string val;
                int ival;
                switch (reader.Name) {
                    case "color":
                        name = reader.GetAttribute("name");
                        val = reader.ReadElementContentAsString();
                        theme.Colors.Add(name, Color.FromArgb(ParseColor(val)));
                        break;
                    case "font-size":
                        name = reader.GetAttribute("name");
                        val = reader.GetAttribute("value");
                        ival = Int32.Parse(val, NumberStyles.Integer);
                        theme.FontSizes.Add(name, ival);
                        reader.Read();
                        break;
                    case "font-family":
                        name = reader.GetAttribute("name");
                        val = reader.ReadElementContentAsString();
                        theme.FontFamilies.Add(name, val);
                        break;
                    case "style":
                        name = reader.GetAttribute("name");

                        TextStyle style = new TextStyle(theme.PhoneTextNormalStyle);

                        reader.ReadStartElement();
                        while(reader.NodeType != XmlNodeType.EndElement){
                            if (reader.NodeType != XmlNodeType.Element)
                                continue;

                            switch (reader.Name) {
                                case "font":
                                    val = reader.ReadElementContentAsString();
                                    theme.FontFamilies.TryGetValue(val, out val);
                                    style.FontFamily = val;
                                    break;
                                case "size":
                                    val = reader.ReadElementContentAsString();
                                    if (!theme.FontSizes.TryGetValue(val, out ival)){
                                        ival = Int32.Parse(val);
                                    }
                                    style.FontSize = ival;
                                    break;
                                case "color":
                                    val = reader.ReadElementContentAsString();
                                    Color color;
                                    if (!theme.Colors.TryGetValue(val, out color)){
                                        color = Color.FromArgb(ParseColor(val));
                                    }
                                    style.Foreground = color;
                                    break;
                            }
                        }
                        reader.ReadEndElement();
                        theme.Styles.Add(name, style);
                        break;
                    default:
                        reader.Read();
                        break;
                }
            }
            reader.Close();

            theme.Styles.TryGetValue("PanoramaTitle", out theme.PhoneTextPanoramaTitleStyle);
            theme.Styles.TryGetValue("PanoramaSubTitle", out theme.PhoneTextPanoramaSubTitleStyle);
            theme.Styles.TryGetValue("PanoramaSectionTitle", out theme.PhoneTextPanoramaSectionTitleStyle);

            theme.Styles.TryGetValue("TextNormal", out theme.PhoneTextNormalStyle);
            theme.Styles.TryGetValue("TextStatus", out theme.PhoneTextStatusStyle);
            theme.Styles.TryGetValue("TextSensorDescr", out theme.PhoneTextSensorDescrStyle);

            }catch(Exception e){
            Logger.error("HOBDTheme", "error parsing theme file", e);
            }

            return theme;
        }
        protected void CreateItems()
        {
            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);

            if (grid != null) {
                this.Remove(grid);
            }

            int height = LayoutY/6;
            grid = new Grid
                {
                    Columns = new MeasureDefinition[] { LayoutX/3, LayoutX/3, LayoutX/3 },
                    Rows = new MeasureDefinition[] { height, height, height, height, height, height }
                };

            int idx = 0, idx2 = 0;

            foreach(var p in SerialPort.GetPortNames().OrderBy(s => s))
            {
                var label = p;

                if (string.Compare(HOBD.config.Port, p, true) == 0){
                    label = ">> " + label;
                }

                var e = new IconTextElement("icon_com.png", label){ HandleTapAction = OnChoosePort };

                portMapping.Add(e, p);

                grid[idx++, idx2] = e;
                if (idx >= grid.Rows.Length){
                    idx = 0;
                    idx2++;
                }
                if (idx2 >= grid.Columns.Length)
                    return;
            }

            uiBTScan = new IconTextElement("icon_bt.png", HOBD.t("Scan Again")){ HandleTapAction = OnBluetoothScan};
            grid[idx++, idx2] = uiBTScan;
            if (idx >= grid.Rows.Length){
                idx = 0;
                idx2++;
            }

            foreach(var di in bluetoothDeviceInfo)
            {
                var label = di.DeviceName;

                var p = "btspp://" + di.DeviceAddress.ToString();
                if (HOBD.config.Port.StartsWith(p)){
                    label = ">> " + label;
                }

                var e = new IconTextElement("icon_bt.png", label){ HandleTapAction = OnChoosePort};

                portMapping.Add(e, p);

                grid[idx++, idx2] = e;
                if (idx >= grid.Rows.Length){
                   idx = 0;
                   idx2++;
                }
                if (idx2 >= grid.Columns.Length)
                    return;
            }
            this.Add(grid, 0, 0, LayoutX, LayoutY);
        }
Beispiel #6
0
        public ScreenMedia(Size _size, bool _white)
        {
            this.Size = _size;

            _state.Title = "";
            _state.Album = "";
            _state.Artist = "";
            _state.Cover = "";
            _state.Status = _StatusPlay.Unknown;
            _state.Run = false;
            _state.Volume = 0;
            _state.PlayerName = "";

            _typeColorIcon = "white";
            if (!_white) _typeColorIcon = "black";

            var _dx = _size.Width / 4;

            this.AddElement(_buttonPrev = new TransparentButton(_typeColorIcon + "_rew.png")
            {
                Location = new Point(_dx / 2 + _dx * 0 - 24, _size.Height - 48),
                Size = new Size(48,48),
                TapHandler = p => OnButtonTap(0),
            });

            this.AddElement(_buttonPause = new TransparentButton(_typeColorIcon + "_pause.png")
            {
                Location = new Point(_dx / 2 + _dx * 1 - 24, _size.Height - 48),
                Size = new Size(48, 48),
                TapHandler = p => OnButtonTap(1),
            });

            this.AddElement(_buttonPlay = new TransparentButton(_typeColorIcon + "_play.png")
            {
                Location = new Point(_dx / 2 + _dx * 2 - 24, _size.Height - 48),
                Size = new Size(48, 48),
                TapHandler = p => OnButtonTap(2),
            });

            this.AddElement(_buttonNext = new TransparentButton(_typeColorIcon + "_next.png")
            {
                Location = new Point(_dx / 2 + _dx * 3 - 24, _size.Height - 48),
                Size = new Size(48, 48),
                TapHandler = p => OnButtonTap(3),
            });

            var _style = new TextStyle(_fontName, _fontSize.ToLogic(), _fontColor);
            var _height = FleuxApplication.DummyDrawingGraphics.Style(_style).CalculateMultilineTextHeight("0", 100);

            this.AddElement(_textTitle = new TextElementAdvanced("")
            {
                Location = new Point(10, _buttonNext.Location.Y - _height * 3),
                Size = new Size(_size.Width - 20, _height),
                Style = _style,
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Center,
            });

            this.AddElement(_textAlbum = new TextElementAdvanced("")
            {
                Location = new Point(10, _buttonNext.Location.Y - _height * 1),
                Size = new Size(_size.Width - 20, _height),
                Style = _style,
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Center,
            });

            this.AddElement(_textArtist = new TextElementAdvanced("")
            {
                Location = new Point(10, _buttonNext.Location.Y - _height * 2),
                Size = new Size(_size.Width - 20, _height),
                Style = _style,
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Center,
            });
            this.TapHandler = OnTap;
            this.HoldHandler = OnHold;
        }
Beispiel #7
0
        private PanoramaSection CreateFeaturedSection()
        {
            var img1 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail.png");
            var img2 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("squareimg.png");
            var img3 = ResourceManager.Instance.GetBitmapFromEmbeddedResource("thumbnail2.png");

            var titleStyle = new TextStyle(HOBD.theme.PhoneFontFamilySemiBold, HOBD.theme.PhoneFontSizeLarge, Color.White);
            var subtitleStyle = HOBD.theme.PhoneTextBlockBase;
            var moreStyle = new TextStyle(HOBD.theme.PhoneTextLargeStyle.FontFamily, HOBD.theme.PhoneFontSizeMediumLarge, HOBD.theme.PanoramaNormalBrush);

            var section = new PanoramaSection("small");

            var grid = new Grid
            {
                Columns = new MeasureDefinition[] { 120, 180 },
                Rows = new MeasureDefinition[] { 70, 50, 70, 50, 70, 50, 75 }
            };

            grid[0, 0] = new ImageElement(img1) { Size = new Size(100, 100) };
            grid[0, 1] = new DynamicElement("ONE") { Style = titleStyle };
            grid[1, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[2, 0] = new ImageElement(img2) { Size = new Size(100, 100) };
            grid[2, 1] = new DynamicElement("TWO") { Style = titleStyle };
            grid[3, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[4, 0] = new ImageElement(img3) { Size = new Size(100, 100) };
            grid[4, 1] = new DynamicElement("THREE") { Style = titleStyle };
            grid[5, 1] = new DynamicElement("LOREM IPSUM LOREM") { Style = subtitleStyle };

            grid[6, 1] = new TextElement("more") { Style = moreStyle };

            section.AddElement(grid);
            // , 0, 0, 300, 700

            return section;
        }
Beispiel #8
0
        protected virtual PanoramaSection CreateMenuSection()
        {
            var section = CreateCommonSection(t("Settings"));

            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);
            //style.FontSize = HOBD.theme.PhoneFontSizeLarge;

            var height0 = (layoutY - SectionContentDelta);
            var height = height0/6;

            menuGrid = new Grid
                           {
                               Columns = new MeasureDefinition[] { layoutX/3-20, layoutX/3-20, layoutX/3-20 },
                               Rows = new MeasureDefinition[] { height, height, height, height, height }
                           };

            menuGrid[0, 0] = new DynamicElement(t("Reset trips")) { Style = style, HandleTapAction = (e) => { HOBD.Registry.TriggerReset(); } };
            menuGrid[1, 0] = new DynamicElement(t("Minimize")) { Style = style, HandleTapAction = (e) => { /* TODO */ } };
            menuGrid[2, 0] = new DynamicElement(t("Exit")) {
                Style = style,
                HandleTapAction = (e) => Application.Exit()

            };

            menuGrid[0, 1] = new DynamicElement(t("Port settings")) {
                Style = style,
                HandleTapAction = (e) => CreatePortSection()
            };
            menuGrid[1, 1] = new DynamicElement(t("Vehicle")) {
                Style = style,
                HandleTapAction = (e) => CreateVehicleSection()
            };
            menuGrid[2, 1] = new DynamicElement(t("Theme")) {
                Style = style,
                HandleTapAction = (e) => CreateThemeSection()
            };
            menuGrid[3, 1] = new DynamicElement(t("Language")) {
                Style = style,
                HandleTapAction = (e) => CreateLanguageSection()
            };
            menuGrid[4, 1] = new DynamicElement(t("Display Units")) {
                Style = style,
                HandleTapAction = (e) => this.PushVolatileSection(
                    new ListSection(t("Display Units"), null, layoutX, layoutY-SectionContentDelta)
                    {
                        Selected = HOBD.config.Units,
                        Content  = new string[]{ "metric", "imperial" }.Select((s) => (object)s),
                        UIContent = (l) => t((string)l),
                        ChooseAction = (l) => {
                            panorama.CurrentSectionIndex -= 1;
                            HOBD.config.Units = (string)l;
                            HOBD.config.Save();
                            HOBD.ReloadUnits();
                            ReloadUI();
                        }
                    })
            };

            menuGrid[0, 2] = new DynamicElement(t("Sensor push")) {
                Style = style,
                HandleTapAction = (e) => CreateSensorPushSection()
            };

            section.AddElement(menuGrid);
            //, 10, 0, layoutX, height0

            var link = t("hobdrive.com");
            var info = new DynamicElement(link) {
                Style = new TextStyle(style){ FontSize = HOBD.theme.PhoneFontSizeNormal },
                HandleTapAction = (e) => {
                    try{
                        System.Diagnostics.Process.Start(link, "");
                    }catch(Exception){}
                }
            };

            section.AddElement(info);
            //, 10, height0 - 40, layoutX, 20

            return section;
        }
Beispiel #9
0
        protected void CreateItems()
        {
            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);

            Grid grid;

            int height = LayoutY/4;
            grid = new Grid
                {
                    Columns = new MeasureDefinition[] { LayoutX/2, LayoutX/2 },
                    Rows = new MeasureDefinition[] { height, height, height, height }
                };

            int idx = 0, idx2 = 0;

            foreach(var p in Content)
            {
                string label = UIContent(p);

                if (p.Equals(Selected)){
                    label = ">> " + label;
                }

                var e = new IconTextElement("icon.png", label){ HandleTapAction = OnChoose };

                uiMapping.Add(e, p);

                grid[idx++, idx2] = e;
                if (idx >= grid.Rows.Length){
                    idx = 0;
                    idx2++;
                }
                if (idx2 >= grid.Columns.Length)
                    return;
            }

            this.AddElement(grid);
            // , 0, 0, LayoutX, LayoutY
        }
Beispiel #10
0
 public ListSection(string title, TextStyle style, int layoutX, int layoutY)
     : base(title)
 {
     LayoutX = layoutX;
     LayoutY = layoutY;
 }
Beispiel #11
0
 public IDrawingGraphics Style(TextStyle style)
 {
     style.ApplyTo(this);
     return this;
 }
Beispiel #12
0
        private PanoramaSection CreateMenuSection()
        {
            var style = new TextStyle(MetroTheme.PhoneTextLargeStyle.FontFamily,
                                      MetroTheme.PhoneFontSizeMediumLarge,
                                      MetroTheme.PanoramaNormalBrush);

            var section = new PanoramaSection("welcome");
            section.Body.AddElement(this.CreateMenuSectionElement(0, "gestures", p => this.NavigateToHandler(new GesturesTestPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(80, "list page", p => this.NavigateToHandler(new ListPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(160, "pivot", p => this.NavigateToHandler(new PivotPage())));
            section.Body.AddElement(this.CreateMenuSectionElement(240, "text samples", p => this.NavigateToHandler(new TextPage())));

            section.Body.AddElement(new TextElement("more is coming...")
            {
                Style = MetroTheme.PhoneTextNormalStyle,
                Location = new Point(20, 320),
                Size = new Size(300, 80)
            });

            return section;
        }
Beispiel #13
0
 public TextStyle(TextStyle parent)
     : this(parent.FontFamily, parent.FontSize, parent.Foreground, parent.Thickness)
 {
 }
Beispiel #14
0
        public ScreenStatus(Size _size, bool _white)
        {
            _status._countPhone = 0;
            _status._countSms = 0;
            _status._countEmail = 0;
            _status._countMms = 0;

            this.Size = _size;

            _typeColorIcon = "white";
            if (!_white) _typeColorIcon = "black";
            var _dx = _size.Width / 4;

            this.AddElement(_imagePhone = new TransparentImage(_typeColorIcon + "_phone.png")
            {
                Location = new Point(leftOffset + _dx * 0 - (_imageSize.Width / 2), _size.Height - _imageSize.Height),
                Size = _imageSize,
            });

            this.AddElement(_imageSms = new TransparentImage(_typeColorIcon + "_sms.png")
            {
                Location = new Point(leftOffset + _dx * 1 - (_imageSize.Width / 2), _size.Height - _imageSize.Height),
                Size = _imageSize,
            });

            this.AddElement(_imageEmail = new TransparentImage(_typeColorIcon + "_email.png")
            {
                Location = new Point(leftOffset + _dx * 2 - (_imageSize.Width / 2), _size.Height - _imageSize.Height),
                Size = _imageSize,
            });

            this.AddElement(_imageMms = new TransparentImage(_typeColorIcon + "_mms.png")
            {
                Location = new Point(leftOffset + _dx * 3 - (_imageSize.Width / 2), _size.Height - _imageSize.Height),
                Size = _imageSize,
            });

            //
            var _style = new TextStyle(_fontName, _fontSize.ToLogic(), _fontColor);
            var _height = FleuxApplication.DummyDrawingGraphics.Style(_style).CalculateMultilineTextHeight("0", 100);
            this.AddElement(_textPhone = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset + _dx * 0 + (_imageSize.Width / 2), _size.Height - _height),
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Left,
                Style = _style,
            });

            this.AddElement(_textSms = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset + _dx * 1 + (_imageSize.Width / 2), _size.Height - _height),
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Left,
                Style = _style,
            });

            this.AddElement(_textEmail = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset + _dx * 2 + (_imageSize.Width / 2), _size.Height - _height),
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Left,
                Style = _style,
            });

            this.AddElement(_textMms = new TextElementAdvanced("")
            {
                Location = new Point(leftOffset + _dx * 3 + (_imageSize.Width / 2), _size.Height - _height),
                AutoSizeMode = TextElementAdvanced.AutoSizeModeOptions.Left,
                Style = _style,
            });
        }
Beispiel #15
0
        private void UpdateStyle()
        {
            if ((_value != null) && (_value.Equals(_object)))
            {
                BackgroundColor = MetroTheme.PhoneAccentBrush;
                Style = new TextStyle(
                    MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeNormal,
                    Color.White);
            }
            else
            {
                BackgroundColor = Color.LightGray;
                Style = new TextStyle(
                    MetroTheme.PhoneFontFamilyNormal, MetroTheme.PhoneFontSizeNormal,
                    Color.Black);
            }
            BorderColor = BackgroundColor;

            Update();
        }
Beispiel #16
0
 public FontPopupPage(TextStyle textStyle)
     : base(true)
 {
     _textStyle = textStyle;
     CreateControls();
 }