Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#WPF OxyPlot x,y应具有相同的缩放比例_C#_Wpf_Coordinates_Coordinate Systems_Oxyplot - Fatal编程技术网

C#WPF OxyPlot x,y应具有相同的缩放比例

C#WPF OxyPlot x,y应具有相同的缩放比例,c#,wpf,coordinates,coordinate-systems,oxyplot,C#,Wpf,Coordinates,Coordinate Systems,Oxyplot,不幸的是,我不知道如何调整轴缩放。 x轴和y轴应具有相同的缩放比例。例如,您可以看到下面两张图片。一次使用蓝色笔划(相同比例),一次使用红色笔划(不同比例)。我如何调整,只有相同的缩放出来(见蓝色笔划的图片)。x和y具有相同的距离,例如从0(开始)到10(结束)。它应该而不是与红色笔划的图片具有不同的缩放比例。稍后我应该可以说,x轴和y轴正好等于点的距离 有人能帮我做同样的缩放吗 我还可以定义值范围本身吗?从-12到+12 XAML 用户控制 using System; using Sy

不幸的是,我不知道如何调整轴缩放。 x轴和y轴应具有相同的缩放比例。例如,您可以看到下面两张图片。一次使用蓝色笔划(相同比例),一次使用红色笔划(不同比例)。我如何调整,只有相同的缩放出来(见蓝色笔划的图片)。x和y具有相同的距离,例如从0(开始)到10(结束)。它应该而不是与红色笔划的图片具有不同的缩放比例。稍后我应该可以说,x轴和y轴正好等于点的距离

有人能帮我做同样的缩放吗

我还可以定义值范围本身吗?从-12到+12

XAML



用户控制

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;
using OxyPlot.Series;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Globalization;
using OxyPlot.Wpf;
using System.Diagnostics;

namespace Vorschau
{
    /// <summary>
    /// Interaktionslogik für UCVorschau.xaml
    /// </summary>
    public partial class UCVorschau : UserControl
    {
        public UCVorschau()
        {
            InitializeComponent();
            try
            {
                DataContext = this;
                this.Title = "Vorschaubild";
                oxyPlot.Width = Vorschau.Properties.Settings.Default.BreiteBitmap;
                oxyPlot.Height = Vorschau.Properties.Settings.Default.HoeheBitmap;
                if (Vorschau.Properties.Settings.Default.MarkerTyp == 0)
                {
                    ls.MarkerType = MarkerType.Circle;
                    ls.MarkerFill = System.Windows.Media.Colors.Transparent;
                    ls.MarkerStrokeThickness = Vorschau.Properties.Settings.Default.Kreisdurchmesser;
                }
                else
                {
                    ls.MarkerType = MarkerType.Square;
                    ls.MarkerFill = System.Windows.Media.Colors.Black;
                    ls.MarkerStroke = System.Windows.Media.Colors.Black;
                    ls.MarkerStrokeThickness = 2;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Es trat ein unerwarteter Fehler auf. \nBitte Starten Sie die Anwendung neu." + error.ToString());
            }

        }
        public string Title { get; set; }
        public IList<DataPoint> Points { get; private set; }

        /// <summary>
        /// Einstelungs-Fenster wird geöffnet
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //btEinstellung


        private void btGenerate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DateTime startZeit = DateTime.Now;
                Cursor = Cursors.Wait;
                if (Vorschau.Properties.Settings.Default.MarkerTyp == 0)
                {
                    ls.MarkerType = MarkerType.Circle;
                    ls.MarkerFill = System.Windows.Media.Colors.Transparent;
                    ls.MarkerStrokeThickness = Vorschau.Properties.Settings.Default.Kreisdurchmesser;
                }
                else
                {
                    ls.MarkerType = MarkerType.Square;
                    ls.MarkerFill = System.Windows.Media.Colors.Black;
                    ls.MarkerStroke = System.Windows.Media.Colors.Black;
                    ls.MarkerStrokeThickness = 2;
                }
                double zufallszahlX;
                double zufallszahlY;

                double XMax = 10;
                double XMin = 0;
                double YMax = 10;
                double YMin = 0;
                // Zur Erstellung des Seeds
                int h = DateTime.Now.Hour;
                int m = DateTime.Now.Minute;
                int s = DateTime.Now.Second;
                String u = h.ToString() + m.ToString() + s.ToString();
                int iu = Int32.Parse(u);
                Random zufall = new Random(iu);
                Console.WriteLine("______________");
                CultureInfo en = new CultureInfo("en-US", false); // Damit ein Punkt ist anstatt ein Komma
                DataContext = this;
                this.Points = new List<DataPoint>();
                System.IO.File.WriteAllText(((Environment.CurrentDirectory + @"\files\koordinaten.txt")), string.Empty);
                using (var fileStream = new FileStream(String.Format(Environment.CurrentDirectory + @"\files\koordinaten.txt"), FileMode.OpenOrCreate))
                {
                    using (var streamWriter = new StreamWriter(fileStream))
                    {
                        for (int i = 0; i < Vorschau.Properties.Settings.Default.AnzahlKoordinaten; i++)
                        {
                            zufallszahlX = zufall.NextDouble() * (XMax - XMin) + XMin;
                            zufallszahlY = zufall.NextDouble() * (YMax - YMin) + YMin;
                            //Console.WriteLine("( " + zufallszahlX + " / " + zufallszahlY + " )" + " |" + i);
                            streamWriter.WriteLine("( " + zufallszahlX.ToString(en.NumberFormat) + " / " + zufallszahlY.ToString(en.NumberFormat) + " )" + " |" + (i + 1));
                            //ls.addPoint(zufallszahlX, zufallszahlY);
                            Points.Add(new DataPoint(zufallszahlX, zufallszahlY));
                        }
                        ls.ItemsSource = Points;
                    }
                }
                Cursor = Cursors.Arrow;
                DateTime endZeit = DateTime.Now;
                TimeSpan gemesseneZeit = endZeit - startZeit;
                // statusbar.Text = "Gemessen Zeit für den Durchlauf: " + gemesseneZeit;
            }
            catch (Exception)
            {
                MessageBox.Show("Hoppla, da lief etwas schief.\nLeider konnten keine Koordinaten generiert werden.\nVersuchen Sie es bitte erneut.", "", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void btClear_Click(object sender, RoutedEventArgs e)
        {
            //botAxis.Minimum = botAxis.InternalAxis.ActualMinimum;
            //botAxis.Maximum = botAxis.InternalAxis.ActualMaximum;
            //lefAxis.Minimum = lefAxis.InternalAxis.ActualMinimum;
            //lefAxis.Maximum = lefAxis.InternalAxis.ActualMaximum;
            ls.ItemsSource = null;
        }

        private void btRead_Click(object sender, RoutedEventArgs e)
        {
            DateTime startZeit = DateTime.Now;
            Cursor = Cursors.Wait;
            String line;

            Console.WriteLine("___________");
            Console.WriteLine("Koordinaten: ");
            using (System.IO.StreamReader file = new System.IO.StreamReader(Environment.CurrentDirectory + @"\files\koordinaten.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    Regex myRegexKF = new Regex(@"^(?<koordinaet>\S\s*\S*\d+\s*\S\s*\S*\d+\s*\S)\s*\S\d+", RegexOptions.IgnoreCase);
                    Match matchSuccess = myRegexKF.Match(line);
                    if (matchSuccess.Success)
                    {
                        String koordinaten = matchSuccess.Groups["koordinate"].Value;
                        System.Console.WriteLine(koordinaten);
                    }
                }
            }
            System.Console.ReadLine();
            Cursor = Cursors.Arrow;
            DateTime endZeit = DateTime.Now;
            TimeSpan gemesseneZeit = endZeit - startZeit;
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用氧图;
使用OxyPlot.系列;
使用System.IO;
使用System.Text.RegularExpressions;
使用系统集合;
利用制度全球化;
使用OxyPlot.Wpf;
使用系统诊断;
名称空间Vorschau
{
/// 
///für UCVorschau.xaml跨部门物流
/// 
公共部分类UCVorschau:UserControl
{
公共图书馆
{
初始化组件();
尝试
{
DataContext=this;
this.Title=“Vorschaubild”;
oxyPlot.Width=Vorschau.Properties.Settings.Default.BreiteBitmap;
oxyPlot.Height=Vorschau.Properties.Settings.Default.hoeheb位图;
if(Vorschau.Properties.Settings.Default.MarkerTyp==0)
{
ls.MarkerType=MarkerType.Circle;
ls.MarkerFill=System.Windows.Media.Colors.Transparent;
ls.MarkerStrokeThickness=Vorschau.Properties.Settings.Default.kreidsourchmesser;
}
其他的
{
ls.MarkerType=MarkerType.Square;
ls.MarkerFill=System.Windows.Media.Colors.Black;
ls.MarkerStroke=System.Windows.Media.Colors.Black;
ls.MarkerStrokeThickness=2;
}
}
捕获(异常错误)
{
MessageBox.Show(“这是一个很好的策略。\n它开始于一个新的领域。”+error.ToString());
}
}
公共字符串标题{get;set;}
公共IList点{get;private set;}
/// 
///爱因斯坦·芬斯特·沃德·格夫内特
/// 
/// 
/// 
//B安装
私有void btGenerate_单击(对象发送方,路由目标)
{
尝试
{
DateTime startZeit=DateTime.Now;
游标=游标。等等;
if(Vorschau.Properties.Settings.Default.MarkerTyp==0)
{
ls.MarkerType=MarkerType.Circle;
ls.MarkerFill=System.Windows.Media.Colors.Transparent;
ls.MarkerStrokeThickness=Vorschau.Properties.Settings.Default.kreidsourchmesser;
}
其他的
{
ls.MarkerType=MarkerType.Square;
ls.MarkerFill=System.Windows.Media.Colors.Black;
ls.MarkerStroke=System.Windows.Media.Colors.Black;
ls.MarkerStrokeThickness=2;
}
双zufallszahlX;
双祖法尔沙利;
双倍XMax=10;
双XMin=0;
双YMax=10;
双YMin=0;
//种子
int h=DateTime.Now.Hour;
int m=DateTime.Now.Minute;
int s=DateTime.Now.Second;
字符串u=h.ToString()+m.ToString()+s.ToString();
intiu=Int32.Parse(u);
Random zufall=新随机(iu);
Console.WriteLine(“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu”);
CultureInfo en=新的CultureInfo(“en-US”,false);//Damit ein Punkt ist anstatt ein Komma
DataContext=this;
this.Points=新列表();
System.IO.File.WriteAllText(((Environment.CurrentDirectory+@“\files\koorderin.txt”)、string.Empty);
使用(var fileStream=newfilestream(String.Format(Environment.CurrentDirectory+@“\files\koorderin.txt”)、FileMode.OpenOrCreate)
{
使用(var streamWriter=newstreamwriter(fileStream))
{
对于(int i=0;iusing 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;
using OxyPlot.Series;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;
using System.Globalization;
using OxyPlot.Wpf;
using System.Diagnostics;

namespace Vorschau
{
    /// <summary>
    /// Interaktionslogik für UCVorschau.xaml
    /// </summary>
    public partial class UCVorschau : UserControl
    {
        public UCVorschau()
        {
            InitializeComponent();
            try
            {
                DataContext = this;
                this.Title = "Vorschaubild";
                oxyPlot.Width = Vorschau.Properties.Settings.Default.BreiteBitmap;
                oxyPlot.Height = Vorschau.Properties.Settings.Default.HoeheBitmap;
                if (Vorschau.Properties.Settings.Default.MarkerTyp == 0)
                {
                    ls.MarkerType = MarkerType.Circle;
                    ls.MarkerFill = System.Windows.Media.Colors.Transparent;
                    ls.MarkerStrokeThickness = Vorschau.Properties.Settings.Default.Kreisdurchmesser;
                }
                else
                {
                    ls.MarkerType = MarkerType.Square;
                    ls.MarkerFill = System.Windows.Media.Colors.Black;
                    ls.MarkerStroke = System.Windows.Media.Colors.Black;
                    ls.MarkerStrokeThickness = 2;
                }
            }
            catch (Exception error)
            {
                MessageBox.Show("Es trat ein unerwarteter Fehler auf. \nBitte Starten Sie die Anwendung neu." + error.ToString());
            }

        }
        public string Title { get; set; }
        public IList<DataPoint> Points { get; private set; }

        /// <summary>
        /// Einstelungs-Fenster wird geöffnet
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //btEinstellung


        private void btGenerate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DateTime startZeit = DateTime.Now;
                Cursor = Cursors.Wait;
                if (Vorschau.Properties.Settings.Default.MarkerTyp == 0)
                {
                    ls.MarkerType = MarkerType.Circle;
                    ls.MarkerFill = System.Windows.Media.Colors.Transparent;
                    ls.MarkerStrokeThickness = Vorschau.Properties.Settings.Default.Kreisdurchmesser;
                }
                else
                {
                    ls.MarkerType = MarkerType.Square;
                    ls.MarkerFill = System.Windows.Media.Colors.Black;
                    ls.MarkerStroke = System.Windows.Media.Colors.Black;
                    ls.MarkerStrokeThickness = 2;
                }
                double zufallszahlX;
                double zufallszahlY;

                double XMax = 10;
                double XMin = 0;
                double YMax = 10;
                double YMin = 0;
                // Zur Erstellung des Seeds
                int h = DateTime.Now.Hour;
                int m = DateTime.Now.Minute;
                int s = DateTime.Now.Second;
                String u = h.ToString() + m.ToString() + s.ToString();
                int iu = Int32.Parse(u);
                Random zufall = new Random(iu);
                Console.WriteLine("______________");
                CultureInfo en = new CultureInfo("en-US", false); // Damit ein Punkt ist anstatt ein Komma
                DataContext = this;
                this.Points = new List<DataPoint>();
                System.IO.File.WriteAllText(((Environment.CurrentDirectory + @"\files\koordinaten.txt")), string.Empty);
                using (var fileStream = new FileStream(String.Format(Environment.CurrentDirectory + @"\files\koordinaten.txt"), FileMode.OpenOrCreate))
                {
                    using (var streamWriter = new StreamWriter(fileStream))
                    {
                        for (int i = 0; i < Vorschau.Properties.Settings.Default.AnzahlKoordinaten; i++)
                        {
                            zufallszahlX = zufall.NextDouble() * (XMax - XMin) + XMin;
                            zufallszahlY = zufall.NextDouble() * (YMax - YMin) + YMin;
                            //Console.WriteLine("( " + zufallszahlX + " / " + zufallszahlY + " )" + " |" + i);
                            streamWriter.WriteLine("( " + zufallszahlX.ToString(en.NumberFormat) + " / " + zufallszahlY.ToString(en.NumberFormat) + " )" + " |" + (i + 1));
                            //ls.addPoint(zufallszahlX, zufallszahlY);
                            Points.Add(new DataPoint(zufallszahlX, zufallszahlY));
                        }
                        ls.ItemsSource = Points;
                    }
                }
                Cursor = Cursors.Arrow;
                DateTime endZeit = DateTime.Now;
                TimeSpan gemesseneZeit = endZeit - startZeit;
                // statusbar.Text = "Gemessen Zeit für den Durchlauf: " + gemesseneZeit;
            }
            catch (Exception)
            {
                MessageBox.Show("Hoppla, da lief etwas schief.\nLeider konnten keine Koordinaten generiert werden.\nVersuchen Sie es bitte erneut.", "", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void btClear_Click(object sender, RoutedEventArgs e)
        {
            //botAxis.Minimum = botAxis.InternalAxis.ActualMinimum;
            //botAxis.Maximum = botAxis.InternalAxis.ActualMaximum;
            //lefAxis.Minimum = lefAxis.InternalAxis.ActualMinimum;
            //lefAxis.Maximum = lefAxis.InternalAxis.ActualMaximum;
            ls.ItemsSource = null;
        }

        private void btRead_Click(object sender, RoutedEventArgs e)
        {
            DateTime startZeit = DateTime.Now;
            Cursor = Cursors.Wait;
            String line;

            Console.WriteLine("___________");
            Console.WriteLine("Koordinaten: ");
            using (System.IO.StreamReader file = new System.IO.StreamReader(Environment.CurrentDirectory + @"\files\koordinaten.txt"))
            {
                while ((line = file.ReadLine()) != null)
                {
                    Regex myRegexKF = new Regex(@"^(?<koordinaet>\S\s*\S*\d+\s*\S\s*\S*\d+\s*\S)\s*\S\d+", RegexOptions.IgnoreCase);
                    Match matchSuccess = myRegexKF.Match(line);
                    if (matchSuccess.Success)
                    {
                        String koordinaten = matchSuccess.Groups["koordinate"].Value;
                        System.Console.WriteLine(koordinaten);
                    }
                }
            }
            System.Console.ReadLine();
            Cursor = Cursors.Arrow;
            DateTime endZeit = DateTime.Now;
            TimeSpan gemesseneZeit = endZeit - startZeit;
        }
    }
}
<oxy:Plot.Axes>
    <oxy:LinearAxis ... MajorStep="1"/>
    <oxy:LinearAxis ... MajorStep="1"/>
</oxy:Plot.Axes>