/// <summary> /// Creates a persons data source. /// </summary> public static NDataSource CreatePersonsDataSource() { NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("Id", typeof(Int32)), new NFieldInfo("Name", typeof(String), true), new NFieldInfo("Gender", typeof(ENGender), true), new NFieldInfo("Birthday", typeof(DateTime), true), new NFieldInfo("Country", typeof(ENCountry), true), new NFieldInfo("Phone", typeof(String), true), new NFieldInfo("Email", typeof(String), true), }); for (int i = 0; i < PersonInfos.Length; i++) { NPersonInfo info = PersonInfos[i]; dataTable.AddRow( i, // id info.Name, // name info.Gender, // gender info.Birthday, // birthday info.Country, // country info.Phone, // pnone info.Email // email ); } return(new NDataSource(dataTable)); }
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 memory data table that supports null values * NMemoryDataTable table = new NMemoryDataTable(); * table.AddField(new NFieldInfo("Name", typeof(string), true)); * table.AddField(new NFieldInfo("Birthday", typeof(DateTime), true)); * table.AddField(new NFieldInfo("Country", typeof(ENCountry), true)); * table.AddField(new NFieldInfo("Email", typeof(string), true)); * * Random rnd = new Random(); * for (int i = 0; i < NDummyDataSource.PersonInfos.Length; i++) * { * NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.PersonInfos[i]; * * bool nullName = (rnd.Next(8) == 1); * bool nullBirthday = (rnd.Next(8) == 2); * bool nullCountry = (rnd.Next(8) == 3); * bool nullEmail = (rnd.Next(8) == 4); * * table.AddRow( * (nullName? null: personInfo.Name), // name * (nullBirthday? null: (object)personInfo.Birthday), // birthday * (nullCountry ? null : (object)personInfo.Country), // country * (nullEmail? null: personInfo.Email)); // email * }*/ // create a memory data table that supports null values NMemoryDataTable table = new NMemoryDataTable(); table.AddField(new NFieldInfo("Name", typeof(string), true)); Random rnd = new Random(); for (int i = 0; i < 1; i++) { NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.PersonInfos[i]; bool nullName = (rnd.Next(8) == 1); bool nullBirthday = (rnd.Next(8) == 2); bool nullCountry = (rnd.Next(8) == 3); bool nullEmail = (rnd.Next(8) == 4); table.AddRow((nullName ? null : personInfo.Name)); } m_TableView = new NTableGridView(); m_TableView.Grid.DataSource = new NDataSource(table); m_TableView.Grid.AllowEdit = true; return(m_TableView); }
protected override NWidget CreateExampleContent() { m_TableView = new NTableGridView(); // create a dummy data source with many columns to demonstrate horizontal scrolling NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { // person info new NFieldInfo("Name-0", typeof(String)), new NFieldInfo("Gender-1", typeof(ENGender)), new NFieldInfo("Birthday-2", typeof(DateTime)), new NFieldInfo("Phone-3", typeof(String)), new NFieldInfo("Email-4", typeof(String)), // address info new NFieldInfo("Country-5", typeof(ENCountry)), new NFieldInfo("City-6", typeof(String)), new NFieldInfo("Address-7", typeof(String)), // product info new NFieldInfo("Product Name-8", typeof(String)), new NFieldInfo("Product Price-9", typeof(Double)), new NFieldInfo("Product Quantity-10", typeof(Int32)), }); for (int i = 0; i < 1000; i++) { NDummyDataSource.NPersonInfo personInfo = NDummyDataSource.RandomPersonInfo(); NDummyDataSource.NAddressInfo addressInfo = NDummyDataSource.RandomAddressInfo(); NDummyDataSource.NProductInfo productInfo = NDummyDataSource.RandomProductInfo(); dataTable.AddRow( // person info personInfo.Name, personInfo.Gender, personInfo.Birthday, personInfo.Phone, personInfo.Email, // address addressInfo.Country, addressInfo.City, addressInfo.Address, // product productInfo.Name, productInfo.Price, NDummyDataSource.RandomInt32(1, 100) ); } m_TableView.Grid.DataSource = new NDataSource(dataTable); return(m_TableView); }
/// <summary> /// Creates a products data source. /// </summary> public static NDataSource CreateProductsDataSource() { NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("Id", typeof(Int32)), new NFieldInfo("Name", typeof(String)), new NFieldInfo("Price", typeof(Double)) }); for (int i = 0; i < ProductInfos.Length; i++) { NProductInfo productInfo = ProductInfos[i]; dataTable.AddRow(i, productInfo.Name, productInfo.Price); } return(new NDataSource(dataTable)); }
/// <summary> /// Creates a fictional data source that represents received e-mails. /// </summary> /// <returns></returns> private NDataSource CreateMailDataSource() { // create a a dummy data table that represents a simple organization. NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("From", typeof(String)), new NFieldInfo("Subject", typeof(String)), new NFieldInfo("Received", typeof(DateTime)), new NFieldInfo("Size", typeof(String)), }); string[] subjects = new string[] { "VIVACOM BILL", "SharePoint Users", "USB Sticks", "Garden Conference", ".NET Core and .NET Native", "Hackers Attack", "Week in Review", "Big Data Analytics", "Encryption Compromise", "Grid Issues", "DSC SOT BILL", "Data Security Bulletin", "How Cybercriminals use Facebook", "Empowering Users Success", "Boost your Income", "The AMISH way to motivate", "Daily news", }; Random rnd = new Random(); for (int i = 0; i < 600; i++) { string name = NDummyDataSource.RandomPersonInfo().Name; string subject = subjects[rnd.Next(subjects.Length)]; DateTime received = m_Now - new TimeSpan(rnd.Next(60), rnd.Next(24), rnd.Next(60), 0); string size = (10 + rnd.Next(100)).ToString() + " KB"; dataTable.AddRow(name, subject, received, size); } return(new NDataSource(dataTable)); }
protected override NWidget CreateExampleContent() { // create a hieararchical data table that represents a simple organization. NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("Id", typeof(Int32)), new NFieldInfo("ParentId", typeof(Int32)), new NFieldInfo("Name", typeof(String)), new NFieldInfo("Job Title", typeof(ENJobTitle)), new NFieldInfo("Company", typeof(string)), }); int i = 0; // company 1 dataTable.AddRow(0, -1, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.President, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(1, 0, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.VicePresident, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(2, 1, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesManager, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(3, 2, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesRepresentative, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(4, 2, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesRepresentative, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(5, 1, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.LeadDevelop, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(6, 5, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SeniorDeveloper, NDummyDataSource.CompanyNames[0]); dataTable.AddRow(7, 5, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SeniorDeveloper, NDummyDataSource.CompanyNames[0]); // company 2 dataTable.AddRow(8, -1, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.President, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(9, 8, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.VicePresident, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(10, 9, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesManager, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(11, 10, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesRepresentative, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(12, 10, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesRepresentative, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(13, 10, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SalesRepresentative, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(14, 9, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.LeadDevelop, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(15, 14, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SeniorDeveloper, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(16, 14, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SeniorDeveloper, NDummyDataSource.CompanyNames[1]); dataTable.AddRow(17, 14, NDummyDataSource.PersonInfos[i++].Name, ENJobTitle.SeniorDeveloper, NDummyDataSource.CompanyNames[1]); // create a tree grid view // records are identified by the Id field. // the parent of each record is specified by the ParentId field. m_TreeGridView = new NTreeGridView(); m_TreeGridView.Grid.IdFieldName = "Id"; m_TreeGridView.Grid.ParentIdFieldName = "ParentId"; m_TreeGridView.Grid.DataSource = new NDataSource(dataTable); return(m_TreeGridView); }
/// <summary> /// Creates a persons order data source. /// </summary> public static NDataSource CreatePersonsOrdersDataSource() { // FIX: Remove NMemoryDataTable dataTable = new NMemoryDataTable(new NFieldInfo[] { new NFieldInfo("PersonId", typeof(Int32)), new NFieldInfo("Product Name", typeof(String)), new NFieldInfo("Product Name1", typeof(String)), new NFieldInfo("Ship To Country", typeof(ENCountry)), new NFieldInfo("Ship To Country1", typeof(ENCountry)), new NFieldInfo("Ship To City", typeof(String)), new NFieldInfo("Ship To City1", typeof(String)), new NFieldInfo("Ship To Address", typeof(String)), new NFieldInfo("Ship To Address1", typeof(String)), new NFieldInfo("Price", typeof(Double)), new NFieldInfo("Price1", typeof(Double)), new NFieldInfo("Quantity", typeof(Int32)) }); for (int i = 0; i < 10000; i++) { NAddressInfo addressInfo = RandomAddressInfo(); NProductInfo productInfo = RandomProductInfo(); dataTable.AddRow( RandomPersonIndex(), // person id productInfo.Name, // product name productInfo.Name, // product name addressInfo.Country, // ship to country addressInfo.Country, // ship to country addressInfo.City, // ship to city addressInfo.City, // ship to city addressInfo.Address, // ship to address addressInfo.Address, // ship to address productInfo.Price, // price productInfo.Price, // price Random.Next(5) + 1 // quantity ); } return(new NDataSource(dataTable)); }
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); }