public void DisablingLayerShouldRefreshMapControlOnce() { var mapControl = new MapControl(); WindowsFormsTestHelper.Show(mapControl); mapControl.Map.Layers.Add(new LayerGroup("group1")); while (mapControl.IsProcessing) { Application.DoEvents(); } var refreshCount = 0; mapControl.MapRefreshed += delegate { refreshCount++; }; mapControl.Map.Layers.First().Enabled = false; while (mapControl.IsProcessing) { Application.DoEvents(); } refreshCount.Should("map should be refreshed once when layer property changes").Be.EqualTo(1); }
public void Bind2DFunctionWith1ComponentAndCheckColumnName() { IFunction function = new Function(); function.Arguments.Add(new Variable <int>("x") { Unit = new Unit("s", "s") }); function.Arguments.Add(new Variable <int>("y") { Unit = new Unit("m", "m") }); function.Components.Add(new Variable <string>("f1") { Unit = new Unit("m/s", "m/s") }); function[0, 0] = new[] { "f1(0,0)", "f2(0,0)" }; function[1, 0] = new[] { "f1(1,0)", "f2(1,0)" }; function[0, 1] = new[] { "f1(0,1)", "f2(0,1)" }; function[1, 1] = new[] { "f1(1,1)", "f2(1,1)" }; var gridView = new DataGridView(); IFunctionBindingList functionBindingList = new FunctionBindingList(function) { SynchronizeInvoke = gridView }; gridView.DataSource = functionBindingList; WindowsFormsTestHelper.ShowModal(gridView); }
public void TestInsertRecordOnGridBoundToAFunctionBindingList() { //setup a function to bind to IFunction function = new Function(); IVariable argument = new Variable <int>(); IVariable component = new Variable <int>(); function.Arguments.Add(argument); function.Components.Add(component); function[0] = 1; function[1] = 1; function[2] = 1; //setup a grid with a menu GridControl gridControl = new GridControl(); gridControl.DataSource = new FunctionBindingList(function) { SynchronizeInvoke = gridControl }; XtraGridContextMenu xtraGridContextMenu = new XtraGridContextMenu(); xtraGridContextMenu.SourceGrid = gridControl; gridControl.ContextMenuStrip = xtraGridContextMenu; WindowsFormsTestHelper windowsFormsTestHelper = new WindowsFormsTestHelper(); windowsFormsTestHelper.ShowControl(gridControl); Assert.AreEqual(3, gridControl.DefaultView.RowCount); }
public void ChartWithDataTableAsSeriesSource() { var table = new DataTable(); table.Columns.Add("x", typeof(double)); table.Columns.Add("y", typeof(double)); table.Rows.Add(2.5, 33.3); table.Rows.Add(0.5, 13.3); // create chart and add function as a data source using object adapter class FunctionSeriesDataSource //IChart chart = new Chart(); IChartSeries series = ChartSeriesFactory.CreateLineSeries(); series.DataSource = table; series.XValuesDataMember = "x"; series.YValuesDataMember = "y"; var chartView1 = new ChartView(); chartView1.Chart.Series.Add(series); var form = new Form { Width = 600, Height = 100 }; form.Controls.Add(chartView1); WindowsFormsTestHelper.ShowModal(form); }
public void BufferAroundLine() { var form = new Form { BackColor = Color.White, Size = new Size(500, 200) }; form.Paint += delegate { Graphics g = form.CreateGraphics(); List <ICoordinate> vertices = new List <ICoordinate>(); vertices.Add(new Coordinate(0, 4)); vertices.Add(new Coordinate(40, 15)); vertices.Add(new Coordinate(50, 50)); vertices.Add(new Coordinate(100, 62)); vertices.Add(new Coordinate(240, 45)); vertices.Add(new Coordinate(350, 5)); IGeometry geometry = new LineString(vertices.ToArray()); g.DrawLines(new Pen(Color.Blue, 1), GetPoints(geometry)); BufferOp bufferOp = new BufferOp(geometry); bufferOp.EndCapStyle = BufferStyle.CapButt; bufferOp.QuadrantSegments = 0; IGeometry bufGeo = bufferOp.GetResultGeometry(5); bufGeo = bufGeo.Union(geometry); g.FillPolygon(new SolidBrush(Color.Pink), GetPoints(bufGeo)); }; WindowsFormsTestHelper.ShowModal(form); }
public void Copy2Paste3Cell() { DataTable table = CreateTableForCopyPaste(); Assert.AreEqual(0, table.Rows[0].ItemArray[1]); Assert.AreEqual(1, table.Rows[1].ItemArray[1]); Assert.AreEqual(2, table.Rows[2].ItemArray[1]); Assert.AreEqual(3, table.Rows[3].ItemArray[1]); Assert.AreEqual(4, table.Rows[4].ItemArray[1]); var tableView = new TableView { Data = table }; Action <Form> onShown = delegate { tableView.Focus(); SendKeys.SendWait("{RIGHT}"); // goto row 1 column 2 SendKeys.SendWait("+{DOWN}"); // also select cell below SendKeys.SendWait("^c"); // copy cells SendKeys.SendWait("{DOWN}"); // navigate to cell below SendKeys.SendWait("+{DOWN}+{DOWN}"); // also select 2 cells below SendKeys.SendWait("^v"); // paste }; WindowsFormsTestHelper.ShowModal(tableView, onShown); Assert.AreEqual(0, table.Rows[0].ItemArray[1]); Assert.AreEqual(1, table.Rows[1].ItemArray[1]); Assert.AreEqual(0, table.Rows[2].ItemArray[1]); // paste 0 1 to 2 3 4 expects pattern 0 1 0 Assert.AreEqual(1, table.Rows[3].ItemArray[1]); Assert.AreEqual(0, table.Rows[4].ItemArray[1]); }
public void ShowReadOnlyFirstColumn() { var x = new Variable <int>("x"); var y = new Variable <int>("y"); y.DefaultValue = -99; var f = new Function { Arguments = { x }, Components = { y } }; f[1] = 1; f[5] = 5; f[10] = 10; f[15] = 15; var tableView = new TableView(); var bindingList = new FunctionBindingList(f) { SynchronizeInvoke = tableView }; tableView.Data = bindingList; tableView.Columns[0].ReadOnly = true; WindowsFormsTestHelper.ShowModal(tableView); }
public void RenderSymbol() { VectorLayer layer = new VectorLayer(); layer.DataSource = new DataTableFeatureProvider("LINESTRING(20 20,40 40)"); VectorLayer symbolLayer = new VectorLayer("GPS"); symbolLayer.DataSource = new DataTableFeatureProvider("POINT(30 30)"); symbolLayer.Style.Symbol = Properties.Resources.NorthArrow; symbolLayer.Style.SymbolRotation = 0; symbolLayer.Style.SymbolOffset = new PointF(0, 0); symbolLayer.Style.SymbolScale = 0.5f; //Show layer on form with mapcontrol Form form = new Form(); MapControl mapControl = new MapControl(); mapControl.Dock = DockStyle.Fill; form.Controls.Add(mapControl); mapControl.Map = new Map(new Size(600, 600)); mapControl.Map.Layers.Add(symbolLayer); mapControl.Map.Layers.Add(layer); form.Show(); mapControl.Map.ZoomToExtents(); mapControl.Refresh(); form.Hide(); WindowsFormsTestHelper.ShowModal(form); }
public void ChangeYMemberSeriesViewWithFunctionAsDataSource() { var function = new Function(); var Y = new Variable <double>("Y"); var Z = new Variable <double>("Z"); var n = new Variable <double>("n"); function.Arguments.Add(Y); function.Components.Add(Z); function.Components.Add(n); Y.SetValues(new[] { 0.0, 3.0, 5.0, 6.0, 7.0 }); Z.SetValues(new[] { 0.0, 10.0, 15.0, 21.0, 15.0 }); n.SetValues(new[] { 0.001, 0.001, 0.01, 0.01, 0.01 }); var chartView = new ChartView(); IChartSeries series = ChartSeriesFactory.CreateLineSeries(); series.XValuesDataMember = Y.DisplayName; series.YValuesDataMember = Z.DisplayName; series.DataSource = new FunctionBindingList(function) { SynchronizeInvoke = chartView }; chartView.Chart.Series.Add(series); WindowsFormsTestHelper.ShowModal(chartView); }
public void DisablingLayerShouldRefreshMapControlOnce() { using (var mapControl = new MapControl { AllowDrop = false }) { WindowsFormsTestHelper.Show(mapControl); mapControl.Map.Layers.Add(new GroupLayer("group1")); while (mapControl.IsProcessing) { Application.DoEvents(); } var refreshCount = 0; mapControl.MapRefreshed += delegate { refreshCount++; }; mapControl.Map.Layers.First().Visible = false; while (mapControl.IsProcessing) { Application.DoEvents(); } // TODO: currently second refresh can happen because of timer in MapControl - timer must be replaced by local Map / Layer / MapControl custom event refreshCount.Should("map should be refreshed once when layer property changes").Be.LessThanOrEqualTo(2); } }
public void ChangingEnvelopeAfterMapControlIsShownWorksCorrectly() { var layer = new VectorLayer { DataSource = new DataTableFeatureProvider("POINT(1 1)") }; var map = new Map { Layers = { layer } }; var mapControl = new MapControl { Map = map, AllowDrop = false }; var viewEnvelope = new Envelope(10000, 10010, 10000, 10010); WindowsFormsTestHelper.Show(mapControl, delegate { map.ZoomToFit(viewEnvelope); }); for (var i = 0; i < 10; i++) { Application.DoEvents(); Thread.Sleep(100); } Assert.IsTrue(map.Envelope.Contains(viewEnvelope)); WindowsFormsTestHelper.CloseAll(); }
public void Show() { var selectFileWizardPage = new SelectFileWizardPage(); selectFileWizardPage.Filter = ""; WindowsFormsTestHelper.ShowModal(selectFileWizardPage); }
public void GivenChartLegendView_WhenSettingData_SelectionChangedFired() { // Given var mocks = new MockRepository(); var contextMenuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>(); mocks.ReplayAll(); using (var view = new ChartLegendView(contextMenuBuilderProvider) { Data = new ChartDataCollection("collection") }) { var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl"); WindowsFormsTestHelper.Show(treeViewControl); var selectionChangedCount = 0; view.SelectionChanged += (sender, args) => selectionChangedCount++; // When view.Data = new ChartDataCollection("collection"); // Then Assert.AreEqual(1, selectionChangedCount); } WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); }
public void Selection_RootNodeData_ReturnsObjectData() { // Setup var mocks = new MockRepository(); var contextMenuBuilderProvider = mocks.Stub <IContextMenuBuilderProvider>(); mocks.ReplayAll(); ChartData chartData = CreateChartData(); var chartDataCollection = new ChartDataCollection("collection"); chartDataCollection.Add(chartData); using (var view = new ChartLegendView(contextMenuBuilderProvider) { Data = chartDataCollection }) { var treeViewControl = TypeUtils.GetField <TreeViewControl>(view, "treeViewControl"); WindowsFormsTestHelper.Show(treeViewControl); treeViewControl.TrySelectNodeForData(chartDataCollection); // Call object selection = view.Selection; // Assert Assert.AreSame(chartDataCollection, selection); } WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); }
public void TableSortingAndFilteringCanBeDisabled() { var x = new Variable <int>("x"); var y = new Variable <int>("y"); y.DefaultValue = -99; var f = new Function { Arguments = { x }, Components = { y } }; f[1] = 15; f[5] = 5; f[10] = 1; f[15] = 10; var tableView = new TableView(); var bindingList = new FunctionBindingList(f) { SynchronizeInvoke = tableView }; tableView.Data = bindingList; tableView.AllowColumnSorting(false); tableView.AllowColumnFiltering(false); WindowsFormsTestHelper.ShowModal(tableView); }
public void MultipleSeriesView() { WindowsFormsTestHelper.ShowModal(new ChartView { Chart = CreateMultipleSeriesChart() }); }
public void RefreshShouldHapenFastWhenFunctionDataSourceHasManyChanges() { IFunction function = new Function { Arguments = { new Variable <int>("x") }, Components = { new Variable <int>("f") } }; var values = new int[1000]; for (var i = 0; i < values.Length; i++) { values[i] = i; } // create function binding list before to exclude it when measuring time var functionBindingList = new FunctionBindingList(function); var tableView = new TableView { Data = functionBindingList }; // now do the same when table view is shown Action <Form> onShown = delegate { var stopwatch = new Stopwatch(); stopwatch.Start(); function.SetValues(values, new VariableValueFilter <int>(function.Arguments[0], values)); stopwatch.Stop(); log.DebugFormat("Refreshing grid while inserting values into function took {0}ms", stopwatch.ElapsedMilliseconds); }; WindowsFormsTestHelper.ShowModal(tableView, onShown); }
public void MultipleSeriesChartViaImage() { WindowsFormsTestHelper.ShowModal(new PictureBox { Image = CreateMultipleSeriesChart().Image(300, 300) }); }
public void FillOutCustomClass() { //don't run on on buildserver because the keys will go everywhere ;) if (WindowsFormsTestHelper.IsBuildServer) { return; } var persons = new BindingList <Person>(); var tableView = new TableView { Data = persons }; bool ranOnShown = false; Action <Form> onShown = delegate { tableView.Focus(); SendKeys.SendWait("J"); // goto row 1 column 2 SendKeys.SendWait("{RIGHT}"); // goto row 1 column 2 SendKeys.SendWait("3"); // also select cell below SendKeys.SendWait("{DOWN}"); //commit cells Assert.AreEqual(1, persons.Count); ranOnShown = true; }; WindowsFormsTestHelper.Show(tableView, onShown); Assert.IsTrue(ranOnShown); }
public void ApplyCustomDateTimeFormatYears() { var random = new Random(); var chartView = new ChartView(); var startTime = DateTime.Now; var times = Enumerable.Range(1, 1000).Select(startTime.AddYears).ToArray(); var y = Enumerable.Range(1000, 1000).Select(i => Convert.ToDouble(random.Next(100))).ToArray(); var pointList = new List <Utils.Tuple <DateTime, double> >(); var lineSeries = ChartSeriesFactory.CreateLineSeries(); var chart = chartView.Chart; chart.Series.Add(lineSeries); chartView.DateTimeLabelFormatProvider = new QuarterNavigatableLabelFormatProvider(); for (int i = 0; i < 1000; i++) { pointList.Add(new Tuple <DateTime, double>(times[i], y[i])); } lineSeries.DataSource = pointList; lineSeries.XValuesDataMember = "First"; lineSeries.YValuesDataMember = "Second"; lineSeries.CheckDataSource(); WindowsFormsTestHelper.ShowModal(chartView); }
public void ShowRowNumbers() { var person = new List <Person> { new Person { Age = 12, Name = "Aaltje" }, new Person { Age = 11, Name = "Berend" } }; for (var i = 0; i < 10; i++) { person.Add(new Person { Age = 11, Name = "Berend" }); } var tableView = new TableView { Data = person, ShowRowNumbers = true }; WindowsFormsTestHelper.ShowModal(tableView); }
public void EmptyLineOrLineWithOnePointShouldDoNothingTools9933() { InitializeControls(); var newLineTool = AddBranchLayerAndTool(); AddNetworkCoverageAndTool(); ((NewLineTool)newLineTool).AutoCurve = false; ((NewLineTool)newLineTool).CloseLine = true; mapControl.ActivateTool(newLineTool); var args = new MouseEventArgs(MouseButtons.Left, 1, -1, -1, -1); WindowsFormsTestHelper.ShowModal(geometryEditorForm, f => { newLineTool.OnMouseDown(new Coordinate(0, 10), args); //click 1 newLineTool.OnMouseUp(new Coordinate(0, 10), args); newLineTool.OnMouseDown(new Coordinate(0, 10), args); //click 2 newLineTool.OnMouseUp(new Coordinate(0, 10), args); newLineTool.OnMouseDown(new Coordinate(0, 10), args); //click 3 newLineTool.OnMouseDoubleClick(null, args); //double click newLineTool.OnMouseUp(new Coordinate(0, 10), args); Assert.IsTrue(newLineTool.IsBusy); }); }
public void ChartWithObjectsAsSeriesSource() { IList objects = new ArrayList { new { X = 2.5, Y = 33.3 }, new { X = 0.5, Y = 13.3 } }; // create chart and add function as a data source using object adapter class FunctionSeriesDataSource IChartSeries series = ChartSeriesFactory.CreateLineSeries(); series.DataSource = objects; series.XValuesDataMember = "X"; series.YValuesDataMember = "Y"; var chartView1 = new ChartView(); chartView1.Chart.Series.Add(series); // show form var form = new Form { Width = 600, Height = 100 }; form.Controls.Add(chartView1); WindowsFormsTestHelper.ShowModal(form); }
public void ToolShouldNoLongerBeBusyAfterDoubleClick() { InitializeControls(); var newLineTool = AddBranchLayerAndTool(); AddNetworkCoverageAndTool(); ((NewLineTool)newLineTool).AutoCurve = false; mapControl.ActivateTool(newLineTool); var args = new MouseEventArgs(MouseButtons.Left, 1, -1, -1, -1); WindowsFormsTestHelper.ShowModal(geometryEditorForm, f => { newLineTool.OnMouseDown(new Coordinate(0, 10), args); //click 1 newLineTool.OnMouseUp(new Coordinate(0, 10), args); newLineTool.OnMouseMove(new Coordinate(0, 20), args); // move newLineTool.OnMouseDown(new Coordinate(0, 20), args); //click 2 newLineTool.OnMouseUp(new Coordinate(0, 20), args); newLineTool.OnMouseDown(new Coordinate(0, 20), args); //2nd click 2 newLineTool.OnMouseDoubleClick(null, args); //first double click newLineTool.OnMouseUp(new Coordinate(0, 20), args); //then up Assert.IsFalse(newLineTool.IsBusy); }); }
public void Bind2DFunctionWithTuple() { IFunction function = new Function(); function.Arguments.Add(new Variable <Pair <string, float> >()); function.Components.Add(new Variable <int>("value")); function[new Pair <string, float>("aap", 0)] = 0; function[new Pair <string, float>("aap", 11)] = 1; function[new Pair <string, float>("muis", 0)] = 1; TypeConverter.RegisterTypeConverter <Pair <string, float>, PairTypeConverter <string, float> >(); Assert.AreEqual(1, function.Arguments.Count); Assert.AreEqual(1, function.Components.Count); var gridView = new DataGridView(); IFunctionBindingList functionBindingList = new FunctionBindingList(function) { SynchronizeInvoke = gridView }; gridView.DataSource = functionBindingList; WindowsFormsTestHelper.ShowModal(gridView); }
public void ShowTableViewWithDatatableEnumType() { //demonstrates how hard it is to add custom editor to tableview for datatable //In this case you need //a typeconverter and comboboxhelper :( //TODO: look into the differences and abstract away from it var dataTable = new DataTable(); dataTable.Columns.Add("Code", typeof(string)); dataTable.Columns.Add("SomeEnum", typeof(FruitType)); for (int i = 0; i < 10; i++) { dataTable.Rows.Add(new object[] { String.Format("Item{0:000}", i), FruitType.Appel }); } dataTable.AcceptChanges(); var tableView = new TableView { Data = dataTable }; var comboBox = new RepositoryItemImageComboBox(); XtraGridComboBoxHelper.Populate(comboBox, typeof(FruitType)); tableView.SetColumnEditor(comboBox, 1); WindowsFormsTestHelper.ShowModal(tableView); }
public void RemoveRowsWhenArgumentValueIsRemovedIn2DFunction_Dimension0_WithForm() { IFunction function = new Function(); function.Arguments.Add(new Variable <int>("x1")); function.Arguments.Add(new Variable <int>("x2")); function.Components.Add(new Variable <string>("y")); function[0, 0] = "00"; function[0, 1] = "01"; function[1, 0] = "10"; function[1, 1] = "11"; var gridView = new DataGridView(); IFunctionBindingList functionBindingList = new FunctionBindingList { Function = function, SynchronizeInvoke = gridView }; gridView.DataSource = functionBindingList; Action <Form> showAction = delegate { function.Arguments[0].Values.RemoveAt(1); Application.DoEvents(); Thread.Sleep(50); Application.DoEvents(); Assert.AreEqual(function.Components[0].Values.Count, functionBindingList.Count); }; WindowsFormsTestHelper.ShowModal(gridView, showAction); }
public void InsertingValuesinTableAreSortedAutomatically() { var x = new Variable <int>("x"); var y = new Variable <int>("y"); y.DefaultValue = -99; var f = new Function { Arguments = { x }, Components = { y } }; f[1] = 1; f[5] = 5; f[10] = 10; f[15] = 15; var tableView = new TableView(); var bindingList = new FunctionBindingList(f) { SynchronizeInvoke = tableView }; tableView.Data = bindingList; WindowsFormsTestHelper.ShowModal(tableView); }
public void ShowRangeBarInForm() { var rangeBar = new RangeBar(); lb = new ListBox(); var form = new Form(); lb.Location = new Point(40, 40); form.Controls.Add(rangeBar); form.Controls.Add(lb); var histogram = new[] { 11, 21, 31, 35 }; var handleValues = new double[] { 10, 20, 30, 40, 50 }; doubleValues = new BindingList <double>(); foreach (double d in handleValues) { doubleValues.Add(d); } doubleValues.AllowEdit = true; lb.DataSource = doubleValues; var colors = new[] { Color.Red, Color.Green, Color.Yellow, Color.Blue }; rangeBar.SetHandles(handleValues, colors); rangeBar.Histogram = histogram; rangeBar.UserDraggingHandle += rangeBar_UserDraggingHandle; WindowsFormsTestHelper.ShowModal(form); }
public void ClearSelectionOnParentGroupLayerRemove() { var featureProvider = new DataTableFeatureProvider(); featureProvider.Add(new WKTReader().Read("POINT(0 0)")); var layer = new VectorLayer { DataSource = featureProvider }; var groupLayer = new GroupLayer { Layers = { layer } }; using (var mapControl = new MapControl { Map = { Layers = { groupLayer } }, AllowDrop = false }) { var selectTool = mapControl.SelectTool; selectTool.Select(featureProvider.Features.Cast <IFeature>()); WindowsFormsTestHelper.Show(mapControl); mapControl.Map.Layers.Remove(groupLayer); mapControl.WaitUntilAllEventsAreProcessed(); selectTool.Selection .Should("selection is cleared on layer remove").Be.Empty(); } WindowsFormsTestHelper.CloseAll(); }