Here are the examples of the csharp api System.Windows.Media.Color.FromArgb(byte, byte, byte, byte) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
627 Examples
19
View Source File : LogarithmicAxis3DView.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var converter = new LogarithmicBase3DConverter();
var logBinding = new Binding("SelectedValue") { ElementName = "logBasesChbx", Converter = converter };
logarithmicNumericYAxis3D.SetBinding(LogarithmicNumericAxis3D.LogarithmicBaseProperty, logBinding);
logarithmicNumericXAxis3D.SetBinding(LogarithmicNumericAxis3D.LogarithmicBaseProperty, logBinding);
var xyzDataSeries3D = new XyzDataSeries3D<double>();
var data = DataManager.Instance.GetExponentialCurve(1.8, 100);
int count = 100;
var random = new Random(0);
for (int i = 0; i < count; i++)
{
double x = data[i].X;
double y = data[i].Y;
double z = DataManager.Instance.GetGaussianRandomNumber(15, 1.5);
Color? randomColor = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
float scale = (float)((random.NextDouble() + 0.5) * 3.0);
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
pointLineSeries3D.DataSeries = xyzDataSeries3D;
}
19
View Source File : CreateABubble3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>() {SeriesName = "Colorful Bubble!"};
const int count = 250;
var random = new Random(0);
DataManager.Instance.SetRandomSeed(0); // required only by some UIAutomationTests, to have consistent results between test runs
for (var i = 0; i < count; i++)
{
var x = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var z = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
// Scale is a multiplier used to increase/decrease ScatterRenderableSeries3D.ScatterPointSize
var scale = (float) ((random.NextDouble() + 0.5)*3.0);
// Color is applied to PointMetadata3D and overrides the default ScatterRenderableSeries.Stroke property
Color? randomColor = Color.FromArgb(0xFF, (byte) random.Next(50, 255), (byte) random.Next(50, 255), (byte) random.Next(50, 255));
// To declare scale and colour, add a VertextData clreplaced as the w (fourth) parameter.
// The PointMetadata3D clreplaced also has other properties defining the behaviour of the XYZ point
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
ScatterSeries3D.DataSeries = xyzDataSeries3D;
PointMarkerCombo.SelectedIndex = 0;
}
19
View Source File : AddGeometryTo3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void CreateCubes()
{
// Create a cubes in 3D World space with TopLeft and BottomRight coordinates
// We set some cubes to transparent colors to demonstrate Order Independent Transparency
var cubeA = new CubeGeometry(new Vector3(0.0f, 0.0f, 0.0f), new Vector3(50.0f, 50.0f, 50.0f), Color.FromArgb(128, 255,0,0));
var cubeB = new CubeGeometry(new Vector3(50.0f, 0.0f, 50.0f), new Vector3(100.0f, 100.0f, 100.0f), Color.FromArgb(128, 0, 255, 0));
var cubeC = new CubeGeometry(new Vector3(100.0f, 0.0f, 100.0f), new Vector3(150.0f, 150.0f, 150.0f), Color.FromArgb(255, 0, 0, 255));
var cubeD = new CubeGeometry(new Vector3(-100.0f, 0.0f, -100.0f), new Vector3(0.0f, 150.0f, 0.0f), Color.FromArgb(255, 0, 255, 255));
var cubeE = new CubeGeometry(new Vector3(-150.0f, 0.0f, -150.0f), new Vector3(50.0f, 200.0f, 50.0f), Color.FromArgb(128, 255, 255, 255));
var cubeF = new CubeGeometry(new Vector3(-150.0f, 0.0f, -150.0f), new Vector3(-100.0f, 50.0f, -100.0f), Color.FromArgb(128, 255, 0, 0));
// NOTE: Commented code below is the example of treating the Location value
// as 3D point in Data Coordinates Space but not in World Coordinates Space
//cubeA = new CubeGeometry(new Vector3(5.0f, 0.0f, 5.0f), new Vector3(6.0f, 1.0f, 6.0f), Color.FromArgb(128, 255, 0, 0));
//cubeB = new CubeGeometry(new Vector3(6.0f, 0.0f, 6.0f), new Vector3(7.0f, 2.0f, 7.0f), Color.FromArgb(128, 0, 255, 0));
//cubeC = new CubeGeometry(new Vector3(7.0f, 0.0f, 7.0f), new Vector3(8.0f, 3.0f, 8.0f), Color.FromArgb(255, 0, 0, 255));
//cubeD = new CubeGeometry(new Vector3(3.0f, 0.0f, 3.0f), new Vector3(5.0f, 3.0f, 5.0f), Color.FromArgb(255, 0, 255, 255));
//cubeE = new CubeGeometry(new Vector3(2.0f, 0.0f, 2.0f), new Vector3(6.0f, 4.0f, 6.0f), Color.FromArgb(128, 255, 255, 255));
//cubeF = new CubeGeometry(new Vector3(2.0f, 0.0f, 2.0f), new Vector3(3.0f, 1.0f, 3.0f), Color.FromArgb(128, 255, 0, 0));
// force a far position on this cube ( user can do this in cases where a box inside another )
TSRVector3 farPosition = new TSRVector3(20000.0f, 20000.0f, 2000.0f);
cubeF.SetPosition(farPosition);
// Add the cubes to the 3D Scene
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeA);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeB);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeC);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeD);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeE);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(cubeF);
}
19
View Source File : AddGeometryTo3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void CreateLabels()
{
// Add some text labels to the scene
var textA = new TextSceneEnreplacedy("Teeny Block", Color.FromArgb(255, 0, 225, 0), new Vector3(75f, 100f, 75f), TextDisplayMode.FacingCameraAlways, 9, "Segoe UI");
var textB = new TextSceneEnreplacedy("Big Block", Color.FromArgb(255, 255, 255, 255), new Vector3(-50f,200f,-50f), TextDisplayMode.FacingCameraAlways, 10, "Tahoma");
// NOTE: Commented code below is the example of treating the Location value
// as 3D point in Data Coordinates Space but not in World Coordinates Space
//textA = new TextSceneEnreplacedy("Teeny Block", Color.FromArgb(255, 0, 225, 0), new Vector3(6.5f, 2.0f, 6.5f), TextDisplayMode.FacingCameraAlways, 9, "Segoe UI");
//textB = new TextSceneEnreplacedy("Big Block", Color.FromArgb(255, 255, 255, 255), new Vector3(4.0f, 4.0f, 4.0f), TextDisplayMode.FacingCameraAlways, 10, "Tahoma");
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(textA);
sciChart3DSurface.Viewport3D.RootEnreplacedy.Children.Add(textB);
}
19
View Source File : ThemeManager3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void ThemeManager3DChart_OnLoaded(object sender, RoutedEventArgs e)
{
scatterSeries3D.PointMarker = new PyramidPointMarker3D();
var xyzDataSeries3D = new XyzDataSeries3D<double>();
int count = 150;
var random = new Random(0);
for (int i = 0; i < count; i++)
{
double x = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
double y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
double z = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
// Scale is a multiplier used to increase/decrease ScatterRenderableSeries3D.ScatterPointSize
float scale = (float)((random.NextDouble() + 0.5) * 3.0);
// Color is applied to PointMetadata3D and overrides the default ScatterRenderableSeries.Stroke property
Color? randomColor = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
// To declare scale and colour, add a VertextData clreplaced as the w (fourth) parameter.
// The PointMetadata3D clreplaced also has other properties defining the behaviour of the XYZ point
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
scatterSeries3D.DataSeries = xyzDataSeries3D;
}
19
View Source File : CreateAPointCloud3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void PointMarkerCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ScatterSeries3D != null && OpacitySlider != null && SizeSlider != null)
{
var pmType = (Type) ((ComboBox) sender).SelectedItem;
// Special case. CustomPointMarker is defined in the XAML as it contains a custom brush
if (pmType == typeof(CustomPointMarker3D))
{
var pointMarker = (CustomPointMarker3D)this.TryFindResource("CustomPointMarkerResource");
ScatterSeries3D.PointMarker = pointMarker;
}
else
{
// Create an instance of the pointmarker we want to draw
var pointMarker = (BasePointMarker3D)Activator.CreateInstance(pmType);
ScatterSeries3D.PointMarker = pointMarker;
}
ScatterSeries3D.PointMarker.Fill = Color.FromArgb(0x77, 0xAD, 0xFF, 0x2F);
ScatterSeries3D.PointMarker.Size = (float)SizeSlider.Value;
ScatterSeries3D.PointMarker.Opacity = OpacitySlider.Value;
}
}
19
View Source File : CreateAPointLine3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
var random = new Random(0);
for (var i = 0; i < Count; i++)
{
var x = 5*Math.Sin(i);
var y = i;
var z = 5*Math.Cos(i);
Color? randomColor = Color.FromArgb(0xFF, (byte) random.Next(50, 255), (byte) random.Next(50, 255), (byte) random.Next(50, 255));
var scale = (float) ((random.NextDouble() + 0.5)*3.0);
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
PointLineSeries3D.DataSeries = xyzDataSeries3D;
}
19
View Source File : SparseColumn3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
for (var i = 1; i < Count; i++)
{
for (var j = 1; j <= Count; j++)
{
if (i != j && i % 3 == 0 && j % 3 == 0)
{
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var randomColor = Color.FromArgb(0xFF, (byte)_random.Next(0, 255), (byte)_random.Next(0, 255), (byte)_random.Next(0, 255));
xyzDataSeries3D.Append(i, y, j, new PointMetadata3D(randomColor));
}
}
}
SciChart.RenderableSeries[0].DataSeries = xyzDataSeries3D;
}
19
View Source File : SparseImpulseSeries3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
for (var i = 1; i < Count; i++)
{
for (var j = 1; j <= Count; j++)
{
if (i != j && i %3 == 0 && j%3 ==0)
{
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var randomColor = Color.FromArgb(0xFF, (byte) _random.Next(0, 255), (byte) _random.Next(0, 255), (byte) _random.Next(0, 255));
xyzDataSeries3D.Append(i, y, j, new PointMetadata3D(randomColor));
}
}
}
ImpulseSeries3D.DataSeries = xyzDataSeries3D;
PointMarkerCombo.SelectedIndex = 0;
}
19
View Source File : CubeGeometry.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public override void RenderScene(IRenderPreplacedInfo3D rpi)
{
float bottomRightCoordX = bottomRight.X;
float bottomRightCoordY = bottomRight.Y;
float bottomRightCoordZ = bottomRight.Z;
float topLeftCoordX = topLeft.X;
float topLeftCoordY = topLeft.Y;
float topLeftCoordZ = topLeft.Z;
// Commented code below is the example of treating the Location value
// as 3D point in Data Coordinates Space but not in World Coordinates Space
//bottomRightCoordX = (float)e.XCalc.GetCoordinate(bottomRight.X) - e.WorldDimensions.X / 2.0f;
//bottomRightCoordY = (float)e.YCalc.GetCoordinate(bottomRight.Y);
//bottomRightCoordZ = (float)e.ZCalc.GetCoordinate(bottomRight.Z) - e.WorldDimensions.Z / 2.0f;
//topLeftCoordX = (float)e.XCalc.GetCoordinate(topLeft.X) - e.WorldDimensions.X / 2.0f;
//topLeftCoordY = (float)e.YCalc.GetCoordinate(topLeft.Y);
//topLeftCoordZ = (float)e.ZCalc.GetCoordinate(topLeft.Z) - e.WorldDimensions.Z / 2.0f;
// y 1--------0
// | /| /|
// | 5--------4 |
// | | | | |
// | | | | |
// | | 2--------3
// | z | / |/
// | / 6--------7
// |/
// ----------- X
Vector3[] corners = {
new Vector3(topLeftCoordX, topLeftCoordY, topLeftCoordZ), //0
new Vector3(bottomRightCoordX, topLeftCoordY, topLeftCoordZ), //1
new Vector3(bottomRightCoordX, bottomRightCoordY, topLeftCoordZ), //2
new Vector3(topLeftCoordX, bottomRightCoordY, topLeftCoordZ), //3
new Vector3(topLeftCoordX, topLeftCoordY, bottomRightCoordZ), //4
new Vector3(bottomRightCoordX, topLeftCoordY, bottomRightCoordZ), //5
new Vector3(bottomRightCoordX, bottomRightCoordY, bottomRightCoordZ), //6
new Vector3(topLeftCoordX, bottomRightCoordY, bottomRightCoordZ), //7
};
Vector3[] normals = {
new Vector3(+0.0f, +0.0f, -1.0f), //front
new Vector3(+0.0f, +0.0f, +1.0f), //back
new Vector3(+1.0f, +0.0f, +0.0f), //right
new Vector3(-1.0f, +0.0f, +0.0f), //left
new Vector3(+0.0f, +1.0f, +0.0f), //top
new Vector3(+0.0f, -1.0f, +0.0f), //bottom
};
// We create a mesh context. There are various mesh render modes. The simplest is Triangles
// For this mode we have to draw a single triangle (three vertices) for each corner of the cube
// You can see
using (var meshContext = BeginLitMesh(TSRRenderMode.TRIANGLES))
{
// Set the Rasterizer State for this enreplacedy
VXccelEngine3D.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);
// Set the color before drawing vertices
meshContext.SetVertexColor(cubeColor);
// Preplaced Enreplacedy ID value for a hit test purpose
ulong selectionColor = VXccelEngine3D.EncodeSelectionId(EnreplacedyId, 0);
meshContext.SetSelectionId(selectionColor);
// Now draw the triangles. Each face of the cube is made up of two triangles
// Front face
SetNormal(meshContext, normals[0]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[3]);
// Right side face
SetNormal(meshContext, normals[2]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[6]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[6]);
SetVertex(meshContext, corners[5]);
// Top face
SetNormal(meshContext, normals[4]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[7]);
SetVertex(meshContext, corners[6]);
SetVertex(meshContext, corners[7]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[3]);
// Left side face
SetNormal(meshContext, normals[3]);
SetVertex(meshContext, corners[3]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[4]);
SetVertex(meshContext, corners[3]);
SetVertex(meshContext, corners[4]);
SetVertex(meshContext, corners[7]);
// Back face
SetNormal(meshContext, normals[1]);
SetVertex(meshContext, corners[7]);
SetVertex(meshContext, corners[5]);
SetVertex(meshContext, corners[6]);
SetVertex(meshContext, corners[7]);
SetVertex(meshContext, corners[4]);
SetVertex(meshContext, corners[5]);
// Bottom face
SetNormal(meshContext, normals[5]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[5]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[5]);
SetVertex(meshContext, corners[4]);
}
// Revert raster state
VXccelEngine3D.PopRasterizerState();
// Set the Rasterizer State for wireframe
VXccelEngine3D.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);
// Create a Line Context for a continuous line and draw the outline of the cube
var lineColor = Color.FromArgb(0xFF, cubeColor.R, cubeColor.G, cubeColor.B);
CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[1], corners[2], corners[3] });
CreateSquare(2.0f, true, lineColor, new[] { corners[4], corners[5], corners[6], corners[7] });
CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[4], corners[7], corners[3] });
CreateSquare(2.0f, true, lineColor, new[] { corners[5], corners[1], corners[2], corners[6] });
// Revert raster state
VXccelEngine3D.PopRasterizerState();
}
19
View Source File : AddRemoveDataSeries3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void AddSeriesButton_OnClick(object sender, RoutedEventArgs e)
{
if (sciChart.RenderableSeries.Count >= MaxSeriesAmount)
{
return;
}
var renderSerias = new ScatterRenderableSeries3D();
var xyzDataSeries3D = new XyzDataSeries3D<double>() {SeriesName = "Series " + ++_currentSeries};
int dataPointsCount = 15;
var random = new Random(0);
for (int i = 0; i < dataPointsCount; i++)
{
double x = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
double y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
double z = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
// Scale is a multiplier used to increase/decrease ScatterRenderableSeries3D.ScatterPointSize
float scale = (float)((random.NextDouble() + 0.5) * 3.0);
// Color is applied to PointMetadata3D and overrides the default ScatterRenderableSeries.Stroke property
Color? randomColor = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
// To declare scale and colour, add a VertextData clreplaced as the w (fourth) parameter.
// The PointMetadata3D clreplaced also has other properties defining the behaviour of the XYZ point
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
var randomPicker = new Random();
int randValue = randomPicker.Next(0, 6);
switch (randValue)
{
case 0:
renderSerias.PointMarker = new CubePointMarker3D();
break;
case 1:
renderSerias.PointMarker = new EllipsePointMarker3D();
break;
case 2:
renderSerias.PointMarker = new PyramidPointMarker3D();
break;
case 3:
renderSerias.PointMarker = new QuadPointMarker3D();
break;
case 4:
renderSerias.PointMarker = new SpherePointMarker3D();
break;
case 5:
renderSerias.PointMarker = new TrianglePointMarker3D();
break;
}
renderSerias.DataSeries = xyzDataSeries3D;
sciChart.RenderableSeries.Add(renderSerias);
var index = sciChart.RenderableSeries.IndexOf(renderSerias);
xyzDataSeries3D.SeriesName = String.Format("Series #{0}", index);
OnPropertyChanged("CanAddSeries");
OnPropertyChanged("CanRemoveSeries");
sciChart.ZoomExtents();
}
19
View Source File : ViewModel3DFactory.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static XyzDataSeries3D<double> GetDataSeries()
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
for (var i = 1; i < 15; i++)
{
for (var j = 1; j <= 15; j++)
{
if (i != j && i % 3 == 0 && j % 3 == 0)
{
var x = DataManager.Instance.GetGaussianRandomNumber(40, 19);
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var z = DataManager.Instance.GetGaussianRandomNumber(10, 5);
var randomColor = Color.FromArgb(0xFF, (byte)_random.Next(1, 255), (byte)_random.Next(0, 255), (byte)_random.Next(0, 255));
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor));
}
}
}
return xyzDataSeries3D;
}
19
View Source File : ViewModel3DFactory.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static XyzDataSeries3D<double> GetScaledDataSeries()
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
const int count = 250;
var random = new Random(0);
for (var i = 0; i < count; i++)
{
var x = DataManager.Instance.GetGaussianRandomNumber(40, 19);
var y = DataManager.Instance.GetGaussianRandomNumber(5, 1.5);
var z = DataManager.Instance.GetGaussianRandomNumber(10, 5);
var scale = (float)((random.NextDouble() + 0.5) * 3.0);
Color? randomColor = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(randomColor, scale));
}
return xyzDataSeries3D;
}
19
View Source File : SeriesCustomTooltips3DChart.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private Color GetRandomColor()
{
return Color.FromArgb(255, (byte)_random.Next(0, 255), (byte)_random.Next(0, 255),
(byte)_random.Next(0, 255));
}
19
View Source File : UseChartModifiers3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
{
var xyzDataSeries3D = new XyzDataSeries3D<double>();
const int count = 25;
double step = 0.3;
var random = new Random(0);
Color color;
for (int x = 0; x < count; x++)
{
// Color is applied to PointMetadata3D and overrides the default ScatterRenderableSeries.Stroke property
color = Color.FromArgb(0xFF, (byte)random.Next(50, 255), (byte)random.Next(50, 255), (byte)random.Next(50, 255));
for (int z = 1; z < count; z++)
{
var y = (z != 0) ? Math.Pow((double) z, step) : Math.Pow((double) z + 1, 0.3);
xyzDataSeries3D.Append(x, y, z, new PointMetadata3D(color, 2));
}
}
ScatterSeries3D.DataSeries = xyzDataSeries3D;
}
19
View Source File : UsingDonutChartExampleViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private SolidColorBrush ToShade(Color baseColor, double shade)
{
return new SolidColorBrush(Color.FromArgb(baseColor.A, (byte)(baseColor.R * shade), (byte)(baseColor.G * shade), (byte)(baseColor.B * shade)));
}
19
View Source File : PolarChartViewModelFactory.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static PolarChartViewModel New<T>() where T : IRenderableSeriesViewModel
{
var type = typeof(T);
var data = Enumerable.Range(0, PointAmount).Select(x => (double) x).ToList();
if (type == typeof(LineRenderableSeriesViewModel))
{
return new PolarChartViewModel(new LineRenderableSeriesViewModel {DataSeries = GetXyDataSeries(data)});
}
if (type == typeof(XyScatterRenderableSeriesViewModel))
{
return new PolarChartViewModel(new XyScatterRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
PointMarker = new EllipsePointMarker
{
Width = 10,
Height = 10,
Fill = Color.FromArgb(255, 71, 187, 255),
Stroke = Colors.Black
}
});
}
if (type == typeof(MountainRenderableSeriesViewModel))
{
return new PolarChartViewModel(new MountainRenderableSeriesViewModel
{DataSeries = GetXyDataSeries(data)});
}
if (type == typeof(ColumnRenderableSeriesViewModel))
{
return new PolarChartViewModel(new ColumnRenderableSeriesViewModel
{DataSeries = GetXyDataSeries(data)});
}
if (type == typeof(ImpulseRenderableSeriesViewModel))
{
return new PolarChartViewModel(new ImpulseRenderableSeriesViewModel
{DataSeries = GetHlcDataSeries(data)});
}
if (type == typeof(CandlestickRenderableSeriesViewModel))
{
return new PolarChartViewModel(new CandlestickRenderableSeriesViewModel
{DataSeries = GetOhlcDataSeries(data)});
}
if (type == typeof(OhlcRenderableSeriesViewModel))
{
return new PolarChartViewModel(new OhlcRenderableSeriesViewModel
{DataSeries = GetOhlcDataSeries(data)});
}
if (type == typeof(BoxPlotRenderableSeriesViewModel))
{
return new PolarChartViewModel(new BoxPlotRenderableSeriesViewModel {DataSeries = GetBoxSeries(data)});
}
if (type == typeof(ErrorBarsRenderableSeriesViewModel))
{
return new PolarChartViewModel(new ErrorBarsRenderableSeriesViewModel
{DataSeries = GetHlcDataSeries(data)});
}
if (type == typeof(BubbleRenderableSeriesViewModel))
{
return new PolarChartViewModel(new BubbleRenderableSeriesViewModel
{
DataSeries = GetXyzDataSeries(data),
BubbleColor = Color.FromArgb(255, 110, 0, 255),
AutoZRange = false,
});
}
if (type == typeof(BandRenderableSeriesViewModel))
{
return new PolarChartViewModel(new BandRenderableSeriesViewModel {DataSeries = GetXyyDataSeries(data)});
}
if (type == typeof(StackedColumnRenderableSeriesViewModel))
{
return new PolarChartViewModel(
new StackedColumnRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 0, 2, 195)),
StackedGroupId = "stackedColumns"
},
new StackedColumnRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 0, 143, 255)),
StackedGroupId = "stackedColumns"
},
new StackedColumnRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 84)),
StackedGroupId = "stackedColumns"
});
}
if (type == typeof(StackedMountainRenderableSeriesViewModel))
{
return new PolarChartViewModel(
new StackedMountainRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 57, 255, 0)),
StackedGroupId = "stackedMountains",
},
new StackedMountainRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 251, 255, 0)),
StackedGroupId = "stackedMountains",
},
new StackedMountainRenderableSeriesViewModel
{
DataSeries = GetXyDataSeries(data),
Fill = new SolidColorBrush(Color.FromArgb(255, 0, 90, 255)),
StackedGroupId = "stackedMountains",
});
}
throw new NotImplementedException("Unsupported Series Type");
}
19
View Source File : ColorHelper.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static Color SetColorTransparency(Color color, byte A)
{
return Color.FromArgb(A, color.R, color.G, color.B);
}
19
View Source File : FastPalettedScatterCharts.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static Color GetRandomColor(Random random)
{
return Color.FromArgb(0xFF, (byte)random.Next(255), (byte)random.Next(255), (byte)random.Next(255));
}
19
View Source File : CustomOverviewViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void Initialize()
{
RenderableSeriesViewModels = new ObservableCollection<IRenderableSeriesViewModel>();
var random = new Random(0);
var generator = new RandomWalkGenerator();
for (int i = 0; i < SeriesCount; i++)
{
var dataSeries = new UniformXyDataSeries<double>();
var someData = generator.GetRandomWalkYData(PointCount);
generator.Reset();
dataSeries.Append(someData);
var rgb = new byte[3];
random.NextBytes(rgb);
RenderableSeriesViewModels.Add(new LineRenderableSeriesViewModel
{
DataSeries = dataSeries,
AntiAliasing = false,
Stroke = Color.FromArgb(255, rgb[0], rgb[1], rgb[2])
});
}
}
19
View Source File : LabelColorGenerator.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private Color FromUInt(uint color)
{
return Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color);
}
19
View Source File : LineSeriesSource.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static void OnDataSeriesDependencyPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var sciChartSurface = d as SciChartSurface;
if (sciChartSurface == null) return;
if (e.NewValue == null)
{
sciChartSurface.RenderableSeries.Clear();
return;
}
using (sciChartSurface.SuspendUpdates())
{
sciChartSurface.RenderableSeries.Clear();
var random = new Random();
var itr = (IEnumerable<IDataSeries>)e.NewValue;
var renderSeries = new List<IRenderableSeries>();
foreach (var dataSeries in itr)
{
if (dataSeries == null) continue;
var rgb = new byte[3];
random.NextBytes(rgb);
var renderableSeries = new FastLineRenderableSeries()
{
AntiAliasing = true,
Stroke = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]),
DataSeries = dataSeries,
StrokeThickness = 1,
};
renderSeries.Add(renderableSeries);
}
sciChartSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>(renderSeries);
}
}
19
View Source File : AnnotationDragModifier3D.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
void AddAnnotation()
{
boxAnnotation = new BoxAnnotation3D();
boxAnnotation.RangeX = new DoubleRange(rand.Next(20, 30), rand.Next(70, 90));
boxAnnotation.RangeY = new DoubleRange(rand.Next(20, 30), rand.Next(70, 90));
boxAnnotation.RangeZ = new DoubleRange(rand.Next(20, 30), rand.Next(70, 90));
boxAnnotation.Color = Color.FromArgb(150, 255, 255, 255);
boxAnnotation.DragColor = Color.FromArgb(220, 240, 147, 43);
boxAnnotation.Stroke = Color.FromRgb(52, 152, 219);
boxAnnotation.StrokeWidth = 2;
SciChart.Viewport3D.RootEnreplacedy.Children.Add(boxAnnotation);
var binding = new System.Windows.Data.Binding("RangeX");
binding.Source = boxAnnotation;
textBlock.SetBinding(System.Windows.Controls.TextBlock.TextProperty, binding);
}
19
View Source File : SeriesSelectionExampleView.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public void SeriesSelectionExampleView_OnLoaded(object sender, RoutedEventArgs e)
{
// Create a number of DataSeries of type X=double, Y=double
var allDataSeries = new IUniformXyDataSeries<double>[SeriesCount];
var initialColor = Colors.Blue;
// Suspend visual updates while we add N RenderableSeries
using (sciChartSurface.SuspendUpdates())
{
// Add N data and renderable series
for (int i = 0; i < SeriesCount; i++)
{
AxisAlignment alignment = i % 2 == 0 ? AxisAlignment.Left : AxisAlignment.Right;
allDataSeries[i] = GenerateDataSeries(alignment, i);
var renderableSeries = new FastLineRenderableSeries {Stroke = initialColor};
renderableSeries.YAxisId = alignment.ToString();
// replacedign DataSeries to RenderableSeries
renderableSeries.DataSeries = allDataSeries[i];
// replacedign RenderableSeries to SciChartSurface
sciChartSurface.RenderableSeries.Add(renderableSeries);
// Colors are incremented for visual purposes only
int newR = initialColor.R == 255 ? 255 : initialColor.R + 5;
int newB = initialColor.B == 0 ? 0 : initialColor.B - 2;
initialColor = Color.FromArgb(255, (byte) newR, initialColor.G, (byte) newB);
}
}
sciChartSurface.RenderableSeries[SeriesCount / 2].IsSelected = true;
sciChartSurface.ZoomExtents();
}
19
View Source File : SciChartMvvmBindingsViewModel.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private void InitializeAnnotations()
{
AnnotationViewModels.Add(new TextAnnotationViewModel
{
Text = "Annotations are Easy!",
FontSize = 24,
X1 = 0.3,
Y1 = 9.7
});
// Text with anchor points
AnnotationViewModels.Add(new TextAnnotationViewModel
{
HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
Text = "Anchor Center (X1, Y1)",
VerticalAnchorPoint = VerticalAnchorPoint.Bottom,
X1 = 5.0,
Y1 = 8
});
AnnotationViewModels.Add(new TextAnnotationViewModel
{
HorizontalAnchorPoint = HorizontalAnchorPoint.Right,
Text = "Anchor Right",
VerticalAnchorPoint = VerticalAnchorPoint.Top,
X1 = 5.0,
Y1 = 8.0
});
AnnotationViewModels.Add(new TextAnnotationViewModel
{
HorizontalAnchorPoint = HorizontalAnchorPoint.Left,
VerticalAnchorPoint = VerticalAnchorPoint.Top,
Text = "or Anchor Left",
X1 = 5.0,
Y1 = 8.0
});
// Watermark
AnnotationViewModels.Add(new TextAnnotationViewModel
{
AnnotationCanvas = AnnotationCanvas.BelowChart,
CoordinateMode = AnnotationCoordinateMode.Relative,
HorizontalAnchorPoint = HorizontalAnchorPoint.Center,
Text = "Create a Watermark",
VerticalAnchorPoint = VerticalAnchorPoint.Center,
X1 = 0.5,
Y1 = 0.5,
FontSize = 56,
FontWeight = FontWeights.Bold,
Foreground = new SolidColorBrush(Color.FromArgb(101, 247, 161, 161))
});
AnnotationViewModels.Add(new LineAnnotationViewModel
{
Stroke = Colors.Chartreuse,
StrokeThickness = 2,
Tooltip = "Hi, I am tooltip!",
X1 = 1,
X2 = 2,
Y1 = 4,
Y2 = 6
});
AnnotationViewModels.Add(new HorizontalLineAnnotationViewModel
{
HorizontalAlignment = HorizontalAlignment.Right,
FontSize = 12,
FontWeight = FontWeights.Bold,
LabelPlacement = LabelPlacement.TopLeft,
LabelValue = "Right Aligned, with text on left",
ShowLabel = true,
Stroke = Colors.Orange,
StrokeThickness = 2,
X1 = 5,
X2 = 6,
Y1 = 3.2,
IsEditable = true
});
AnnotationViewModels.Add(new LineArrowAnnotationViewModel
{
Stroke = Colors.Cyan,
StrokeThickness = 2,
X1 = 1.2,
X2 = 2.5,
Y1 = 3.8,
Y2 = 6,
HeadWidth = 8,
HeadLength = 4
});
AnnotationViewModels.Add(new VerticalLineAnnotationViewModel
{
VerticalAlignment = VerticalAlignment.Stretch,
FontSize = 12,
FontWeight = FontWeights.Bold,
ShowLabel = true,
Stroke = Colors.Brown,
LabelValue = "Vertical Line, hello everybody",
LabelPlacement = LabelPlacement.Bottom,
StrokeThickness = 2,
X1 = 9,
Y1 = 4,
IsEditable = true
});
AnnotationViewModels.Add(new BoxAnnotationViewModel
{
Background = new SolidColorBrush(Colors.LawnGreen),
BorderBrush = new SolidColorBrush(Colors.DarkGreen),
BorderThickness = new Thickness(5),
CornerRadius = new CornerRadius(3),
X1 = 5.5,
X2 = 7,
Y1 = -2,
Y2 = -5,
IsEditable = true
});
AnnotationViewModels.Add(new AxisMarkerAnnotationViewModel
{
X1 = 4,
Y1 = 3,
Background = new SolidColorBrush(Colors.Red),
IsEditable = true
});
AnnotationViewModels.Add(new ArrowAnnotationViewModel
{
X1 = 6.96,
Y1 = 5.05,
IsEditable = true
});
AnnotationViewModels.Add(new BoxAnnotationViewModel
{
X1 = 2,
X2 = 5,
Y1 = -2,
Y2 = -4,
IsEditable = true,
StyleKey = "CustomBoxAnnotationStyle"
});
}
19
View Source File : DataManager.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public Color GetRandomColor()
{
return Color.FromArgb(0xFF, (byte)_random.Next(255), (byte)_random.Next(255), (byte)_random.Next(255));
}
19
View Source File : ColorGenerator.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public static Color FromUInt(uint color)
{
return Color.FromArgb((byte)(color >> 24), (byte)(color >> 16), (byte)(color >> 8), (byte)color);
}
19
View Source File : VerticalPlaneGeometry.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public override void RenderScene(IRenderPreplacedInfo3D rpi)
{
float fStartCoordX = (float)rpi.XCalc.GetCoordinate(m_startX) - rpi.WorldDimensions.X / 2.0f;
float fStartCoordY = (float)rpi.YCalc.GetCoordinate(m_startY);
float fStartCoordZ = (float)rpi.ZCalc.GetCoordinate(m_startZ) - rpi.WorldDimensions.Z / 2.0f;
float fEndCoordX = (float)rpi.XCalc.GetCoordinate(m_endX) - rpi.WorldDimensions.X / 2.0f;
float fEndCoordY = (float)rpi.YCalc.GetCoordinate(m_endY);
float fEndCoordZ = (float)rpi.ZCalc.GetCoordinate(m_endZ) - rpi.WorldDimensions.Z / 2.0f;
float fHalfHeightCoord = (float)((rpi.YCalc.GetCoordinate(m_height) - rpi.YCalc.GetCoordinate(0.0)) / 2.0);
Vector3[] corners = {
new Vector3(fStartCoordX, fStartCoordY - fHalfHeightCoord, fStartCoordZ), // bottom start
new Vector3(fEndCoordX, fEndCoordY - fHalfHeightCoord, fEndCoordZ), // bottom end
new Vector3(fStartCoordX, fStartCoordY + fHalfHeightCoord, fStartCoordZ), // top start
new Vector3(fEndCoordX, fEndCoordY + fHalfHeightCoord, fEndCoordZ), // top end
};
Plane plane = new Plane(corners[0], corners[1], corners[2]);
Vector3[] normals = {
new Vector3(plane.NormalX, plane.NormalY, plane.NormalZ), // front
new Vector3(-plane.NormalX, -plane.NormalY, -plane.NormalZ) // back
};
// We create a mesh context. There are various mesh render modes. The simplest is Triangles
// For this mode we have to draw a couple of triangles (three vertices) for each side of the plane
// You can see
using (var meshContext = BeginLitMesh(TSRRenderMode.TRIANGLES))
{
// Set the Rasterizer State for this enreplacedy
VXccelEngine3D.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);
// Set the color before drawing vertices
meshContext.SetVertexColor(m_color);
// Now draw the triangles. Each face of the plane is made up of two triangles
// Front face
SetNormal(meshContext, normals[1]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[3]);
// Back face
SetNormal(meshContext, normals[0]);
SetVertex(meshContext, corners[0]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[2]);
SetVertex(meshContext, corners[1]);
SetVertex(meshContext, corners[3]);
SetVertex(meshContext, corners[2]);
}
// Revert raster state
VXccelEngine3D.PopRasterizerState();
if (m_drawWireframe)
{
// Set the Rasterizer State for wireframe
VXccelEngine3D.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);
// Create a Line Context for a continuous line and draw the outline of the cube
var lineColor = Color.FromArgb(0xFF, m_color.R, m_color.G, m_color.B);
CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[1], corners[3], corners[2] });
// Revert raster state
VXccelEngine3D.PopRasterizerState();
}
}
19
View Source File : DimTracePaletteProvider.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public Color? OverrideStrokeColor(IRenderableSeries rSeries, int index, IPointMetadata metadata)
{
var defaultColor = rSeries.Stroke;
if (rSeries.DataSeries == null)
return defaultColor;
var xyzSeries = ((XyzDataSeries<double, double, double>)rSeries.DataSeries);
double actualTime = xyzSeries.ZValues[index];
double latestTime = (double) xyzSeries.Tag;
// how old is the sample? 1.0 = New, 0.0 = Oldest
double sampleAge = (actualTime - latestTime) / 10.0;
// Clamp in ten steps, e.g. 0.1, 0.2 .... 0.9, 1.0
// Why? Creating a new Pen for each single sample will slow down SciChart significantly
sampleAge = Math.Round(sampleAge * 10.0, 0) * 0.1;
// Ensure in the range 0.3 ... 1.0 always
sampleAge = Math.Max(0.3, sampleAge);
sampleAge = Math.Min(1.0, sampleAge);
// Compute the Alpha based on sample age
var modifiedColor = Color.FromArgb((byte)(sampleAge * 0xFF), defaultColor.R, defaultColor.G, defaultColor.B);
return modifiedColor;
}
19
View Source File : TimeLineControl.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private int GetRandomColor()
{
return (int)Color.FromArgb(0xFF, (byte)_random.Next(50, 255), (byte)_random.Next(50, 255), (byte)_random.Next(50, 255)).ToArgb();
}
19
View Source File : LineSeriesSource.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static void OnDataSeriesDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var sciChartSurface = d as SciChartSurface;
if (sciChartSurface == null) return;
if (e.NewValue == null)
{
sciChartSurface.RenderableSeries.Clear();
return;
}
using (sciChartSurface.SuspendUpdates())
{
sciChartSurface.RenderableSeries.Clear();
var random = new Random();
var itr = (IEnumerable<IDataSeries>)e.NewValue;
var renderSeries = new List<IRenderableSeries>();
// 1.7.2 specific
var dataset = new DataSeriesSet<double, double>();
foreach (var dataSeries in itr)
{
if (dataSeries == null) continue;
// 1.7.2 specific
dataset.Add(dataSeries);
var rgb = new byte[3];
random.NextBytes(rgb);
var renderableSeries = new FastLineRenderableSeries()
{
ResamplingMode = ResamplingMode.MinMax,
SeriesColor = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]),
DataSeries = dataSeries,
};
renderSeries.Add(renderableSeries);
}
// 1.7.2 specific
sciChartSurface.DataSet = dataset;
sciChartSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>(renderSeries);
}
}
19
View Source File : FifoLineSeriesSpeedTest.xaml.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
public void Execute(TestParameters testParameters, TimeSpan duration, Action<double> fpsResult)
{
_generator = new RandomLinesGenerator();
var initialData = _generator.GetRandomLinesSeries(testParameters.PointCount);
Random random = new Random();
for (int i = 0; i < SeriesCount; i++)
{
// Setup
_xyDataSeries = new XyDataSeries<double, double>() { FifoCapacity = testParameters.PointCount, DataDistributionCalculator = d };
_listSeries.Add(_xyDataSeries);
var rgb = new byte[3];
random.NextBytes(rgb);
_xyDataSeries.Append(initialData.XData, ScaleAndOffset(initialData.YData, 0.1, (double)i*0.2));
var tmp = new SciChart.Charting.Visuals.RenderableSeries.FastLineRenderableSeries();
tmp.DataSeries = _xyDataSeries;
tmp.AntiAliasing = testParameters.AntiAliasing;
tmp.Stroke = System.Windows.Media.Color.FromArgb(255, rgb[0], rgb[1], rgb[2]);
tmp.ResamplingMode = (ResamplingMode)Enum.Parse(typeof(ResamplingMode), testParameters.SamplingMode.ToString());
sciChart.RenderableSeries.Add(tmp);
}
// Execute
if (testParameters.TestRunner == TestRunnerType.Composition)
_testRunner = new CompositionTestRunner(duration, OnAppendData, fpsResult);
else
_testRunner = new DispatcherTimerRunner(duration, OnAppendData, fpsResult);
sciChart.Rendered += _testRunner.OnSciChartRendered;
_testRunner.Run();
}
19
View Source File : LineSeriesSource.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static void OnDataSeriesDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var sciChartSurface = d as SciChartSurface;
if (sciChartSurface == null) return;
if (e.NewValue == null)
{
sciChartSurface.RenderableSeries.Clear();
return;
}
using (sciChartSurface.SuspendUpdates())
{
sciChartSurface.RenderableSeries.Clear();
var random = new Random();
var itr = (IEnumerable<IDataSeries>)e.NewValue;
var renderSeries = new List<IRenderableSeries>();
var strokeThckness = GetStrokeThickness(sciChartSurface);
var aa = GetAntiAliasing(sciChartSurface);
foreach (var dataSeries in itr)
{
if (dataSeries == null) continue;
var rgb = new byte[3];
random.NextBytes(rgb);
var renderableSeries = new FastLineRenderableSeries()
{
ResamplingMode = ResamplingMode.MinMax,
StrokeThickness = (int) strokeThckness,
Stroke = Color.FromArgb(255, rgb[0], rgb[1], rgb[2]),
AntiAliasing = aa,
DataSeries = dataSeries,
};
renderSeries.Add(renderableSeries);
}
sciChartSurface.RenderableSeries = new ObservableCollection<IRenderableSeries>(renderSeries);
}
}
19
View Source File : HeatProvider.cs
License : MIT License
Project Creator : ABTSoftware
License : MIT License
Project Creator : ABTSoftware
private static Color DoubleToArgbColor(double x, int r1, int g1, int b1, int r2, int g2, int b2)
{
if (x > 1) x = 1;
if (x < 0) x = 0;
int r = r1 + (int)((r2 - r1) * x);
int g = g1 + (int)((g2 - g1) * x);
int b = b1 + (int)((b2 - b1) * x);
return Color.FromArgb(255 , (byte) r , (byte) g , (byte) b);
}
19
View Source File : MainControl.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void OnLoaded(object sender, EventArgs e) {
// Create the main CircularGauge and add it to the target panel
CircularGauge circularGauge = new CircularGauge() {
Width = 220,
Height = 220,
Radius = 110,
HorizontalAlignment = HorizontalAlignment.Center,
Background = new SolidColorBrush(Color.FromArgb(0xff, 0xee, 0xee, 0xe3)),
RimBrush = new SolidColorBrush(Color.FromArgb(0xff, 0xf4, 0xf3, 0xf8)),
FrameType = CircularFrameType.CircularGear,
IsBackgroundEffectEnabled = false,
};
this.targetPanel.Children.Insert(0, circularGauge);
// Create and add a CircularScale to the CircularGauge
CircularScale circularScale = new CircularScale() {
Radius = 75,
StartAngle = 30,
SweepAngle = 330,
BarExtent = 1
};
circularGauge.Scales.Add(circularScale);
// Create and add a CircularTickSet to the CircularScale
CircularTickSet circularTickSet = new CircularTickSet() {
MajorInterval = 10,
MinorInterval = 2
};
circularScale.TickSets.Add(circularTickSet);
// Create and add two CircularRanges to the CircularTickSet
circularTickSet.Ranges.Add(new CircularRange() {
ScalePlacement = ScalePlacement.Inside,
StartValue = 80,
EndValue = 100,
HasDropShadow = false,
StartExtent = 15,
EndExtent = 15,
Background = LinearGradientBrushExtension.CreateBrush(Colors.Red, Colors.DarkRed, LinearGradientType.LeftToRight),
});
circularTickSet.Ranges.Add(new CircularRange() {
ScalePlacement = ScalePlacement.Inside,
StartValue = 0,
EndValue = 20,
HasDropShadow = false,
StartExtent = 15,
EndExtent = 15,
Background = LinearGradientBrushExtension.CreateBrush(Colors.Green, Colors.DarkGreen, LinearGradientType.LeftToRight)
});
// Create and add a CircularTickMarkMajor and CircularTickMarkMinor to the CircularTickSet
circularTickSet.Ticks.Add(new CircularTickMarkMajor() {
TickMarkExtent = 10,
TickMarkAscent = 4,
TickMarkType = TickMarkType.SwordBlunt,
Background = LinearGradientBrushExtension.CreateBrush(Colors.Black, Colors.DarkGray, LinearGradientType.TopToBottom)
});
circularTickSet.Ticks.Add(new CircularTickMarkMinor() {
TickMarkExtent = 7,
TickMarkAscent = 4,
TickMarkType = TickMarkType.TriangleSharp,
Background = LinearGradientBrushExtension.CreateBrush(Colors.Black, Colors.DarkGray, LinearGradientType.TopToBottom)
});
// Create and add a CircularTickLabelMajor to the CircularTickSet
circularTickSet.Ticks.Add(new CircularTickLabelMajor() {
Foreground = new SolidColorBrush(Color.FromArgb(0xff, 0x0c, 0x09, 0x09)),
FontSize = 10,
ScalePlacement = ScalePlacement.Outside,
ScaleOffset = 5,
TextOrientation = TextOrientation.Rotated
});
// Create and add a CircularPointerNeedle and CircularPointerCap to the CircularTickSet
CircularPointerNeedle circularPointerNeedle = new CircularPointerNeedle() {
NeedleType = PointerNeedleType.TriangleSharp,
PointerExtent = 75,
PointerAscent = 10,
Background = LinearGradientBrushExtension.CreateBrush(Color.FromArgb(0xff, 0xe1, 0x61, 0x79), Color.FromArgb(0xff, 0x9a, 0x12, 0x25), LinearGradientType.LeftToRight),
};
circularTickSet.Pointers.Add(circularPointerNeedle);
// Binding the needle to the value slider
circularPointerNeedle.SetBinding(CircularPointerNeedle.ValueProperty, new Binding("Value") {
Source = this,
Mode = BindingMode.TwoWay
});
// Create and add a CircularPointerCap to the CircularTickSet
circularTickSet.Pointers.Add(new CircularPointerCap() {
PointerExtent = 25,
CapType = PointerCapType.CircleConvex,
Background = new SolidColorBrush(Color.FromArgb(0xff, 0x9a, 0x12, 0x25))
});
}
19
View Source File : SegmentColorConverter.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
#endif
// Create a green to yellow to red gradient effect
var intValue = (int)value;
switch (intValue) {
case 1:
return new SolidColorBrush(Color.FromArgb(0xff, 0x00, 0x80, 0x00));
case 2:
return new SolidColorBrush(Color.FromArgb(0xff, 0x20, 0x90, 0x00));
case 3:
return new SolidColorBrush(Color.FromArgb(0xff, 0x4e, 0xa7, 0x00));
case 4:
return new SolidColorBrush(Color.FromArgb(0xff, 0x7f, 0xbf, 0x00));
case 5:
return new SolidColorBrush(Color.FromArgb(0xff, 0xb1, 0xd8, 0x00));
case 6:
return new SolidColorBrush(Color.FromArgb(0xff, 0xea, 0xf4, 0x00));
case 7:
return new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xdc, 0x00));
case 8:
return new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0xae, 0x00));
case 9:
return new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0x50, 0x00));
default:
return new SolidColorBrush(Color.FromArgb(0xff, 0xff, 0x30, 0x00));
}
}
19
View Source File : AlternatingRowsAdornmentManager.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void OnDrawAdornment(TextViewDrawContext context, IAdornment adornment) {
var color = Color.FromArgb(0x20, 0x80, 0x80, 0x80);
context.FillRectangle(new Rect(adornment.Location, adornment.Size), color);
}
19
View Source File : ColorPreviewTagger.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
public override IEnumerable<TagSnapshotRange<ColorPreviewTag>> GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object parameter) {
if (snapshotRanges != null) {
// Loop through the snapshot ranges
foreach (TextSnapshotRange snapshotRange in snapshotRanges) {
// Get the text of the snapshot range
string text = snapshotRange.Text;
// Look for a regex pattern match
MatchCollection matches = Regex.Matches(text, this.Pattern, RegexOptions.IgnoreCase);
if (matches.Count > 0) {
// Loop through the matches
foreach (Match match in matches) {
// Create a tag
ColorPreviewTag tag = new ColorPreviewTag();
tag.Color = UIColor.FromWebColor(match.Value).ToColor();
// Ensure full alpha
if (tag.Color.A < 255)
tag.Color = Color.FromArgb(255, tag.Color.R, tag.Color.G, tag.Color.B);
// Yield the tag
yield return new TagSnapshotRange<ColorPreviewTag>(
TextSnapshotRange.FromSpan(snapshotRange.Snapshot, snapshotRange.StartOffset + match.Index, match.Length), tag);
}
}
}
}
}
19
View Source File : CustomIndicatorTag.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
public override void DrawGlyph(TextViewDrawContext context, ITextViewLine viewLine, TagSnapshotRange<IIndicatorTag> tagRange, Rect bounds) {
var diameter = Math.Max(8.0, Math.Min(13, Math.Round(Math.Min(bounds.Width, bounds.Height) - 2.0)));
var x = bounds.X + (bounds.Width - diameter) / 2.0;
var y = bounds.Y + (bounds.Height - diameter) / 2.0;
context.FillEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x8a, 0xf3, 0x82));
context.DrawEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x00, 0x40, 0x00), LineKind.Solid, 1);
}
19
View Source File : CalendarPage.xaml.cs
License : MIT License
Project Creator : Actipro
License : MIT License
Project Creator : Actipro
private void ClearAndPopulateCalendar() {
coreGrid.Children.Clear();
Month month = this.Month;
Day startDay = this.StartDay;
int totalDays;
daysPerMonth.TryGetValue(month, out totalDays);
if (totalDays == 0)
return;
// Populate blank day boxes
Day currentDay = Day.Sunday;
for (int i = 0; i < (int)startDay; i++) {
// Create a border and set parameters
Border border = new Border() {
BorderBrush = new SolidColorBrush(Colors.Black),
BorderThickness = new Thickness(0)
};
Grid.SetColumn(border, (int)currentDay);
Grid.SetRow(border, 0);
// Create a grid
Grid grid = new Grid();
// Make the grid a child of the border
border.Child = grid;
// Color the current day
grid.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));
// Add the border to the core grid
coreGrid.Children.Add(border);
// Increment the current day
currentDay++;
}
// Iterate through all the days of the month
currentDay = startDay;
for (int i = 0; i < totalDays; i++) {
// Create a border and set parameters
Border border = new Border() {
BorderBrush = new SolidColorBrush(Colors.Black),
BorderThickness = new Thickness(1)
};
Grid.SetColumn(border, (int)currentDay);
Grid.SetRow(border, (int)((i + (int)startDay) / 7));
// Create a grid and configure it
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() {
Height = new GridLength(0, GridUnitType.Auto)
});
grid.RowDefinitions.Add(new RowDefinition());
// Make the grid a child of the border
border.Child = grid;
// Create the text block that displays the day number and set parameters
TextBlock textBox = new TextBlock() {
Text = (i + 1).ToString(),
FontSize = 10,
Margin = new Thickness(1, 1, 0, 0)
};
// Make the text block that displays the day number a child of the grid
grid.Children.Add(textBox);
// Generate this day's holiday string
string holidayString = "";
foreach (var holiday in holidays) {
if (holiday.Day == i + 1)
holidayString += holiday.HolidayName + Environment.NewLine;
}
if (!String.IsNullOrEmpty(holidayString))
holidayString = holidayString.Remove(holidayString.Length - 2);
// Create the text block that displays holiday information
textBox = new TextBlock() {
Text = holidayString,
FontSize = 8,
Margin = new Thickness(1, 0, 0, 0),
VerticalAlignment = VerticalAlignment.Bottom
};
// Set the grid row of the text block that displays holiday information to 1
Grid.SetRow(textBox, 1);
// Make the text block that displays the holiday information a child of the grid
grid.Children.Add(textBox);
// Color the current day
if ((DateTime.Now.Month == ((int)Month) + 1) && (DateTime.Now.Day == (i + 1)))
grid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 150));
// Color days that contain holidays
else if (!String.IsNullOrEmpty(holidayString))
grid.Background = new SolidColorBrush(Color.FromArgb(255, 158, 211, 255));
// Add the border to the core grid
coreGrid.Children.Add(border);
// Increment the current day
if (currentDay != Day.Saturday)
currentDay++;
else
currentDay = Day.Sunday;
}
int cell = (int)startDay + totalDays;
int row = (int)(cell / 7);
int column = cell % 7;
while (row < 6) {
// Create a border and set parameters
Border border = new Border() {
BorderBrush = new SolidColorBrush(Colors.Black),
BorderThickness = new Thickness(0)
};
Grid.SetColumn(border, column);
Grid.SetRow(border, row);
// Create a grid
Grid grid = new Grid();
// Make the grid a child of the border
border.Child = grid;
// Color the current day
grid.Background = new SolidColorBrush(Color.FromArgb(255, 224, 224, 224));
// Add the border to the core grid
coreGrid.Children.Add(border);
// Increment the cell
column++;
if (column > 6) {
column = 0;
row++;
}
}
}
19
View Source File : ModelGenerator.cs
License : GNU General Public License v3.0
Project Creator : ahmed605
License : GNU General Public License v3.0
Project Creator : ahmed605
internal static ModelNode GenerateModel(Drawable drawable, TextureFile[] textures)
{
var random = new Random();
var materials = new Material[drawable.Materials.Count];
for (int i = 0; i < materials.Length; i++)
{
Brush brush =
new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, (byte)random.Next(0, 255),
(byte)random.Next(0, 255),
(byte)random.Next(0, 255)));
var drawableMat = drawable.Materials[i];
var texture = drawableMat.Parameters[(int)ParamNameHash.Texture] as MaterialParamTexture;
if (texture != null)
{
// 1. Try looking in the embedded texture file (if any)
var textureObj = FindTexture(drawable.AttachedTexture, texture.TextureName);
// 2. Try looking in any attached external texture dictionaries
if (textureObj == null)
{
foreach (var file in textures)
{
textureObj = FindTexture(file, texture.TextureName);
if (textureObj != null)
{
break;
}
}
}
// Generate a brush if we were successful
if (textureObj != null)
{
var bitmap = textureObj.Decode() as Bitmap;
var bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
bitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
// For memory leak work around
bitmapSource.Freeze();
brush = new ImageBrush(bitmapSource);
(brush as ImageBrush).ViewportUnits = BrushMappingMode.Absolute;
(brush as ImageBrush).TileMode = TileMode.Tile;
bitmap.Dispose();
}
}
materials[i] = new DiffuseMaterial(brush);
}
var drawableModelGroup = new Model3DGroup();
var drawableModelNode = new ModelNode {DataModel = drawable, Model3D = drawableModelGroup, Name = "Drawable", NoCount = true};
foreach (var model in drawable.Models)
{
var modelGroup = new Model3DGroup();
var modelNode = new ModelNode {DataModel = model, Model3D = modelGroup, Name = "Model"};
drawableModelNode.Children.Add(modelNode);
foreach (var geometry in model.Geometries)
{
var geometryIndex = 0;
var geometryGroup = new Model3DGroup();
var geometryNode = new ModelNode { DataModel = geometry, Model3D = geometryGroup, Name = "Geometry" };
modelNode.Children.Add(geometryNode);
foreach (var mesh in geometry.Meshes)
{
var mesh3D = new MeshGeometry3D();
var meshNode = new ModelNode { DataModel = mesh, Model3D = null, Name = "Mesh" };
geometryNode.Children.Add(meshNode);
Data.Vertex[] vertices = mesh.DecodeVertexData();
foreach (var vertex in vertices)
{
mesh3D.Positions.Add(new Point3D(vertex.Position.X, vertex.Position.Y, vertex.Position.Z));
if (mesh.VertexHasNormal)
{
mesh3D.Normals.Add(new Vector3D(vertex.Normal.X, vertex.Normal.Y, vertex.Normal.Z));
}
if (mesh.VertexHasTexture)
{
mesh3D.TextureCoordinates.Add(new Point(vertex.TextureCoordinates[0].X, vertex.TextureCoordinates[0].Y));
}
}
ushort[] indices = mesh.DecodeIndexData();
for (int i = 0; i < mesh.FaceCount; i++)
{
mesh3D.TriangleIndices.Add(indices[i * 3 + 0]);
mesh3D.TriangleIndices.Add(indices[i * 3 + 1]);
mesh3D.TriangleIndices.Add(indices[i * 3 + 2]);
}
var material = materials[geometry.Meshes[geometryIndex].MaterialIndex];
var model3D = new GeometryModel3D(mesh3D, material);
geometryGroup.Children.Add(model3D);
meshNode.Model3D = model3D;
geometryIndex++;
}
modelGroup.Children.Add(geometryGroup);
}
drawableModelGroup.Children.Add(modelGroup);
}
return drawableModelNode;
}
19
View Source File : Search.cs
License : MIT License
Project Creator : alaabenfatma
License : MIT License
Project Creator : alaabenfatma
private void Go_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
lv.Items.Clear();
foreach (var node in _host.Nodes)
if (node.Search(tb.Text) != null)
{
var tv = new TreeView {Background = new SolidColorBrush(Color.FromArgb(35, 35, 35, 35))};
tv.Items.Add(node.Search(tb.Text));
lv.Items.Add(tv);
}
}
19
View Source File : AlertToChartCreateUi.xaml.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private void LoadFromAlert()
{
ComboBoxSignalType.SelectedItem = MyAlert.SignalType;
ComboBoxType.SelectedItem = MyAlert.Type;
CheckBoxOnOff.IsChecked = MyAlert.IsOn;
CheckBoxMusicAlert.IsChecked = MyAlert.IsMusicOn;
ComboBoxMusicType.SelectedItem = MyAlert.Music;
ComboBoxFatLine.Text = MyAlert.BorderWidth.ToString();
TextBoxLabelAlert.Text = MyAlert.Label;
System.Drawing.Color labelColor = MyAlert.ColorLabel;
System.Drawing.Color labelLine = MyAlert.ColorLine;
ButtonColorLabel.Background =
new SolidColorBrush(Color.FromArgb(labelColor.A, labelColor.R, labelColor.G, labelColor.B));
ButtonColorLine.Background =
new SolidColorBrush(Color.FromArgb(labelLine.A, labelLine.R, labelLine.G, labelLine.B));
CheckBoxWindow.IsChecked = MyAlert.IsMessageOn;
TextBoxAlertMessage.Text = MyAlert.Message;
TextBoxVolumeReaction.Text = MyAlert.VolumeReaction.ToString();
TextBoxSlippage.Text = MyAlert.Slippage.ToString(new CultureInfo("ru-RU"));
TextBoxClosePosition.Text = MyAlert.NumberClosePosition.ToString();
TextBoxVolumeReaction.Text = MyAlert.VolumeReaction.ToString();
ComboBoxOrderType.SelectedItem = MyAlert.OrderPriceType;
ComboBoxSignalType.SelectedItem = MyAlert.SignalType;
}
19
View Source File : AlertToChartCreateUi.xaml.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private void ButtonColorLabel_Click(object sender, RoutedEventArgs e)
{
ColorDialog ui = new ColorDialog();
System.Windows.Media.Color labelColor = ((SolidColorBrush)ButtonColorLabel.Background).Color;
ui.Color = System.Drawing.Color.FromArgb(labelColor.A, labelColor.R, labelColor.G, labelColor.B);
ui.ShowDialog();
System.Drawing.Color newColor = ui.Color;
ButtonColorLabel.Background =
new SolidColorBrush(Color.FromArgb(newColor.A, newColor.R, newColor.G, newColor.B));
SaveAlert();
}
19
View Source File : AlertToChartCreateUi.xaml.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private void ButtonColorLine_Click(object sender, RoutedEventArgs e)
{
ColorDialog ui = new ColorDialog();
System.Windows.Media.Color lineColor = ((SolidColorBrush)ButtonColorLine.Background).Color;
ui.Color = System.Drawing.Color.FromArgb(lineColor.A, lineColor.R, lineColor.G, lineColor.B);
ui.ShowDialog();
System.Drawing.Color newColor = ui.Color;
ButtonColorLine.Background =
new SolidColorBrush(Color.FromArgb(newColor.A, newColor.R, newColor.G, newColor.B));
SaveAlert();
}
19
View Source File : ChartClusterPainter.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
public void StartPaintPrimeChart(WindowsFormsHost host, Rectangle rectangle)
{
_host = host;
_rectangle = rectangle;
try
{
if (_host.Child != null && _host.Child.Text == _chart.Text)
{
return;
}
if (_host != null && !_host.Dispatcher.CheckAccess())
{
_host.Dispatcher.Invoke(new Action<WindowsFormsHost, Rectangle>(StartPaintPrimeChart), host, rectangle);
return;
}
_host.Child = _chart;
_host.Child.Show();
_rectangle.Fill =
new SolidColorBrush(System.Windows.Media.Color.FromArgb(_colorKeeper.ColorBackChart.A,
_colorKeeper.ColorBackChart.R, _colorKeeper.ColorBackChart.G, _colorKeeper.ColorBackChart.B));
//ResizeYAxisOnArea("Prime");
}
catch (Exception error)
{
SendLogMessage(error.ToString(), LogMessageType.Error);
}
}
19
View Source File : ChartClusterPainter.cs
License : Apache License 2.0
Project Creator : AlexWan
License : Apache License 2.0
Project Creator : AlexWan
private void CreateChart()
{
try
{
if (_chart != null && _chart.InvokeRequired)
{
_chart.Invoke(new Action(CreateChart));
return;
}
_chart = new Chart();
_chart.Series.Clear();
_chart.ChartAreas.Clear();
_chart.BackColor = _colorKeeper.ColorBackChart;
_chart.SuppressExceptions = true;
if (_rectangle != null)
{
_rectangle.Fill = new SolidColorBrush(System.Windows.Media.Color.FromArgb(_colorKeeper.ColorBackSecond.A,
_colorKeeper.ColorBackSecond.R, _colorKeeper.ColorBackSecond.G, _colorKeeper.ColorBackSecond.B));
}
ChartArea prime = new ChartArea("Prime")
{
CursorX = { AxisType = AxisType.Secondary, IsUserSelectionEnabled = false, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
CursorY = { AxisType = AxisType.Primary, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
//AxisX2 = { IsMarginVisible = false, Enabled = AxisEnabled.False },
BorderDashStyle = ChartDashStyle.Solid,
BorderWidth = 2,
BackColor = _colorKeeper.ColorBackChart,
BorderColor = _colorKeeper.ColorBackSecond,
};
prime.AxisY.replacedleAlignment = StringAlignment.Near;
prime.AxisY.replacedleForeColor = _colorKeeper.ColorBackCursor;
prime.AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
prime.AxisY.LabelAutoFitMinFontSize = 12;
prime.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont;
foreach (var axe in prime.Axes)
{
axe.LabelStyle.ForeColor = _colorKeeper.ColorText;
}
prime.CursorY.LineColor = _colorKeeper.ColorBackCursor;
prime.CursorX.LineColor = _colorKeeper.ColorBackCursor;
_chart.ChartAreas.Add(prime);
Series clusterSeries = new Series("SeriesCluster");
clusterSeries.ChartType = SeriesChartType.RangeBar;
clusterSeries.YAxisType = AxisType.Primary;
clusterSeries.XAxisType = AxisType.Secondary;
clusterSeries.ChartArea = "Prime";
clusterSeries.ShadowOffset = 2;
clusterSeries.YValuesPerPoint = 2;
_chart.Series.Add(clusterSeries);
_chart.MouseMove += _chart_MouseMove2;
_chart.ClientSizeChanged += _chart_ClientSizeChanged;
}
catch (Exception error)
{
SendLogMessage(error.ToString(), LogMessageType.Error);
}
}
19
View Source File : HeatSeriesControl.xaml.cs
License : MIT License
Project Creator : alfarok
License : MIT License
Project Creator : alfarok
private void BuildUI(HeatSeriesNodeModel model)
{
// Load sample data if any ports are not connected
if (!model.InPorts[0].IsConnected && !model.InPorts[1].IsConnected && !model.InPorts[2].IsConnected && !model.InPorts[3].IsConnected)
{
// X - Products
var XLabels = new[]
{
"Item-1",
"Item-2",
"Item-3",
"Item-4",
"Item-5"
};
// Y - Day of the week
var YLabels = new[]
{
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
// Value for each product on every day of the week
var chartValues = new ChartValues<HeatPoint>();
for(var i = 0; i < XLabels.Length; i++)
{
for ( var j = 0; j < YLabels.Length; j++)
{
chartValues.Add(new HeatPoint(i, j, rnd.Next(0, 10)));
}
}
XAxis.Labels = XLabels;
YAxis.Labels = YLabels;
HeatSeriesUI.Series.Add(new HeatSeries()
{
Values = chartValues,
DrawsHeatRange = false,
DataLabels = true
});
}
// Else load input data
else if (model.InPorts[0].IsConnected && model.InPorts[1].IsConnected && model.InPorts[2].IsConnected && model.InPorts[3].IsConnected)
{
if (model.XLabels.Count == model.Values.Count && model.XLabels.Count > 0)
{
var chartValues = new ChartValues<HeatPoint>();
for (var i = 0; i < model.XLabels.Count; i++)
{
for (var j = 0; j < model.YLabels.Count; j++)
{
chartValues.Add(new HeatPoint(i, j, model.Values[i][j]));
}
}
var colors = BuildColors(model);
var hoverIconColor = new SolidColorBrush(Color.FromArgb(255, 94, 92, 90));
XAxis.Labels = model.XLabels;
YAxis.Labels = model.YLabels;
HeatSeriesUI.Series.Add(new HeatSeries()
{
Values = chartValues,
DrawsHeatRange = false,
GradientStopCollection = colors,
Fill = hoverIconColor,
PointGeometry = DefaultGeometries.Square
//DataLabels = true
});
}
}
}
19
View Source File : BarChartNodeModel.cs
License : MIT License
Project Creator : alfarok
License : MIT License
Project Creator : alfarok
private void DataBridgeCallback(object data)
{
// Grab input data which always returned as an ArrayList
var inputs = data as ArrayList;
// Each of the list inputs are also returned as ArrayLists
var labels = inputs[0] as ArrayList;
var values = inputs[1] as ArrayList;
var colors = inputs[2] as ArrayList;
// Only continue if key/values match in length
if(labels.Count != values.Count || labels.Count < 1)
{
throw new Exception("Label and Values do not properly align in length.");
}
// Update chart properties
Labels = new List<string>();
Values = new List<List<double>>();
Colors = new List<SolidColorBrush>();
if (colors.Count != labels.Count)
{
for (var i = 0; i < labels.Count; i++)
{
Labels.Add((string)labels[i]);
var unpackedValues = values[i] as ArrayList;
var labelValues = new List<double>();
for (var j = 0; j < unpackedValues.Count; j++)
{
labelValues.Add(Convert.ToDouble(unpackedValues[j]));
}
Values.Add(labelValues);
Color randomColor = Color.FromArgb(255, (byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256));
SolidColorBrush brush = new SolidColorBrush(randomColor);
brush.Freeze();
Colors.Add(brush);
}
}
else
{
for (var i = 0; i < labels.Count; i++)
{
Labels.Add((string)labels[i]);
var unpackedValues = values[i] as ArrayList;
var labelValues = new List<double>();
for (var j = 0; j < unpackedValues.Count; j++)
{
labelValues.Add(Convert.ToDouble(unpackedValues[j]));
}
Values.Add(labelValues);
var dynColor = (DSCore.Color)colors[i];
var convertedColor = Color.FromArgb(dynColor.Alpha, dynColor.Red, dynColor.Green, dynColor.Blue);
SolidColorBrush brush = new SolidColorBrush(convertedColor);
brush.Freeze();
Colors.Add(brush);
}
}
// Notify UI the data has been modified
RaisePropertyChanged("DataUpdated");
}
19
View Source File : HeatSeriesNodeModel.cs
License : MIT License
Project Creator : alfarok
License : MIT License
Project Creator : alfarok
private void DataBridgeCallback(object data)
{
// Grab input data which always returned as an ArrayList
var inputs = data as ArrayList;
// Each of the list inputs are also returned as ArrayLists
var xLabels = inputs[0] as ArrayList;
var yLabels = inputs[1] as ArrayList;
var values = inputs[2] as ArrayList;
var colors = inputs[3] as ArrayList;
// TODO - is it worth/possible to display jagged data
// If data is jagged throw warning
if (xLabels.Count != values.Count || xLabels.Count == 0)
{
throw new Exception("Label and Values do not properly align in length.");
}
// Clear current chart values
XLabels = new List<string>();
YLabels = new List<string>();
Values = new List<List<double>>();
Colors = new List<Color>();
// Iterate the x and y values separately as they may be different lengths
for (var i = 0; i < xLabels.Count; i++)
{
XLabels.Add((string)xLabels[i]);
}
for (var i = 0; i < yLabels.Count; i++)
{
YLabels.Add((string)yLabels[i]);
}
// Iterate values (count should be x-labels length * y-lables length)
for (var i = 0; i < values.Count; i++)
{
var unpackedValues = values[i] as ArrayList;
var outputValues = new List<double>();
for(int j = 0; j < unpackedValues.Count; j++)
{
outputValues.Add(Convert.ToDouble(unpackedValues[j]));
}
Values.Add(outputValues);
}
// If colors is empty add 1 random color
if (colors == null || colors.Count == 0)
{
Color randomColor = Color.FromArgb(255, (byte)rnd.Next(256), (byte)rnd.Next(256), (byte)rnd.Next(256));
Colors.Add(randomColor);
}
// If provided with 1 color blend white to color
// Else create color range from provided color
else
{
for(var i = 0; i < colors.Count; i++)
{
var dynColor = (DSCore.Color)colors[i];
var convertedColor = Color.FromArgb(dynColor.Alpha, dynColor.Red, dynColor.Green, dynColor.Blue);
Colors.Add(convertedColor);
}
}
// TODO - Should this use Dynamo Scheduler to prevent timing issues with redundant calls?
// Notify UI the data has been modified
RaisePropertyChanged("DataUpdated");
}
See More Examples