Page 1 of 1

WPF(x64) tool drawline is not moved on dragging

Posted: Fri Feb 21, 2014 10:34 am
by 10554623
Hi,

the drawline is not moved on dragging on c# wpf(x64). We are using tee chart for .net (Version .NET 2013 4.1.2013.07300)
The position of the line is changed on dragging, but the line is not moved to the new position.

Screenshot:
Begin.png
Begin.png (51.66 KiB) Viewed 5104 times
After selected with the mouse and dragging around, the black line isn't move at it should, but the labels start and endposition
are at the new position.

Following code shows the behavior:

XAML:

Code: Select all

<Window x:Class="WpfTestTeeChart.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:my="clr-namespace:Steema.TeeChart.WPF;assembly=TeeChart.WPF"
        Title="MainWindow" Height="350" Width="525">
    <Grid Name="NameGrid">
		<Grid.RowDefinitions>
			<RowDefinition Height="90*"></RowDefinition>
			<RowDefinition Height="10*"></RowDefinition>
		</Grid.RowDefinitions>		
		<AdornerDecorator>
			<my:TChart Margin="0,0,0,0" Name="MyTeeChart" Grid.Row="2" />
		</AdornerDecorator>
		<Label Content="Start" Height="28" HorizontalAlignment="Left" Name="label1" VerticalAlignment="Top" Grid.Row="1" />
		<Label Content="End" Height="28" HorizontalAlignment="Left" Margin="133,0,0,0" Name="label2" VerticalAlignment="Top" Grid.Row="1" />
	</Grid>
</Window>
cs

Code: Select all

namespace WpfTestTeeChart
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		private Steema.TeeChart.WPF.Styles.Line _lineSeries1;
		private Steema.TeeChart.WPF.Tools.DrawLine _drawLine1;

		public MainWindow()
		{
			InitializeComponent();

			// Set chart properties
			MyTeeChart.Aspect.View3D = false;
			MyTeeChart.Header.Text = "Test for Tool DragLine";
			MyTeeChart.AutoRepaint = true;

			// Create line series and set properities and add to series
			_lineSeries1 = new Steema.TeeChart.WPF.Styles.Line();
			_lineSeries1.Color = System.Windows.Media.Colors.Blue;
			_lineSeries1.ColorEach = false;
			_lineSeries1.LinePen.Color = System.Windows.Media.Colors.Green;
			_lineSeries1.Title = "lineSeries1";
			_lineSeries1.XValues.DataMember = "X";
			_lineSeries1.XValues.Order = Steema.TeeChart.WPF.Styles.ValueListOrder.Ascending;
			_lineSeries1.YValues.DataMember = "Y";
			_lineSeries1.FillSampleValues();
			MyTeeChart.Series.Add(_lineSeries1);

			// Create drawline and set properties and add to tools
			_drawLine1 = new Steema.TeeChart.WPF.Tools.DrawLine();
			_drawLine1.EnableDraw = false;
			_drawLine1.EnableSelect = true;
			_drawLine1.Style = Steema.TeeChart.WPF.Tools.DrawLineStyle.Line;
			_drawLine1.DragLine += new Steema.TeeChart.WPF.Tools.DrawLineEventHandler(drawLine1_DragLine);			
			MyTeeChart.Tools.Add(_drawLine1);

			Steema.TeeChart.WPF.Tools.DrawLineItem drawLineItem = new Steema.TeeChart.WPF.Tools.DrawLineItem(_drawLine1);
			double tmp = _lineSeries1.YValues.Range / 5.0;
			drawLineItem.StartPos = new Steema.TeeChart.WPF.Drawing.PointDouble(5, _lineSeries1.YValues.Maximum - tmp);
			drawLineItem.EndPos = new Steema.TeeChart.WPF.Drawing.PointDouble(15, _lineSeries1.YValues.Minimum + tmp);
			drawLineItem.Pen.Color = System.Windows.Media.Colors.Black;
			drawLineItem.Pen.Width = 4;
		}

		private void drawLine1_DragLine(Steema.TeeChart.WPF.Tools.DrawLine sender)
		{
			ShowDrawLinePosition();
		}

		private void ShowDrawLinePosition()
		{
			Steema.TeeChart.WPF.Tools.DrawLineItem I = _drawLine1.Selected;
			label1.Content = "Start: (x: " + I.StartPos.X.ToString("0.00") + ", y: " + I.StartPos.Y.ToString("0.00") + ")";
			label2.Content = "End: (x: " + I.EndPos.X.ToString("0.00") + ", y: " + I.EndPos.Y.ToString("0.00") + ")";
		}
	}
}
Some Suggestions ?

Re: WPF(x64) tool drawline is not moved on dragging

Posted: Fri Feb 21, 2014 12:13 pm
by Christopher
Hello,
Eskimo17 wrote:Some Suggestions ?
Yes, you can use this:

Code: Select all

 public MainWindow()
    {
      //... other code ...
      MyTeeChart.MouseUp += MyTeeChart_MouseUp;
      MyTeeChart.MouseMove += MyTeeChart_MouseMove;

    }

    void MyTeeChart_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
    {
      _drawLine1.EnableDraw = true;
    }

    void MyTeeChart_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
    {
      _drawLine1.EnableDraw = true;
    }
I will add similar code internally to the source code to enable this to work directly.