Ejemplo n.º 1
0
        public double GetTagFloatValue(string tagName, double defValue)
        {
            string str    = GetTagStringValue(tagName);
            double result = ((str == "") ? defValue : SysUtils.ParseFloat(str, defValue));

            return(result);
        }
Ejemplo n.º 2
0
 private void btnShowOnMap_Click(object sender, EventArgs e)
 {
     if (txtLatitude.Text != "" && txtLongitude.Text != "")
     {
         fMapBrowser.SetCenter(SysUtils.ParseFloat(txtLatitude.Text, 0), SysUtils.ParseFloat(txtLongitude.Text, 0), -1);
     }
 }
Ejemplo n.º 3
0
        public void ConvHelper_Tests()
        {
            int ival = SysUtils.ParseInt("495", 0);

            Assert.AreEqual(495, ival);

            ival = SysUtils.ParseInt("asdfa", 11);
            Assert.AreEqual(11, ival);

            Assert.AreEqual(11.05, SysUtils.ParseFloat(null, 11.05, false));
            Assert.AreEqual(11.05, SysUtils.ParseFloat("495,575", 11.05, false)); // badVal -> defVal

            double fval = SysUtils.ParseFloat("495.575", 0);

            Assert.AreEqual(495.575, fval);

            fval = SysUtils.ParseFloat("575,495", 0, true);
            Assert.AreEqual(575.495, fval);

            fval = SysUtils.ParseFloat("", 22.1);
            Assert.AreEqual(22.1, fval);

            fval = SysUtils.ParseFloat("sdgfdf", 22.2);
            Assert.AreEqual(22.2, fval);

            string st = SysUtils.AdjustNum(9, 3);

            Assert.AreEqual("009", st);
        }
Ejemplo n.º 4
0
        private IList <GeoPoint> ParseXml(string url)
        {
            List <GeoPoint> geoObjects = new List <GeoPoint>();

            HttpWebRequest request = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));

            request.ContentType = "application/x-www-form-urlencoded";
            request.Proxy       = fProxy;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
                using (Stream stream = response.GetResponseStream()) {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(stream);
                    XmlNode node = xmlDocument.DocumentElement;

                    if (node != null && node.ChildNodes.Count > 0)
                    {
                        int num = node.ChildNodes.Count;
                        for (int i = 0; i < num; i++)
                        {
                            XmlNode xNode = node.ChildNodes[i];
                            if (xNode.Name == "result")
                            {
                                XmlNode addressNode = xNode["formatted_address"];
                                XmlNode geometry    = xNode["geometry"];
                                XmlNode pointNode   = geometry["location"];

                                if (addressNode != null && pointNode != null)
                                {
                                    string ptHint      = addressNode.InnerText;
                                    double ptLongitude = SysUtils.ParseFloat(pointNode["lng"].InnerText, -1.0);
                                    double ptLatitude  = SysUtils.ParseFloat(pointNode["lat"].InnerText, -1.0);

                                    if (ptLatitude != -1.0 && ptLongitude != -1.0)
                                    {
                                        GeoPoint gpt = new GeoPoint(ptLatitude, ptLongitude, ptHint);
                                        geoObjects.Add(gpt);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(geoObjects);
        }
Ejemplo n.º 5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try {
                fLocationRecord.LocationName = txtName.Text;
                fLocationRecord.Map.Lati     = SysUtils.ParseFloat(txtLatitude.Text, 0.0);
                fLocationRecord.Map.Long     = SysUtils.ParseFloat(txtLongitude.Text, 0.0);

                CommitChanges();

                fBase.NotifyRecord(fLocationRecord, RecordAction.raEdit);

                DialogResult = DialogResult.Ok;
            } catch (Exception ex) {
                Logger.LogWrite("LocationEditDlg.btnAccept_Click(): " + ex.Message);
                DialogResult = DialogResult.None;
            }
        }
Ejemplo n.º 6
0
        private static object ConvertColumnStr(string val, DataType type)
        {
            switch (type)
            {
            case DataType.dtString:
                return(val);

            case DataType.dtInteger:
                return(SysUtils.ParseInt(val, 0));

            case DataType.dtFloat:
                return(SysUtils.ParseFloat(val, 0.0));

            case DataType.dtDateTime:
                return(DateTime.Parse(val));

            case DataType.dtGEDCOMDate:
                return(GEDCOMDate.GetUDNByFormattedStr(val, GEDCOMCalendar.dcGregorian));
            }

            return(val);
        }
Ejemplo n.º 7
0
        private void PrepareArray(ChartStyle style, bool excludeUnknowns, List <StatsItem> vals = null)
        {
            if (style != ChartStyle.ClusterBar)
            {
                vals = new List <StatsItem>();

                int num = fListStats.Items.Count;
                for (int i = 0; i < num; i++)
                {
                    ListViewItem item = fListStats.Items[i];

                    string s   = item.Text;
                    double lab = (s == "?") ? 0.0f : SysUtils.ParseFloat(s, 0.0f, true);

                    if (lab != 0.0d || !excludeUnknowns)
                    {
                        int val = int.Parse(item.SubItems[1].Text);
                        vals.Add(new StatsItem(item.Text, val));
                    }
                }
            }

            fGraph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, style, excludeUnknowns, vals);
        }
Ejemplo n.º 8
0
        public void PrepareArray(string title, string xAxis, string yAxis, ChartStyle style, bool excludeUnknowns, List <StatsItem> vals)
        {
            GraphPane gPane = fGraph.GraphPane;

            try
            {
                gPane.CurveList.Clear();

                gPane.Title.Text       = title;
                gPane.XAxis.Title.Text = xAxis;
                gPane.YAxis.Title.Text = yAxis;

                if (style != ChartStyle.ClusterBar)
                {
                    PointPairList ppList = new PointPairList();

                    int num = vals.Count;
                    for (int i = 0; i < num; i++)
                    {
                        StatsItem item = vals[i];

                        string s   = item.Caption;
                        double lab = (s == "?") ? 0.0f : SysUtils.ParseFloat(s, 0.0f, true);

                        if (lab != 0.0d || !excludeUnknowns)
                        {
                            ppList.Add(lab, item.Value);
                        }
                    }
                    ppList.Sort();

                    switch (style)
                    {
                    case ChartStyle.Bar:
                        gPane.AddBar("-", ppList, Color.Green);
                        break;

                    case ChartStyle.Point:
                        gPane.AddCurve("-", ppList, Color.Green, SymbolType.Diamond).Symbol.Size = 3;
                        break;
                    }
                }
                else
                {
                    gPane.CurveList.Clear();

                    int      itemscount = vals.Count;
                    double[] yValuesF   = new double[itemscount];
                    double[] yValuesM   = new double[itemscount];
                    double[] xValues    = new double[itemscount];

                    for (int i = 0; i < itemscount; i++)
                    {
                        StatsItem sti = vals[i];
                        xValues[i]  = SysUtils.ParseInt(sti.Caption, 0);
                        yValuesF[i] = sti.ValF;
                        yValuesM[i] = sti.ValM;
                    }

                    gPane.AddBar("F", xValues, yValuesF, Color.Red);
                    gPane.AddBar("M", xValues, yValuesM, Color.Blue);

                    gPane.BarSettings.MinBarGap     = 0.0f;
                    gPane.BarSettings.MinClusterGap = 2.5f;

                    // expand the range of the Y axis slightly to accommodate the labels
                    //gPane.YAxis.Scale.Max += gPane.YAxis.Scale.MajorStep;

                    // Create TextObj's to provide labels for each bar
                    BarItem.CreateBarLabels(gPane, false, "f0");
                }
            }
            finally
            {
                fGraph.AxisChange();
                fGraph.Invalidate();
            }
        }