Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > .NET Frameworks (точка нет фреймворки) > WPF, UWP, WinRT, XAML
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 08.06.2015, 22:49   #1
CWD
Пользователь
 
Регистрация: 10.11.2009
Сообщений: 50
По умолчанию OxyPlot Rectangle

Добрый день, при изменение масштаба осей изменяется сам нарисованный Четырехугольник. Хотелось бы реализовать инвариантность Четырехугольника, относительно масштаба осей. При любых значениях осей Четырехугольник на екране всегда одного размера и в том же месте. Так же будущие значения осей не известны. Спасибо.

Код:
using GalaSoft.MvvmLight.Command;
using OxyPlot;
using OxyPlot.Annotations;
using OxyPlot.Axes;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
 
namespace WpfApplication22
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = new PlotRectangle();
        }
    }
    public class PlotRectangle
    {
        public ICommand ComboCommand { get; set; }
        public PlotModel PlotModel { get; set; }
        public LinearAxis XAxis { get; set; }
        public LinearAxis YAxis { get; set; }
        public LineSeries LineSeries { get; set; }
        public RectangleAnnotation Rect {get;set;}
        public List<string> Items { get; set; }
        public PlotRectangle()
        {
            ComboCommand = new RelayCommand(()=>ChangeAxis());
            PlotModel = new PlotModel();
            Rect = new RectangleAnnotation();
            LineSeries = new LineSeries();
            Items = new List<string>();
            Items.Add("5");
            Items.Add("10");
            Items.Add("15");
            
            Rect.MinimumX = 10;
            Rect.MaximumX = 20;
            Rect.MinimumY = 1;
            Rect.MaximumY = 10;
 
            XAxis = new LinearAxis
            {
                Position=AxisPosition.Bottom,
            };
            YAxis = new LinearAxis
            {
                Position = AxisPosition.Left,
                IsPanEnabled=false
            };
            PlotModel.Axes.Add(XAxis);
            PlotModel.Axes.Add(YAxis);
            PlotModel.Series.Add(LineSeries);
            PlotModel.Annotations.Add(Rect);
        }
        public void ChangeAxis()
        {
            Random rnd1 = new Random();
            Random rnd2 = new Random();
            Random rnd3 = new Random();
            Random rnd4 = new Random();
            
            PlotModel.Axes[1] = new LinearAxis
            {
                //Minimum=rnd1.Next(1,10),
                //Maximum=rnd2.Next(15,50)
                Minimum=20,
                Maximum=30,
                Position=AxisPosition.Bottom
            };
            PlotModel.Axes[0] = new LinearAxis
            {
                //Minimum = rnd3.Next(1, 10),
                //Maximum = rnd4.Next(15, 50)
                Minimum=20,
                Maximum=30,
                Position=AxisPosition.Left,
                IsPanEnabled=false
            };
 
 
            //Rect.MinimumX = Rect.MinimumX * rnd1.Next(1, 10);
            //Rect.MaximumX = Rect.MaximumX * rnd2.Next(15, 50);
            //Rect.MinimumY = Rect.MinimumY * rnd3.Next(1, 10);
            //Rect.MaximumY = Rect.MaximumY * rnd4.Next(15, 50);
            PlotModel.InvalidatePlot(true);
        }
    }
}
Код:
<Window x:Class="WpfApplication22.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:oxy="http://oxyplot.org/wpf"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        Title="MainWindow" Height="350" Width="525">
    <StackPanel Orientation="Horizontal">
        <ComboBox Height="20" VerticalAlignment="Top" SelectedIndex="0" ItemsSource="{Binding Items}">
            <i:Interaction.Triggers>
            <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding ComboCommand}"></i:InvokeCommandAction>
            </i:EventTrigger>
            </i:Interaction.Triggers>
        </ComboBox>
        <Grid>
 
    <oxy:Plot Model="{Binding PlotModel}" Width="490"></oxy:Plot>
    </Grid>
    </StackPanel>
</Window>
CWD вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
OxyPlot canvas CWD WPF, UWP, WinRT, XAML 0 25.04.2015 20:05
Ошибка 1 error LNK2019: ссылка на неразрешенный внешний символ "public: __thiscall Rectangle::~Rectangle(void)" (??1Rectangle@@QAE Dimka-novitsek Общие вопросы C/C++ 4 15.10.2014 13:34
класс Rectangle совпадает с функцией Rectangle sofen.ru Общие вопросы C/C++ 5 06.11.2010 14:32
canvas.rectangle Terrance! Помощь студентам 3 22.09.2010 12:59
Проекция Rectangle _-Re@l-_ Паскаль, Turbo Pascal, PascalABC.NET 8 09.09.2010 11:13