コード例 #1
0
        static NCalendarExample()
        {
            NCalendarExampleSchema = NSchema.Create(typeof(NCalendarExample), NExampleBase.NExampleBaseSchema);

            // Fill the list of cultures
            string[] cultureNames = new string[] { "en-US", "en-GB", "fr-FR", "de-DE", "es-ES", "ru-RU", "zh-CN", "ja-JP",
                                                   "it-IT", "hi-IN", "ar-AE", "he-IL", "id-ID", "ko-KR", "pt-BR", "sv-SE", "tr-TR", "pt-BR", "bg-BG", "ro-RO",
                                                   "pl-PL", "nl-NL", "cs-CZ" };
            Cultures = new NList <CultureInfo>();

            for (int i = 0, count = cultureNames.Length; i < count; i++)
            {
                CultureInfo cultureInfo;
                try
                {
                    cultureInfo = new CultureInfo(cultureNames[i]);
                }
                catch
                {
                    cultureInfo = null;
                }

                if (cultureInfo != null && Cultures.Contains(cultureInfo) == false)
                {
                    Cultures.Add(cultureInfo);
                }
            }

            // Sort the cultures by their English name
            Cultures.Sort(new NCultureNameComparer());
        }
コード例 #2
0
        private NList <NCountry> LoadCountryData()
        {
            // Get the country list XML stream
            Stream stream = NResources.Instance.GetResourceStream("RSTR_CountryList_xml");

            // Load an xml document from the stream
            NXmlDocument xmlDocument = NXmlDocument.LoadFromStream(stream);

            // Process it
            NXmlNode         rows      = xmlDocument.GetChildAt(0).GetChildAt(1);
            NList <NCountry> countries = new NList <NCountry>();

            for (int i = 0, countryCount = rows.ChildrenCount; i < countryCount; i++)
            {
                NXmlNode row = rows.GetChildAt(i);

                // Get the country name
                NCountry country = new NCountry(GetValue(row.GetChildAt(1)));
                if (String.IsNullOrEmpty(country.Name))
                {
                    continue;
                }

                // Get the country's capital
                country.Capital = GetValue(row.GetChildAt(6));
                if (String.IsNullOrEmpty(country.Capital))
                {
                    continue;
                }

                // Get the country's currency
                country.CurrencyCode = GetValue(row.GetChildAt(7));
                country.CurrencyName = GetValue(row.GetChildAt(8));
                if (String.IsNullOrEmpty(country.CurrencyCode) || String.IsNullOrEmpty(country.CurrencyName))
                {
                    continue;
                }

                // Get the country code (ISO 3166-1 2 Letter Code)
                country.Code = GetValue(row.GetChildAt(10));
                if (String.IsNullOrEmpty(country.Code))
                {
                    continue;
                }

                // Get the country flag
                string            flagResourceName = "RIMG_CountryFlags_" + country.Code.ToLower() + "_png";
                NEmbeddedResource flagResource     = NResources.Instance.GetResource(flagResourceName);
                if (flagResource == null)
                {
                    continue;
                }

                country.Flag = new NImage(new NEmbeddedResourceRef(flagResource));

                // Add the country to the list
                countries.Add(country);
            }

            // Sort the countries by name and return them
            countries.Sort();
            return(countries);
        }
コード例 #3
0
 public list <T> Sort(Function <T, T, int> cmp)
 {
     return(NList.Sort <T>(this, cmp));
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Combo Chart";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // Setup the primary Y axis
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Title.Text = "Number of Occurences";

            // add interlace stripe
            NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale.Strips.Add(strip);

            // Setup the secondary Y axis
            NLinearScale scaleY2 = new NLinearScale();

            scaleY2.Labels.TextProvider = new NFormattedScaleLabelTextProvider(new NNumericValueFormatter("0%"));
            scaleY2.Title.Text          = "Cumulative Percent";

            NCartesianAxis axisY2 = new NCartesianAxis();

            m_Chart.Axes.Add(axisY2);

            axisY2.Anchor            = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Right);
            axisY2.Visible           = true;
            axisY2.Scale             = scaleY2;
            axisY2.ViewRangeMode     = ENAxisViewRangeMode.FixedRange;
            axisY2.MinViewRangeValue = 0;
            axisY2.MaxViewRangeValue = 1;

            // add the bar series
            NBarSeries bar = new NBarSeries();

            m_Chart.Series.Add(bar);
            bar.Name           = "Bar Series";
            bar.DataLabelStyle = new NDataLabelStyle(false);

            // add the line series
            NLineSeries line = new NLineSeries();

            m_Chart.Series.Add(line);
            line.Name           = "Cumulative %";
            line.DataLabelStyle = new NDataLabelStyle(false);

            NMarkerStyle markerStyle = new NMarkerStyle();

            markerStyle.Visible = true;
            markerStyle.Shape   = ENPointShape.Ellipse;
            markerStyle.Size    = new NSize(10, 10);
            markerStyle.Fill    = new NColorFill(NColor.Orange);

            line.MarkerStyle = markerStyle;

            line.VerticalAxis = axisY2;

            // fill with random data and sort in descending order
            int            count        = 10;
            NList <double> randomValues = new NList <double>();
            Random         random       = new Random();

            for (int i = 0; i < count; i++)
            {
                randomValues.Add(random.Next(100, 700));
            }

            randomValues.Sort();

            for (int i = 0; i < randomValues.Count; i++)
            {
                bar.DataPoints.Add(new NBarDataPoint(randomValues[i]));
            }

            // calculate cumulative sum of the bar values
            double cs = 0;

            double[] arrCumulative = new double[count];

            for (int i = 0; i < count; i++)
            {
                cs += randomValues[i];
                arrCumulative[i] = cs;
            }

            if (cs > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    arrCumulative[i] /= cs;
                    line.DataPoints.Add(new NLineDataPoint(arrCumulative[i]));
                }
            }

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }