コード例 #1
0
ファイル: FormControl.cs プロジェクト: yrenlai/VBASync
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = MinorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ MajorVersion.GetHashCode();
         hashCode = (hashCode * 397) ^ (PropMask?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (BackColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ForeColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (FontTextProps?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)NextAvailableId;
         hashCode = (hashCode * 397) ^ (BooleanProperties?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)BorderStyle;
         hashCode = (hashCode * 397) ^ (int)MousePointer;
         hashCode = (hashCode * 397) ^ (ScrollBars?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ GroupCount;
         hashCode = (hashCode * 397) ^ (int)Cycle;
         hashCode = (hashCode * 397) ^ (int)SpecialEffect;
         hashCode = (hashCode * 397) ^ (BorderColor?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (int)Zoom;
         hashCode = (hashCode * 397) ^ (int)PictureAlignment;
         hashCode = (hashCode * 397) ^ (int)PictureSizeMode;
         hashCode = (hashCode * 397) ^ (int)ShapeCookie;
         hashCode = (hashCode * 397) ^ (int)DrawBuffer;
         hashCode = (hashCode * 397) ^ (DisplayedSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (LogicalSize?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (ScrollPosition?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Caption?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ FontIsStdFont.GetHashCode();
         hashCode = (hashCode * 397) ^ (FontStdFont?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
コード例 #2
0
        /// <summary>
        /// Returns the boolean value of the given label. Can be redefined in children classes.
        /// </summary>
        /// <param name="label">The label to get the boolean</param>
        /// <returns>A boolean value of the given label.</returns>
        public virtual bool GetBoolean(string label)
        {
            if (BooleanProperties.ContainsKey(label) == false)
            {
                return(false);
            }

            return(BooleanProperties[label].Boolean);
        }
コード例 #3
0
        /// <summary>
        /// Adds the given label to the <see cref="BooleanProperties"/> dictionary if it is not present.
        /// </summary>
        /// <param name="label">The label to be added.</param>
        public virtual void UpdateBooleanDictionaries(string label)
        {
            lock (BooleanLocks)
            {
                if (ContainsBoolean(label))
                {
                    return;
                }

                BooleanLocks.Add(label, new object());
                BooleanProperties.Add(label, new UdpBoolean());
            }
        }
コード例 #4
0
 /// <summary>
 /// Checks if this set of data has boolean information about the given label.
 /// </summary>
 /// <param name="label">The label to search for booleans</param>
 /// <returns>Returns true if the <see cref="BooleanProperties"/> dictionary has any key equals to the given label.</returns>
 public bool ContainsBoolean(string label)
 {
     return(BooleanProperties.ContainsKey(label));
 }
コード例 #5
0
        /// <summary>
        /// Removes all data from the dictionaries that are older than <see cref="GenericDeviceController.TimeToLive"/>
        /// </summary>
        private void CleanDictionaries()
        {
            //sleeps in the beggining to give time for the software to stabilize
            //Thread.Sleep(2000);

            while (true)
            {
                //Debug.Log("Cleaning Dictionary");
                var keysToKill = new List <string>();

                //Debug.Log("TimeToLive" + Controller.TimeToLive);

                #region floats

                foreach (var floatQueueEntry in FloatQueues)
                {
                    if (floatQueueEntry.Key.Contains("max_"))
                    {
                        continue;
                    }

                    lock (FloatLocks[floatQueueEntry.Key])
                    {
                        while (floatQueueEntry.Value.Count != 0 && (DateTime.Now - floatQueueEntry.Value.Peek().LastTimeUpdated).TotalSeconds >= Controller.TimeToLive)
                        {
                            floatQueueEntry.Value.Dequeue();
                        }

                        if (floatQueueEntry.Value.Count == 0)
                        {
                            keysToKill.Add(floatQueueEntry.Key);
                        }
                    }
                }

                foreach (var key in keysToKill)
                {
                    FloatQueues.Remove(key);
                    FloatLocks.Remove(key);
                }

                //Debug.Log("Float count: " + FloatQueues.Count);

                #endregion floats

                keysToKill.Clear();

                #region positions

                foreach (var positionQueueEntry in PositionQueues)
                {
                    lock (PositionLocks[positionQueueEntry.Key])
                    {
                        while (positionQueueEntry.Value.Count != 0 && (DateTime.Now - positionQueueEntry.Value.Peek().LastTimeUpdated).TotalSeconds >= Controller.TimeToLive)
                        {
                            positionQueueEntry.Value.Dequeue();
                        }

                        if (positionQueueEntry.Value.Count == 0)
                        {
                            keysToKill.Add(positionQueueEntry.Key);
                        }
                    }
                }

                foreach (var key in keysToKill)
                {
                    PositionQueues.Remove(key);
                    PositionLocks.Remove(key);
                }
                //Debug.Log("Position count: " + PositionQueues.Count);

                #endregion positions

                keysToKill.Clear();

                #region rotations

                foreach (var rotationsQueueEntry in RotationQueues)
                {
                    lock (RotationLocks[rotationsQueueEntry.Key])
                    {
                        while (rotationsQueueEntry.Value.Count != 0 && (DateTime.Now - rotationsQueueEntry.Value.Peek().LastTimeUpdated).TotalSeconds >= Controller.TimeToLive)
                        {
                            rotationsQueueEntry.Value.Dequeue();
                        }

                        if (rotationsQueueEntry.Value.Count == 0)
                        {
                            keysToKill.Add(rotationsQueueEntry.Key);
                        }
                    }
                }

                foreach (var key in keysToKill)
                {
                    RotationQueues.Remove(key);
                    RotationLocks.Remove(key);
                }
                //Debug.Log("Rotation count: " + RotationQueues.Count);

                #endregion rotations

                keysToKill.Clear();

                #region samples

                foreach (var sampleQueueEntry in SampleList)
                {
                    lock (SampleLocks[sampleQueueEntry.Key])
                    {
                        if ((DateTime.Now - sampleQueueEntry.Value.LastTimeUpdated).TotalSeconds >= Controller.TimeToLive)
                        {
                            keysToKill.Add(sampleQueueEntry.Key);
                        }
                    }
                }

                foreach (var key in keysToKill)
                {
                    SampleList.Remove(key);
                    SampleLocks.Remove(key);
                }
                //Debug.Log("Samples count: " + SampleList.Count);

                #endregion samples

                keysToKill.Clear();

                #region booleans

                foreach (var booleanQueueEntry in BooleanProperties)
                {
                    lock (BooleanLocks[booleanQueueEntry.Key])
                    {
                        if ((DateTime.Now - booleanQueueEntry.Value.LastTimeUpdated).TotalSeconds >= Controller.TimeToLive)
                        {
                            keysToKill.Add(booleanQueueEntry.Key);
                        }
                    }
                }

                foreach (var key in keysToKill)
                {
                    BooleanProperties.Remove(key);
                    BooleanLocks.Remove(key);
                }
                //Debug.Log("Boolean count: " + BooleanProperties.Count);

                #endregion booleans

                //Debug.Log("cleaning dictionaries");

                Thread.Sleep(50);
            }
        }
コード例 #6
0
        private ControlProperties CreateProperties(PropertyType type, PropertyInfo info, ExposePropertyAttribute attribute)
        {
            ControlProperties control = null;

            switch (type)
            {
            case PropertyType.AnimationCurve:
                control = new AnimationCurveProperties(this, info, attribute);
                break;

            case PropertyType.Boolean:
                control = new BooleanProperties(this, info, attribute);
                break;

            case PropertyType.Bounds:
                control = new BoundsProperties(this, info, attribute);
                break;

            case PropertyType.Color:
                control = new ColorProperties(this, info, attribute);
                break;

            case PropertyType.Enum:
                control = new EnumProperties(this, info, attribute);
                break;

            case PropertyType.Float:
                control = new FloatProperties(this, info, attribute);
                break;

            case PropertyType.Integer:
                control = new IntegerProperties(this, info, attribute);
                break;

            case PropertyType.LayerMask:
                control = new LayerMaskProperties(this, info, attribute);
                break;

            case PropertyType.ObjectReference:
                control = new UnityObjectProperties(this, info, attribute);
                break;

            case PropertyType.Quaternion:
                control = new QuaternionProperties(this, info, attribute);
                break;

            case PropertyType.Rect:
                control = new RectProperties(this, info, attribute);
                break;

            case PropertyType.String:
                control = new StringProperties(this, info, attribute);
                break;

            case PropertyType.Vector2:
                control = new Vector2Properties(this, info, attribute);
                break;

            case PropertyType.Vector3:
                control = new Vector3Properties(this, info, attribute);
                break;

            case PropertyType.Vector4:
                control = new Vector4Properties(this, info, attribute);
                break;

            case PropertyType.SerializableObject:
                control = new SerializableObjectProperties(this, info, attribute);
                break;

            case PropertyType.Array:
                control = new ArrayProperties(this, info, attribute);
                break;
            }

            if (control != null)
            {
                var margin = control.Control.Margin;
                margin.Left           += 2;
                margin.Top            += 2;
                margin.Bottom         += 2;
                control.Control.Margin = margin;
            }
            return(control);
        }