示例#1
0
        protected override void LoadExample()
        {
            // init layout
            m_Layout = new NDockLayout();

            // by default shapes are resized to fit the cell
            // both horizontally and vertically
            m_Layout.HorizontalContentPlacement = ContentPlacement.Fit;
            m_Layout.VerticalContentPlacement   = ContentPlacement.Fit;

            // show layout properties in the property grid
            propertyGrid1.SelectedObject = m_Layout;

            // init view
            view.BeginInit();
            view.Grid.Visible = false;
            view.GlobalVisibility.ShowPorts = false;
            view.ViewLayout = ViewLayout.Fit;

            // init document
            document.BeginInit();
            InitDocument();
            document.EndInit();

            // init form controls
            InitFormControls();

            // end view init
            view.EndInit();
        }
示例#2
0
        protected override NWidget CreateExampleContent()
        {
            m_FormulaEngine = new NFormulaEngine();

            NStackPanel stack = new NStackPanel();

            NDockLayout.SetDockArea(stack, ENDockArea.Center);

            m_InputTextBox = new NTextBox();
            stack.Add(m_InputTextBox);

            NStackPanel hstack = new NStackPanel();

            hstack.Direction = ENHVDirection.LeftToRight;
            stack.Add(hstack);

            NButton evaluateButton = new NButton("Evaluate");

            evaluateButton.Click += new Function <NEventArgs>(OnEvaluateButtonClick);
            hstack.Add(evaluateButton);

            NButton evaluateAllButton = new NButton("Evaluate All");

            evaluateAllButton.Click += new Function <NEventArgs>(OnEvaluateAllButtonClick);
            hstack.Add(evaluateAllButton);

            m_ResultTextBox = new NTextBox();
            stack.Add(m_ResultTextBox);

            return(stack);
        }
示例#3
0
        private NWidget CreateCustomRequestWidget()
        {
            NGroupBox groupBox = new NGroupBox("Custom Request");

            NDockPanel dock = new NDockPanel();

            groupBox.Content = dock;

            NLabel label = new NLabel("URI:");

            label.VerticalPlacement = ENVerticalPlacement.Center;
            NDockLayout.SetDockArea(label, ENDockArea.Left);
            dock.Add(label);

            m_CustomURITextBox         = new NTextBox();
            m_CustomURITextBox.Text    = "http://www.nevron.com/gallery/FullGalleries/chart/pie/images/3D-pie-cut-edge-ring.png";
            m_CustomURITextBox.Padding = new NMargins(0, 3, 0, 3);
            NDockLayout.SetDockArea(m_CustomURITextBox, ENDockArea.Center);
            dock.Add(m_CustomURITextBox);

            NButton submitButton = new NButton("Submit");

            NDockLayout.SetDockArea(submitButton, ENDockArea.Right);
            submitButton.Click += new Function <NEventArgs>(OnSumbitCustomRequestClick);
            dock.Add(submitButton);

            return(groupBox);
        }
        private NPieChart CreatePieChart()
        {
            NPieChart pieChart = new NPieChart();

            NDockLayout.SetDockArea(pieChart, ENDockArea.Center);
            pieChart.Margins = new NMargins(10, 0, 10, 10);

            NPieSeries pieSeries = new NPieSeries();

            pieChart.Series.Add(pieSeries);
            pieChart.DockSpiderLabelsToSides = false;

            NDataLabelStyle dataLabelStyle = new NDataLabelStyle();

            dataLabelStyle.ArrowLength        = 15;
            dataLabelStyle.ArrowPointerLength = 0;
            pieSeries.DataLabelStyle          = dataLabelStyle;

            pieSeries.LabelMode         = ENPieLabelMode.Spider;
            pieSeries.LegendView.Mode   = ENSeriesLegendMode.DataPoints;
            pieSeries.LegendView.Format = "<label> <percent>";

            pieSeries.DataPoints.Add(new NPieDataPoint(24, "Cars"));
            pieSeries.DataPoints.Add(new NPieDataPoint(18, "Airplanes"));
            pieSeries.DataPoints.Add(new NPieDataPoint(32, "Trains"));
            pieSeries.DataPoints.Add(new NPieDataPoint(23, "Ships"));
            pieSeries.DataPoints.Add(new NPieDataPoint(19, "Buses"));

            return(pieChart);
        }
示例#5
0
        /// <summary>
        /// Sets a custom dock area to the specified widget and colors its background accordingly
        /// </summary>
        /// <param name="widget"></param>
        /// <param name="dockArea"></param>
        private void SetDockArea(NWidget widget, ENDockArea dockArea)
        {
            NDockLayout.SetDockArea(widget, dockArea);
            switch (dockArea)
            {
            case ENDockArea.Bottom:
                widget.BackgroundFill = new NColorFill(new NColor(0, 162, 232));
                break;

            case ENDockArea.Center:
                widget.BackgroundFill = new NColorFill(new NColor(239, 228, 176));
                break;

            case ENDockArea.Left:
                widget.BackgroundFill = new NColorFill(new NColor(34, 177, 76));
                break;

            case ENDockArea.Right:
                widget.BackgroundFill = new NColorFill(new NColor(163, 73, 164));
                break;

            case ENDockArea.Top:
                widget.BackgroundFill = new NColorFill(new NColor(237, 28, 36));
                break;

            default:
                throw new Exception("New ENDockArea?");
            }
        }
示例#6
0
        private NListBoxItem CreateDetailedListBoxItem(int index)
        {
            NDockPanel dock = new NDockPanel();

            dock.HorizontalSpacing = 3;
            dock.Padding           = new NMargins(0, 2, 0, 2);

            // Add the image
            string imageName = ImageNames[index % ImageNames.Length];
            NImage icon      = new NImage(new NEmbeddedResourceRef(NResources.Instance, "RIMG__24x24_" + imageName + "_png"));

            NImageBox imageBox = new NImageBox(icon);

            imageBox.HorizontalPlacement = ENHorizontalPlacement.Center;
            imageBox.VerticalPlacement   = ENVerticalPlacement.Center;
            NDockLayout.SetDockArea(imageBox, ENDockArea.Left);

            dock.Add(imageBox);

            // Add the title
            NLabel titleLabel = new NLabel("Item " + index.ToString());

            titleLabel.Font = new NFont(NFontDescriptor.DefaultSansFamilyName, 10, ENFontStyle.Bold);
            NDockLayout.SetDockArea(titleLabel, ENDockArea.Top);
            dock.AddChild(titleLabel);

            // Add the description
            NLabel descriptionLabel = new NLabel("This is item " + index.ToString() + "'s description.");

            NDockLayout.SetDockArea(descriptionLabel, ENDockArea.Center);
            dock.AddChild(descriptionLabel);

            return(new NListBoxItem(dock));
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            m_ChartView = new NChartView();

            NDockPanel dockPanel = new NDockPanel();

            m_ChartView.Surface.Content = dockPanel;

            NLabel label = new NLabel();

            label.Margins       = new NMargins(10);
            label.Font          = new NFont(NFontDescriptor.DefaultSansFamilyName, 12);
            label.TextFill      = new NColorFill(NColor.Black);
            label.TextAlignment = ENContentAlignment.MiddleCenter;
            label.Text          = "Multiple Legends";
            NDockLayout.SetDockArea(label, ENDockArea.Top);
            dockPanel.AddChild(label);

            // stack panel holding content
            NStackPanel stackPanel = new NStackPanel();

            stackPanel.UniformHeights = ENUniformSize.Max;
            stackPanel.FillMode       = ENStackFillMode.Equal;
            stackPanel.FitMode        = ENStackFitMode.Equal;
            NDockLayout.SetDockArea(stackPanel, ENDockArea.Center);
            dockPanel.AddChild(stackPanel);

            // first group of pie + legend
            NDockPanel firstGroupPanel = new NDockPanel();

            stackPanel.AddChild(firstGroupPanel);

            m_PieChart1 = CreatePieChart();
            m_Legend1   = CreateLegend();

            m_PieChart1.Legend = m_Legend1;

            firstGroupPanel.AddChild(m_Legend1);
            firstGroupPanel.AddChild(m_PieChart1);

            // second group of pie + legend
            NDockPanel secondGroupPanel = new NDockPanel();

            stackPanel.AddChild(secondGroupPanel);

            // setup the volume chart
            m_PieChart2 = CreatePieChart();
            m_Legend2   = CreateLegend();

            m_PieChart2.Legend = m_Legend2;

            secondGroupPanel.AddChild(m_Legend2);
            secondGroupPanel.AddChild(m_PieChart2);

            m_ChartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, true));

            return(m_ChartView);
        }
        private NLegend CreateLegend()
        {
            NLegend legend = new NLegend();

            NDockLayout.SetDockArea(legend, ENDockArea.Center);

            legend.HorizontalPlacement = ENHorizontalPlacement.Right;
            legend.VerticalPlacement   = ENVerticalPlacement.Top;

            return(legend);
        }
示例#9
0
        protected override NWidget CreateExampleControls()
        {
            NStackPanel stack = new NStackPanel();

            stack.VerticalSpacing = 10;

            // Create the predefined tests list box
            NListBox testListBox = new NListBox();

            testListBox.Items.Add(CreateTestListBoxItem(new NRichTextBorders()));
            testListBox.Items.Add(CreateTestListBoxItem(new NRichTextLists()));
            testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTables()));
            testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTextStyles()));
            testListBox.Items.Add(CreateTestListBoxItem(new NRichTextElementPositioning()));
            testListBox.Selection.Selected += OnTestListBoxItemSelected;

            // Add the list box in a group box
            stack.Add(new NGroupBox("Predefined text documents", testListBox));

            // Create the Load from file group box
            NDockPanel dockPanel = new NDockPanel();

            dockPanel.HorizontalSpacing = 3;
            dockPanel.VerticalSpacing   = 3;

            NButton loadButton = new NButton("Load");

            loadButton.Click += OnLoadButtonClick;
            NDockLayout.SetDockArea(loadButton, ENDockArea.Bottom);
            dockPanel.Add(loadButton);

            m_FileNameTextBox = new NTextBox();
            m_FileNameTextBox.VerticalPlacement = ENVerticalPlacement.Center;
            NDockLayout.SetDockArea(m_FileNameTextBox, ENDockArea.Center);
            dockPanel.Add(m_FileNameTextBox);

            NButton browseButton = new NButton("...");

            browseButton.Click += OnBrowseButtonClick;
            NDockLayout.SetDockArea(browseButton, ENDockArea.Right);
            dockPanel.Add(browseButton);

            stack.Add(new NGroupBox("Load from file", dockPanel));

            m_ElapsedTimeLabel = new NLabel();
            stack.Add(m_ElapsedTimeLabel);

            // Select the initial test
            testListBox.Selection.SingleSelect(testListBox.Items[0]);

            return(stack);
        }
        void OnLegendDockAreaComboBoxSelectedIndexChanged(NValueChangeEventArgs arg)
        {
            ENDockArea dockArea = (ENDockArea)((NComboBox)arg.TargetNode).SelectedIndex;
            NLegend    legend   = m_ChartView.Surface.Legends[0];

            // adjust the legend layout / position accordingly to the dock area
            switch (dockArea)
            {
            case ENDockArea.Left:
                legend.ExpandMode        = ENLegendExpandMode.RowsOnly;
                legend.VerticalPlacement = ENVerticalPlacement.Center;
                break;

            case ENDockArea.Top:
                legend.ExpandMode          = ENLegendExpandMode.ColsOnly;
                legend.HorizontalPlacement = ENHorizontalPlacement.Center;
                break;

            case ENDockArea.Right:
                legend.ExpandMode        = ENLegendExpandMode.RowsOnly;
                legend.VerticalPlacement = ENVerticalPlacement.Center;
                break;

            case ENDockArea.Bottom:
                legend.ExpandMode          = ENLegendExpandMode.ColsOnly;
                legend.HorizontalPlacement = ENHorizontalPlacement.Center;
                break;

            case ENDockArea.Center:
                legend.ExpandMode          = ENLegendExpandMode.RowsOnly;
                legend.HorizontalPlacement = ENHorizontalPlacement.Center;
                legend.VerticalPlacement   = ENVerticalPlacement.Center;
                break;
            }

            NDockLayout.SetDockArea(legend, dockArea);
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            m_ChartView = new NChartView();

            NDockPanel dockPanel = new NDockPanel();

            m_ChartView.Surface.Content = dockPanel;

            NLabel label = new NLabel();

            label.Margins       = new NMargins(10);
            label.Font          = new NFont(NFontDescriptor.DefaultSansFamilyName, 12);
            label.TextFill      = new NColorFill(NColor.Black);
            label.TextAlignment = ENContentAlignment.MiddleCenter;
            label.Text          = "Aligning Chart Areas";
            NDockLayout.SetDockArea(label, ENDockArea.Top);
            dockPanel.AddChild(label);

            // configure title
            NStackPanel stackPanel = new NStackPanel();

            stackPanel.UniformHeights = ENUniformSize.Max;
            stackPanel.FillMode       = ENStackFillMode.Equal;
            stackPanel.FitMode        = ENStackFitMode.Equal;
            NDockLayout.SetDockArea(stackPanel, ENDockArea.Center);
            dockPanel.AddChild(stackPanel);

            NCartesianChart stockPriceChart = new NCartesianChart();

            stockPriceChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XValueTimelineYLinear);
            stockPriceChart.FitMode = ENCartesianChartFitMode.Stretch;
            stockPriceChart.Margins = new NMargins(10, 0, 10, 10);
            ConfigureInteractivity(stockPriceChart);
            stackPanel.AddChild(stockPriceChart);

            // setup the stock series
            m_StockPrice = new NStockSeries();
            stockPriceChart.Series.Add(m_StockPrice);
            m_StockPrice.Name            = "Price";
            m_StockPrice.LegendView.Mode = ENSeriesLegendMode.None;
            m_StockPrice.DataLabelStyle  = new NDataLabelStyle(false);
            m_StockPrice.CandleShape     = ENCandleShape.Stick;

            m_StockPrice.UpStroke       = new NStroke(1, NColor.RoyalBlue);
            m_StockPrice.CandleWidth    = 10;
            m_StockPrice.UseXValues     = true;
            m_StockPrice.InflateMargins = false;

            // setup the volume chart
            NCartesianChart stockVolumeChart = new NCartesianChart();

            stockVolumeChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XValueTimelineYLinear);
            stockVolumeChart.FitMode = ENCartesianChartFitMode.Stretch;
            stockVolumeChart.Margins = new NMargins(10, 0, 10, 10);
            ConfigureInteractivity(stockVolumeChart);
            stackPanel.AddChild(stockVolumeChart);

            // setup the stock volume series
            // setup the volume series
            m_StockVolume = new NAreaSeries();
            stockVolumeChart.Series.Add(m_StockVolume);
            m_StockVolume.Name            = "Volume";
            m_StockVolume.DataLabelStyle  = new NDataLabelStyle(false);
            m_StockVolume.LegendView.Mode = ENSeriesLegendMode.None;
            m_StockVolume.Fill            = new NColorFill(NColor.YellowGreen);
            m_StockVolume.UseXValues      = true;

            // make sure all axes are synchronized
            stockPriceChart.Axes[ENCartesianAxis.PrimaryX].SynchronizedAxes  = new NDomArray <NNodeRef>(new NNodeRef(stockVolumeChart.Axes[ENCartesianAxis.PrimaryX]));
            stockVolumeChart.Axes[ENCartesianAxis.PrimaryX].SynchronizedAxes = new NDomArray <NNodeRef>(new NNodeRef(stockPriceChart.Axes[ENCartesianAxis.PrimaryX]));

            GenerateData();

            // align the left parts of those charts
            NAlignmentGuidelineCollection guideLines = new NAlignmentGuidelineCollection();

            NAlignmentGuideline guideLine = new NAlignmentGuideline();

            guideLine.ContentSide = ENContentSide.Left;
            guideLine.Targets     = new NDomArray <NNodeRef>(new NNodeRef[] { new NNodeRef(stockPriceChart), new NNodeRef(stockVolumeChart) });

            guideLines.Add(guideLine);

            m_ChartView.Surface.AlignmentGuidelines = guideLines;

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

            return(m_ChartView);
        }
        protected override NWidget CreateExampleContent()
        {
            NMemoryDataTable dataTable = new NMemoryDataTable(
                new NFieldInfo("Company", typeof(String)),
                new NFieldInfo("RegionSales", typeof(Double[])));

            Random rnd = new Random();

            for (int i = 0; i < 1000; i++)
            {
                Double[] arr = new Double[10];
                for (int j = 0; j < 10; j++)
                {
                    arr[j] = rnd.Next(100);
                }

                dataTable.AddRow(NDummyDataSource.RandomCompanyName(), arr);
            }

            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg)
            {
                if (arg.DataColumn.FieldName == "RegionSales")
                {
                    NCustomColumnFormat pieColumnFormat = new NCustomColumnFormat();
                    pieColumnFormat.FormatDefaultDataCellDelegate = delegate(NDataCell theDataCell)
                    {
                        NWidget widget = new NWidget();
                        widget.PreferredSize = new NSize(400, 300);
                    };

                    pieColumnFormat.CreateValueDataCellViewDelegate = delegate(NDataCell theDataCell, object value)
                    {
                        double[] values = (double[])value;

                        NChartView chartView = new NChartView();
                        chartView.PreferredSize = new NSize(300, 60);

                        NCartesianChart cartesianChart = new NCartesianChart();

                        NDockLayout.SetDockArea(cartesianChart, ENDockArea.Center);
                        chartView.Surface.Content = cartesianChart;

                        cartesianChart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
                        cartesianChart.Legend = null;

                        cartesianChart.Axes[ENCartesianAxis.PrimaryX].Visible = false;
                        NCartesianAxis yAxis = cartesianChart.Axes[ENCartesianAxis.PrimaryY];

                        NValueScaleLabelStyle labelStyle = new NValueScaleLabelStyle();
                        labelStyle.TextStyle.Font = new NFont("Arimo", 8);
                        ((NLinearScale)yAxis.Scale).Labels.Style = labelStyle;

                        NBarSeries barSeries = new NBarSeries();
                        barSeries.DataLabelStyle = new NDataLabelStyle(false);
                        barSeries.InflateMargins = false;
                        cartesianChart.Series.Add(barSeries);

                        int count = values.Length;
                        for (int i = 0; i < count; i++)
                        {
                            barSeries.DataPoints.Add(new NBarDataPoint(values[i]));
                        }

                        return(chartView);
                    };

                    arg.DataColumn.Format = pieColumnFormat;
                }
            };

            grid.DataSource = new NDataSource(dataTable);
            return(view);
        }