//--------------------------------------------------------------
// Press F1 to get help about using script.
// To access an object that is not located in the current class, start the call with Globals.
// When using events and timers be cautious not to generate memoryleaks,
// please see the help for more information.
//---------------------------------------------------------------

namespace Neo.ApplicationFramework.Generated
{
    using System.Windows.Forms;
    using System;
    using System.Drawing;
    using Neo.ApplicationFramework.Tools;
    using Neo.ApplicationFramework.Common.Graphics.Logic;
    using Neo.ApplicationFramework.Controls;
    using Neo.ApplicationFramework.Interfaces;
    
    
    public partial class Other_Trend
	{
		//Zoom in trend Y-axis
		void btnZoomIn_Click(System.Object sender, System.EventArgs e)
		{ 
			
			double newYmax = Globals.Tags.Ymax.Value - 5;
			double newYmin = Globals.Tags.Ymin.Value + 5;
			if(newYmin < newYmax)
			{
				Globals.Tags.Ymin.Value += 5;
				Globals.Tags.Ymax.Value -= 5;
			}
		}
		
		//Zoom out trend Y-axis
		void btnZoomOut_Click(System.Object sender, System.EventArgs e)
		{
			
			if(Globals.Tags.Ymax.Value < 200)
			{
				Globals.Tags.Ymin.Value -= 5;
				Globals.Tags.Ymax.Value += 5;
			}
		}
		
		//Pan down trend Y-axis
		void btnPanDown_Click(System.Object sender, System.EventArgs e)
		{
			if(Globals.Tags.Ymin.Value > -100)
			{
				Globals.Tags.Ymin.Value-=5;
				Globals.Tags.Ymax.Value-=5;
			}
		}
		
		//Pan up trend Y-axis
		void btnPanUp_Click(System.Object sender, System.EventArgs e)
		{
			if(Globals.Tags.Ymax.Value < 200)
			{
				Globals.Tags.Ymin.Value+=5;
				Globals.Tags.Ymax.Value+=5;
			}
		}
		
		//Restore trend Y-axis to default values
		void btnRestore_Click(System.Object sender, System.EventArgs e)
		{
			Globals.Tags.Ymin.Value = 0;
			Globals.Tags.Ymax.Value = 100;
		}
		
		//Set the trend in History Mode
		void btnPause_Click(System.Object sender, System.EventArgs e)
		{
			Trend1.ShowHistory("On");
			Globals.Tags.HistoryEnabled.Value = true;
		}
		
		//Leave History Mode
		void btnPlay_Click(System.Object sender, System.EventArgs e)
		{
			Trend1.ShowHistory("Off");
			Globals.Tags.HistoryEnabled.Value = false;
		}
		
		//25% of time range backwards in time
		void btnForward25Percent_Click(System.Object sender, System.EventArgs e)
		{
			Globals.Tags.Offset.Value -= Globals.Tags.Span.Value/4;
			if(Globals.Tags.Offset.Value < 0)
			{
				Globals.Tags.Offset.Value = 0;
			}
		}
		
		//100% of time range backwards in time
		void btnForward100Percent_Click(System.Object sender, System.EventArgs e)
		{
			double offset = Globals.Tags.Span.Value;
			Globals.Tags.Offset.Value -= offset;
			if(Globals.Tags.Offset.Value < 0)
			{
				Globals.Tags.Offset.Value = 0;
			}
		}
		
		//25% of time range forward in time
		void btnBack25Percent_Click(System.Object sender, System.EventArgs e)
		{
			Globals.Tags.Offset.Value += Globals.Tags.Span.Value/4;
		}
		
		//100% of time range backwards in time
		void btnBack100Percent_Click(System.Object sender, System.EventArgs e)
		{
			double offset = Globals.Tags.Span.Value;
			Globals.Tags.Offset.Value += offset;
		}
		
		//Restore trend parameters/offset when leaving the screen
		void Other_Trend_Closed(System.Object sender, System.EventArgs e)
		{
			Globals.Tags.HistoryEnabled.Value = false;
			Globals.Tags.Offset.Value = 0;
			Globals.Tags.Ymin.Value = 0;
			Globals.Tags.Ymax.Value = 100;
		}
		
		//Move to latest samples in trend database
		void btnLatest_Click(System.Object sender, System.EventArgs e)
		{
			Trend1.ShowHistory("Off");
			Globals.Tags.Offset.Value = 0;
			Trend1.ShowHistory("On");
		}
		
    }
}