1
(C#應用程序的WPF)繪製圖形 - 只顯示單點
我有一個問題,我有「畫」一個座標系,並只輸入座標(不含線)所看到的圖片。
我想用一個圖書館,因爲我也有畫一個框架,我想有一個圖書館它會很容易。所以我發現了GnuPlot,Oxyplot並繪製了自己。不幸的是,GnuPlot沒有用於C#應用程序的庫。 (或者如果你有一個,請讓我知道)。因此,我使用了OxyPlot,但不幸的是OxyPlot只顯示了我的座標系。 現在我的問題。 有沒有更好的座標系繪製座標系? 應符合下列要求:
- 它應該是一個預覽應用程序,也就是說,如果我改變它的大小應直接發生
- 我想提出一個框架,因此它應該幫助我過程
- 應該有一個圖書館
- 它應該是一個C#應用程序
- 我想成爲爲X第一點標記,Y座標,但後來應該是一個圓直徑 圈
- 以後作爲位圖
正如上面提到的,我已經與OxyPlot使用它,但遺憾的是它並沒有繪製圖形(我使用的樣本文檔)
也許你有更好的想法/解決方案爲OxyPlot。
在此先感謝,我對每一個回覆感到高興。
XAML:
<Window x:Class="TestOxyPlot.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oxy="http://oxyplot.org/wpf"
xmlns:local="clr-namespace:TestOxyPlot"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<oxy:Plot x:Name="oxyPlot" Title="{Binding Title}" Margin="207,53,0,0">
<oxy:Plot.Series>
<oxy:LineSeries ItemsSource="{Binding Points}"/>
</oxy:Plot.Series>
</oxy:Plot>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="44,64,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" MouseLeave="textBox_MouseLeave" TextChanged="textBox_TextChanged"/>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="23" Margin="44,101,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" TextChanged="textBox1_TextChanged"/>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="68,174,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OxyPlot;
namespace TestOxyPlot
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Title = "Example 2";
this.Points = new List<DataPoint>
{
new DataPoint(0, 4),
new DataPoint(10, 13),
new DataPoint(20, 15),
new DataPoint(30, 16),
new DataPoint(40, 12),
new DataPoint(50, 12)
};
}
public string Title { get; private set; }
public IList<DataPoint> Points { get; private set; }
private void textBox_MouseLeave(object sender, MouseEventArgs e)
{
}
private void textBox_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
oxyPlot.Width = Int32.Parse(textBox.Text);
}
catch (Exception error)
{
MessageBox.Show("Message: " + error);
}
}
private void button_Click(object sender, RoutedEventArgs e)
{
}
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
oxyPlot.Width = Int32.Parse(textBox.Text);
}
catch (Exception error)
{
MessageBox.Show("Message: " + error);
}
}
}
}
首先,非常感謝! 它解決了,但不幸的是我想插入代碼到一個按鈕,當我點擊一個按鈕,首先座標出現+生成。但有些錯誤。你看到錯誤嗎? 這是代碼的鏈接: https://gist.github.com/anonymous/42525209b6eec77d1aea5006f443eea3 – GabelUndMesser
添加數據後重置LineSeries ItemsSource。我提供了我的工作示例。 – Ron
感謝您的支持。我希望你能再回答一個問題。 我想在座標系中創建一個邊距。 我如何得到這個?我用「保證金」試了一下,遺憾的是沒有成功。所以座標不是直接在邊緣,而是有一定的距離。 ' ' –
GabelUndMesser