예제 #1
0
        /// <summary>
        /// Invoked when the value of the adjustable has changed.
        /// </summary>
        public virtual void AdjustmentValueChanged(AdjustmentEvent e)
        {
            Adjustable     adj   = e.Adjustable;
            int            value = e.Value;
            ScrollPanePeer peer  = (ScrollPanePeer)Scroller.Peer_Renamed;

            if (peer != null)
            {
                peer.SetValue(adj, value);
            }

            Component c = Scroller.GetComponent(0);

            switch (adj.Orientation)
            {
            case Adjustable_Fields.VERTICAL:
                c.Move(c.Location.x, -(value));
                break;

            case Adjustable_Fields.HORIZONTAL:
                c.Move(-(value), c.Location.y);
                break;

            default:
                throw new IllegalArgumentException("Illegal adjustable orientation");
            }
        }
예제 #2
0
 /// <summary>
 /// Constructs an <code>AdjustmentEvent</code> object with the
 /// specified Adjustable source, event type, adjustment type, and value.
 /// <para> This method throws an
 /// <code>IllegalArgumentException</code> if <code>source</code>
 /// is <code>null</code>.
 ///
 /// </para>
 /// </summary>
 /// <param name="source"> The <code>Adjustable</code> object where the
 ///               event originated </param>
 /// <param name="id">     An integer indicating the type of event.
 ///                     For information on allowable values, see
 ///                     the class description for <seealso cref="AdjustmentEvent"/> </param>
 /// <param name="type">   An integer indicating the adjustment type.
 ///                     For information on allowable values, see
 ///                     the class description for <seealso cref="AdjustmentEvent"/> </param>
 /// <param name="value">  The current value of the adjustment </param>
 /// <param name="isAdjusting"> A boolean that equals <code>true</code> if the event is one
 ///               of a series of multiple adjusting events,
 ///               otherwise <code>false</code> </param>
 /// <exception cref="IllegalArgumentException"> if <code>source</code> is null
 /// @since 1.4 </exception>
 /// <seealso cref= #getSource() </seealso>
 /// <seealso cref= #getID() </seealso>
 /// <seealso cref= #getAdjustmentType() </seealso>
 /// <seealso cref= #getValue() </seealso>
 /// <seealso cref= #getValueIsAdjusting() </seealso>
 public AdjustmentEvent(Adjustable source, int id, int type, int value, bool isAdjusting) : base(source, id)
 {
     Adjustable_Renamed          = source;
     this.AdjustmentType_Renamed = type;
     this.Value_Renamed          = value;
     this.IsAdjusting            = isAdjusting;
 }
예제 #3
0
 /// <summary>
 /// Performs initialization related to the adjusting component.
 /// </summary>
 private void InitAdjustableComponent()
 {
     adjustableComponent = gameObject.GetComponent <Adjustable>();
     if (adjustableComponent != null)
     {
         adjustableComponent.TargetGameObject = gameObject;
     }
     else
     {
         Debug.LogError("Adjustable component not found.");
     }
 }
예제 #4
0
 /// <summary>
 /// Performs initialization related to the adjusting component.
 /// </summary>
 private void InitAdjustableComponent()
 {
     adjustableComponent = gameObject.GetComponent <Adjustable>();
     if (adjustableComponent != null)
     {
         adjustableComponent.TargetGameObject  = gameObject;
         adjustableComponent.AnchorId          = Id;
         adjustableComponent.AdjustingStarted += ForceSleep;
     }
     else
     {
         Debug.LogError("Souvenir.cs expects an HSAdjustable component.");
     }
 }
예제 #5
0
        public bool ReadItem(Activity activityInput)
        {
            //TODO : Implement description
            string desc = "";

            if (activityInput == null)
            {
                throw new NullReferenceException();
            }
            if (activityInput.Item == null)
            {
                return(false);
            }

            //Add or get activity type
            ActivityType actType = _context.ActivityType.FirstOrDefault(x => x.TypeName == activityInput.ActivityType.TypeName) ??
                                   _context.ActivityType.Add(new ActivityType()
            {
                TypeName = activityInput.ActivityType.TypeName
            });

            //Add activity
            Activity activityDb = new Activity()
            {
                ActivityTypeId = actType.Id,
                DateTime       = activityInput.DateTime
            };

            //Check if Item exist
            Item itemDb = _context.Item.Where(x => x.OriginalId == activityInput.Item.OriginalId).Include(x => x.Adjustable).FirstOrDefault();

            //If item is null, send to register
            if (itemDb == null)
            {
                RegisterItem(activityInput);
                itemDb = _context.Item.Where(x => x.OriginalId == activityInput.Item.OriginalId).Include(x => x.Adjustable).FirstOrDefault();
                if (itemDb != null)
                {
                    desc += " | Item registered.";
                }
            }

            if (itemDb == null)
            {
                return(false);
            }
            else
            {
                activityDb.ItemId = itemDb.Id;
            }

            //Add or update adjustables
            if (activityInput.Item.Adjustable != null && activityInput.Item.Adjustable.Count > 0)
            {
                //Adjustable types list
                List <AdjustableType> adjTypeList     = _context.AdjustableType.ToList();
                List <AdjustableType> tempAdjTypeList = new List <AdjustableType>();

                foreach (Adjustable adjustableInput in activityInput.Item.Adjustable)
                {
                    //Check if adjustables exist
                    Adjustable adjustableDb = itemDb.Adjustable.FirstOrDefault(
                        x => x.ItemId == itemDb.Id &&
                        x.IdentifierName == adjustableInput.IdentifierName);

                    //Update
                    if (adjustableDb != null)
                    {
                        adjustableDb.Value            = adjustableInput.Value;
                        adjustableDb.ModifiedDateTime = adjustableInput.ModifiedDateTime;

                        _context.Entry(adjustableDb).State = EntityState.Modified;

                        desc += " | Adjustable updated. (" + adjustableDb.Id + ")";
                    }
                    //Add
                    else
                    {
                        adjustableDb = new Adjustable()
                        {
                            ItemId           = itemDb.Id,
                            Name             = adjustableInput.Name,
                            Value            = adjustableInput.Value,
                            CreatedDateTime  = DateTime.Now,
                            ModifiedDateTime = DateTime.Now,
                            IdentifierName   = adjustableInput.IdentifierName
                        };

                        //Add or get adjustable type
                        AdjustableType adjType     = adjTypeList.FirstOrDefault(x => x.TypeName == adjustableInput.AdjustableType.TypeName);
                        AdjustableType tempAdjType = tempAdjTypeList.FirstOrDefault(x => x.TypeName == adjustableInput.AdjustableType.TypeName);

                        //DB has this type
                        if (adjType != null)
                        {
                            adjustableDb.TypeId = adjType.Id;
                        }
                        //Temp list has this type
                        else if (tempAdjType != null)
                        {
                            adjustableDb.AdjustableType = tempAdjType;
                        }
                        //Type doesn't exist. Add to db and to temp list
                        else //if (adjType == null && tempAdjType == null)
                        {
                            var type = new AdjustableType()
                            {
                                TypeName = adjustableInput.AdjustableType.TypeName
                            };
                            adjustableDb.AdjustableType = type;
                            tempAdjTypeList.Add(type);

                            desc += " | Adjustable type added.";
                        }

                        _context.Adjustable.Add(adjustableDb);
                        desc += " | Adjustable added. (" + adjustableDb.Id + ")";
                    }
                }
                //Add activity
                activityDb.Description = desc;
                activityDb             = _context.Activity.Add(activityDb);

                _context.SaveChanges();

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
 /// <summary>
 /// Constructs an <code>AdjustmentEvent</code> object with the
 /// specified Adjustable source, event type, adjustment type, and value.
 /// </summary>
 public AdjustmentEvent(Adjustable @source, int @id, int @type, int @value, bool @isAdjusting)
 {
 }
예제 #7
0
 /// <summary>
 /// Constructs an <code>AdjustmentEvent</code> object with the
 /// specified <code>Adjustable</code> source, event type,
 /// adjustment type, and value.
 /// </summary>
 public AdjustmentEvent(Adjustable @source, int @id, int @type, int @value)
 {
 }
예제 #8
0
 /// <summary>
 /// Constructs an <code>AdjustmentEvent</code> object with the
 /// specified <code>Adjustable</code> source, event type,
 /// adjustment type, and value.
 /// <para> This method throws an
 /// <code>IllegalArgumentException</code> if <code>source</code>
 /// is <code>null</code>.
 ///
 /// </para>
 /// </summary>
 /// <param name="source"> The <code>Adjustable</code> object where the
 ///               event originated </param>
 /// <param name="id">     An integer indicating the type of event.
 ///                     For information on allowable values, see
 ///                     the class description for <seealso cref="AdjustmentEvent"/> </param>
 /// <param name="type">   An integer indicating the adjustment type.
 ///                     For information on allowable values, see
 ///                     the class description for <seealso cref="AdjustmentEvent"/> </param>
 /// <param name="value">  The current value of the adjustment </param>
 /// <exception cref="IllegalArgumentException"> if <code>source</code> is null </exception>
 /// <seealso cref= #getSource() </seealso>
 /// <seealso cref= #getID() </seealso>
 /// <seealso cref= #getAdjustmentType() </seealso>
 /// <seealso cref= #getValue() </seealso>
 public AdjustmentEvent(Adjustable source, int id, int type, int value) : this(source, id, type, value, false)
 {
 }
		/// <summary>
		/// Constructs an <code>AdjustmentEvent</code> object with the
		/// specified Adjustable source, event type, adjustment type, and value.
		/// </summary>
		public AdjustmentEvent(Adjustable @source, int @id, int @type, int @value, bool @isAdjusting)
		{
		}
		/// <summary>
		/// Constructs an <code>AdjustmentEvent</code> object with the
		/// specified <code>Adjustable</code> source, event type,
		/// adjustment type, and value.
		/// </summary>
		public AdjustmentEvent(Adjustable @source, int @id, int @type, int @value)
		{
		}