Group: Forum Members
Last Active: Last Year
Posts: 60,
Visits: 157
|
I have an issue where previously shown controls briefly appear in Nevron chart controls that are rendering to a window when the chart control is first shown .& nbsp ; In order to reproduce the issue run the sample code and click the " Change Chart " button several times .& nbsp ; Notice that the TextBox briefly appears each time a new chart control is shown , even though the TextBox is hidden before the first chart control is shown .& nbsp ; Any advice for how to prevent this issue ? Public Class ControlImageShowsInChartIssueForm Inherits Windows.Forms.Form
Private _BackgroundControl As Windows.Forms.TextBox
Private _ChartControl1 As Nevron.Chart.WinForm.NChartControl Private _ChartControl2 As Nevron.Chart.WinForm.NChartControl Private _ChartControls() As Nevron.Chart.WinForm.NChartControl Private _IndexOfVisibleChartControl As Integer
Private WithEvents _Button1 As Windows.Forms.Button Private WithEvents _CheckBox1 As Windows.Forms.CheckBox Public Sub New() MyBase.New() Call InitializeControls() End Sub
Private Sub InitializeControls() Me.Size = New Drawing.Size(1200, 900) Me.StartPosition = FormStartPosition.CenterScreen
Dim lowResolutionDataSize As New Drawing.Size(20, 20)
Const fillMode As Nevron.Chart.SurfaceFillMode = Nevron.Chart.SurfaceFillMode.Uniform 'Const fillMode As Nevron.Chart.SurfaceFillMode = Nevron.Chart.SurfaceFillMode.ZoneTexture Const renderSurface As Nevron.GraphicsCore.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window 'Const renderSurface As Nevron.GraphicsCore.RenderSurface = Nevron.GraphicsCore.RenderSurface.Bitmap Const shadingMode As Nevron.Chart.ShadingMode = Nevron.Chart.ShadingMode.Smooth Const triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode = Nevron.Chart.MeshSurfaceCellTriangulationMode.MaxDiagonal
Dim bounds As Drawing.Rectangle = Me.ClientRectangle Me._ChartControl1 = CreateChartControlWithMeshSurface(Me, "Chart #1", bounds, Drawing.Color.SlateBlue, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize) Me._ChartControl2 = CreateChartControlWithMeshSurface(Me, "Chart #2", bounds, Drawing.Color.Coral, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize) Me._ChartControls = {Me._ChartControl1, Me._ChartControl2} Me._IndexOfVisibleChartControl = 0
Me._Button1 = New Windows.Forms.Button Me._Button1.Text = "Change Chart" Me._Button1.Location = New Drawing.Point(4, Me._ChartControl1.Bottom) Me._Button1.Width = 128 Me.Height += (Me._Button1.Height) Me.Controls.Add(Me._Button1)
Me._CheckBox1 = New Windows.Forms.CheckBox Me._CheckBox1.Text = "Render to Window" Me._CheckBox1.Location = New Drawing.Point(Me._Button1.Right + 4, Me._ChartControl1.Bottom) Me._CheckBox1.AutoSize = True Me._CheckBox1.Anchor = AnchorStyles.Left Or AnchorStyles.Bottom Me._CheckBox1.Checked = (renderSurface = Nevron.GraphicsCore.RenderSurface.Window) Me.Controls.Add(Me._CheckBox1)
Call Me.UpdateVisibleChartControl(updateIndex:=False)
Me._BackgroundControl = New Windows.Forms.TextBox Me._BackgroundControl.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom Me._BackgroundControl.Multiline = True Me._BackgroundControl.Bounds = Me._ChartControl1.Bounds 'Me._BackgroundControl.Size = Me.ClientSize Me._BackgroundControl.Text = System.String.Format("Click the ""Change Chart"" button several times.{0}{0}This control is hidden after the first time the ""Change Chart"" button is clicked so it should never be visible again.", System.Environment.NewLine) Me._BackgroundControl.BackColor = Drawing.Color.Red Me._BackgroundControl.ForeColor = Drawing.Color.Black Me._BackgroundControl.Font = New Drawing.Font(Me._BackgroundControl.Font.Name, 36, Drawing.FontStyle.Bold) Me._BackgroundControl.WordWrap = True Me._BackgroundControl.ScrollBars = ScrollBars.None Me.Controls.Add(Me._BackgroundControl) Me._BackgroundControl.BringToFront() End Sub
Private Sub _Button_Click(sender As Object, e As System.EventArgs) Handles _Button1.Click If (Me._BackgroundControl.Visible) Then Me._BackgroundControl.Visible = False Me._BackgroundControl.Text = "" Me._BackgroundControl.BackColor = Drawing.Color.Blue Me._BackgroundControl.ForeColor = Drawing.Color.White End If
Call Me.UpdateVisibleChartControl(updateIndex:=True) End Sub
Private Sub _CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles _CheckBox1.CheckedChanged Dim uBound As Integer = Me._ChartControls.GetUpperBound(0) For i As Integer = 0 To uBound With Me._ChartControls(i) If (Me._CheckBox1.Checked) Then .Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window Else .Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Bitmap End If End With Next i End Sub
Private Sub UpdateVisibleChartControl(ByVal updateIndex As Boolean) Dim uBound As Integer = Me._ChartControls.GetUpperBound(0) If updateIndex Then If (Me._IndexOfVisibleChartControl = uBound) Then Me._IndexOfVisibleChartControl = 0 Else Me._IndexOfVisibleChartControl += 1 End If End If
Me._ChartControls(Me._IndexOfVisibleChartControl).Visible = True Me._ChartControls(Me._IndexOfVisibleChartControl).BringToFront() For i As Integer = 0 To uBound If (i <> Me._IndexOfVisibleChartControl) Then Me._ChartControls(i).Visible = False End If Next i End Sub
Private Function CreateChartControlWithMeshSurface( _ ByVal parent As Windows.Forms.Control, _ ByVal title As String, _ ByVal bounds As Drawing.Rectangle, _ ByVal color As Drawing.Color, _ ByVal fillMode As Nevron.Chart.SurfaceFillMode, _ ByVal renderSurface As Nevron.GraphicsCore.RenderSurface, _ ByVal shadingMode As Nevron.Chart.ShadingMode, _ ByVal triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode, _ ByVal dataSize As Drawing.Size) As Nevron.Chart.WinForm.NChartControl
Dim chartControl As New Nevron.Chart.WinForm.NChartControl chartControl.Bounds = bounds chartControl.Settings.RenderSurface = renderSurface ' chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NPanelSelectorTool()) chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NTrackballTool())
Dim titleLabel As Nevron.Chart.NLabel = chartControl.Labels.AddHeader(title) titleLabel.TextStyle.FontStyle = New Nevron.GraphicsCore.NFontStyle("Times New Roman", 18, Drawing.FontStyle.Italic) titleLabel.TextStyle.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(Drawing.Color.FromArgb(64, 64, 255))
Dim chart As Nevron.Chart.NChart = chartControl.Charts(0) chart.Enable3D = True chart.Width = 60.0F chart.Depth = 60.0F chart.Height = 25.0F chart.Projection.SetPredefinedProjection(Nevron.GraphicsCore.PredefinedProjection.PerspectiveTilted) chart.LightModel.SetPredefinedLightModel(Nevron.GraphicsCore.PredefinedLightModel.MetallicLustre)
Dim linearScale As Nevron.Chart.NLinearScaleConfigurator = New Nevron.Chart.NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Back, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(Nevron.Chart.StandardAxis.PrimaryX).ScaleConfigurator = linearScale
linearScale = New Nevron.Chart.NLinearScaleConfigurator() linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True) linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Left, True) linearScale.RoundToTickMax = False linearScale.RoundToTickMin = False chart.Axis(Nevron.Chart.StandardAxis.Depth).ScaleConfigurator = linearScale
Dim surface As Nevron.Chart.NMeshSurfaceSeries = CType(chart.Series.Add(Nevron.Chart.SeriesType.MeshSurface), Nevron.Chart.NMeshSurfaceSeries) surface.Name = "Surface" surface.Legend.Mode = Nevron.Chart.SeriesLegendMode.None surface.FillMode = fillMode surface.SyncPaletteWithAxisScale = False surface.PaletteSteps = 8 surface.ValueFormatter.FormatSpecifier = "0.00" ' surface.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(color) ' surface.ShadingMode = shadingMode surface.CellTriangulationMode = triangulationMode ' Call SetSurfaceData(surface, dataSize)
parent.Controls.Add(chartControl)
Return chartControl End Function
Private Sub SetSurfaceData( _ ByVal surface As Nevron.Chart.NMeshSurfaceSeries, _ ByVal dataSize As Drawing.Size)
Dim x, y, z As Double Dim width As Integer = dataSize.Width Dim height As Integer = dataSize.Height Dim positionScaleFactorX As Double = CDbl(width) / 20.0# Dim positionScaleFactorZ As Double = CDbl(height) / 20.0# Const positionRangeX As Double = 20.0# Const positionRangeZ As Double = 20.0# Const positionStartX As Double = -(0.5# * positionRangeX) Const positionStartZ As Double = -(0.5# * positionRangeZ) Dim deltaX As Double = (positionRangeX / CDbl(width - 1)) Dim deltaZ As Double = (positionRangeZ / CDbl(height - 1)) ' surface.Data.SetGridSize(dataSize.Width, dataSize.Height) ' For j As Integer = 0 To (height - 1) z = CDbl(j) * deltaZ + positionStartZ For i As Integer = 0 To (width - 1) x = CDbl(i) * deltaX + positionStartX
y = Math.Sin(i / (3.0 * positionScaleFactorX)) * Math.Sin(j / (3.0 * positionScaleFactorZ))
If y < 0 Then y = Math.Abs(y / 2.0) End If
surface.Data.SetValue(i, j, y, x, z) Next i Next j End Sub
End Class
Public Class ControlImageShowsInChartIssueForm
Inherits Windows.Forms.Form
Private _BackgroundControl As Windows.Forms.TextBox
Private _ChartControl1 As Nevron.Chart.WinForm.NChartControl
Private _ChartControl2 As Nevron.Chart.WinForm.NChartControl
Private _ChartControls() As Nevron.Chart.WinForm.NChartControl
Private _IndexOfVisibleChartControl As Integer
Private WithEvents _Button1 As Windows.Forms.Button
Private WithEvents _CheckBox1 As Windows.Forms.CheckBox
Public Sub New()
MyBase.New()
Call InitializeControls()
End Sub
Private Sub InitializeControls()
Me.Size = New Drawing.Size(1200, 900)
Me.StartPosition = FormStartPosition.CenterScreen
Dim lowResolutionDataSize As New Drawing.Size(20, 20)
Const fillMode As Nevron.Chart.SurfaceFillMode = Nevron.Chart.SurfaceFillMode.Uniform
'Const fillMode As Nevron.Chart.SurfaceFillMode = Nevron.Chart.SurfaceFillMode.ZoneTexture
Const renderSurface As Nevron.GraphicsCore.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window
'Const renderSurface As Nevron.GraphicsCore.RenderSurface = Nevron.GraphicsCore.RenderSurface.Bitmap
Const shadingMode As Nevron.Chart.ShadingMode = Nevron.Chart.ShadingMode.Smooth
Const triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode = Nevron.Chart.MeshSurfaceCellTriangulationMode.MaxDiagonal
Dim bounds As Drawing.Rectangle = Me.ClientRectangle
Me._ChartControl1 = CreateChartControlWithMeshSurface(Me, "Chart #1", bounds, Drawing.Color.SlateBlue, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize)
Me._ChartControl2 = CreateChartControlWithMeshSurface(Me, "Chart #2", bounds, Drawing.Color.Coral, fillMode, renderSurface, shadingMode, triangulationMode, lowResolutionDataSize)
Me._ChartControls = {Me._ChartControl1, Me._ChartControl2}
Me._IndexOfVisibleChartControl = 0
Me._Button1 = New Windows.Forms.Button
Me._Button1.Text = "Change Chart"
Me._Button1.Location = New Drawing.Point(4, Me._ChartControl1.Bottom)
Me._Button1.Width = 128
Me.Height += (Me._Button1.Height)
Me.Controls.Add(Me._Button1)
Me._CheckBox1 = New Windows.Forms.CheckBox
Me._CheckBox1.Text = "Render to Window"
Me._CheckBox1.Location = New Drawing.Point(Me._Button1.Right + 4, Me._ChartControl1.Bottom)
Me._CheckBox1.AutoSize = True
Me._CheckBox1.Anchor = AnchorStyles.Left Or AnchorStyles.Bottom
Me._CheckBox1.Checked = (renderSurface = Nevron.GraphicsCore.RenderSurface.Window)
Me.Controls.Add(Me._CheckBox1)
Call Me.UpdateVisibleChartControl(updateIndex:=False)
Me._BackgroundControl = New Windows.Forms.TextBox
Me._BackgroundControl.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right Or AnchorStyles.Bottom
Me._BackgroundControl.Multiline = True
Me._BackgroundControl.Bounds = Me._ChartControl1.Bounds
'Me._BackgroundControl.Size = Me.ClientSize
Me._BackgroundControl.Text = System.String.Format("Click the ""Change Chart"" button several times.{0}{0}This control is hidden after the first time the ""Change Chart"" button is clicked so it should never be visible again.", System.Environment.NewLine)
Me._BackgroundControl.BackColor = Drawing.Color.Red
Me._BackgroundControl.ForeColor = Drawing.Color.Black
Me._BackgroundControl.Font = New Drawing.Font(Me._BackgroundControl.Font.Name, 36, Drawing.FontStyle.Bold)
Me._BackgroundControl.WordWrap = True
Me._BackgroundControl.ScrollBars = ScrollBars.None
Me.Controls.Add(Me._BackgroundControl)
Me._BackgroundControl.BringToFront()
End Sub
Private Sub _Button_Click(sender As Object, e As System.EventArgs) Handles _Button1.Click
If (Me._BackgroundControl.Visible) Then
Me._BackgroundControl.Visible = False
Me._BackgroundControl.Text = ""
Me._BackgroundControl.BackColor = Drawing.Color.Blue
Me._BackgroundControl.ForeColor = Drawing.Color.White
End If
Call Me.UpdateVisibleChartControl(updateIndex:=True)
End Sub
Private Sub _CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles _CheckBox1.CheckedChanged
Dim uBound As Integer = Me._ChartControls.GetUpperBound(0)
For i As Integer = 0 To uBound
With Me._ChartControls(i)
If (Me._CheckBox1.Checked) Then
.Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Window
Else
.Settings.RenderSurface = Nevron.GraphicsCore.RenderSurface.Bitmap
End If
End With
Next i
End Sub
Private Sub UpdateVisibleChartControl(ByVal updateIndex As Boolean)
Dim uBound As Integer = Me._ChartControls.GetUpperBound(0)
If updateIndex Then
If (Me._IndexOfVisibleChartControl = uBound) Then
Me._IndexOfVisibleChartControl = 0
Else
Me._IndexOfVisibleChartControl += 1
End If
End If
Me._ChartControls(Me._IndexOfVisibleChartControl).Visible = True
Me._ChartControls(Me._IndexOfVisibleChartControl).BringToFront()
For i As Integer = 0 To uBound
If (i <> Me._IndexOfVisibleChartControl) Then
Me._ChartControls(i).Visible = False
End If
Next i
End Sub
Private Function CreateChartControlWithMeshSurface( _
ByVal parent As Windows.Forms.Control, _
ByVal title As String, _
ByVal bounds As Drawing.Rectangle, _
ByVal color As Drawing.Color, _
ByVal fillMode As Nevron.Chart.SurfaceFillMode, _
ByVal renderSurface As Nevron.GraphicsCore.RenderSurface, _
ByVal shadingMode As Nevron.Chart.ShadingMode, _
ByVal triangulationMode As Nevron.Chart.MeshSurfaceCellTriangulationMode, _
ByVal dataSize As Drawing.Size) As Nevron.Chart.WinForm.NChartControl
Dim chartControl As New Nevron.Chart.WinForm.NChartControl
chartControl.Bounds = bounds
chartControl.Settings.RenderSurface = renderSurface
'
chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NPanelSelectorTool())
chartControl.Controller.Tools.Add(New Nevron.Chart.Windows.NTrackballTool())
Dim titleLabel As Nevron.Chart.NLabel = chartControl.Labels.AddHeader(title)
titleLabel.TextStyle.FontStyle = New Nevron.GraphicsCore.NFontStyle("Times New Roman", 18, Drawing.FontStyle.Italic)
titleLabel.TextStyle.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(Drawing.Color.FromArgb(64, 64, 255))
Dim chart As Nevron.Chart.NChart = chartControl.Charts(0)
chart.Enable3D = True
chart.Width = 60.0F
chart.Depth = 60.0F
chart.Height = 25.0F
chart.Projection.SetPredefinedProjection(Nevron.GraphicsCore.PredefinedProjection.PerspectiveTilted)
chart.LightModel.SetPredefinedLightModel(Nevron.GraphicsCore.PredefinedLightModel.MetallicLustre)
Dim linearScale As Nevron.Chart.NLinearScaleConfigurator = New Nevron.Chart.NLinearScaleConfigurator()
linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True)
linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Back, True)
linearScale.RoundToTickMax = False
linearScale.RoundToTickMin = False
chart.Axis(Nevron.Chart.StandardAxis.PrimaryX).ScaleConfigurator = linearScale
linearScale = New Nevron.Chart.NLinearScaleConfigurator()
linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Floor, True)
linearScale.MajorGridStyle.SetShowAtWall(Nevron.Chart.ChartWallType.Left, True)
linearScale.RoundToTickMax = False
linearScale.RoundToTickMin = False
chart.Axis(Nevron.Chart.StandardAxis.Depth).ScaleConfigurator = linearScale
Dim surface As Nevron.Chart.NMeshSurfaceSeries = CType(chart.Series.Add(Nevron.Chart.SeriesType.MeshSurface), Nevron.Chart.NMeshSurfaceSeries)
surface.Name = "Surface"
surface.Legend.Mode = Nevron.Chart.SeriesLegendMode.None
surface.FillMode = fillMode
surface.SyncPaletteWithAxisScale = False
surface.PaletteSteps = 8
surface.ValueFormatter.FormatSpecifier = "0.00"
'
surface.FillStyle = New Nevron.GraphicsCore.NColorFillStyle(color)
'
surface.ShadingMode = shadingMode
surface.CellTriangulationMode = triangulationMode
'
Call SetSurfaceData(surface, dataSize)
parent.Controls.Add(chartControl)
Return chartControl
End Function
Private Sub SetSurfaceData( _
ByVal surface As Nevron.Chart.NMeshSurfaceSeries, _
ByVal dataSize As Drawing.Size)
Dim x, y, z As Double
Dim width As Integer = dataSize.Width
Dim height As Integer = dataSize.Height
Dim positionScaleFactorX As Double = CDbl(width) / 20.0#
Dim positionScaleFactorZ As Double = CDbl(height) / 20.0#
Const positionRangeX As Double = 20.0#
Const positionRangeZ As Double = 20.0#
Const positionStartX As Double = -(0.5# * positionRangeX)
Const positionStartZ As Double = -(0.5# * positionRangeZ)
Dim deltaX As Double = (positionRangeX / CDbl(width - 1))
Dim deltaZ As Double = (positionRangeZ / CDbl(height - 1))
'
surface.Data.SetGridSize(dataSize.Width, dataSize.Height)
'
For j As Integer = 0 To (height - 1)
z = CDbl(j) * deltaZ + positionStartZ
For i As Integer = 0 To (width - 1)
x = CDbl(i) * deltaX + positionStartX
y = Math.Sin(i / (3.0 * positionScaleFactorX)) * Math.Sin(j / (3.0 * positionScaleFactorZ))
If y < 0 Then
y = Math.Abs(y / 2.0)
End If
surface.Data.SetValue(i, j, y, x, z)
Next i
Next j
End Sub
End Class
|
Group: Forum Members
Last Active: Last Month
Posts: 3,055,
Visits: 4,055
|
Hi Lance , This is most likely a Windows forms issue - we located a simple workaround though and it is to first make the charts hidden and then show the active chart : & nbsp ; Dim uBound As Integer = Me . _ChartControls . GetUpperBound ( 0 ) & nbsp ;& nbsp ; If updateIndex Then & nbsp ;& nbsp ;& nbsp ; If ( Me . _IndexOfVisibleChartControl = uBound ) Then & nbsp ;& nbsp ;& nbsp ;& nbsp ; Me . _IndexOfVisibleChartControl = 0 & nbsp ;& nbsp ;& nbsp ; Else & nbsp ;& nbsp ;& nbsp ;& nbsp ; Me . _IndexOfVisibleChartControl += 1 & nbsp ;& nbsp ;& nbsp ; End If & nbsp ;& nbsp ; End If & nbsp ;& nbsp ; For i As Integer = 0 To uBound & nbsp ;& nbsp ;& nbsp ; If ( i & lt ;& gt ; Me . _IndexOfVisibleChartControl ) Then & nbsp ;& nbsp ;& nbsp ;& nbsp ; Me . _ChartControls ( i ). Visible = False & nbsp ;& nbsp ;& nbsp ; End If & nbsp ;& nbsp ; Next i & nbsp ;& nbsp ; Me . _ChartControls ( Me . _IndexOfVisibleChartControl ). Visible = True & nbsp ;& nbsp ; Me . _ChartControls ( Me . _IndexOfVisibleChartControl ). BringToFront () Hope this helps & nbsp ;- let us know if the problem persists ...
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: Last Year
Posts: 60,
Visits: 157
|
Yes, that helps. Thanks!
|