protected override NWidget CreateExampleContent()
        {
            m_TreeView = new NTreeView();
            m_TreeView.SelectedPathChanged += OnTreeViewSelectedPathChanged;

            m_ResourcesMap = new NMap <NTreeViewItem, NEmbeddedResourceContainer>();
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Presentation.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Diagram.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Text.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Schedule.NResources.Instance));
            m_TreeView.Items.Add(CreateRootItem(Nevron.Nov.Grid.NResources.Instance));

            // Create a data table
            m_DataTable = new NMemoryDataTable();
            m_DataTable.AddField(new NFieldInfo("Image", typeof(NImage)));
            m_DataTable.AddField(new NFieldInfo("Name", typeof(string)));
            m_DataTable.AddField(new NFieldInfo("Size", typeof(string)));
            m_DataTable.AddField(new NFieldInfo("Action", typeof(string)));

            // Create a grid view
            m_GridView = new NTableGridView();
            m_GridView.GroupingPanel.Visibility = ENVisibility.Collapsed;
            m_GridView.ReadOnly = true;

            NTableGrid tableGrid = m_GridView.Grid;

            tableGrid.AlternatingRows    = false;
            tableGrid.RowHeaders.Visible = false;
            tableGrid.AutoCreateColumn  += OnGridAutoCreateColumn;
            tableGrid.DataSource         = new NDataSource(m_DataTable);

            NSplitter splitter = new NSplitter(m_TreeView, m_GridView, ENSplitterSplitMode.OffsetFromNearSide, 200);

            return(splitter);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // create persons order data source
            NDataSource personOrders = NDummyDataSource.CreatePersonsOrdersDataSource();

            // get the min and max price. We will use it in the progress bars.
            object min, max;

            personOrders.TryGetMin("Price", out min);
            personOrders.TryGetMax("Price", out max);

            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs args)
            {
                if (args.FieldInfo.Name == "Price")
                {
                    // create a progress bar column format for the Price field
                    NProgressBarColumnFormat progressBarColumnFormat = new NProgressBarColumnFormat();
                    progressBarColumnFormat.Minimum = Convert.ToDouble(min);
                    progressBarColumnFormat.Maximum = Convert.ToDouble(max);
                    args.DataColumn.Format          = progressBarColumnFormat;
                }
            };

            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();
            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // bind to sales data source
            NDataSource dataSource = NDummyDataSource.CreateCompanySalesDataSource();

            grid.DataSource = dataSource;

            // create an expression filter rule that matches records for which Company is equal to Leka
            string companyFxName = dataSource.CreateFormulaFieldName("Company");
            string expression1   = companyFxName + "==\"" + NDummyDataSource.RandomCompanyName() + "\"";

            grid.FilteringRules.Add(new NFilteringRule(new NFormulaRowCondition(expression1)));

            // create an expression filter rule that matches records for which Sales is larger than 1000
            string salesFxName = dataSource.CreateFormulaFieldName("Sales");
            string expression2 = salesFxName + ">1000";

            grid.FilteringRules.Add(new NFilteringRule(new NFormulaRowCondition(expression2)));

            grid.AllowSortColumns   = true;
            grid.AlternatingRows    = true;
            grid.RowHeaders.Visible = true;

            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            grid.AllowEdit = true;

            // create persons order data source
            NDataSource personOrders = NDummyDataSource.CreatePersonsOrdersDataSource();

            // get the min and max price. We will use it in the progress bars.
            object min, max;

            personOrders.TryGetMin("Price", out min);
            personOrders.TryGetMax("Price", out max);

            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs args)
            {
                if (args.FieldInfo.Name == "Price")
                {
                    // create a progress bar column format for the Price field
                    NSliderColumnEditor sliderColumnEditor = new NSliderColumnEditor();
                    args.DataColumn.Editor     = sliderColumnEditor;
                    args.DataColumn.WidthMode  = ENColumnWidthMode.Fixed;
                    args.DataColumn.FixedWidth = 150;
                }
            };

            grid.DataSource = personOrders;
            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // customize the grid
            grid.AllowEdit = false;

            // create the dummy persons data source - we will use it to obtain person names from person ids from it.
            m_PersonsDataSource = NDummyDataSource.CreatePersonsDataSource();

            // bind to data source, but exclude the "PersonId" field from binding
            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg)
            {
                if (arg.FieldInfo.Name == "PersonId")
                {
                    arg.DataColumn = null;
                }
            };
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // create a grouping rule that groups by the PersonId field
            NGroupingRule groupingRule = new NGroupingRule();

            groupingRule.RowValue = new NFieldRowValue("PersonId");

            // create a custom grouping header named "Person"
            groupingRule.CreateGroupingHeaderContentDelegate = delegate(NGroupingRule theGroupingRule)
            {
                return(new NLabel("Person"));
            };

            // create custom group row cells that display the person Name and number of orders
            groupingRule.CreateGroupRowCellsDelegate = delegate(NGroupingRuleCreateGroupRowCellsArgs arg)
            {
                // get the person id from the row for which we create row cells.
                int personId = (int)arg.GroupRow.GroupValue;

                // get the person name that corresponds to that person id.
                int        idField    = m_PersonsDataSource.GetFieldIndex("Id");
                NRecordset rs         = m_PersonsDataSource.GetOrCreateIndex(idField).GetRecordsForValue(personId);
                string     personName = (string)m_PersonsDataSource.GetValue(rs[0], "Name");

                // create the group row cells
                NGroupRowCell personNameCell = new NGroupRowCell(personName);
                personNameCell.EndXPosition.Mode = ENSpanCellEndXPositionMode.NextCellBeginX;

                NGroupRowCell ordersCountCell = new NGroupRowCell("Orders Count:" + arg.GroupRow.Recordset.Count);
                ordersCountCell.EndXPosition.Mode   = ENSpanCellEndXPositionMode.RowEndX;
                ordersCountCell.BeginXPosition.Mode = ENSpanCellBeginXPositionMode.AnchorToEndX;

                return(new NGroupRowCell[] { personNameCell, ordersCountCell });
            };
            grid.GroupingRules.Add(groupingRule);

            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // bind the grid to the data source, but exclude the "PersonId" column.
            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg)
            {
                if (arg.FieldInfo.Name == "PersonId")
                {
                    arg.DataColumn = null;
                }
            };
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // add a custom calculated column of type Double that displays the Total (e.g. Price * Quantity)
            NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>();

            totalColumn.Title = "Total";
            totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg)
            {
                // calculate a RowValue for the RowIndex
                double price    = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price"));
                double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity"));
                return((double)(price * quantity));
            };
            totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell);
            grid.Columns.Add(totalColumn);

            // show only records where PersonId = "0"
            // NOTE: when the rule is not associated with a column, you must explicitly specify a row value for the row condition.
            NFilteringRule        personIdFilterRule = new NFilteringRule();
            NOperatorRowCondition rowCondition       = new NOperatorRowCondition(ENRowConditionOperator.Equals, "0");

            rowCondition.RowValue           = new NFieldRowValue("PersonId");
            personIdFilterRule.RowCondition = rowCondition;
            grid.FilteringRules.Add(personIdFilterRule);

            // show only records for which the total column is larger than 150
            // NOTE: when the rule is associated with a column, by default the row condition operates on the column values.
            NFilteringRule companyFilterRule = new NFilteringRule();

            companyFilterRule.Column       = totalColumn;
            companyFilterRule.RowCondition = new NOperatorRowCondition(ENRowConditionOperator.GreaterThan, "150");
            grid.FilteringRules.Add(companyFilterRule);

            // customize the grid
            grid.AllowSortColumns   = true;
            grid.AlternatingRows    = true;
            grid.RowHeaders.Visible = true;

            return(view);
        }
Example #7
0
        NSortingRule CreateTotalSortingRule(NTableGrid grid)
        {
            NColumn salesColumn = grid.Columns.GetColumnByFieldName("Sales");
            NColumn priceColumn = grid.Columns.GetColumnByFieldName("Price");

            // create a sorting rule that sorts by the Total value
            string quantityFieldName = grid.CreateFormulaFieldName("Quantity");
            string priceFieldName    = grid.CreateFormulaFieldName("Price");

            NSortingRule sortingRule = NSortingRule.FromFormula(null, priceFieldName + "*" + quantityFieldName, ENSortingDirection.Ascending);

            sortingRule.Column = salesColumn;
            return(sortingRule);
        }
        protected override NWidget CreateExampleContent()
        {
            // store current date time
            m_Now = DateTime.Now;

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

            // bind the grid to the data source
            grid.DataSource = CreateMailDataSource();

            // create a grouping rule with a custom row value.
            // NOTE: The RowValue associated with each grouping rule, returns an object for each row of the data source.
            // the rows in the data source are grouped according to that object.
            // The NCustomRowValue provides a delegate that help you return a custom object object for each data source row.
            // In our example the NCustomRowValue returns a member of the ENMailGroup enumeraiton for each record, depending on its Received row value.
            NCustomRowValue <ENMailGroup> customRowValue = new NCustomRowValue <ENMailGroup>();

            customRowValue.Description         = "Received";
            customRowValue.GetRowValueDelegate = GetRowValueDelegate;

            // NOTE: The NGroupingRule provides the following events:
            // CreateGroupRowCells - raised when the grid needs to create the cells of the group row.
            // CreateGroupingHeaderContent - raised when the grid needs to create a grouping header content for the grouping in the groupings panel.
            NGroupingRule groupingRule = new NGroupingRule();

            groupingRule.RowValue = customRowValue;
            groupingRule.CreateGroupRowCellsDelegate = delegate(NGroupingRuleCreateGroupRowCellsArgs arg)
            {
                int    groupValue = Convert.ToInt32(arg.GroupRow.GroupValue);
                string text       = NStringHelpers.InsertSpacesBeforeUppersAndDigits(((ENMailGroup)groupValue).ToString());
                return(new NGroupRowCell[] { new NGroupRowCell(text) });
            };

            groupingRule.CreateGroupingHeaderContentDelegate = delegate(NGroupingRule theGroupingRule)
            {
                return(new NLabel("Received"));
            };

            grid.GroupingRules.Add(groupingRule);

            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            m_GridView = new NTableGridView();
            NTableGrid grid = m_GridView.Grid;

            NItem[] items = new NItem[] {
                new NItem(Nevron.Nov.Examples.NResources.Image_CountryFlags_ad_png, NColor.Navy, new NColorFill(NColor.Moccasin), new NStroke(NColor.AntiqueWhite)),
                new NItem(Nevron.Nov.Examples.NResources.Image_CountryFlags_ae_png, NColor.Olive, new NStockGradientFill(NColor.Violet, NColor.WhiteSmoke), new NStroke(NColor.Bisque)),
                new NItem(Nevron.Nov.Examples.NResources.Image_CountryFlags_af_png, NColor.OldLace, new NHatchFill(ENHatchStyle.DiagonalBrick, NColor.Yellow, NColor.Red), new NStroke(NColor.DarkCyan)),
                new NItem(Nevron.Nov.Examples.NResources.Image_CountryFlags_ag_png, NColor.Plum, new NImageFill(NResources.Image__16x16_Birthday_png), new NStroke(NColor.DimGray)),
                new NItem(Nevron.Nov.Examples.NResources.Image_CountryFlags_ai_png, NColor.Peru, new NStockGradientFill(ENGradientStyle.FromCenter, ENGradientVariant.Variant1, NColor.Wheat, NColor.DarkGoldenrod), new NStroke(NColor.CadetBlue))
            };

            // bind the grid to the data source
            grid.DataSource        = new NDataSource(new NGenericIListDataTable <NItem>(items));
            grid.AutoCreateColumn += grid_AutoCreateColumn;

            return(m_GridView);
        }
Example #10
0
        protected override NWidget CreateExampleContent()
        {
            m_GridView = new NTableGridView();
            NTableGrid grid = m_GridView.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // add a formula column
            m_TotalColumn       = new NFormulaCalculatedColumn();
            m_TotalColumn.Title = "Total";
            string fx = grid.CreateFormulaFieldName("Price") + "*" + grid.CreateFormulaFieldName("Quantity");

            m_TotalColumn.Formula = fx;
            m_TotalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell);
            grid.Columns.Add(m_TotalColumn);

            return(m_GridView);
        }
Example #11
0
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreateCompanySalesDataSource();

            // create a sorting rule that sorts by the company column first
            NColumn companyColumn = grid.Columns.GetColumnByFieldName("Company");

            grid.SortingRules.Add(new NSortingRule(companyColumn, ENSortingDirection.Ascending));

            // create a sorting rule that sorts by the sales column next
            NColumn salesColumn = grid.Columns.GetColumnByFieldName("Sales");

            grid.SortingRules.Add(new NSortingRule(salesColumn, ENSortingDirection.Ascending));

            return(view);
        }
Example #12
0
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // add a custom calculated column of type Double that displays the Total (e.g. Price * Quantity)
            NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>();

            totalColumn.Title = "Total";
            totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg)
            {
                // calculate a RowValue for the RowIndex
                double price    = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price"));
                double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity"));
                return((double)(price * quantity));
            };
            totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell);
            grid.Columns.Add(totalColumn);

            // create the sales sorting rule.
            // also subcribe for the create sorting rule event to recreate the rule when users
            grid.SortingRules.Add(CreateTotalSortingRule(grid));
            totalColumn.CreateSortingRuleDelegate = delegate(NColumn theColumn)
            {
                return(CreateTotalSortingRule(grid));
            };

            // alter some view preferences
            grid.AllowSortColumns   = true;
            grid.AlternatingRows    = true;
            grid.RowHeaders.Visible = true;

            return(view);
        }
        protected override NWidget CreateExampleContent()
        {
            NTableGridView gridView = new NTableGridView();
            NTableGrid     grid     = gridView.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreateCompanySalesDataSource();

            // create a grouping rule that groups by the company field value first
            // note that in order to indicate the grouping in the grouping panel, the rule must reference the respective column
            NColumn          companyColumn = grid.Columns.GetColumnByFieldName("Company");
            string           fx1           = grid.CreateFormulaFieldName("Company");
            NFormulaRowValue fxRowValue    = new NFormulaRowValue(fx1);
            NGroupingRule    groupingRule1 = new NGroupingRule(companyColumn, fxRowValue, ENSortingDirection.Ascending);

            grid.GroupingRules.Add(groupingRule1);

            // create a grouping rule that groups by sales larger than 1000 next
            // note that in order to indicate the grouping in the grouping panel, the rule must reference the respective column
            string        fx2           = grid.CreateFormulaFieldName("Sales") + ">1000";
            NColumn       salesColumn   = grid.Columns.GetColumnByFieldName("Sales");
            NGroupingRule groupingRule2 = NGroupingRule.FromFormula(salesColumn, fx2);

            groupingRule2.CreateGroupRowCellsDelegate += delegate(NGroupingRuleCreateGroupRowCellsArgs arg)
            {
                bool   groupValue = (bool)((NVariant)arg.GroupRow.GroupValue);
                string text       = groupValue? "Sales greater than 1000" : "Sales less than or equal to 1000";
                return(new NGroupRowCell[] { new NGroupRowCell(text) });
            };
            grid.GroupingRules.Add(groupingRule2);

            // alter some view preferences
            grid.AllowSortColumns   = true;
            grid.AlternatingRows    = true;
            grid.RowHeaders.Visible = true;

            return(gridView);
        }
Example #14
0
        protected override NWidget CreateExampleContent()
        {
            m_GridView = new NTableGridView();
            NTableGrid grid = m_GridView.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // add an event calculated column of type Double
            NCustomCalculatedColumn <Double> totalColumn = new NCustomCalculatedColumn <Double>();

            totalColumn.Title = "Total";
            totalColumn.GetRowValueDelegate += delegate(NCustomCalculatedColumnGetRowValueArgs <double> arg)
            {
                // calculate a RowValue for the RowIndex
                double price    = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Price"));
                double quantity = Convert.ToDouble(arg.DataSource.GetValue(arg.RowIndex, "Quantity"));
                return((double)(price * quantity));
            };
            totalColumn.Format.BackgroundFill = new NColorFill(NColor.SeaShell);
            grid.Columns.Add(totalColumn);

            return(m_GridView);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            m_View = new NTableGridView();
            NTableGrid grid = m_View.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreatePersonsDataSource();

            // configure the master grid
            grid.AllowEdit = false;

            // assign some icons to the columns
            for (int i = 0; i < grid.Columns.Count; i++)
            {
                NDataColumn dataColumn = grid.Columns[i] as NDataColumn;
                if (dataColumn == null)
                {
                    continue;
                }

                NImage image = null;
                switch (dataColumn.FieldName)
                {
                case "Name":
                    image = NResources.Image__16x16_Contacts_png;
                    break;

                case "Gender":
                    image = NResources.Image__16x16_Gender_png;
                    break;

                case "Birthday":
                    image = NResources.Image__16x16_Birthday_png;
                    break;

                case "Country":
                    image = NResources.Image__16x16_Globe_png;
                    break;

                case "Phone":
                    image = NResources.Image__16x16_Phone_png;
                    break;

                case "Email":
                    image = NResources.Image__16x16_Mail_png;
                    break;

                default:
                    continue;
                }

                // NOTE: The CreateHeaderContentDelegate is invoked whenever the Title changes or the UpdateHeaderContent() is called.
                // you can use this event to create custom column header content
                dataColumn.CreateHeaderContentDelegate = delegate(NColumn theColumn)
                {
                    NPairBox pairBox = new NPairBox(image, dataColumn.Title, ENPairBoxRelation.Box1BeforeBox2);
                    pairBox.Spacing = 2;
                    return(pairBox);
                };
                dataColumn.UpdateHeaderContent();
            }

            // get the grid master details
            NMasterDetails masterDetails = grid.MasterDetails;

            // creater the table grid detail.
            // NOTE: It shows information from the sales data source. the details are bound using field binding
            NTableGridDetail detail = new NTableGridDetail();

            masterDetails.Details.Add(detail);
            detail.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // configure the details grid
            detail.GridView.Grid.AllowEdit = false;

            NRelationMasterBinding masterBinding = new NRelationMasterBinding();

            masterBinding.Relations.Add(new NRelation("Id", "PersonId"));
            detail.MasterBinding = masterBinding;

            return(m_View);
        }
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            m_View = new NTableGridView();
            NTableGrid grid = m_View.Grid;

            // bind the grid to the data source
            grid.DataSource = NDummyDataSource.CreatePersonsDataSource();

            // configure the master grid
            grid.AllowEdit = false;

            // assign some icons to the columns
            for (int i = 0; i < grid.Columns.Count; i++)
            {
                NDataColumn dataColumn = grid.Columns[i] as NDataColumn;
                if (dataColumn == null)
                {
                    continue;
                }

                NImage image = null;
                switch (dataColumn.FieldName)
                {
                case "Name":
                    image = NResources.Image__16x16_Contacts_png;
                    break;

                case "Gender":
                    image = NResources.Image__16x16_Gender_png;
                    break;

                case "Birthday":
                    image = NResources.Image__16x16_Birthday_png;
                    break;

                case "Country":
                    image = NResources.Image__16x16_Globe_png;
                    break;

                case "Phone":
                    image = NResources.Image__16x16_Phone_png;
                    break;

                case "Email":
                    image = NResources.Image__16x16_Mail_png;
                    break;

                default:
                    continue;
                }

                // NOTE: The CreateHeaderContentDelegate is invoked whenever the Title changes or the UpdateHeaderContent() is called.
                // you can use this event to create custom column header content
                dataColumn.CreateHeaderContentDelegate = delegate(NColumn theColumn)
                {
                    NPairBox pairBox = new NPairBox(image, theColumn.Title, ENPairBoxRelation.Box1BeforeBox2);
                    pairBox.Spacing = 2;
                    return(pairBox);
                };
                dataColumn.UpdateHeaderContent();
            }

            // create the custom detail that creates a widget displaying information about the row.
            // NOTE: The widget is created by the OnCustomDetailCreateWidget event handler.
            NMasterDetails masterDetails = grid.MasterDetails;

            NCustomDetail customDetail = new NCustomDetail();

            masterDetails.Details.Add(customDetail);

            customDetail.CreateWidgetDelegate = delegate(NCustomDetailCreateWidgetArgs arg)
            {
                // get information about the data source row
                string    name     = (string)arg.DataSource.GetValue(arg.RowIndex, "Name");
                ENGender  gender   = (ENGender)arg.DataSource.GetValue(arg.RowIndex, "Gender");
                DateTime  birthday = (DateTime)arg.DataSource.GetValue(arg.RowIndex, "Birthday");
                ENCountry country  = (ENCountry)arg.DataSource.GetValue(arg.RowIndex, "Country");
                string    phone    = (string)arg.DataSource.GetValue(arg.RowIndex, "Phone");
                string    email    = (string)arg.DataSource.GetValue(arg.RowIndex, "Email");

                // display the information as a widget
                NPairBox namePair     = new NPairBox("Name:", name);
                NPairBox genderPair   = new NPairBox("Gender:", gender.ToString());
                NPairBox birthdayPair = new NPairBox("Birthday:", birthday.ToString());
                NPairBox countryPair  = new NPairBox("Country:", country.ToString());
                NPairBox phonePair    = new NPairBox("Phone:", phone.ToString());
                NPairBox emailPair    = new NPairBox("Email:", email.ToString());

                NImageBox image = new NImageBox();
                switch (gender)
                {
                case ENGender.Male:
                    image.Image = Nevron.Nov.Examples.NResources.Image__256x256_MaleIcon_jpg;
                    break;

                case ENGender.Female:
                    image.Image = Nevron.Nov.Examples.NResources.Image__256x256_FemaleIcon_jpg;
                    break;

                default:
                    break;
                }

                NStackPanel infoStack = new NStackPanel();
                infoStack.VerticalSpacing = 2.0d;
                infoStack.Add(namePair);
                infoStack.Add(genderPair);
                infoStack.Add(birthdayPair);
                infoStack.Add(countryPair);
                infoStack.Add(phonePair);
                infoStack.Add(emailPair);

                NDockPanel dock = new NDockPanel();
                dock.Add(image, ENDockArea.Left);
                dock.Add(infoStack, ENDockArea.Center);

                // assign the widget to the event arguments.
                return(dock);
            };

            return(m_View);
        }
Example #17
0
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // customize the grid
            grid.AllowEdit = false;

            // bind to data source, but exclude the "PersonId" field from binding
            grid.AutoCreateColumn += delegate(NAutoCreateColumnEventArgs arg)
            {
                if (arg.FieldInfo.Name == "PersonId")
                {
                    arg.DataColumn = null;
                }
            };
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // create a calculated Total column
            NCustomCalculatedColumn <double> totalColumn = new NCustomCalculatedColumn <double>();

            totalColumn.Title = "Total";
            totalColumn.GetRowValueDelegate = delegate(NCustomCalculatedColumnGetRowValueArgs <double> args)
            {
                double price    = Convert.ToDouble(args.DataSource.GetValue(args.RowIndex, "Price"));
                int    quantity = Convert.ToInt32(args.DataSource.GetValue(args.RowIndex, "Quantity"));
                return((double)(price * quantity));
            };
            grid.Columns.Add(totalColumn);

            // create a grouping rule that groups by the Product Name column
            NGroupingRule groupingRule = new NGroupingRule(grid.Columns.GetColumnByFieldName("Product Name"));

            // create a footer summary row for the total total
            groupingRule.CreateFooterSummaryRowsDelegate = delegate(NGroupingRuleCreateSummaryRowsArgs args)
            {
                // get the recordset for the group
                NRecordset recordset = args.GroupRow.Recordset;

                // calculate the sum of totals
                double total = 0;
                for (int i = 0; i < recordset.Count; i++)
                {
                    total += Convert.ToDouble(totalColumn.GetRowValue(recordset[i]));
                }

                // create the total summary row
                NSummaryRow totalRow = new NSummaryRow();
                totalRow.Cells = new NSummaryCellCollection();

                NSummaryCell cell = new NSummaryCell();
                cell.BeginXPosition.Mode = ENSpanCellBeginXPositionMode.AnchorToEndX;
                cell.EndXPosition.Mode   = ENSpanCellEndXPositionMode.RowEndX;
                cell.Content             = new NLabel("Grand Total: " + total.ToString("0.00"));
                totalRow.Cells.Add(cell);

                return(new NSummaryRow[] { totalRow });
            };
            grid.GroupingRules.Add(groupingRule);

            return(view);
        }
Example #18
0
        protected override NWidget CreateExampleContent()
        {
            // create a view and get its grid
            NTableGridView view = new NTableGridView();
            NTableGrid     grid = view.Grid;

            // bind the grid to the PersonsOrders data source
            grid.DataSource = NDummyDataSource.CreatePersonsOrdersDataSource();

            // Formatting Rule 1 = applied to the Product Name column.
            // make the Aptax, Joykix, Zun Zimtam,  Dingtincof cell backgrounds LightCoral, with a bold Font
            {
                // create the formatting rule and add it in the "Product Name" column
                NColumn column = grid.Columns.GetColumnByFieldName("Product Name");

                NFormattingRule formattingRule = new NFormattingRule();
                column.FormattingRules.Add(formattingRule);

                // row condition
                NOrGroupRowCondition orCondition = new NOrGroupRowCondition();
                orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Aptax"));
                orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Joykix"));
                orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Zun Zimtam"));
                orCondition.Add(new NOperatorRowCondition(new NFieldRowValue("Product Name"), ENRowConditionOperator.Equals, "Dingtincof"));
                formattingRule.RowCondition = orCondition;

                // LightCoral background fill declaration
                NBackgroundFillDeclaration backgroundFillDeclaration = new NBackgroundFillDeclaration();
                backgroundFillDeclaration.Mode        = ENFillDeclarationMode.Uniform;
                backgroundFillDeclaration.UniformFill = new NColorFill(NColor.LightCoral);
                formattingRule.Declarations.Add(backgroundFillDeclaration);

                // Bold font style declaration
                NFontStyleDeclaration fontStyleDeclaration = new NFontStyleDeclaration();
                fontStyleDeclaration.FontStyle = ENFontStyle.Bold;
                formattingRule.Declarations.Add(fontStyleDeclaration);
            }

            // Formatting Rule 2 = applied to the Product Name column.
            // make the Aptax and Joykix cell backgrounds LightCoral, with a bold Font
            {
                // create the formatting rule and add it in the "Product Name" column
                NColumn         column         = grid.Columns.GetColumnByFieldName("Price");
                NFormattingRule formattingRule = new NFormattingRule();
                column.FormattingRules.Add(formattingRule);

                // row condition
                formattingRule.RowCondition = new NTrueRowCondition();

                // get price field min and max
                object minPrice, maxPrice;
                int    priceFieldIndex = grid.DataSource.GetFieldIndex("Price");
                grid.DataSource.TryGetMin(priceFieldIndex, out minPrice);
                grid.DataSource.TryGetMax(priceFieldIndex, out maxPrice);

                // make a graident fill declaration
                NBackgroundFillDeclaration backgroundFillDeclaration = new NBackgroundFillDeclaration();
                backgroundFillDeclaration.Mode         = ENFillDeclarationMode.TwoColorGradient;
                backgroundFillDeclaration.MinimumValue = Convert.ToDouble(minPrice);
                backgroundFillDeclaration.MaximumValue = Convert.ToDouble(maxPrice);
                backgroundFillDeclaration.BeginColor   = NColor.Green;
                backgroundFillDeclaration.EndColor     = NColor.Red;
                formattingRule.Declarations.Add(backgroundFillDeclaration);
            }

            return(view);
        }
        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);
        }