Пример #1
0
        /// <summary>
        /// cTor with content
        /// </summary>
        /// <param name="deviceName">The device name</param>
        /// <param name="cmdCtrl">The command e.g. x,y, rotz etc</param>
        /// <param name="dz">The deadzone value as string (empty string disables)</param>
        /// <param name="sa">The saturation value as string (empty string disables)</param>
        public DeviceOptionParameter(DeviceCls device, string cmdCtrl, string dz, string sa)
        {
            m_deviceClass  = device.DevClass;
            m_deviceName   = device.DevName;
            m_deviceGUID   = device.DevInstanceGUID;
            m_deviceNumber = device.DevInstance;

            m_doID    = Deviceoptions.DevOptionID(m_deviceClass, m_deviceName, cmdCtrl);
            m_cmdCtrl = cmdCtrl;

            m_deadzone        = "0.000";
            m_deadzoneEnabled = false;
            if (!string.IsNullOrEmpty(dz))
            {
                m_deadzone        = dz;
                m_deadzoneEnabled = true;
            }

            m_saturationSupported = false;
            m_saturation          = "1.000";
            m_saturationEnabled   = false;
            if (Devices.Joystick.JoystickCls.IsDeviceClass(m_deviceClass))
            {
                m_saturationSupported = true;
                if (!string.IsNullOrEmpty(sa))
                {
                    m_saturation        = sa;
                    m_saturationEnabled = true;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns>A deep Clone of this object</returns>
        public new object Clone()
        {
            var dop = new Deviceoptions((CloneableDictionary <string, DeviceOptionParameter>)base.Clone( ));

            // more objects to deep copy
            dop.m_stringOptions = new List <string>(m_stringOptions);

#if DEBUG
            // check cloned item
            System.Diagnostics.Debug.Assert(CheckClone(dop));
#endif
            return(dop);
        }
Пример #3
0
        /// <summary>
        /// Check clone against This
        /// </summary>
        /// <param name="clone"></param>
        /// <returns>True if the clone is identical but not a shallow copy</returns>
        private bool CheckClone(Deviceoptions clone)
        {
            bool ret = true;

            // object vars first
            ret &= (!object.ReferenceEquals(this.m_stringOptions, clone.m_stringOptions)); // shall not be the same object !!

            // check THIS Dictionary
            ret &= (this.Count == clone.Count);
            if (ret)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    ret &= (this.ElementAt(i).Key == clone.ElementAt(i).Key);

                    ret &= (!object.ReferenceEquals(this.ElementAt(i).Value, clone.ElementAt(i).Value)); // shall not be the same object !!
                    ret &= (this.ElementAt(i).Value.CheckClone(clone.ElementAt(i).Value));               // sub check
                }
            }
            return(ret);
        }