only the first listpicker opens windows phone - c#

I am using Windows Phone Toolkit - Nov 2011 (7.1 SDK) and I want to display multiple listpickers each
within a grid and each grid in a listbox. The problem is, only the first listpicker pops open and the rest don't. secondly how do I customize the full mode page of the listpicker to be displayed exclusively in Landscape orientation and set the page's "shell:SystemTray.IsVisible" to false.
Sorry I couldn't post a screenshot. error "Earn more than 10 reputation to post images".
Thanks
public MainPage()
{
InitializeComponent();
for (int g = 0; g < 10; g++)
{
// Define the margins template dor elements
Thickness elemThick = new Thickness();
// Create the Grid that will hold all the elements of a single entry
Grid entryGrd = new Grid();
entryGrd.VerticalAlignment = VerticalAlignment.Top;
entryGrd.HorizontalAlignment = HorizontalAlignment.Left;
elemThick.Left = 0;
elemThick.Bottom = 0;
elemThick.Right = 0;
elemThick.Top = 0;
entryGrd.Margin = elemThick;
entryGrd.Tag = lstbxPH.Items.Count;
// Setup the backgound value of the letBoder element
LinearGradientBrush elemLGB = new LinearGradientBrush();
elemLGB.EndPoint = new Point(0.5, 1);
elemLGB.StartPoint = new Point(0.5, 0);
GradientStop AquamarineGS = new GradientStop();
AquamarineGS.Color = Color.FromArgb(255, 127, 255, 212);
AquamarineGS.Offset = 0;
GradientStop greenLikeGS = new GradientStop();
greenLikeGS.Color = Color.FromArgb(255, 101, 250, 193);
greenLikeGS.Offset = 0.988;
elemLGB.GradientStops.Add(AquamarineGS);
elemLGB.GradientStops.Add(greenLikeGS);
// Draw the letter
for (int x = 0; x < 9; x++)
{
Border letBoder = new Border();
letBoder.Width = 53;
letBoder.Height = 51;
letBoder.VerticalAlignment = VerticalAlignment.Top;
letBoder.HorizontalAlignment = HorizontalAlignment.Left;
elemThick.Left = x * 60 + 71;
elemThick.Top = lstbxPH.Items.Count * 1 + 20;
letBoder.Margin = elemThick;
letBoder.Background = elemLGB;
// The Texblock
TextBlock let = new TextBlock();
let.VerticalAlignment = VerticalAlignment.Center;
let.HorizontalAlignment = HorizontalAlignment.Center;
let.FontSize = 25;
let.FontWeight = FontWeights.Bold;
let.Foreground = new SolidColorBrush(Color.FromArgb(200, 255, 255, 255));
let.Text = x.ToString();
let.Tag = x;
letBoder.Child = let;
entryGrd.Children.Add(letBoder);
}
// Draw the List picker element for the draw types
ListPicker DType = new ListPicker();
DType.Width = 48;
DType.VerticalAlignment = VerticalAlignment.Top;
DType.HorizontalAlignment = HorizontalAlignment.Left;
DType.Background = new SolidColorBrush(Color.FromArgb(200, 255, 255, 255));
DType.BorderBrush = new SolidColorBrush(Color.FromArgb(200, 255, 255, 255));
elemThick.Left = 17;
elemThick.Top = lstbxPH.Items.Count * 1 + 10;
DType.Margin = elemThick;
DType.FontSize = 18;
ListPickerItem item1 = new ListPickerItem() { Content = "A" };
ListPickerItem item2 = new ListPickerItem() { Content = "B" };
ListPickerItem item3 = new ListPickerItem() { Content = "C" };
DType.Items.Add(item1);
DType.Items.Add(item2);
DType.Items.Add(item3);
entryGrd.Children.Add(DType);
if (lstbxPH.Items.Count != 0)
{
// The delete button and related image
Button btnDel = new Button();
btnDel.Height = 65;
btnDel.Width = 60;
btnDel.Tag = lstbxPH.Items.Count;
btnDel.VerticalAlignment = VerticalAlignment.Top;
btnDel.HorizontalAlignment = HorizontalAlignment.Left;
btnDel.VerticalContentAlignment = VerticalAlignment.Top;
btnDel.HorizontalContentAlignment = HorizontalAlignment.Left;
elemThick.Left = 600;
elemThick.Top = lstbxPH.Items.Count + 13;
btnDel.Margin = elemThick;
elemThick.Left = 0;
elemThick.Bottom = 0;
elemThick.Right = 0;
elemThick.Top = 0;
btnDel.Name = "btnDel";
btnDel.Padding = elemThick;
btnDel.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
Image imgDel = new Image();
imgDel.Source = new BitmapImage(new Uri("/appbar.delete.rest.png", UriKind.RelativeOrAbsolute));
imgDel.VerticalAlignment = VerticalAlignment.Top;
imgDel.HorizontalAlignment = HorizontalAlignment.Left;
imgDel.Height = 35;
imgDel.Width = 30;
elemThick.Left = 0;
elemThick.Bottom = 0;
elemThick.Right = 0;
elemThick.Top = 0;
imgDel.Margin = elemThick;
imgDel.Stretch = Stretch.UniformToFill;
btnDel.Content = imgDel;
entryGrd.Children.Add(btnDel);
}
// Add the grid with to the list box
this.lstbxPH.Items.Add(entryGrd);
}
}

This issue was actually solved by the Windows Phone Toolkit - Nov 2011 (7.1 SDK).
Here is how I worked it out.
Download the November release of the toolkit http://silverlight.codeplex.com/releases/view/75888
if you had a previous release of the toolkit installed, please uninstall it and unreferenced the tool kit on you project
Install the November release of the toolkit
Reference the toolkit on your project, debug and boom! it woks.

Related

How to print C# chart with more pages

I have C# project already done but im having issue with printing it's charts when comes out with more pages of data points, i got the scroll bar work when start getting more pages so the user can review all data on all pages but i could not find how to make the print preview shows them or print them,
when click on print, it shows only the first page on the print preview and same thing when print it out.
her is the print code:
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = this.chart1.Printing.PrintDocument;
((Form)ppd).WindowState = FormWindowState.Maximized;
chart1.Printing.PrintDocument.DefaultPageSettings.Landscape = true;
chart1.Printing.PrintDocument.DefaultPageSettings.Margins.Left = 0;
chart1.Printing.PrintDocument.DefaultPageSettings.Margins.Right = 0;
chart1.Printing.PrintDocument.DefaultPageSettings.Margins.Top = 0;
chart1.Printing.PrintDocument.DefaultPageSettings.Margins.Bottom = 0;
ppd.ShowDialog();
and here is the chart load code:
public void loadChart(string sqlvalue)//load chart method
{
chart1.ChartAreas[0].AxisY.Maximum = 55;
chart1.ChartAreas[0].AxisY.Minimum = 35;
chart1.ChartAreas[0].AxisY.Interval = 5;//control how many lines/Interval
chart1.ChartAreas[0].AxisY.ScrollBar.Enabled = true;
chart1.ChartAreas[0].AxisY.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.Minimum = 0;
// chart1.ChartAreas[0].AxisX.Maximum = 10;
chart1.ChartAreas[0].AxisX.Interval = 1;
//X AXES label angle
chart1.ChartAreas[0].AxisX.LabelStyle.Angle = 60;
da = new SqlDataAdapter(sqlvalue, cn.connect());
da.Fill(dt);
this.chart1.DataSource = dt;
this.chart1.Series["left"].XValueMember = dt.Columns[3].ToString();//date data
this.chart1.Series["left"].YValueMembers = dt.Columns[1].ToString();//spindle 1 data
this.chart1.Series["Right"].YValueMembers = dt.Columns[2].ToString();//spindle 2 data
//label the series lines, Backcolor and forcolor
chart1.Series[0].LabelBackColor = Color.Red;
chart1.Series[0].LabelForeColor = Color.White;
//datapoint marker's color, bordercolor,style and size
chart1.Series[0].MarkerColor = Color.White;
chart1.Series[0].MarkerBorderColor = Color.Black;
chart1.Series[0].MarkerStyle = MarkerStyle.Circle;
chart1.Series[0].MarkerSize = 8;
//datapoint marker's color, style and size
chart1.Series[1].MarkerColor = Color.White;
chart1.Series[1].MarkerBorderColor = Color.Black;
chart1.Series[1].MarkerStyle = MarkerStyle.Circle;
chart1.Series[1].MarkerSize = 8;
chart1.Series[1].LabelBackColor = Color.Blue;
chart1.Series[1].LabelForeColor = Color.White;
//Chart background lines color
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Silver;
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Silver;
this.chart1.DataBind();
cn.disconnect();
// enable autoscroll
chart1.ChartAreas[0].CursorX.AutoScroll = true;//------------
chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
chart1.ChartAreas[0].AxisX.ScaleView.Zoom(0, 15);
chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;
// set scrollbar small change to the target size
chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollSize = 15;
Legend left = new Legend();
Legend LC = CustomCloneLegend(chart1, left);
chart1.Legends.Add(LC);
chart1.Padding = Padding.Empty;
ChartArea CA = chart1.ChartAreas[0];
CA.Position = new ElementPosition(4,6, 100, 90);
}
Thank you for your time and help, here is the chart code update:
private static Image MergeImages(List<Image> imageList)
{
var finalSize = new Size();
foreach (var image in imageList)
{
if (image.Width > finalSize.Width)
{
finalSize.Width = image.Width;
}
finalSize.Height += image.Height;
}
var outputImage = new Bitmap(finalSize.Width, finalSize.Height);
using (var gfx = Graphics.FromImage(outputImage))
{
var y = 0;
foreach (var image in imageList)
{
gfx.DrawImage(image, 0, y);
y += image.Height;
}
}
return outputImage;
}
The second method:
List<Image> ChartsToImages(List<Chart> charts)
{
var imageList = new List<Image>();
foreach (var c in charts)
{
using (var ms = new MemoryStream())
{
c.SaveImage(ms, ChartImageFormat.Png);
var bmp = System.Drawing.Bitmap.FromStream(ms);
imageList.Add(bmp);
}
}
return imageList;
}
and this code
var chartList = new List<Chart> { chart1 };
var imageList = ChartsToImages(chartList);
var finalImage = MergeImages(imageList);
finalImage.Save("D:\\Junk.png", ImageFormat.Png);
Im not sure is that what you mean by your first comment, but i found this code here under Converting chart to image questions. this code convert and saves the chart in the same amount of pages but i need to show them in the printpreviewcontrol and print them.
Below code refers to the as per page count starting point and ending point based printing. And Grid view value chars are row loop based counting the page.
private int numberOfItemsPerPage = 0;
private int numberOfItemsPrintedSoFar = 0;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int height = 480; //page height stating point
for (int l = numberOfItemsPrintedSoFar; l < dataGridView2.Rows.Count; l++)
{
numberOfItemsPerPage = numberOfItemsPerPage + 1;
if (numberOfItemsPerPage <= 25) // 25 is Page Line Item
{
numberOfItemsPrintedSoFar++;
if (numberOfItemsPrintedSoFar <= dataGridView2.Rows.Count)
{
height += dataGridView2.Rows[0].Height;
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[0].FormattedValue.ToString(), dataGridView2.Font = new Font("Book Antiqua", 8), Brushes.Black, new RectangleF(5, height, dataGridView2.Columns[0].Width, dataGridView2.Rows[0].Height));
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[1].FormattedValue.ToString(), dataGridView2.Font = new Font("Book Antiqua", 8), Brushes.Black, new RectangleF(170, height, dataGridView2.Columns[0].Width, dataGridView2.Rows[0].Height));
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[2].FormattedValue.ToString(), dataGridView2.Font = new Font("Book Antiqua", 8), Brushes.Black, new RectangleF(290, height, dataGridView2.Columns[0].Width, dataGridView2.Rows[0].Height));
e.Graphics.DrawString(dataGridView2.Rows[l].Cells[3].FormattedValue.ToString(), dataGridView2.Font = new Font("Book Antiqua", 8), Brushes.Black, new RectangleF(345, height, dataGridView2.Columns[0].Width, dataGridView2.Rows[0].Height));
}
else
{
e.HasMorePages = false;
}
}
else
{
numberOfItemsPerPage = 0;
e.HasMorePages = true;
return;
}
}
numberOfItemsPerPage = 0;
numberOfItemsPrintedSoFar = 0;
}

i need audio frequency response graph c#

i need logarithm x-axis based linechart for audio frequency magnitude response for c# winform , i have tested default chart and livechart but c'ant align x axis attached photo like . anybody know please help me.
sorry for my bad english
Live Chart Code :
cartesianChart1.AxisY.Add(new Axis
{
Title = "Gain",
MaxValue = 10,
MinValue = -15,
Separator = new Separator
{
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(46, 35, 35))
}
});
cartesianChart1.AxisX.Add(new LogarithmicAxis
{
Title = "Freq",
LabelFormatter = (value) => (Math.Pow(10, value).ToString("N0")+"Hz"),
Base = 10,
Separator = new Separator
{
Step=0,
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(35, 35, 35))
},
});
cartesianChart1.BackColor = System.Drawing.Color.FromArgb(0, 0, 0);
cartesianChart1.DisableAnimations = true;
cartesianChart1.Hoverable = false;
cartesianChart1.DataTooltip = null;
var Datapoint = new ChartValues<ObservablePoint>{
new ObservablePoint(1, 5),
new ObservablePoint(5, -4),
new ObservablePoint(10, 6),
new ObservablePoint(100, 4),
new ObservablePoint(150, 7),
new ObservablePoint(1000, 2),
new ObservablePoint(10000, 8),
new ObservablePoint(15000, 2),
new ObservablePoint(20000, -7),
};
cartesianChart1.Series = new SeriesCollection(Mappers.Xy<ObservablePoint>()
.X(point => Math.Log10(point.X))
.Y(point => point.Y))
{
new LineSeries
{
PointGeometry = null,
PointGeometrySize = 0,
Values = Datapoint,
}
};
Live Chart Display :
Default Chart Code :
var r = new Random();
float val;
var chart = chart1.ChartAreas[0];
chart.AxisX.IntervalType = DateTimeIntervalType.Number;
chart.AxisX.LabelStyle.Format = "";
chart.AxisY.LabelStyle.Format = "";
chart.AxisY.LabelStyle.IsEndLabelVisible = true;
chart.AxisX.Minimum = 0;
chart.AxisX.Maximum = 20000;
chart.AxisY.Minimum = -15;
chart.AxisY.Maximum = 10;
chart.AxisX.Interval = 500;
chart.AxisY.Interval = 3;
chart.BackColor = Color.Black;
chart1.Series.Add("Sakthi");
chart1.Series["Sakthi"].ChartType = SeriesChartType.Spline;
chart1.Series["Sakthi"].Color = Color.Yellow;
chart1.Series["Sakthi"].BorderWidth = 3;
chart1.Series["Sakthi"].BorderColor = Color.Black;
chart1.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Solid;
chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(35, 35, 35);
chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(35, 35, 35);
chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
chart1.Legends[0].Enabled = false;
chart.AxisY.StripLines.Add(new StripLine
{
BorderDashStyle = ChartDashStyle.Dot,
BorderColor = Color.White,
StripWidth = 0
});
chart1.Series.Clear();
chart1.Series.Add("Sakthi");
chart1.Series["Sakthi"].ChartType = SeriesChartType.Spline;
chart1.Series["Sakthi"].Color = Color.Yellow;
chart1.Series["Sakthi"].BorderWidth = 3;
chart1.Series["Sakthi"].BorderColor = Color.Black;
for (int i = 0; i < 10; i++)
{
val = r.Next(-15, 10);
chart1.Series["Sakthi"].Points.AddXY(i*2000, val);
}
Default Chart Display :
i want this this type x axis label :

Border wont apply programatically to my grid WPF C#

I have problems with Styling my grid, I am working on small app for caffe bars lets say, customer is able to choose drink from the middle of screen and drink will be shown in the right part of screen in my grid, this is how that looks like right now (when customer choose something - lets say Coke, sprite etc.):
This is my code for now :
public DrinksPanel(byte[] image)
: base()
{
BrushConverter MyBrush8 = new BrushConverter();
var myBorder = new Border();
myBorder.Background = (Brush)MyBrush8.ConvertFrom("#83D744");
Thickness marginT = this.Margin;
marginT.Top = 10;
this.Margin = marginT;
ColumnDefinition col1 = new ColumnDefinition();
col1.Width = new GridLength(45);
ColumnDefinition col2 = new ColumnDefinition();
col2.Width = new GridLength(80, GridUnitType.Star);
ColumnDefinition col3 = new ColumnDefinition();
col3.Width = new GridLength(45);
this.ColumnDefinitions.Add(col1);
this.ColumnDefinitions.Add(col2);
this.ColumnDefinitions.Add(col3);
this.Height = 45;
this.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
this.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
ArticleNameLabel.VerticalContentAlignment = VerticalAlignment.Center;
ArticleNameLabel.HorizontalContentAlignment = HorizontalAlignment.Left;
ArticleNameLabel.FontSize = fontSize;
ArticleNameLabel.Foreground = System.Windows.Media.Brushes.White;
ArticleNameLabel.FontFamily = Util.Font;//new System.Windows.Media.FontFamily("HelveticaNeueLTStd-Bd.otf#Helvetica Neue LT Std");
ArticleNameLabel.Content = tekst;
ArticleNameLabel.SetValue(Grid.RowProperty, 0);
ArticleNameLabel.SetValue(Grid.RowSpanProperty, 1);
ArticleNameLabel.SetValue(Grid.ColumnProperty, 1);
ArticleNameLabel.SetValue(Grid.ColumnSpanProperty, 1);
ArticleNameLabel.Width = Double.NaN;
ArticleNameLabel.Height = Double.NaN;
QuantityNumberLabel.Width = Double.NaN;
QuantityNumberLabel.Height = Double.NaN;
QuantityNumberLabel.SetValue(Grid.RowProperty, 0);
QuantityNumberLabel.SetValue(Grid.RowSpanProperty, 1);
QuantityNumberLabel.SetValue(Grid.ColumnProperty, 2);
ArticleNameLabel.SetValue(Grid.ColumnSpanProperty, 1);
QuantityNumberLabel.HorizontalAlignment = HorizontalAlignment.Center;
QuantityNumberLabel.VerticalAlignment = VerticalAlignment.Center;
QuantityNumberLabel.FontFamily = Util.Font;
QuantityNumberLabel.FontSize = numberSize;
QuantityNumberLabel.Content = "x1";
QuantityNumberLabel.Foreground = System.Windows.Media.Brushes.White;
BrushConverter MyBrush3 = new BrushConverter();
QuantityNumberLabel.Background = (Brush)MyBrush3.ConvertFrom("#83D744");
_image.Width = Double.NaN;
_image.Height = Double.NaN;
_image.HorizontalAlignment = HorizontalAlignment.Stretch;
_image.VerticalAlignment = VerticalAlignment.Stretch;
_image.SetValue(Grid.RowProperty, 0);
_image.SetValue(Grid.RowSpanProperty, 1);
_image.SetValue(Grid.ColumnProperty, 0);
_image.SetValue(Grid.ColumnSpanProperty, 1);
Image.Source = GetSlikaFromByte(image);
Rectangle background = new Rectangle();
background.SetValue(Grid.RowProperty, 0);
background.SetValue(Grid.RowSpanProperty, 1);
background.SetValue(Grid.ColumnProperty, 0);
background.SetValue(Grid.ColumnSpanProperty,3);
background.HorizontalAlignment = HorizontalAlignment.Stretch;
background.VerticalAlignment = VerticalAlignment.Stretch;
background.Width = Double.NaN;
background.Height = Double.NaN;
background.Fill = (Brush)MyBrush.ConvertFrom("#50000000");
_animation = new DoubleAnimation(numberSize, numberSize + 15, new Duration(new TimeSpan(0, 0, 0, 0, 300)));
_animation.AutoReverse = true;
this.Children.Add(background);
this.Children.Add(_image);
this.Children.Add(ArticleNameLabel);
this.Children.Add(QuantityNumberLabel);
}
***So my question is guys, how could apply
myborder
around grid?***
If anyone could help me about this I would appreciate that so much =)

Chart font style always bold when background is transparent

I have a basic asp.net chart writing into the response stream.
Changing BackColor to Color.Transparent and every text being bold automaticly. Searched many posts/forums about this issue but couldnt find any solution.
This my Chart builder Code.
public static void BuildChart(Chart chart, IEnumerable<MultiMeasureData> source, Measure[] measures,bool transparent)
{
var ca = chart.ChartAreas.FirstOrDefault();
if (ca == null)
chart.ChartAreas.Add(ca = new ChartArea());
//added for transparency support.
ca.BackImageTransparentColor = Color.White;
ca.BackColor = Color.Transparent;
Series s = new Series("Ölçümler");
s.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
chart.Series.Add(s);
var leg = new Legend("legend1");
leg.Docking = Docking.Top;
//added for transparenct support.
leg.BackColor = Color.Transparent;
leg.Font = new Font("Arial", 8, FontStyle.Regular);
chart.Legends.Add(leg);
chart.Palette = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.Berry;
//Transparency.
chart.BackColor = transparent ? Color.Transparent : Color.White;
//chart.BackSecondaryColor = Color.FromArgb(187, 205, 237);
//chart.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.LeftRight;
if (source != null)
{
if (measures.Length > 0)
{
ca.AxisX.LabelStyle.Format = "dd.MM.yy";
ca.AxisX.MinorGrid.Enabled = true;
ca.AxisX.MinorGrid.Interval = 12;
ca.AxisX.MinorGrid.IntervalType = DateTimeIntervalType.Hours;
ca.AxisX.MinorGrid.LineColor = Color.LightGray;
ca.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.HorizontalCenter;
// ca.BackColor = Color.FromArgb(134, 218, 239);
ca.AxisY.LabelStyle.Format = "{0}" + measures.First().Type.Unit;
ca.AxisY.LabelStyle.ForeColor = Color.Black;
ca.AxisY.LabelStyle.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
ca.AxisX.LabelStyle.ForeColor = Color.Black;
ca.AxisX.LabelStyle.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
ca.AxisX.MajorGrid.LineColor = Color.Silver;
ca.AxisY.MajorGrid.LineColor = Color.Silver;
// var tm = (e - s).TotalMinutes / 10;
var data = source
.Select(a =>
{
var ret = new { Time = a.Time, Values = new double?[measures.Length] };
for (int i = 0; i < measures.Length; i++)
ret.Values[i] = a.Values[i].HasValue ? a.Values[i] / measures[i].Type.ValueScale:null;
return ret;
}
).OrderBy(a => a.Time);
var times = data.Select(a => a.Time).ToArray();
for (int i = 0; i < measures.Length; i++)
{
var serie = new Series(measures[i].Type.Name) { ChartType = SeriesChartType.Spline };
serie.XValueType = ChartValueType.DateTime;
serie.ShadowColor = Color.Gray;
serie.BorderWidth = 2;
serie.ShadowOffset = 1;
serie.Points.DataBindXY(times, new[] { data.Select(a => a.Values[i]).ToArray() });
serie.LegendText = measures[i].Type.Name;
serie.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular);
chart.Series.Add(serie);
}
}
}
}
this is mainly stream writer method using BuildChart method
public static void SaveChart(System.IO.Stream stream, System.Drawing.Imaging.ImageFormat format, int w, int h, IEnumerable<MultiMeasureData> source, Measure[] measures,bool transparent)
{
var c = new Chart() { Width = w, Height = h};
BuildChart(c, source, measures,transparent);
c.SaveImage(stream, format);
}
And here is both results.
Background.White (transparent parameter is false)
Background.Transparent (transparent parameter is true)
look at this answer :MS Chart Control: Formatting Axis Labels
This solved my problems
Regards
Nemanja

Drawing dynamic panels C#

Good afternoon.
There was a problem with the rendering of dynamically created panel, all panels initially were 100px and I their renders (y + = 100), but now the production has changed a bit, these panels can be of different sizes, and the distance between them actually remains unchanged 100rh ...
Pliz tell me how to make, that they are somehow drawn at equal (10px) distances from each other. Read that you can somehow make a method SetBounds, but did not understand.
http://pastebin.com/TnSuFTti
for (int i = data_list.Count - 1; i >= 0; i--)
{
Panel panel = new Panel(); //создание блока сообщения и наложение картинки
panel.Name = i.ToString();
panel.MouseEnter += new EventHandler(panel_MouseEnter);
Label textBox_name = new Label();
Label textBox_date = new Label();
Label textBox_msg = new Label();
panel.Width = 308;
Bitmap btm_msg = new Bitmap(
Properties.Resources.NotificationCenterWindow_msg_box);
panel.BackgroundImage = btm_msg;
panel.BackgroundImageLayout = ImageLayout.Stretch;
panel.Location = new Point(5, 5);
panel.Controls.Add(textBox_date);
textBox_date.Name = "textBox_date" + i.ToString();
textBox_date.Location = new Point(232, 8);
textBox_date.Size = new System.Drawing.Size(70, 15);
textBox_date.BorderStyle = BorderStyle.None;
textBox_date.MinimumSize = new System.Drawing.Size(72, 15);
textBox_date.TextAlign = ContentAlignment.MiddleRight;
textBox_date.BackColor = Color.DarkGray;
textBox_date.Anchor = AnchorStyles.Right | AnchorStyles.Top;
textBox_date.ForeColor = SystemColors.ScrollBar;
panel.Controls.Add(textBox_name);
textBox_name.Size = new System.Drawing.Size(100, 15);
textBox_name.MinimumSize = new System.Drawing.Size(100, 15);
textBox_name.Location = new Point(5, 8);
textBox_name.BorderStyle = BorderStyle.None;
textBox_name.BackColor = Color.DarkGray;
textBox_name.ForeColor = SystemColors.ScrollBar;
panel.Height = textBox_name.Height + 19;
panel1.Controls.Add(panel);
panel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
y += 100;
}
panel.Location = new Point(5, y);
//.....
y = panel.Bottom + 10;
Just set the position based on the previous panel...
// This will put the panel to the right of an existing one
panel_b.Left = panel_a.Left + panel_a.Width + 10;
.
// This will put the panel below an existing one
panel_b.Top= panel_a.Top+ panel_a.Height+ 10;

Categories

Resources