using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetSDKCS;

namespace NetClient
{
    public class PTZClient : RealPlayClient
    {
        //PTZControl function
        private void PTZControl(EM_EXTPTZ_ControlType type, int channel, int param1, int param2, bool isStop)
        {
            try
            {
                NETClient.PTZControl(LoginID, channel, type, param1, param2, 0, isStop, IntPtr.Zero);
            }
            catch (NetSDKCS.NETClientExcetion ex)
            {
                throw new NETClientExcetion(ex.ErrorCode, ex.Message);
            }
        }

        /// <summary>
        /// PTZ topleft start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void TopLeftStart(int channel, int verticalSpeed, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFTTOP, channel, verticalSpeed, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// PTZ topleft end 
        /// </summary>
        /// <param name="channel">device channel</param>
        public void TopLeftEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFTTOP, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ topright start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void TopRightStart(int channel, int verticalSpeed, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHTTOP, channel, verticalSpeed, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ topright end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void TopRightEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHTTOP, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ leftbottom start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void LeftBottomStart(int channel, int verticalSpeed, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFTDOWN, channel, verticalSpeed, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ leftbottom end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void LeftBottomEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFTDOWN, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ rightbottom start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void RightBottomStart(int channel, int verticalSpeed, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHTDOWN, channel, verticalSpeed, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ rightbottom end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void RightBottomEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHTDOWN, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ top start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        public void TopStart(int channel, int verticalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.UP_CONTROL, channel, 0, verticalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ top end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void TopEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.UP_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ bottom start 
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="verticalSpeed">vertical speed</param>
        public void BotttomStart(int channel, int verticalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.DOWN_CONTROL, channel, 0, verticalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ bottom end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void BottomEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.DOWN_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ left start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void LeftStart(int channel, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFT_CONTROL, channel, 0, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ left end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void LeftEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.LEFT_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ right start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="horizontalSpeed">horizontal speed</param>
        public void RightStart(int channel, int horizontalSpeed)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHT_CONTROL, channel, 0, horizontalSpeed, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ right end
        /// </summary>
        /// <param name="channel">device channel</param>
        public void RightEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.RIGHT_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        /// <summary>
        /// PTZ zoom add start
        /// </summary>
        /// <param name="channel">device channel</param>
        /// <param name="multiple">multiple</param>
        public void ZoomAddSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.ZOOM_ADD_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ZoomAddEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.ZOOM_ADD_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ZoomDecSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.ZOOM_DEC_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ZoomDecEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.ZOOM_DEC_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void FocusAddSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.FOCUS_ADD_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void FocusAddEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.FOCUS_ADD_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void FocusDecSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.FOCUS_DEC_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void FocusDecEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.FOCUS_DEC_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ApertureAddSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.APERTURE_ADD_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ApertureAddEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.APERTURE_ADD_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ApertureDecSatrt(int channel, int multiple)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.APERTURE_DEC_CONTROL, channel, 0, multiple, false);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

        public void ApertureDecEnd(int channel)
        {
            try
            {
                PTZControl(EM_EXTPTZ_ControlType.APERTURE_DEC_CONTROL, channel, 0, 0, true);
            }
            catch (NETClientExcetion ex)
            {
                throw ex;
            }
        }

    }
}
