// グラフ画像を保存する public static void SaveSupplyGraph(PlotModel plotModel) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = (int)plotModel.PlotArea.Width, Height = (int)plotModel.PlotArea.Height, Background = OxyColors.White }; var bitmapSource = pngExporter.ExportToBitmap(plotModel); // BitmapSourceを保存する var sfd = new SaveFileDialog { // ファイルの種類を設定 Filter = "画像ファイル(*.png)|*.png|全てのファイル (*.*)|*.*" }; // ダイアログを表示 if ((bool)sfd.ShowDialog()) { // 保存処理 using (var stream = new FileStream(sfd.FileName, FileMode.Create)) { var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmapSource)); encoder.Save(stream); } } }
public void SaveAsPNG() { string filename; try { if (ShowSaveFileDialog("png", "PNG files|*.png", out filename)) { //var pngExporter = new OxyPlot.Wpf.PngExporter { Width = (int)Plot.Width, Height = (int)Plot.Height, Background = OxyColors.White }; // OxyPlot.Wpf.PngExporter.Export(Plot, filename, (int)Plot.Width, (int)Plot.Height, OxyColors.White); using (var stream = File.Create(filename)) { var exporter = new OxyPlot.Wpf.PngExporter { Width = (int)Plot.Width, Height = (int)Plot.Height, Background = OxyColors.White }; exporter.Export(Plot, stream); } } } catch (Exception e) { System.Windows.MessageBox.Show(e.Message, "Error"); } }
public void SaveToFile(string filename) { using (var stream = File.Create(filename)) { var pngExporter = new OxyPlot.Wpf.PngExporter(); pngExporter.Export(this.PlotModel, stream); } }
/// <summary> /// Сохранение результирующего графика в формат BMP /// </summary> /// <param name="path">Путь к результирующему файлу</param> /// <param name="width">Ширина рисунка</param> /// <param name="height">Высота рисунка</param> public void SavePlotToBMP(string path, int width, int height) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = width, Height = height, Background = OxyColors.White }; var bitmap = pngExporter.ExportToBitmap(PlotModel); bitmap.GetBitmap().Save(path); }
/// <summary> /// Exports the plot to a .png file. /// </summary> public void ExportToPng(string path, int width = 800, int height = 600) { using (var s = File.Create(path)) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = width, Height = height, Background = OxyColors.White }; pngExporter.Export(Model, s); } }
/// <summary> /// Сохранение результирующего графика в формат PNG /// </summary> /// <param name="path">Путь к результирующему файлу</param> /// <param name="width">Ширина рисунка</param> /// <param name="height">Высота рисунка</param> public void SavePlotToPNG(string path, int width, int height) { using (FileStream s = new FileStream(path, FileMode.Create)) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = width, Height = height, Background = OxyColors.White }; pngExporter.Export(PlotModel, s); } }
/// <summary> /// PlotModelのグラフをクリップボードにコピーする /// </summary> /// <param name="pm"></param> /// <param name="width"></param> /// <param name="height"></param> public void CopyPlot(PlotModel pm, int width = 800, int height = 600) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = width, Height = height, Background = OxyColors.White }; Application.Current.Dispatcher.Invoke((Action)(() => { var bitmap = pngExporter.ExportToBitmap(pm); Clipboard.SetImage(bitmap); })); }
private static void SavePlotToPng(string filePath, PlotModel plot) { // OxyPlot.WPF: requires STAThread, or new thread in STA using (var stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)) { var pngExporter = new OxyPlot.Wpf.PngExporter() { Width = ExportImageWidth, Height = ExportImageHeight }; pngExporter.Export(plot, stream); } }
public void ExportPlotBitmap(string path) { MemoryStream ms = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 1024, Height = 768, Background = OxyColors.White }; pngExporter.Export(ThePlotModel, ms); var newImage = new Bitmap(ms); newImage.Save(path); }
public static void SavePlotAsPNG(PlotModel plot, string filename, int horizontalRes, int verticalRes, bool isDarkMode) { var exporter = new OxyPlot.Wpf.PngExporter { Width = horizontalRes, Height = verticalRes, Background = isDarkMode ? OxyColor.Parse("#414b54") : OxyColor.Parse("#f2f2f2") }; using (var memoryStream = new MemoryStream()) { exporter.Export(plot, memoryStream); SaveFile(filename, "PNG files|*.png", "png", memoryStream.ToArray()); } }
// Exporting to Excel/Image Files /// <summary> /// Exports an OxyPlot PlotModel to a PNG image file /// </summary> /// <param name="plot"> The PlotModel to export </param> /// <param name="fileName"> The path to the image file to be created </param> public static void ExportImage(PlotModel plot, string fileName) { var export = new OxyPlot.Wpf.PngExporter(); export.Width = 1280; export.Height = 720; export.Background = OxyColors.White; MemoryStream stream = new MemoryStream(); FileStream file = new FileStream(fileName, FileMode.Create); export.Export(plot, stream); stream.WriteTo(file); file.Close(); stream.Close(); }
private void CopyEarnedValueChartToClipboard() { lock (m_Lock) { if (CanCopyEarnedValueChartToClipboard()) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = EarnedValueChartOutputWidth, Height = EarnedValueChartOutputHeight, Background = OxyColors.White }; BitmapSource bitmap = pngExporter.ExportToBitmap(EarnedValueChartPlotModel); System.Windows.Clipboard.SetImage(bitmap); } } }
private void FuncToCall(object context) { //this is called when the button is clicked SaveFileDialog saveFileDialog = new SaveFileDialog(); if (saveFileDialog.ShowDialog() == true) { using (var stream = File.Create(saveFileDialog.FileName)) { var pngExporter = new OxyPlot.Wpf.PngExporter(); pngExporter.Height = 500; pngExporter.Width = 1500; pngExporter.Background = OxyColors.White; pngExporter.Resolution = 96; pngExporter.Export(plotModel, stream); } } }
private void Mi_SaveAsImage_Click(object sender, RoutedEventArgs e) { var fileDialog = new SaveFileDialog { DefaultExt = ".png", Filter = "Portable Network Graphics (.png)|*.png" }; if (fileDialog.ShowDialog().Value) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White, }; OxyPlot.Wpf.ExporterExtensions.ExportToFile(pngExporter, PlotModel, fileDialog.FileName); } }
private void Print2DIDs() { string[] plots = new string[] { "MxMy", "MxN", "MyN" }; foreach (var p in plots) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var bitmap = pngExporter.ExportToBitmap(this.GetType().GetProperty(p + "ID").GetValue(this) as PlotModel); MemoryStream stream = new MemoryStream(); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.Save(stream); Bitmap bmp = new Bitmap(stream); ImageConverter converter = new ImageConverter(); byte[] output = (byte[])converter.ConvertTo(bmp, typeof(byte[])); string path = System.IO.Path.GetTempPath() + p + ".tmp"; File.WriteAllBytes(path, output); } }
public MemoryStream KayraKuva(Window win) { if (win.Name == "kiviohjelma") { Kiviohjelma _kivi = (Kiviohjelma)win; List <SeulakirjastoIndex> selist = new List <SeulakirjastoIndex>(); //Seulat joita on käytetty laskennassa, eli X-arvot. List <SeulaLapPros> tulist = new List <SeulaLapPros>(); //Läpäisyprosenttitulokset, eli Y-arvot List <Seulakirjasto> selistALL = new List <Seulakirjasto>(); //Kaikki seulat mitä on valittuna. Tehdään täysi X-akseli tällä. List <SeulaLapPros> sisOhjeAla = new List <SeulaLapPros>(); //Sisempi ohjealue, alempi ohje% List <SeulaLapPros> sisOhjeYla = new List <SeulaLapPros>(); //Sisempi ohjealue, ylempi ohje% List <SeulaLapPros> uloOhjeAla = new List <SeulaLapPros>(); //Ulompi ohjealue, alempi ohje% List <SeulaLapPros> uloOhjeYla = new List <SeulaLapPros>(); //Ulompi ohjealue, ylempi ohje% //Lukee tarvittavat prosenttiarvot ja lisää ne tulist-listaan //Ottaa valitut seulat ohjelmasta, ottaa talteen niiden sijainnin järjestyslukuna ja laittaa ne selist-listaan //Tuloksissa saattaa olla välejä (kaikkeja rivejä ei täytetty) joten koodi tarkistaa sen myös if (_kivi.lapaisypros1.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 0, tulos = Convert.ToDouble(_kivi.lapaisypros1.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula1.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 17, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros2.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 1, tulos = Convert.ToDouble(_kivi.lapaisypros2.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula2.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 16, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros3.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 2, tulos = Convert.ToDouble(_kivi.lapaisypros3.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula3.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 15, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros4.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 3, tulos = Convert.ToDouble(_kivi.lapaisypros4.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula4.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 14, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros5.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 4, tulos = Convert.ToDouble(_kivi.lapaisypros5.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula5.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 13, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros6.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 5, tulos = Convert.ToDouble(_kivi.lapaisypros6.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula6.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 12, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros7.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 6, tulos = Convert.ToDouble(_kivi.lapaisypros7.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula7.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 11, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros8.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 7, tulos = Convert.ToDouble(_kivi.lapaisypros8.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula8.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 10, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros9.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 8, tulos = Convert.ToDouble(_kivi.lapaisypros9.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula9.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 9, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros10.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 9, tulos = Convert.ToDouble(_kivi.lapaisypros10.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula10.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 8, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros11.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 10, tulos = Convert.ToDouble(_kivi.lapaisypros11.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula11.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 7, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros12.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 11, tulos = Convert.ToDouble(_kivi.lapaisypros12.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula12.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 6, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros13.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 12, tulos = Convert.ToDouble(_kivi.lapaisypros13.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula13.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 5, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros14.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 13, tulos = Convert.ToDouble(_kivi.lapaisypros14.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula14.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 4, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros15.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 14, tulos = Convert.ToDouble(_kivi.lapaisypros15.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula15.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 3, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros16.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 15, tulos = Convert.ToDouble(_kivi.lapaisypros16.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula16.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 2, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros17.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 16, tulos = Convert.ToDouble(_kivi.lapaisypros17.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula17.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 1, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } if (_kivi.lapaisypros18.Text != String.Empty) { SeulaLapPros sl = new SeulaLapPros { index = 17, tulos = Convert.ToDouble(_kivi.lapaisypros18.Text) }; tulist.Add(sl); string seulatxt = _kivi.Seula18.Text; seulatxt = seulatxt.Replace(".", ","); SeulakirjastoIndex ke = new SeulakirjastoIndex { index = 0, seula = Convert.ToDouble(seulatxt) }; selist.Add(ke); } foreach (Control c in _kivi.seulaArvot.Children) //Kaikille esineille seulaArvot-canvasissa. Tarkoituksena ottaa kaikki valitut seulat dropdown-valikoista talteen { if (c.GetType() == typeof(ComboBox)) //jos esineen tyyppi on combobox { //Console.WriteLine("Combobox text: " + ((ComboBox)c).Text+", tag: "+ ((ComboBox)c).Tag); if (((ComboBox)c).Tag.ToString() != null) //Jos comboboxin tagi on tyhjä { if (((ComboBox)c).Tag.ToString() == "seula") //jos comboboxin tagi on "seula", eli kaikki seuladropdown-valikot { //Console.WriteLine(((ComboBox)c).Text); string seulatxt = ((ComboBox)c).Text; seulatxt = seulatxt.Replace(".", ","); Seulakirjasto ke = new Seulakirjasto { seula = Convert.ToDouble(seulatxt) }; selistALL.Add(ke); } } } } for (int i = 0; i < 4; i++)//Otetaan ohjealueet talteen yksi kolumni kerrallaan { switch (i) { case 0: int o = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "sisAla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = o, tulos = Convert.ToDouble(seulatxt) }; sisOhjeAla.Add(ohj); } o--; } } } } break; case 1: int k = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "sisYla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = k, tulos = Convert.ToDouble(seulatxt) }; sisOhjeYla.Add(ohj); } k--; } } } } break; case 2: int l = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "uloAla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = l, tulos = Convert.ToDouble(seulatxt) }; uloOhjeAla.Add(ohj); } l--; } } } } break; case 3: int m = 17; foreach (Control c in _kivi.ohjeArvot.Children) { if (c.GetType() == typeof(TextBox)) { if (((TextBox)c).Tag.ToString() != null) { if (((TextBox)c).Tag.ToString() == "uloYla") { if (((TextBox)c).Text != String.Empty) { string seulatxt = ((TextBox)c).Text; seulatxt = seulatxt.Replace(".", ","); SeulaLapPros ohj = new SeulaLapPros { index = m, tulos = Convert.ToDouble(seulatxt) }; uloOhjeYla.Add(ohj); } m--; } } } } break; default: break; } } //---------------------------------------------------------------------- //Luodaan listoista käyrä ja otetaan kuva //---------------------------------------------------------------------- PlotModel plotModel = new PlotModel(); plotModel.PlotType = PlotType.XY; plotModel.IsLegendVisible = false; plotModel.PlotMargins = new OxyThickness(15, 15, 15, 15); //asetetaan legendan asetukset //plotModel.LegendPosition = LegendPosition.TopRight; //plotModel.LegendOrientation = LegendOrientation.Horizontal; //plotModel.LegendPlacement = LegendPlacement.Outside; //Tehdään kokoelma, jossa on kaikki käytössä olevat seulat. Nämä sidotaan X-akseliin /*Collection<Item> items = new Collection<Item>(); * for (int i = selistALL.Count - 1; i >= 0; i--) * { * items.Add(new Item(selistALL[i].seula.ToString(), selistALL[i].seula)); * }*/ //Luodaan Y-akseli LinearAxis yaxis = new LinearAxis //Y-akseli { Maximum = 100, Minimum = 0, //Title = "Prosentti", TickStyle = TickStyle.Inside, MinorStep = 5, MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Left, //AbsoluteMaximum = 100, //AbsoluteMinimum = 0, MajorStep = 10, //MinorStep = 5, MajorGridlineStyle = LineStyle.Dash, //MinorGridlineStyle = LineStyle.Dash, IsZoomEnabled = false, IsPanEnabled = false }; //------------------------------Logaritmiakseli------------------------- LogarithmicAxis xaxis = new LogarithmicAxis(); //X-akseli /* double yhteensa = 0; * foreach (Seulakirjasto value in selistALL) * { * yhteensa += value.seula; * }*/ //double keskimaara = yhteensa / kaikkiseulat.Count; //double logbase = 1.0 / Math.Log(Math.E, keskimaara); if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0) { //xaxis.Title = "Seula"; xaxis.TickStyle = TickStyle.Inside; xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; //xaxis.Base = logbase; //xaxis.MajorStep = 2; //xaxis.MinorGridlineStyle = LineStyle.Dash; //xaxis.Maximum = seulat[0].seula; //xaxis.Minimum = seulat[(seulat.Count - 1)].seula; xaxis.IsZoomEnabled = false; xaxis.IsPanEnabled = false; } else { //xaxis.Title = "Seula"; xaxis.TickStyle = TickStyle.Inside; xaxis.Position = AxisPosition.Bottom; xaxis.MajorGridlineStyle = LineStyle.Solid; //xaxis.Base = logbase; //xaxis.MajorStep = //xaxis.MinorGridlineStyle = LineStyle.Dash; xaxis.Maximum = selistALL[0].seula; xaxis.Minimum = selistALL[(selistALL.Count - 1)].seula; xaxis.IsZoomEnabled = false; xaxis.IsPanEnabled = false; } //------------------------------------------------------------------- //Luodaan X-akseli /*CategoryAxis caxis = new CategoryAxis();//X-akseli * * if (selist == null || tulist == null || selist.Count == 0 || tulist.Count == 0) //Jos jokin lista on tyhjä, luodaan tyhjä perusakseli * { * caxis.Title = "Seula"; * caxis.TickStyle = TickStyle.Inside; * caxis.Position = AxisPosition.Bottom; * caxis.IsTickCentered = true; * caxis.MajorGridlineStyle = LineStyle.Solid; * caxis.MajorGridlineColor = OxyColors.DarkSlateGray; * caxis.MajorTickSize = 7; * //caxis.Maximum = seulat[0].seula; * //caxis.Minimum = seulat[(seulat.Count - 1)].seula; * caxis.IsZoomEnabled = false; * caxis.IsPanEnabled = false; * caxis.MinorStep = 0.5; * caxis.MajorStep = 1; * caxis.ItemsSource = items; * caxis.LabelField = "Label"; * } * else * { * caxis.Title = "Seula"; * caxis.TickStyle = TickStyle.Inside; * caxis.Position = AxisPosition.Bottom; * caxis.IsTickCentered = true; * caxis.MajorGridlineStyle = LineStyle.Solid; * caxis.MajorGridlineColor = OxyColors.DarkSlateGray; * caxis.MajorTickSize = 7; * //caxis.Maximum = seulat[0].seula; * //caxis.Minimum = seulat[(seulat.Count-1)].seula; * caxis.IsZoomEnabled = false; * caxis.IsPanEnabled = false; * caxis.MinorStep = 0.5; * caxis.MajorStep = 1; * caxis.ItemsSource = items; * caxis.LabelField = "Label"; * } * for (int i = selistALL.Count - 1; i >= 0; i--) //Laittaa Y-akselille otsikot, eli seulat jotka on käytössä tällä hetkellä * { * caxis.ActualLabels.Add(selistALL[i].seula.ToString()); * }*/ LineSeries l1 = new LineSeries //Tuloskäyrä/viiva { Title = "Rakeisuuskäyrä", MarkerType = MarkerType.Circle, CanTrackerInterpolatePoints = false, MarkerSize = 3 //LabelFormatString = "Läp%: {1:0.0} %" }; //Luodaan itse viivat LineSeries ohje1 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 1, Color = OxyColors.CadetBlue }; LineSeries ohje2 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.CadetBlue }; LineSeries ohje3 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.Indigo }; LineSeries ohje4 = new LineSeries { MarkerType = MarkerType.None, CanTrackerInterpolatePoints = false, MarkerSize = 0, Color = OxyColors.Indigo }; //selist.Reverse(); //Luodaan listat joihin tulee viivojen pisteet List <Pisteet> la = new List <Pisteet>(); //Pääviiva List <Pisteet> o1 = new List <Pisteet>(); List <Pisteet> o2 = new List <Pisteet>(); List <Pisteet> o3 = new List <Pisteet>(); List <Pisteet> o4 = new List <Pisteet>(); //------------------Käytetään CategoryAxisin kanssa-------------------- /*int j = 0; * for (int i = tulist.Count - 1; i >= 0; i--) * { * //Syötetään yhden pisteen koordinaatit listaan esineeksi * Pisteet l = new Pisteet(); * l.X = selist[i].index; * l.Y = tulist[j].tulos; * la.Add(l); * j++; * }//--------------------------------------------------------------------*/ //---------------Käytetään LogarithmAxisin kanssa--------------------- for (int i = 0; i < tulist.Count; i++) { Pisteet l = new Pisteet(); l.X = selist[i].seula;//seulat[i].seula kun käytetään LogarithmAxisia l.Y = tulist[i].tulos; la.Add(l); }//--------------------------------------------------------------------*/ for (int i = sisOhjeAla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = sisOhjeAla[i].index; l.Y = sisOhjeAla[i].tulos; o1.Add(l); } for (int i = sisOhjeYla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = sisOhjeYla[i].index; l.Y = sisOhjeYla[i].tulos; o2.Add(l); } for (int i = uloOhjeAla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = uloOhjeAla[i].index; l.Y = uloOhjeAla[i].tulos; o3.Add(l); } for (int i = uloOhjeYla.Count - 1; i >= 0; i--) { Pisteet l = new Pisteet(); l.X = uloOhjeYla[i].index; l.Y = uloOhjeYla[i].tulos; o4.Add(l); } //Laitetaan luodut pistelistat viivoihinsa foreach (Pisteet e in la) { l1.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o1) { ohje1.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o2) { ohje2.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o3) { ohje3.Points.Add(new DataPoint(e.X, e.Y)); } foreach (Pisteet e in o4) { ohje4.Points.Add(new DataPoint(e.X, e.Y)); } //----------------------Kovakoodatut arvot, testitapaus----------------------------- /*double[] ar = new double[] { 0.063, 0.125, 0.25, 0.5, 1, 2, 4, 6, 8, 12, 16, 18, 20, 25, 30, 64, 100, 200 }; * double[] er = new double[] { 1.8, 3, 4.5, 5.6, 6.5, 8.3, 9.0, 9.9, 13.8, 15.6, 16.5, 17.4, 18.6, 20.4, 30.8, 31.4, 50.5, 62.7 }; * List<Pisteet> la = new List<Pisteet>(); * for (int i = 0; i < ar.Length; i++)//prosentit.Count * { * Pisteet l = new Pisteet(); * l.X = ar[i]; * l.Y = er[i]; * la.Add(l); * } * foreach (Pisteet e in la) * { * l1.Points.Add(new DataPoint(e.X, e.Y)); * }*///----------------------------------------------------------------------------------- //Syötetään kaikki luodut viivat ja akselit kaavioon plotModel.Axes.Add(yaxis); plotModel.Axes.Add(xaxis); //plotModel.Axes.Add(caxis); plotModel.Series.Add(l1); plotModel.Series.Add(ohje1); plotModel.Series.Add(ohje2); plotModel.Series.Add(ohje3); plotModel.Series.Add(ohje4); //Palautetaan kuva viivakaaviosta var kuvastream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 750, Height = 500, Background = OxyColors.White }; pngExporter.Export(plotModel, kuvastream); return(kuvastream); } else { return(null); } }
public override void Execute() { if (_rawdata == null || _rawdata.Rows.Count == 0) { System.Windows.MessageBox.Show("部分爐區資料數不足,請重新確認時間範圍"); //throw new ArgumentNullException("查無對應資料"); } _oxyrptLst = new List <IOxyRptOutput>(); Model = new PlotModel(); Model.Title = base.Title; #region basic setting for LineSeries LineSeries lineSeries = new LineSeries() { //LabelFormatString = "{0:.00}", MarkerType = OxyPlot.MarkerType.Circle, MarkerSize = 4, MarkerFill = OxyColor.FromRgb(121, 168, 225), //TrackerFormatString = "{0} " + Environment.NewLine + "{1}: {2} " + Environment.NewLine + "{3}: {4:0.00} ", TrackerFormatString = "{4:0.00}", CanTrackerInterpolatePoints = false, //LabelFormatString = "{4:0.00 }", }; lineSeries.Color = OxyColor.FromRgb(121, 168, 225); foreach (DataRow row in RawData.Rows) { lineSeries.Points.Add(new DataPoint(DateTimeAxis.ToDouble(row[0]), Math.Round(System.Convert.ToDouble(row[1]), 2))); } Model.Series.Add(lineSeries); #endregion #region setting for Axes var xAxis = new DateTimeAxis { StringFormat = "yyyy/MM/dd", Title = XTitle, MinorIntervalType = DateTimeIntervalType.Days, IntervalType = DateTimeIntervalType.Days, IsZoomEnabled = false, TitleFontSize = 14, }; //test LinearAxis to y-axis for fixed max and min //Model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = 200, Maximum = 600, IsAxisVisible = true }); // test LinearAxis to y-axis for appearance interval var yAxis = new LinearAxis { Position = AxisPosition.Left, Title = YTitle, IntervalLength = 10, IsZoomEnabled = false, TitleFontSize = 14, Maximum = Max * 1.1, Minimum = Min * 0.9, //LabelFormatter = ValueAxisLabelFormatter, //StringFormat = "0.00", //LabelFormatString = "{0:.00}", }; Model.Axes.Add(yAxis); Model.Axes.Add(xAxis); #endregion #region add warning line var la = new LineAnnotation { Type = LineAnnotationType.Horizontal, Y = warningline, Color = OxyColors.Red }; Model.Annotations.Add(la); #endregion #region fail method, sometimes successful, interesting //var stream = new MemoryStream(); var stream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var thread = new Thread(() => { pngExporter.Export(this.Model, stream); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); byte[] bytes = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); //can't write into bytes, length too long? bytes.Length stream.Close(); #endregion #region mouse click close lineSeries.MouseDown += (s, e) => { if (e.ChangedButton == OxyMouseButton.Left) { e.Handled = true;// } else { } }; #endregion //pngExporter. //將檔案轉為二進位陣列 this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.GRAPH, OutputInByteArr = bytes, Tag = this.Tag, }); #region if MR, compute stat table if (Tag == "MR") { this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.TABLE, OutputInByteArr = Tool.ConvertDataSetToByteArray(statTable), }); } #endregion }
public override void Execute() { if (_rawdata == null || _rawdata.Rows.Count == 0) { throw new ArgumentNullException("查無對應資料"); } _oxyrptLst = new List <IOxyRptOutput>(); #region Model = new PlotModel(); Model.Title = Title; #region x-axis setting //var xAxis = new DateTimeAxis //{ // StringFormat = "yyyy/MM/dd", // Title = XTitle, // MinorIntervalType = DateTimeIntervalType.Days, // IntervalType = DateTimeIntervalType.Days, // IsZoomEnabled = false, // TitleFontSize = 14, //}; //Model.Axes.Add(xAxis); CategoryAxis categoriesAxis = new CategoryAxis() { Position = AxisPosition.Bottom, IsZoomEnabled = false, }; ColumnSeries barChart = new ColumnSeries(); barChart.FillColor = OxyColor.FromRgb(121, 168, 225); // the rgb of minitab default #endregion #region y-axis setting LinearAxis yAxis = new LinearAxis() { IsZoomEnabled = false, Position = AxisPosition.Left, }; Model.Axes.Add(yAxis); #endregion #region add each data point to bar chart items foreach (DataRow row in _rawdata.Rows) { int emptyIndex = row[0].ToString().IndexOf(" "); categoriesAxis.ActualLabels.Add(row[0].ToString().Substring(0, emptyIndex)); barChart.Items.Add(new ColumnItem(Convert.ToDouble(row[1]))); } ; #endregion #region mouse click on bar barChart.MouseDown += (s, e) => { if (e.ChangedButton == OxyMouseButton.Left) { //if ((int)Math.Round(e.HitTestResult.Index) != indexOfNearestBarChart) IndexOfNearestBarChart = (int)Math.Round(e.HitTestResult.Index); e.Handled = true;// } else { } }; #endregion #region add warning line at y = 10 Model.Axes.Add(categoriesAxis); Model.Series.Add(barChart); var la = new LineAnnotation { Type = LineAnnotationType.Horizontal, Y = Warningline, Color = OxyColors.Red }; Model.Annotations.Add(la); #endregion #endregion #region fail method, sometimes successful, interesting var stream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var thread = new Thread(() => { pngExporter.Export(this.Model, stream); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); byte[] bytes = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); //can't write into bytes, length too long? bytes.Length stream.Close(); #endregion //將檔案轉為二進位陣列 this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.GRAPH, OutputInByteArr = bytes, Tag = "Bar", }); this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.TABLE, OutputInByteArr = Tool.ConvertDataSetToByteArray(statTable), }); }
private void Button_Click(object sender, RoutedEventArgs e) { OxyPlot.Wpf.PngExporter pe = new OxyPlot.Wpf.PngExporter(); var f = File.Create(@"D:\t1.png"); pe.Export(plotView1.Model, f); }
public ResultViewModel(Dictionary <int, double> finalAAV, List <List <List <int> > > awsCount) { // グラフを描画 LastAAVGraphModel.Value = CreateLastAAVGraphModel(finalAAV); AwsCountGraphModel.Value = CreateAwsCountGraphModel(awsCount); // データをバックアップ this.finalAAV = finalAAV; this.awsCount = awsCount; // タイトルバーを設定 TitleStr.Value = SetTitleBar(finalAAV); // コマンドを設定 CopyAAVPictureCommand.Subscribe(_ => { // 制空値のグラフを画像としてクリップボードにコピー var pngExporter = new OxyPlot.Wpf.PngExporter(); var bitmapSource = pngExporter.ExportToBitmap(LastAAVGraphModel.Value); Clipboard.SetImage(bitmapSource); }); CopyAAVTextCommand.Subscribe(_ => { // 制空値の下側確率の情報をテキストとしてクリップボードにコピー double sum1 = 1.0, sum2 = 0.0; var temp = new Dictionary <int, List <double> >(); foreach (var pair in finalAAV.OrderBy((x) => x.Key)) { sum2 += pair.Value; temp[pair.Key] = new List <double> { pair.Value, sum1, sum2 }; sum1 -= pair.Value; } string output = "制空値,確率分布(%),上側確率(%),下側確率(%)\n"; foreach (var record in temp) { output += $"{record.Key},{100.0 * record.Value[0]},{100.0 * record.Value[1]},{100.0 * record.Value[2]}\n"; } Clipboard.SetText(output); }); CopyAwsPictureCommand.Subscribe(_ => { // 制空状況のグラフを画像としてクリップボードにコピー var pngExporter = new OxyPlot.Wpf.PngExporter(); var bitmapSource = pngExporter.ExportToBitmap(AwsCountGraphModel.Value); Clipboard.SetImage(bitmapSource); }); CopyAwsTextCommand.Subscribe(_ => { // 制空状況の詳細をテキストとしてクリップボードにコピー string output = "航空隊,回数,確保(%),優勢(%),均衡(%),劣勢(%),喪失(%)\n"; int loopCount = awsCount[0][0].Sum(); for (int si = 0; si < awsCount.Count; ++si) { for (int ci = 0; ci < awsCount[si].Count; ++ci) { output += $"{si + 1},{ci + 1},"; output += $"{100.0 * awsCount[si][ci][0] / loopCount},"; output += $"{100.0 * awsCount[si][ci][1] / loopCount},"; output += $"{100.0 * awsCount[si][ci][2] / loopCount},"; output += $"{100.0 * awsCount[si][ci][3] / loopCount},"; output += $"{100.0 * awsCount[si][ci][4] / loopCount}\n"; } } Clipboard.SetText(output); }); }
public override void Execute() { if (_rawdata == null || _rawdata.Rows.Count == 0) { throw new ArgumentNullException("查無對應資料"); } _oxyrptLst = new List <IOxyRptOutput>(); #region create oxy code // This data would be used in bar chart too, so move it to view model. // Here we only handle the PlotModel //// Initialize in View Model //_rptLst = new List<IOxyRptOutput>(); //重新建立一個分析結果列舉 //DataTable distinctPlant = new DataTable(); //// search different plant //distinctPlant.Columns.Add("Plant", typeof(int)); //foreach(DataRow row in RawData.Rows) //{ // if (!(distinctPlant.Rows.Find(row[0])==row[0])) // { // DataRow addrow = new DataRow(); // addrow[0] = row[0]; // distinctPlant.Rows.Add(addrow); // } //}; //DataTable ComputeResult = new DataTable(); //ComputeResult.Columns.Add("Plant", typeof(int)); //ComputeResult.Columns.Add("Max MR", typeof(int)); //foreach (DataRow row in distinctPlant.Rows) //{ // DataRow dt = new DataRow(); // dt[0] = row; // DataTable tmpdt= new DataTable(); // tmpdt.Rows.Add(RawData.Rows.Find(row)); //}; //RawData.Columns.Add("Plant", typeof(int)); //RawData.Columns.Add("Max MR", typeof(int)); Model = new PlotModel(); Model.IsLegendVisible = true; Model.Title = Title; PieSeries pieSeries = new PieSeries(); //RawData.DefaultView.Sort = "Plant DESC"; //int countRangeOver10 = 0; //int countRangeUnover10 = 0; int tmpIndex = 0; foreach (DataRow row in _rawdata.Rows) { tmpIndex++; if (tmpIndex == 1) { pieSeries.Slices.Add(new PieSlice((string)row[0], Convert.ToDouble(row[1])) { IsExploded = false, Fill = OxyColors.PaleVioletRed }); } else { pieSeries.Slices.Add(new PieSlice((string)row[0], Convert.ToDouble(row[1])) { IsExploded = true }); } } ; Model.Series.Add(pieSeries); //查無資料 construct #endregion #region Thread to solve //var stream = new MemoryStream(); var stream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var thread = new Thread(() => { pngExporter.Export(this.Model, stream); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); byte[] bytes = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); //can't write into bytes, length too long? bytes.Length stream.Close(); //stream.Seek(0, SeekOrigin.Begin); #endregion // untry method , but it seems not for this problem //using (MemoryStream ms = new MemoryStream()) //{ // using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress)) // { // ds.Write(data, 0, data.Length); // ds.Flush(); // } // return ms.ToArray(); //} Console.WriteLine(""); //pngExporter. //將檔案轉為二進位陣列 this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.GRAPH, OutputInByteArr = bytes, Tag = "Pie", }); }
public override void Execute() { if (_rawdata == null || _rawdata.Rows.Count == 0) { throw new ArgumentNullException("查無對應資料"); } _oxyrptLst = new List <IOxyRptOutput>(); #region Model = new PlotModel(); Model.Title = Title; #region x-axis setting CategoryAxis categoriesAxis = new CategoryAxis() { Position = AxisPosition.Bottom, IsZoomEnabled = false, }; ColumnSeries barChart = new ColumnSeries(); barChart.FillColor = OxyColor.FromRgb(121, 168, 225); // the rgb of minitab default if (_rawdata.Rows.Count > 10) { categoriesAxis.Angle = 90; } #endregion #region y-axis setting LinearAxis yAxis = new LinearAxis() { IsZoomEnabled = false, Position = AxisPosition.Left, }; Model.Axes.Add(yAxis); #endregion //barChart.Title = BarTitle; #region add each data point to bar chart items int iCnt = 0; // only 50 appears in the graph foreach (DataRow row in _rawdata.Rows) { if (iCnt > 49) { break; } categoriesAxis.ActualLabels.Add(row[0].ToString()); barChart.Items.Add(new ColumnItem(Convert.ToDouble(row[1]))); iCnt++; } ; #endregion #region mouse click on bar barChart.MouseDown += (s, e) => { if (e.ChangedButton == OxyMouseButton.Left) { if ((int)Math.Round(e.HitTestResult.Index) != indexOfNearestBarChart) { IndexOfNearestBarChart = (int)Math.Round(e.HitTestResult.Index); } //int indexOfNearestBarChart = (int)Math.Round(e.HitTestResult.Index); // var nearestBarChart = series.Transform(series.Items[indexOfNearestBarChart]); //bool tmpa = series.IsItemSelected(indexOfNearestBarChart); //barChart.Items.ElementAt(indexOfNearestBarChart); //move //int a = 0; //move e.Handled = true;// } else { } }; #endregion #region add warning line at y = 10 Model.Axes.Add(categoriesAxis); Model.Series.Add(barChart); var la = new LineAnnotation { Type = LineAnnotationType.Horizontal, Y = Warningline, Color = OxyColors.Red }; Model.Annotations.Add(la); #endregion #endregion #region fail method, sometimes successful, interesting //var stream = new MemoryStream(); var stream = new MemoryStream(); var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var thread = new Thread(() => { pngExporter.Export(this.Model, stream); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); byte[] bytes = new byte[stream.Length]; stream.Seek(0, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); //can't write into bytes, length too long? bytes.Length stream.Close(); //stream.Seek(0, SeekOrigin.Begin); #endregion //pngExporter. //將檔案轉為二進位陣列 this.OxyContents.Add(new OxyRptOutput() { OxyOType = OxyOType.GRAPH, OutputInByteArr = bytes, Tag = "Bar", }); }
public static void Generate2DIDs(Column col) { if (col.diagramVertices.Count == 0) { col.GetInteractionDiagram(); } if (col.MxMyPts.Count == 0) { col.Get2DMaps(); } LineSeries sp1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp1.Points.Add(new DataPoint(col.SelectedLoad.MEdx, col.SelectedLoad.MEdy)); PlotModel colMxMyID = new PlotModel() { Title = "Mx-My interaction diagram", Subtitle = "(N = " + Math.Round(col.SelectedLoad.P) + "kN)" }; colMxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMxMyID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s1 = new LineSeries() { Color = OxyColors.Red, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MxMyPts) { s1.Points.Add(new DataPoint(p.X, p.Y)); } colMxMyID.Series.Add(s1); colMxMyID.Series.Add(sp1); LineSeries sp2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})" }; sp2.Points.Add(new DataPoint(col.SelectedLoad.MEdx, -col.SelectedLoad.P)); PlotModel colMxNID = new PlotModel() { Title = "Mx-N interaction diagram", Subtitle = "(My = " + Math.Round(col.SelectedLoad.MEdy) + "kN.m)" }; colMxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "Mx", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMxNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s2 = new LineSeries() { Color = OxyColors.Blue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MxNPts) { s2.Points.Add(new DataPoint(p.X, p.Y)); } colMxNID.Series.Add(s2); colMxNID.Series.Add(sp2); LineSeries sp3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "({0},{1})", }; sp3.Points.Add(new DataPoint(col.SelectedLoad.MEdy, -col.SelectedLoad.P)); PlotModel colMyNID = new PlotModel() { Title = "My-N interaction diagram", Subtitle = "(Mx = " + Math.Round(col.SelectedLoad.MEdx) + "kN.m)", }; colMyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Bottom, Title = "My", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); colMyNID.Axes.Add(new LinearAxis() { Position = AxisPosition.Left, Title = "N", MajorGridlineColor = OxyColors.LightGray, MajorGridlineStyle = LineStyle.Dash, MinorGridlineColor = OxyColors.LightGray, MinorGridlineStyle = LineStyle.Dash, }); LineSeries s3 = new LineSeries() { Color = OxyColors.Green, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.MyNPts) { s3.Points.Add(new DataPoint(p.X, p.Y)); } colMyNID.Series.Add(s3); colMyNID.Series.Add(sp3); if (col.FireDesignMethod == FDesignMethod.Advanced) { LineSeries spf1 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf1.Points.Add(new DataPoint(col.FireLoad.MEdx, col.FireLoad.MEdy)); LineSeries sf1 = new LineSeries() { Color = OxyColors.DarkRed, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMxMyPts) { sf1.Points.Add(new DataPoint(p.X, p.Y)); } colMxMyID.Series.Add(sf1); colMxMyID.Series.Add(spf1); LineSeries spf2 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf2.Points.Add(new DataPoint(col.FireLoad.MEdx, -col.FireLoad.P)); LineSeries sf2 = new LineSeries() { Color = OxyColors.DarkBlue, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMxNPts) { sf2.Points.Add(new DataPoint(p.X, p.Y)); } colMxNID.Series.Add(sf2); colMxNID.Series.Add(spf2); LineSeries spf3 = new LineSeries() { Color = OxyColors.Black, MarkerType = MarkerType.Plus, MarkerSize = 4, MarkerStroke = OxyColors.Black, MarkerFill = OxyColors.Black, MarkerStrokeThickness = 1, LabelFormatString = "fire ({0},{1})" }; spf3.Points.Add(new DataPoint(col.FireLoad.MEdy, -col.FireLoad.P)); LineSeries sf3 = new LineSeries() { Color = OxyColors.DarkGreen, MarkerType = MarkerType.None, StrokeThickness = 1 }; foreach (var p in col.fireMyNPts) { sf3.Points.Add(new DataPoint(p.X, p.Y)); } colMyNID.Series.Add(sf3); colMyNID.Series.Add(spf3); } PlotModel[] plots = new PlotModel[] { colMxMyID, colMxNID, colMyNID }; string[] plotNames = new string[] { "MxMy", "MxN", "MyN" }; for (int i = 0; i < plots.Length; i++) { var pngExporter = new OxyPlot.Wpf.PngExporter { Width = 600, Height = 400, Background = OxyColors.White }; var bitmap = pngExporter.ExportToBitmap(plots[i]); MemoryStream stream = new MemoryStream(); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); encoder.Save(stream); Bitmap bmp = new Bitmap(stream); ImageConverter converter = new ImageConverter(); byte[] output = (byte[])converter.ConvertTo(bmp, typeof(byte[])); string path = System.IO.Path.GetTempPath() + plotNames[i] + ".tmp"; File.WriteAllBytes(path, output); } }