t() public static method

public static t ( string v ) : string
v string
return string
Example #1
0
        public ConfigurationSection(int layoutX, int layoutY) :
            base(HOBD.t("Connection port settings"))
        {
            LayoutX = layoutX;
            LayoutY = layoutY;

            CreateItems();

            OnBluetoothScan(null);
        }
Example #2
0
        protected virtual UIElement CreateItem(Dictionary <string, string> attrs, PanoramaSection section)
        {
            string id = "";

            try{
                if (!attrs.TryGetValue("id", out id))
                {
                    return(null);
                }

                var sensor = HOBD.Registry.Sensor(id);
                if (sensor != null)
                {
                    var sensorItem = new SensorTextElement(sensor, attrs);
                    sensorItem.HandleTapAction = () => { sensorItem.Text = HOBD.t("sdesc." + sensor.Name); Redraw(); };

                    List <SensorTextElement> ui_list = null;
                    sensorUIMap.TryGetValue(sensor, out ui_list);
                    if (ui_list == null)
                    {
                        ui_list = new List <SensorTextElement>();
                        sensorUIMap.Add(sensor, ui_list);
                    }
                    ui_list.Add(sensorItem);

                    List <SensorListener> sensor_list = null;
                    sectionSensorMap.TryGetValue(section, out sensor_list);
                    if (sensor_list == null)
                    {
                        sensor_list = new List <SensorListener>();
                        sectionSensorMap.Add(section, sensor_list);
                    }

                    SensorListener sl = new SensorListener();
                    sl.sensor = sensor;
                    sl.period = 0;
                    string period = null;
                    if (attrs.TryGetValue("period", out period))
                    {
                        sl.period = int.Parse(period);
                    }

                    sensor_list.Add(sl);

                    return(sensorItem);
                }
            }catch (Exception e)
            {
                Logger.error("CreateItem", "Failed creating Sensor Element: " + id, e);
            }
            return(new DynamicElement("n/a: " + id)
            {
                Style = HOBD.theme.PhoneTextSmallStyle
            });
        }
Example #3
0
        void DiscoverBT()
        {
            try{
                BluetoothRadio.PrimaryRadio.Mode = RadioMode.Discoverable;
                BluetoothClient bluetoothClient = new BluetoothClient();
                UpdateBTStatus(HOBD.t("Scanning Bluetooth.."));

                bluetoothDeviceInfo = bluetoothClient.DiscoverDevices(10, true, false, true);
                foreach (var di in bluetoothDeviceInfo)
                {
                    Logger.info("ConfigurationPage", "BT name=" + di.DeviceName + ", addr=" + di.DeviceAddress.ToString());
                }
            }catch (Exception e) {
                UpdateBTStatus(HOBD.t("Bluetooth scan failed"));
                Logger.error("ConfigurationPage", "", e);
            }
            UpdateBTStatus(HOBD.t("Scan Again"));
            CreateItems();
            discoverBThread = null;
        }
Example #4
0
        protected void CreateItems()
        {
            var style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);

            if (grid != null)
            {
                this.RemoveElement(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.AddElement(grid);
            // , 0, 0, LayoutX, LayoutY
        }
Example #5
0
        public SensorTextElement(Sensor sensor, Dictionary <string, string> attrs)
        {
            this.Text = "-";

            this.Name = HOBD.t("sname." + sensor.Name);

            this.Units          = sensor.Units;
            this.needConversion = HOBD.uConverter.NeedConversion(this.Units);
            if (this.needConversion)
            {
                this.TUnits = HOBD.uConverter.ConvertUnits(this.Units);
            }
            else
            {
                this.TUnits = this.Units;
            }
            this.TUnits = HOBD.t(this.TUnits);
            if (this.Units == "seconds")
            {
                customFormat = true;
            }

            this.Style = new TextStyle(HOBD.theme.PhoneTextNormalStyle);

            string textSize = null;

            attrs.TryGetValue("size", out textSize);

            if (textSize == "small")
            {
                this.Style.FontSize = HOBD.theme.PhoneFontSizeNormal;
            }
            else if (textSize == "large")
            {
                this.Style.FontSize = HOBD.theme.PhoneFontSizeLarge;
            }
            else if (textSize == "huge")
            {
                this.Style.FontSize = HOBD.theme.PhoneFontSizeExtraExtraLarge;
            }
            else if (textSize == "giant")
            {
                this.Style.FontSize = HOBD.theme.PhoneFontSizeHuge;
            }
            else
            {
                this.Style.FontSize = HOBD.theme.PhoneFontSizeMediumLarge;
            }

            string precision = null;

            attrs.TryGetValue("precision", out precision);
            if (precision != null)
            {
                try {
                    this.Precision = int.Parse(precision);
                }catch (Exception e) {
                    Logger.error("SensorTextElement", "init", e);
                }
            }

            //var style = new TextStyle(HOBD.theme.PhoneTextLargeStyle.FontFamily, HOBD.theme.PhoneFontSizeMediumLarge, HOBD.theme.PanoramaNormalBrush);
        }
Example #6
0
 protected static string t(string val)
 {
     return(HOBD.t(val));
 }