Ejemplo n.º 1
0
		public LogImpl(DateTime date, EventType eventType, IFlow flow)
		{
			this._date = date;
			this._eventType = eventType;
			this._flow = flow;
			this._details = new ListSet();
		}
Ejemplo n.º 2
0
 public CRUDSubscriptionEvent(EventType type, Schema schema, Row row, DataTimeStamp version)
 {
     Type = type;
       Schema = schema;
       Row = row;
       Version = version;
 }
Ejemplo n.º 3
0
		public void Ctor_withValidArgs_works(EventType type)
		{
			// arrange:
			List<object> mocks = new List<object>();
			Username userId = new Username("Giacomo");
			IUser user = MockRepository.GenerateStrictMock<IUser>();
			user.Expect(u => u.Username).Return(userId).Repeat.Once();
			mocks.Add(user);
			TrackingId cargoId = new TrackingId("CARGO001");
			UnLocode location = new UnLocode("UNLOC");
			VoyageNumber voyage = new VoyageNumber("VYG001");
			ICargo cargo = MockRepository.GenerateStrictMock<ICargo>();
			cargo.Expect(c => c.TrackingId).Return(cargoId).Repeat.Once();
			IDelivery delivery = MockRepository.GenerateStrictMock<IDelivery>();
			delivery.Expect(d => d.LastKnownLocation).Return(location).Repeat.Once();
			delivery.Expect(d => d.CurrentVoyage).Return(voyage).Repeat.Once();
			mocks.Add(delivery);
			cargo.Expect(c => c.Delivery).Return(delivery).Repeat.Twice();
			mocks.Add(cargo);
			DateTime completionDate = DateTime.UtcNow;
			
			// act:
			IEvent underTest = new Event(user, cargo, type, completionDate);
		
			// assert:
			Assert.AreSame(userId, underTest.User);
			Assert.AreSame(cargoId, underTest.Cargo);
			Assert.AreSame(location, underTest.Location);
			Assert.AreSame(voyage, underTest.Voyage);
			Assert.AreEqual(completionDate, underTest.Date);
			Assert.AreEqual(type, underTest.Type);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
Ejemplo n.º 4
0
 public UpdateData(EventType eventType, string message, string imageName, ImageStatus imageStatus)
 {
     this.EventType = eventType;
     this.Message = message;
     this.ImageName = imageName;
     this.ImageStatus = imageStatus;
 }
        public void NotifyMe(EventType type, object data)
        {
            if (type == EventType.LanguageChanged)
            {
                var lDGridBindingExpr = lDataGridDescription.GetBindingExpression(Label.ContentProperty);
                if (lDGridBindingExpr != null) lDGridBindingExpr.UpdateTarget();

                var tBlockBindingExpr = DateTextBlock.GetBindingExpression(TextBlock.TextProperty);
                if (tBlockBindingExpr != null) tBlockBindingExpr.UpdateTarget();

                var tBlock1BindingExpr = textBlock1.GetBindingExpression(TextBlock.TextProperty);
                if (tBlock1BindingExpr != null) tBlock1BindingExpr.UpdateTarget();
            }
            else
                if (type == EventType.SelectedDateChanged)
                {
                    m_DtList = ((IData)data).DtList;

                    //foreach (var item in m_DtList)
                    //{
                    //    DateTime dt = new DateTime(item.Date.Year, item.Date.Month, item.Date.Day);
                    //    MainCalendar.SelectedDates.Add(dt);
                    //}

                    //menu1.Focus();
                    //bAddNote.Focus();
                }
        }
Ejemplo n.º 6
0
 public Event(EventType type, int ctxId, int auxId = 0)
 {
     Type = type;
     ContextID = ctxId;
     AuxiliaryID = auxId;
     TimeStamp = DateTime.Now;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Event" /> class.
        /// </summary>
        /// <param name="msg">The event message to record.</param>
        /// <param name="data">Additional optional data to record. May be null.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with. If it is not specific to a gallery
        ///   or the gallery ID is unknown, specify the ID for the template gallery.</param>
        /// <param name="eventType">Type of the event. Defaults to <see cref="Business.EventType.Info" /> when not specified.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception>
        internal Event(string msg, int galleryId, EventType eventType = EventType.Info, Dictionary<string, string> data = null)
        {
            if (galleryId == int.MinValue)
                throw new ArgumentOutOfRangeException("galleryId", string.Format("The galleryId parameter in the Event contructor must represent an existing gallery. Instead, it was {0}", galleryId));

            EventId = int.MinValue;
            EventType = eventType;
            _message = msg;
            _galleryId = galleryId;
            _timeStampUtc = DateTime.UtcNow;

            _exceptionType = String.Empty;
            _source = String.Empty;
            _targetSite = String.Empty;
            _stackTrace = String.Empty;

            _innerExType = String.Empty;
            _innerExMessage = String.Empty;
            _innerExSource = String.Empty;
            _innerExTargetSite = String.Empty;
            _innerExStackTrace = String.Empty;

            if (data != null)
            {
                foreach (var dataItem in data)
                {
                    _eventData.Add(dataItem);
                }
            }

            ExtractVersion();

            ExtractHttpContextInfo();
        }
Ejemplo n.º 8
0
 public OnNodeEvent(EventType type, Node node, Vector2 localMousePos, ConnectionPoint conPoint)
 {
     this.eventType = type;
     this.eventSourceNode = node;
     this.eventSourceConnectionPoint = conPoint;
     this.globalMousePosition = new Vector2(localMousePos.x + node.GetX(), localMousePos.y + node.GetY());
 }
Ejemplo n.º 9
0
		public string GetText(string template, string language, EventType type, ApplicationData application,
			byte[] bytes)
		{
			var data = GetTextLocalizedData(type, application, language, bytes);

			return _bulder.GetText(template, language, data);
		}
        internal AuditLog CreateLogRecord(object userName, EventType eventType, ITrackerContext context)
        {
            Type entityType = _dbEntry.Entity.GetType().GetEntityType();

            if (!EntityTrackingConfiguration.IsTrackingEnabled(entityType))
            {
                return null;
            }

            DateTime changeTime = DateTime.UtcNow;

            //todo: make this a static class
            var mapping = new DbMapping(context, entityType);

            List<PropertyConfiguerationKey> keyNames = mapping.PrimaryKeys().ToList();

            var newlog = new AuditLog
            {
                UserName = userName?.ToString(),
                EventDateUTC = changeTime,
                EventType = eventType,
                TypeFullName = entityType.FullName,
                RecordId = GetPrimaryKeyValuesOf(_dbEntry, keyNames).ToString()
            };

            var detailsAuditor = GetDetailsAuditor(eventType, newlog);

            newlog.LogDetails = detailsAuditor.CreateLogDetails().ToList();

            if (newlog.LogDetails.Any())
                return newlog;
            else
                return null;
        }
Ejemplo n.º 11
0
 void Accept(EventType type, int num)
 {
     EventType = type;
     EventNumber = num;
     this.DialogResult = DialogResult.OK;
     Close();
 }
Ejemplo n.º 12
0
			public ColEvent(EventType type, Fixture fxA, Fixture fxB, CollisionData data)
			{
				this.Type = type;
				this.FixtureA = fxA;
				this.FixtureB = fxB;
				this.Data = data;
			}
Ejemplo n.º 13
0
        public void ConnectListener(EventType eventType, Delegate listener)
        {
            if (disposed) { return; }
            var ex = events[eventType].CheckListener(listener);
            if (ex != null)
            {
                throw ex;
            }

            if (!ConnectedListeners.ContainsKey(eventType))
            {
                ConnectedListeners[eventType] = new ConcurrentDictionary<int, Delegate>();
            }
            else if (ConnectedListeners[eventType].Values.Contains(listener))
            {
                throw new ArgumentException("'listener' has already been connected to this event type.", "listener");
            }

            if (ConnectedListeners[eventType].Count == 0)
            {
                ConnectedListeners[eventType][0] = listener;
            }
            else
            {
                var index = ConnectedListeners[eventType].Keys.Max() + 1;
                ConnectedListeners[eventType][index] = listener;
            }
        }
Ejemplo n.º 14
0
 public SystemEventPacket(EventType eventType, string message, Connection client = null)
 {
     Client = client;
     packetType = PacketType.system;
     this.eventType = eventType;
     this.message = message;
 }
Ejemplo n.º 15
0
 public static void Send(int clientId, EventType eventType)
 {
     if (null != MonitoringNotificationSended)
     {
         MonitoringNotificationSended(null, new MonitorEventArgs(clientId, eventType, DateTime.Now));
     }
 }
Ejemplo n.º 16
0
 internal EventArg(string cacheName, EventType eventType, EventCacheItem item, EventCacheItem oldItem)
 {
     _cacheName = cacheName;
     _eventType = eventType;
     _item = item;
     _oldItem = oldItem;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// パラメータを指定して新しい SystemExclusiveEvent クラスのインスタンスを初期化します。
        /// </summary>
        /// <param name="deltaTime">デルタタイム。</param>
        /// <param name="tick">ティック位置。</param>
        /// <param name="type">イベントのタイプ。</param>
        /// <param name="br">読み込まれるバイトリーダ。</param>
        internal SystemExclusiveEvent(int deltaTime, long tick, EventType type, BinaryReader br)
            : base(deltaTime, tick)
        {
            this.Type = type;

            this.Load(br);
        }
 public InventoryActionInput(PointerEventData.InputButton button, EventType eventType, KeyCode keyCode, MobileUIActions mobileAction = MobileUIActions.None)
 {
     this.button = button;
     this.keyCode = keyCode;
     this.mobileAction = mobileAction;
     this.eventType = eventType;
 }
 public static void NotifyListeners(EventType eventType, params object[] args)
 {
     foreach (var listener in listeners)
     {
         listener.HandleEvent(eventType, args);
     }
 }
Ejemplo n.º 20
0
 public PlayVideo(EventType actionEv, int sourceObjectId, int targetObjectId)
 {
     ActionEventType = actionEv;
     Type = ActionType.playVideo;
     SourceObjectId = sourceObjectId;
     TargetObjectId = targetObjectId;
 }
Ejemplo n.º 21
0
        public void SendNetworkEvent(int ID, long when, EventType what, int posX, int posY)
        {
            networkBufferSize++;

            if (networkConnection == null)
            {
                // buffer events until connection is available
                queue.Enqueue(new NetworkEvent(networkBufferSize, when, ID, what, posX, posY));
            }
            else
            {
                // put buffered events to the queue for sending
                if (queue.Count > 0)
                {
                    while (queue.Count > 0)
                    {
                        NetworkEvent ne = queue.Dequeue();
                        networkConnection.AddEventToBuffer(ne.SimulationTime, ne.GameObjectID, ne.EventType, ne.PosX, ne.PosY);
                    }
                }

                // send
                networkConnection.AddEventToBuffer(when, ID, what, posX, posY);

                if (what == EventType.gameWon)
                {
                    gameChange = GameChange.Won;
                }
            }
        }
Ejemplo n.º 22
0
 public static void RegisterEventMessage(EventType evt, PfControllerDelegate callback)
 {
     PfControllerDelegate storedDelegate;
     eventCallbacks.TryGetValue(evt, out storedDelegate);
     storedDelegate += callback;
     eventCallbacks[evt] = storedDelegate;
 }
Ejemplo n.º 23
0
        public void Write(EventType eventType, Func<string> logMessage)
        {
            if (eventType >= _minLevel)
            {
                string message;
                try
                {
                    message = logMessage();
                    const int maxLogMessageLength = 10000;
                    if (message.Length > maxLogMessageLength)
                        message = message.Substring(0, maxLogMessageLength)
                            + " ... (trimmed to max " + GetType().Name + " message length of " + maxLogMessageLength + ")";

                    Write(eventType, _eventName, message);
                }
                catch (Exception ex)
                {
                    Write(EventType.Error, GetType().Name, string.Format(
                        "Error while getting the log message ({0}: {1}). {2}",
                        eventType, _eventName, ex.ToString()));
                }
            }

            if (_decoratedLogger != null)
                _decoratedLogger.Write(eventType, logMessage);
        }
Ejemplo n.º 24
0
		public void ReadProcessData(XmlElement xmlElement, CreationContext creationContext)
		{
			DefinitionObjectImpl definitionObject = creationContext.DefinitionObject;

			// first make sure the definitionObject has got an id
			DbSession dbSession = creationContext.DbSession;
			dbSession.SaveOrUpdate(definitionObject);

			// store the reference link to the definitionObject 
			this._definitionObjectId = definitionObject.Id;

			log.Debug("adding action : ");
			log.Debug("  definitionObjectId: " + _definitionObjectId);
			log.Debug("  definitionObject: " + definitionObject);

			this._eventType = EventTypeHelper.fromText(xmlElement.GetAttribute("event"));

			log.Debug("action on eventType '" + _eventType + "' and definitionObject " + creationContext.DefinitionObject);

			// reading the action delegation
			creationContext.DelegatingObject = this;
			this._actionDelegation = new DelegationImpl();
			this._actionDelegation.ReadProcessData(xmlElement, creationContext);
			creationContext.DelegatingObject = null;

			dbSession.SaveOrUpdate(this);
		}
Ejemplo n.º 25
0
        private ActionResult Add(string projectId, int? transitionId, EventLevel level, EventType eventType, AppUser creator, object item, DateTime? createdOn = null)
        {
            try
            {
                var i = new ProjectHistory
                {
                    CreatedBy = creator,
                    CreatedOn = createdOn ?? DateTime.UtcNow,
                    Description = JsonConvert.SerializeObject(item),
                    Level = level,
                    ProjectId = projectId,
                    TransitionId = transitionId,
                    Type = eventType
                };

                if (!_dbContext.ChangeTracker.Entries().Where(e => e.State != EntityState.Unchanged).Any())
                {
                    _dbContext.ProjectHistory.Add(i);
                    _dbContext.SaveChanges();
                }
                else
                {
                    _dbContext.ProjectHistory.Add(i);
                }

                return ActionResult.Success(item);
            }
            catch(Exception ex)
            {
                return ActionResult.Failed(ex);
            }
        }
Ejemplo n.º 26
0
 internal Event(Object obj, EventType type, int num)
 {
     Object = obj;
     EventType = type;
     EventNumber = num;
     Actions = new List<Action>();
 }
Ejemplo n.º 27
0
        public void PrepareMovement(Int64 goTime, double phase, IGamePlugin who, EventType ev, int speed)
        {
            IMovableElement gamePlugin = who as IMovableElement;

            if (gamePlugin != null)
            {
                // Change X, Y coordinates

                if (((MovableEssentials)gamePlugin).ImmediatelyOccupyNewField == false)
                {
                    gamePlugin.InitializeMove((MovementDirection)ev);
                }
                else
                {
                    gamePlugin.FinishMove((MovementDirection)ev);
                }
                
                gamePlugin.MovementStartTime = goTime;
                gamePlugin.MovementStartTimePhase = phase;
                gamePlugin.MovementEndTime = goTime + speed;
                gamePlugin.LastMovementEvent = ev;

                // Forced event!
                MakePlan("PrepMovWentXXX", gamePlugin.MovementEndTime, who, (EventType)((int)ev + 10), true); // goXXX -> wentXXX
            }
        }
Ejemplo n.º 28
0
    public static void QueueActivity(
      string userId, 
      EventType eventType, 
      string message)
    {
      try
      {
        var cloudStorageAccount = 
          CloudStorageAccount.Parse(
            CloudConfigurationManager.GetSetting("StorageConnectionString"));

        var queueReference = 
          cloudStorageAccount.CreateCloudQueueClient()
            .GetQueueReference("activity");

        queueReference.CreateIfNotExists();

        var activity = new Activity
        {
          UserId = userId,
          Event = eventType,
          Date = DateTime.Now,
          Message = message
        };

        var cloudQueueMessage = 
          new CloudQueueMessage(JsonConvert.SerializeObject(activity));

        queueReference.AddMessage(cloudQueueMessage);
      }
      catch (Exception exception)
      {
        Trace.TraceError(exception.Message);
      }
    }
 public void Notify(EventType e)
 {
     if (e == EventType.Death)
         _observers.ForEach(o => o.UpdateObserver(_mother.ID, e));
     else if (e == EventType.Birth)
         _observers.ForEach(o => o.UpdateObserver(_pregnancy.ID, e));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Publishes events.
 /// </summary>
 /// <param name="guiregion">The GUIRegion instance that triggered the event.</param>
 /// <param name="t">The type of event triggered.</param>
 public void Publish(GUIRegion guiregion, EventType t)
 {
     if (regionActivated != null)
     {
        regionActivated(this, new GUIRegionEvent(this, t));
     }
 }
Ejemplo n.º 31
0
            public static int DragReorder(Rect position, int elementHeight, List <MonoScript> elements, DrawElementDelegate drawElementDelegate)
            {
                int id = GUIUtility.GetControlID(s_DragReorderGUIHash, FocusType.Passive);

                Rect elementRect = position;

                elementRect.height = elementHeight;

                int  defPos = 0;
                Rect defRect;

                // If we're dragging, draw elements based on their animated reordering positions,
                // but only for repainting. Control event handling does't like to suddenly change order,
                // so things will screw up if we HANDLE the controls in a different order when dragging.
                if (GUIUtility.hotControl == id && Event.current.type == EventType.Repaint)
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        // Don't draw the dragged element as part of loop
                        if (i == s_ReorderingDraggedElement)
                        {
                            continue;
                        }
                        if (IsDefaultTimeElement(elements[i]))
                        {
                            defPos = i;
                            i++;
                            continue;
                        }
                        elementRect.y = position.y + s_ReorderingPositions[i] * elementHeight;
                        drawElementDelegate(elementRect, elements[i], false);
                    }
                    defRect = new Rect(elementRect.x, position.y + s_ReorderingPositions[defPos] * elementHeight, elementRect.width, (s_ReorderingPositions[defPos + 1] - s_ReorderingPositions[defPos] + 1) * elementHeight);
                }
                // For everything else than repainting while dragging,
                // draw controls based on their positions in the array.
                else
                {
                    for (int i = 0; i < elements.Count; i++)
                    {
                        elementRect.y = position.y + i * elementHeight;
                        if (IsDefaultTimeElement(elements[i]))
                        {
                            defPos = i;
                            i++;
                            continue;
                        }
                        drawElementDelegate(elementRect, elements[i], false);
                    }
                    defRect = new Rect(elementRect.x, position.y + defPos * elementHeight, elementRect.width, elementHeight * 2);
                }

                GUI.Label(defRect, Content.defaultTimeContent, Styles.defaultTime);

                bool isAddingToDefault = defRect.height > elementHeight * 2.5f;

                if (GUIUtility.hotControl == id)
                {
                    if (isAddingToDefault)
                    {
                        GUI.color = new Color(1, 1, 1, 0.5f);
                    }
                    // Draw the dragged element after all the other ones
                    elementRect.y = position.y + s_ReorderingPositions[s_ReorderingDraggedElement] * elementHeight;
                    drawElementDelegate(elementRect, elements[s_ReorderingDraggedElement], true);

                    GUI.color = Color.white;
                }

                int       changed = -1;
                EventType type    = Event.current.GetTypeForControl(id);

                switch (type)
                {
                case EventType.MouseDown:
                    if (position.Contains(Event.current.mousePosition))
                    {
                        GUIUtility.keyboardControl = 0;
                        EditorGUI.EndEditingActiveTextField();

                        s_ReorderingDraggedElement = Mathf.FloorToInt((Event.current.mousePosition.y - position.y) / elementHeight);
                        if (!IsDefaultTimeElement(elements[s_ReorderingDraggedElement]))
                        {
                            s_ReorderingPositions = new float[elements.Count];
                            s_ReorderingGoals     = new int[elements.Count];
                            for (int i = 0; i < elements.Count; i++)
                            {
                                s_ReorderingGoals[i]     = i;
                                s_ReorderingPositions[i] = i;
                            }
                            GUIUtility.hotControl = id;
                            Event.current.Use();
                        }
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl != id)
                    {
                        break;
                    }

                    // Set reordering position of dragged element based on mouse cursor
                    s_ReorderingPositions[s_ReorderingDraggedElement] = (Event.current.mousePosition.y - position.y) / elementHeight - 0.5f;
                    // Clamp to range of list
                    s_ReorderingPositions[s_ReorderingDraggedElement] = Mathf.Clamp(s_ReorderingPositions[s_ReorderingDraggedElement], 0, elements.Count - 1);
                    // Set draggedToPosition based on dragged position
                    int draggedToPosition = Mathf.RoundToInt(s_ReorderingPositions[s_ReorderingDraggedElement]);

                    // if dragged to a new position, re-assign goals
                    if (draggedToPosition != s_ReorderingGoals[s_ReorderingDraggedElement])
                    {
                        // Reset
                        for (int i = 0; i < elements.Count; i++)
                        {
                            s_ReorderingGoals[i] = i;
                        }
                        // Find direction that other elements must be moved in
                        int direction = (draggedToPosition > s_ReorderingDraggedElement ? -1 : 1);

                        // Move goals of elements to make room for the dragged one
                        for (int i = s_ReorderingDraggedElement; i != draggedToPosition; i -= direction)
                        {
                            s_ReorderingGoals[i - direction] = i;
                        }

                        // At last, move the goal of the dragged element
                        s_ReorderingGoals[s_ReorderingDraggedElement] = draggedToPosition;
                    }
                    Event.current.Use();
                    break;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl != id)
                    {
                        break;
                    }

                    if (s_ReorderingGoals[s_ReorderingDraggedElement] != s_ReorderingDraggedElement)
                    {
                        // Reorder array according to the reordering goals
                        List <MonoScript> reorderedArray = new List <MonoScript>(elements);
                        for (int i = 0; i < elements.Count; i++)
                        {
                            elements[s_ReorderingGoals[i]] = reorderedArray[i];
                        }

                        // Return which elements was just moved
                        changed = s_ReorderingGoals[s_ReorderingDraggedElement];
                    }

                    // Reset
                    s_ReorderingGoals          = null;
                    s_ReorderingPositions      = null;
                    s_ReorderingDraggedElement = -1;
                    GUIUtility.hotControl      = 0;
                    Event.current.Use();
                    break;

                case EventType.Repaint:
                    // Animate elements to move towards their goals
                    if (GUIUtility.hotControl == id)
                    {
                        for (int i = 0; i < elements.Count; i++)
                        {
                            if (i != s_ReorderingDraggedElement)
                            {
                                s_ReorderingPositions[i] = Mathf.MoveTowards(s_ReorderingPositions[i], s_ReorderingGoals[i], 0.075f);
                            }
                        }
                        GUIView.current.Repaint();
                    }
                    break;
                }

                return(changed);
            }
Ejemplo n.º 32
0
 public override string ToString()
 => $"{AggregateType.PrettyPrint()} v{AggregateSequenceNumber}/{EventType.PrettyPrint()}:{AggregateIdentity}";
Ejemplo n.º 33
0
 public EventData(bool bindToEntity, EventType eventType, int priority)
 {
     this.bindToEntity = bindToEntity;
     this.eventType    = eventType;
     this.priority     = priority;
 }
Ejemplo n.º 34
0
        public StmtForgeMethodResult Make(
            string @namespace,
            string classPostfix,
            StatementCompileTimeServices services)
        {
            var statementSpec = @base.StatementSpec;
            if (statementSpec.Raw.OptionalContextName != null) {
                throw new ExprValidationException(
                    "A create-context statement cannot itself be associated to a context, please declare a nested context instead");
            }

            IList<FilterSpecCompiled> filterSpecCompileds = new List<FilterSpecCompiled>();
            IList<ScheduleHandleCallbackProvider> scheduleHandleCallbackProviders =
                new List<ScheduleHandleCallbackProvider>();
            IList<FilterSpecParamExprNodeForge> filterBooleanExpressions = new List<FilterSpecParamExprNodeForge>();

            var context = statementSpec.Raw.CreateContextDesc;
            if (services.ContextCompileTimeResolver.GetContextInfo(context.ContextName) != null) {
                throw new ExprValidationException("Context by name '" + context.ContextName + "' already exists");
            }

            // compile filter specs, if any
            var validationEnv = new CreateContextValidationEnv(
                context.ContextName,
                @base.StatementRawInfo,
                services,
                filterSpecCompileds,
                scheduleHandleCallbackProviders,
                filterBooleanExpressions);
            ValidateContextDetail(context.ContextDetail, 0, validationEnv);

            // get controller factory forges
            var controllerFactoryForges = GetForges(
                context.ContextName,
                context.ContextDetail);

            // build context properties type information
            var contextProps = MakeContextProperies(
                controllerFactoryForges,
                @base.StatementRawInfo,
                services);

            // allocate type for context properties
            var contextEventTypeName =
                services.EventTypeNameGeneratorStatement.GetContextPropertyTypeName(context.ContextName);
            var metadata = new EventTypeMetadata(
                contextEventTypeName,
                @base.ModuleName,
                EventTypeTypeClass.CONTEXTPROPDERIVED,
                EventTypeApplicationType.MAP,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());
            var contextPropertiesType = BaseNestableEventUtil.MakeMapTypeCompileTime(
                metadata,
                contextProps,
                null,
                null,
                null,
                null,
                services.BeanEventTypeFactoryPrivate,
                services.EventTypeCompileTimeResolver);
            services.EventTypeCompileTimeRegistry.NewType(contextPropertiesType);

            // register context
            var visibilityContext =
                services.ModuleVisibilityRules.GetAccessModifierContext(@base, context.ContextName);
            var validationInfo =
                new ContextControllerPortableInfo[controllerFactoryForges.Length];
            for (var i = 0; i < validationInfo.Length; i++) {
                validationInfo[i] = controllerFactoryForges[i].ValidationInfo;
            }

            var detail = new ContextMetaData(
                context.ContextName,
                @base.ModuleName,
                visibilityContext,
                contextPropertiesType,
                validationInfo);
            services.ContextCompileTimeRegistry.NewContext(detail);

            // define output event type
            var statementEventTypeName =
                services.EventTypeNameGeneratorStatement.GetContextStatementTypeName(context.ContextName);
            var statementTypeMetadata = new EventTypeMetadata(
                statementEventTypeName,
                @base.ModuleName,
                EventTypeTypeClass.STATEMENTOUT,
                EventTypeApplicationType.MAP,
                NameAccessModifier.TRANSIENT,
                EventTypeBusModifier.NONBUS,
                false,
                EventTypeIdPair.Unassigned());
            EventType statementEventType = BaseNestableEventUtil.MakeMapTypeCompileTime(
                statementTypeMetadata,
                new EmptyDictionary<string, object>(),
                null,
                null,
                null,
                null,
                services.BeanEventTypeFactoryPrivate,
                services.EventTypeCompileTimeResolver);
            services.EventTypeCompileTimeRegistry.NewType(statementEventType);

            IList<StmtClassForgable> forgables = new List<StmtClassForgable>();

            var statementProviderClassName =
                CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementProvider), classPostfix);
            var statementAIFactoryProviderClassName =
                CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementAIFactoryProvider), classPostfix);
            var statementFieldsClassName =
                CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementFields), classPostfix);
            var packageScope = new CodegenNamespaceScope(
                @namespace,
                statementFieldsClassName,
                services.IsInstrumented);

            var forge =
                new StatementAgentInstanceFactoryCreateContextForge(context.ContextName, statementEventType);
            forgables.Add(
                new StmtClassForgableAIFactoryProviderCreateContext(
                    statementAIFactoryProviderClassName,
                    packageScope,
                    context.ContextName,
                    controllerFactoryForges,
                    contextPropertiesType,
                    forge));

            var selectSubscriberDescriptor = new SelectSubscriberDescriptor();
            var informationals = StatementInformationalsUtil.GetInformationals(
                @base,
                filterSpecCompileds,
                scheduleHandleCallbackProviders,
                new EmptyList<NamedWindowConsumerStreamSpec>(),
                false,
                selectSubscriberDescriptor,
                packageScope,
                services);
            forgables.Add(
                new StmtClassForgableStmtProvider(
                    statementAIFactoryProviderClassName,
                    statementProviderClassName,
                    informationals,
                    packageScope));
            forgables.Add(
                new StmtClassForgableStmtFields(
                    statementFieldsClassName,
                    packageScope,
                    0));

            return new StmtForgeMethodResult(
                forgables,
                filterSpecCompileds,
                scheduleHandleCallbackProviders,
                new EmptyList<NamedWindowConsumerStreamSpec>(),
                FilterSpecCompiled.MakeExprNodeList(filterSpecCompileds, filterBooleanExpressions));
        }
 public static T.Task AddJobsEventAsync(this CloudUtilities u, JobType jobType, int jobId, string message, EventType type = EventType.Information, CancellationToken token = default(CancellationToken), ILogger logger = null) =>
 u.AddJobsEventAsync(jobType, jobId, new Event()
 {
     Content = message, Source = EventSource.Job, Type = type
 }, token, logger);
 public static T.Task AddJobsEventAsync(this CloudUtilities u, Job job, string message, EventType type = EventType.Information, CancellationToken token = default(CancellationToken), ILogger logger = null) =>
 u.AddJobsEventAsync(job.Type, job.Id, message, type, token, logger);
Ejemplo n.º 37
0
        internal void OnGUI()
        {
            // Here due to static vars being thrown out when reloading assemblies
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }

            // Escape pressed?
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                CloseWindow();
            }

            Texture2D selectedIcon          = m_MultipleSelectedIcons ? null : EditorGUIUtility.GetIconForObject(m_TargetObject);
            bool      isSelectionALabelIcon = false;

            if (Event.current.type == EventType.Repaint)
            {
                selectedIcon = ConvertLargeIconToSmallIcon(selectedIcon, ref isSelectionALabelIcon);
            }

            Event     evt       = Event.current;
            EventType eventType = evt.type;

            GUI.BeginGroup(new Rect(0, 0, position.width, position.height), m_Styles.background);

            DoTopSection(selectedIcon != null || m_MultipleSelectedIcons);

            GUILayout.Space(22);
            GUILayout.BeginHorizontal();
            GUILayout.Space(1);
            GUI.enabled = false;
            GUILayout.Label("", m_Styles.seperator);
            GUI.enabled = true;
            GUILayout.Space(1);
            GUILayout.EndHorizontal();
            GUILayout.Space(3);

            if (m_ShowLabelIcons)
            {
                // Label icons
                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = 0; i < m_LabelIcons.Length / 2; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = m_LabelIcons.Length / 2; i < m_LabelIcons.Length; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.Space(1);
                GUI.enabled = false;
                GUILayout.Label("", m_Styles.seperator);
                GUI.enabled = true;
                GUILayout.Space(1);
                GUILayout.EndHorizontal();
                GUILayout.Space(3);
            }

            // Small icons
            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = 0; i < m_SmallIcons.Length / 2; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = m_SmallIcons.Length / 2; i < m_SmallIcons.Length; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();
            GUILayout.Space(6);

            // Object selector section
            GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
            bool clicked = false;
            int  id      = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(s_Other))
            {
                GUIUtility.keyboardControl = id;
                clicked = true;
            }
            GUI.backgroundColor = new Color(1, 1, 1, 1);
            GUI.EndGroup();

            if (clicked)
            {
                ObjectSelector.get.Show(m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = id;
                GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
                evt.Use();
                GUIUtility.ExitGUI();
            }

            // Check for icon selected from ObjectSelector
            switch (eventType)
            {
            case EventType.ExecuteCommand:
                string commandName = evt.commandName;
                if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    SetIconForSelectedObjects(icon);

                    GUI.changed = true;
                    evt.Use();
                }
                break;
            }
        }
 /// <summary>Ctor. </summary>
 /// <param name="streamNum">is the stream number of the indexed stream</param>
 /// <param name="eventType">is the event type of the indexed stream</param>
 /// <param name="propertyName">is the property names to be indexed</param>
 public PollResultIndexingStrategyIndexSingle(int streamNum, EventType eventType, String propertyName)
 {
     _streamNum    = streamNum;
     _eventType    = eventType;
     _propertyName = propertyName;
 }
 public MovementEventArgs(IReadOnlyCollection <IndexedObject> array, IReadOnlyCollection <IndexedObject> changes, EventType eventType, object?item, int index, RoutedEvent @event) : base(eventType, item, index, @event)
 {
     Objects = array;
     Changes = changes;
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Adds the required event handlers
        /// </summary>
        public void AddEventHandlers()
        {
            EventType eventMask = EventType.ProcessStart | EventType.ProcessEnd | EventType.Trace | EventType.ApplySettings | EventType.Keys;

            EventManager.AddEventHandler(this, eventMask);
        }
 public CollectionItemEventArgs(EventType eventType, object?item, int index, RoutedEvent @event) : base(eventType, @event)
 {
     Item  = item;
     Index = index;
 }
 public CollectionEventArgs(EventType eventType, RoutedEvent @event) : base(@event)
 {
     EventType = eventType;
 }
Ejemplo n.º 43
0
 public Task LogCipherEventAsync(Cipher cipher, EventType type, DateTime?date = null)
 {
     return(Task.FromResult(0));
 }
 public CollectionItemChangedEventArgs(IEnumerable array, IReadOnlyCollection <object> changes, EventType eventType, object?item, int index, RoutedEvent @event) : base(eventType, item, index, @event)
 {
     Objects = array;
     Changes = changes;
 }
Ejemplo n.º 45
0
 public Task LogOrganizationUserEventAsync(OrganizationUser organizationUser, EventType type,
                                           DateTime?date = null)
 {
     return(Task.FromResult(0));
 }
Ejemplo n.º 46
0
        internal void OnGUI()
        {
            if (IconSelector.m_Styles == null)
            {
                IconSelector.m_Styles = new IconSelector.Styles();
            }
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                this.CloseWindow();
            }
            Texture2D texture2D = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      flag      = false;

            if (Event.current.type == EventType.Repaint)
            {
                texture2D = this.ConvertLargeIconToSmallIcon(texture2D, ref flag);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), IconSelector.m_Styles.background);
            this.DoTopSection(texture2D != null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int i = 0; i < this.m_LabelIcons.Length / 2; i++)
                {
                    this.DoButton(this.m_LabelIcons[i], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int j = this.m_LabelIcons.Length / 2; j < this.m_LabelIcons.Length; j++)
                {
                    this.DoButton(this.m_LabelIcons[j], texture2D, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label(string.Empty, IconSelector.m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int k = 0; k < this.m_SmallIcons.Length / 2; k++)
            {
                this.DoButton(this.m_SmallIcons[k], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int l = this.m_SmallIcons.Length / 2; l < this.m_SmallIcons.Length; l++)
            {
                this.DoButton(this.m_SmallIcons[l], texture2D, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag2     = false;
            int  controlID = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0]))
            {
                GUIUtility.keyboardControl = controlID;
                flag2 = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag2)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = controlID;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            EventType eventType = type;

            if (eventType == EventType.ExecuteCommand)
            {
                string commandName = current.commandName;
                if (commandName == "ObjectSelectorUpdated" && ObjectSelector.get.objectSelectorID == controlID && GUIUtility.keyboardControl == controlID)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon);
                    GUI.changed = true;
                    current.Use();
                }
            }
        }
Ejemplo n.º 47
0
 public Task LogCollectionEventAsync(Collection collection, EventType type, DateTime?date = null)
 {
     return(Task.FromResult(0));
 }
Ejemplo n.º 48
0
 public Task LogUserEventAsync(Guid userId, EventType type, DateTime?date = null)
 {
     return(Task.FromResult(0));
 }
Ejemplo n.º 49
0
 /// <summary>Ctor. </summary>
 /// <param name="streamNum">is the stream number of the indexed stream</param>
 /// <param name="eventType">is the event type of the indexed stream</param>
 /// <param name="propertyNames">are the property names to get property values</param>
 /// <param name="coercionType">are the classes to coerce indexed values to</param>
 public PropertyIndexedEventTableCoerceAllFactory(int streamNum, EventType eventType, IList <string> propertyNames, IList <Type> coercionType)
     : base(streamNum, eventType, propertyNames, coercionType)
 {
 }
Ejemplo n.º 50
0
 public Task LogGroupEventAsync(Group group, EventType type, DateTime?date = null)
 {
     return(Task.FromResult(0));
 }
Ejemplo n.º 51
0
 public ViewableDefaultImpl(EventType eventType)
 {
     _eventType = eventType;
 }
Ejemplo n.º 52
0
        internal void Update()
        {
            this.lastSeenEvent = Event.current.type;

            this.SetCurrentDragAndDropMethod();

            if (this.lastSeenEvent == EventType.Repaint)
            {
                this.FinalizeDropObject();
            }

            if (Event.current.isMouse || Event.current.type == EventType.DragUpdated)
            {
                Rect screenSpaceRect;

                if (this.DragHandleRect.HasValue)
                {
                    screenSpaceRect = this.DragHandleRect.Value;
                }
                else
                {
                    screenSpaceRect = this.Rect;
                }

                Vector2 screenPos = GUIUtility.GUIToScreenPoint(new Vector2(screenSpaceRect.x, screenSpaceRect.y));
                screenSpaceRect.x = screenPos.x;
                screenSpaceRect.y = screenPos.y;

                this.IsHovering = screenSpaceRect.Contains(GUIUtility.GUIToScreenPoint(Event.current.mousePosition));
            }

            this.OnDragStarted = false;

            if (DragAndDropManager.IsDragInProgress == false)
            {
                if (Event.current.isMouse)
                {
                    if (this.IsHovering)
                    {
                        if (this.Enabled && Event.current.type == EventType.MouseDown == true && Event.current.button == 0)
                        {
                            this.isMouseDown            = true;
                            this.mouseDownPostionOffset = Event.current.mousePosition - new Vector2(this.Rect.x, this.Rect.y);
                            GUIHelper.RemoveFocusControl();
                            Event.current.Use();
                            DragAndDrop.PrepareStartDrag();
                        }

                        if (this.isMouseDown && Event.current.type == EventType.MouseDrag)
                        {
                            this.isDragging    = true;
                            this.OnDragStarted = true;
                            if (this.Object != null)
                            {
                                DragAndDrop.objectReferences = new UnityEngine.Object[0];
                                DragAndDrop.paths            = null;
                                DragAndDrop.SetGenericData(this.Object.GetType().Name, this.Object);
                                DragAndDrop.StartDrag("Odin Drag Operation");
                            }
                        }
                    }
                }
            }
            else
            {
                GUIHelper.RequestRepaint();
            }

            if (this.isDragging)
            {
                GUIHelper.RequestRepaint();

                DragAndDropManager.CurrentDraggingHandle = this;

                if (EditorWindow.mouseOverWindow != null)
                {
                    EditorWindow.mouseOverWindow.Focus();
                }

                if (DragAndDropManager.WasDragPerformed)
                {
                    this.IsReadyToBeClaimed = true;

                    if (DragAndDropManager.IsHoveringDropZone == false)
                    {
                        this.DropObject(DropEvents.Canceled);
                    }
                }
            }
            else
            {
                if (this.IsHovering)
                {
                    if (currentHoveringDragHandle == null || this.LayoutDepth >= currentHoveringDragHandle.LayoutDepth)
                    {
                        currentHoveringDragHandle = this;
                    }
                }
                else if (currentHoveringDragHandle == this)
                {
                    currentHoveringDragHandle = null;
                }

                this.IsHovering = currentHoveringDragHandle == this;
            }
        }
    /// <summary>
    /// Make it possible to easily drag the transform around.
    /// </summary>

    public void OnSceneGUI()
    {
        NGUIEditorTools.HideMoveTool(true);
        if (!UIWidget.showHandles)
        {
            return;
        }
        if (UnityEditor.Tools.current != Tool.Move)
        {
            return;
        }

        MonoBehaviour mb = target as MonoBehaviour;

        if (mb.GetComponent <UIWidget>() != null)
        {
            return;
        }
        if (mb.GetComponent <UIPanel>() != null)
        {
            return;
        }

        Transform t = mb.transform;

        UIWidget[] widgets = t.GetComponentsInChildren <UIWidget>();

        Event     e            = Event.current;
        int       id           = GUIUtility.GetControlID(mHash, FocusType.Passive);
        EventType type         = e.GetTypeForControl(id);
        bool      isWithinRect = false;

        Vector3[] corners = null;
        Vector3[] handles = null;

        if (widgets.Length > 0)
        {
            Matrix4x4 worldToLocal = t.worldToLocalMatrix;
            Matrix4x4 localToWorld = t.localToWorldMatrix;
            Bounds    bounds       = new Bounds();

            // Calculate the local bounds
            for (int i = 0; i < widgets.Length; ++i)
            {
                Vector3[] wcs = widgets[i].worldCorners;

                for (int b = 0; b < 4; ++b)
                {
                    wcs[b] = worldToLocal.MultiplyPoint3x4(wcs[b]);
                    if (i == 0 && b == 0)
                    {
                        bounds = new Bounds(wcs[b], Vector3.zero);
                    }
                    else
                    {
                        bounds.Encapsulate(wcs[b]);
                    }
                }
            }

            // Calculate the 4 local corners
            Vector3 v0 = bounds.min;
            Vector3 v1 = bounds.max;

            float z = Mathf.Min(v0.z, v1.z);
            corners    = new Vector3[4];
            corners[0] = new Vector3(v0.x, v0.y, z);
            corners[1] = new Vector3(v0.x, v1.y, z);
            corners[2] = new Vector3(v1.x, v1.y, z);
            corners[3] = new Vector3(v1.x, v0.y, z);

            // Transform the 4 corners into world space
            for (int i = 0; i < 4; ++i)
            {
                corners[i] = localToWorld.MultiplyPoint3x4(corners[i]);
            }

            handles = new Vector3[8];

            handles[0] = corners[0];
            handles[1] = corners[1];
            handles[2] = corners[2];
            handles[3] = corners[3];

            handles[4] = (corners[0] + corners[1]) * 0.5f;
            handles[5] = (corners[1] + corners[2]) * 0.5f;
            handles[6] = (corners[2] + corners[3]) * 0.5f;
            handles[7] = (corners[0] + corners[3]) * 0.5f;

            Color handlesColor = UIWidgetInspector.handlesColor;
            NGUIHandles.DrawShadowedLine(handles, handles[0], handles[1], handlesColor);
            NGUIHandles.DrawShadowedLine(handles, handles[1], handles[2], handlesColor);
            NGUIHandles.DrawShadowedLine(handles, handles[2], handles[3], handlesColor);
            NGUIHandles.DrawShadowedLine(handles, handles[0], handles[3], handlesColor);

            isWithinRect = mIsDragging || (e.modifiers == 0 &&
                                           NGUIEditorTools.SceneViewDistanceToRectangle(corners, e.mousePosition) == 0f);
#if !UNITY_3_5
            // Change the mouse cursor to a more appropriate one
            Vector2[] screenPos = new Vector2[8];
            for (int i = 0; i < 8; ++i)
            {
                screenPos[i] = HandleUtility.WorldToGUIPoint(handles[i]);
            }

            bounds = new Bounds(screenPos[0], Vector3.zero);
            for (int i = 1; i < 8; ++i)
            {
                bounds.Encapsulate(screenPos[i]);
            }

            // Change the cursor to a move arrow when it's within the screen rectangle
            Vector2 min  = bounds.min;
            Vector2 max  = bounds.max;
            Rect    rect = new Rect(min.x, min.y, max.x - min.x, max.y - min.y);
            UIWidgetInspector.SetCursorRect(rect, isWithinRect ? MouseCursor.MoveArrow : MouseCursor.Arrow);
#endif
        }

        switch (type)
        {
        case EventType.Repaint:
        {
            if (handles != null)
            {
                Vector3 v0 = HandleUtility.WorldToGUIPoint(handles[0]);
                Vector3 v2 = HandleUtility.WorldToGUIPoint(handles[2]);

                if ((v2 - v0).magnitude > 60f)
                {
                    Vector3 v1 = HandleUtility.WorldToGUIPoint(handles[1]);
                    Vector3 v3 = HandleUtility.WorldToGUIPoint(handles[3]);

                    Handles.BeginGUI();
                    {
                        for (int i = 0; i < 4; ++i)
                        {
                            UIWidgetInspector.DrawKnob(handles[i], false, false, id);
                        }

                        if (Mathf.Abs(v1.y - v0.y) > 80f)
                        {
                            UIWidgetInspector.DrawKnob(handles[4], false, false, id);
                            UIWidgetInspector.DrawKnob(handles[6], false, false, id);
                        }

                        if (Mathf.Abs(v3.x - v0.x) > 80f)
                        {
                            UIWidgetInspector.DrawKnob(handles[5], false, false, id);
                            UIWidgetInspector.DrawKnob(handles[7], false, false, id);
                        }
                    }
                    Handles.EndGUI();
                }
            }
        }
        break;

        case EventType.MouseDown:
        {
            mAllowSelection = true;
            mStartMouse     = e.mousePosition;

            if (e.button == 1)
            {
                GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                e.Use();
            }
            else if (e.button == 0 && isWithinRect && corners != null && UIWidgetInspector.Raycast(corners, out mStartDrag))
            {
                mCanDrag              = true;
                mStartPos             = t.position;
                GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                e.Use();
            }
        }
        break;

        case EventType.MouseDrag:
        {
            // Prevent selection once the drag operation begins
            bool dragStarted = (e.mousePosition - mStartMouse).magnitude > 3f;
            if (dragStarted)
            {
                mAllowSelection = false;
            }

            if (GUIUtility.hotControl == id)
            {
                e.Use();

                if (mCanDrag)
                {
                    Vector3 pos;

                    if (corners != null & UIWidgetInspector.Raycast(corners, out pos))
                    {
                        // Wait until the mouse moves by more than a few pixels
                        if (!mIsDragging && dragStarted)
                        {
                            NGUIEditorTools.RegisterUndo("Move " + t.name, t);
                            mStartPos   = t.position;
                            mIsDragging = true;
                        }

                        if (mIsDragging)
                        {
                            t.position      = mStartPos + (pos - mStartDrag);
                            pos             = t.localPosition;
                            pos.x           = Mathf.Round(pos.x);
                            pos.y           = Mathf.Round(pos.y);
                            pos.z           = Mathf.Round(pos.z);
                            t.localPosition = pos;
                        }
                    }
                }
            }
        }
        break;

        case EventType.MouseUp:
        {
            if (GUIUtility.hotControl == id)
            {
                GUIUtility.hotControl      = 0;
                GUIUtility.keyboardControl = 0;

                if (e.button == 0)
                {
                    if (mIsDragging)
                    {
                        mIsDragging = false;
                        Vector3 pos = t.localPosition;
                        pos.x           = Mathf.Round(pos.x);
                        pos.y           = Mathf.Round(pos.y);
                        pos.z           = Mathf.Round(pos.z);
                        t.localPosition = pos;
                    }
                    else if (mAllowSelection)
                    {
                        // Left-click: Select the topmost widget
                        NGUIEditorTools.SelectWidget(e.mousePosition);
                        e.Use();
                    }
                    e.Use();
                }
                else
                {
                    // Right-click: Open a context menu listing all widgets underneath
                    NGUIEditorTools.ShowSpriteSelectionMenu(e.mousePosition);
                    e.Use();
                }
                mCanDrag = false;
            }
        }
        break;

        case EventType.KeyDown:
        {
            if (e.keyCode == KeyCode.UpArrow)
            {
                Vector3 pos = t.localPosition;
                pos.y          += 1f;
                t.localPosition = pos;
                e.Use();
            }
            else if (e.keyCode == KeyCode.DownArrow)
            {
                Vector3 pos = t.localPosition;
                pos.y          -= 1f;
                t.localPosition = pos;
                e.Use();
            }
            else if (e.keyCode == KeyCode.LeftArrow)
            {
                Vector3 pos = t.localPosition;
                pos.x          -= 1f;
                t.localPosition = pos;
                e.Use();
            }
            else if (e.keyCode == KeyCode.RightArrow)
            {
                Vector3 pos = t.localPosition;
                pos.x          += 1f;
                t.localPosition = pos;
                e.Use();
            }
            else if (e.keyCode == KeyCode.Escape)
            {
                if (GUIUtility.hotControl == id)
                {
                    if (mIsDragging)
                    {
                        mIsDragging = false;
                        t.position  = mStartPos;
                    }

                    GUIUtility.hotControl      = 0;
                    GUIUtility.keyboardControl = 0;
                    e.Use();
                }
                else
                {
                    Selection.activeGameObject = null;
                }
            }
        }
        break;
        }
    }
 public static void SetEventType(this ComponentData data, EventType eventType)
 {
     data[COMPONENT_EVENT_TYPE] = eventType;
 }
Ejemplo n.º 55
0
        private async Task <EventMessage> BuildCipherEventMessageAsync(Cipher cipher, EventType type, DateTime?date = null)
        {
            // Only logging organization cipher events for now.
            if (!cipher.OrganizationId.HasValue || (!_currentContext?.UserId.HasValue ?? true))
            {
                return(null);
            }

            if (cipher.OrganizationId.HasValue)
            {
                var orgAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();

                if (!CanUseEvents(orgAbilities, cipher.OrganizationId.Value))
                {
                    return(null);
                }
            }

            return(new EventMessage(_currentContext)
            {
                OrganizationId = cipher.OrganizationId,
                UserId = cipher.OrganizationId.HasValue ? null : cipher.UserId,
                CipherId = cipher.Id,
                Type = type,
                ActingUserId = _currentContext?.UserId,
                ProviderId = await GetProviderIdAsync(cipher.OrganizationId),
                Date = date.GetValueOrDefault(DateTime.UtcNow)
            });
        }
        private static void DropTargetOnDragOver(object sender, DragEventArgs e, EventType eventType)
        {
            var elementPosition = e.GetPosition((IInputElement)sender);

            var dragInfo     = m_DragInfo;
            var dropInfo     = new DropInfo(sender, e, dragInfo, eventType);
            var dropHandler  = TryGetDropHandler(dropInfo, sender as UIElement);
            var itemsControl = dropInfo.VisualTarget;

            dropHandler.DragOver(dropInfo);

            if (DragAdorner == null && dragInfo != null)
            {
                CreateDragAdorner(dropInfo);
            }

            DragAdorner?.Move(e.GetPosition(DragAdorner.AdornedElement), dragInfo != null ? GetDragMouseAnchorPoint(dragInfo.VisualSource) : default(Point), ref _adornerMousePosition, ref _adornerSize);

            Scroll(dropInfo, e);

            if (HitTestUtilities.HitTest4Type <ScrollBar>(sender, elementPosition) ||
                HitTestUtilities.HitTest4GridViewColumnHeader(sender, elementPosition) ||
                HitTestUtilities.HitTest4DataGridTypesOnDragOver(sender, elementPosition))
            {
                e.Effects = DragDropEffects.None;
                e.Handled = true;
                return;
            }

            // If the target is an ItemsControl then update the drop target adorner.
            if (itemsControl != null)
            {
                // Display the adorner in the control's ItemsPresenter. If there is no
                // ItemsPresenter provided by the style, try getting hold of a
                // ScrollContentPresenter and using that.
                UIElement adornedElement = null;
                if (itemsControl is TabControl)
                {
                    adornedElement = itemsControl.GetVisualDescendent <TabPanel>();
                }
                else if (itemsControl is DataGrid || (itemsControl as ListView)?.View is GridView)
                {
                    adornedElement = itemsControl.GetVisualDescendent <ScrollContentPresenter>() as UIElement ?? itemsControl.GetVisualDescendent <ItemsPresenter>() as UIElement ?? itemsControl;
                }
                else
                {
                    adornedElement = itemsControl.GetVisualDescendent <ItemsPresenter>() as UIElement ?? itemsControl.GetVisualDescendent <ScrollContentPresenter>() as UIElement ?? itemsControl;
                }

                if (adornedElement != null)
                {
                    if (dropInfo.DropTargetAdorner == null)
                    {
                        DropTargetAdorner = null;
                    }
                    else if (!dropInfo.DropTargetAdorner.IsInstanceOfType(DropTargetAdorner))
                    {
                        DropTargetAdorner = DropTargetAdorner.Create(dropInfo.DropTargetAdorner, adornedElement, dropInfo);
                    }

                    var adorner = DropTargetAdorner;
                    if (adorner != null)
                    {
                        var adornerBrush = GetDropTargetAdornerBrush(dropInfo.VisualTarget);
                        if (adornerBrush != null)
                        {
                            adorner.Pen.Brush = adornerBrush;
                        }
                        adorner.DropInfo = dropInfo;
                        adorner.InvalidateVisual();
                    }
                }
            }

            // Set the drag effect adorner if there is one
            if (dragInfo != null && (EffectAdorner == null || EffectAdorner.Effects != dropInfo.Effects))
            {
                CreateEffectAdorner(dropInfo);
            }

            EffectAdorner?.Move(e.GetPosition(EffectAdorner.AdornedElement), default(Point), ref _effectAdornerMousePosition, ref _effectAdornerSize);

            e.Effects = dropInfo.Effects;
            e.Handled = !dropInfo.NotHandled;

            if (!dropInfo.IsSameDragDropContextAsSource)
            {
                e.Effects = DragDropEffects.None;
            }
        }
Ejemplo n.º 57
0
 public static void RemoveListener<T, X, Y>(EventType eventType, CallBack<T, X, Y> callBack)
 {
     OnListenerRemoving(eventType, callBack);
     m_EventTable[eventType] = (CallBack<T, X, Y>)m_EventTable[eventType] - callBack;
     OnListenerRemoved(eventType);
 }
Ejemplo n.º 58
0
 public async Task LogOrganizationUserEventAsync(OrganizationUser organizationUser, EventType type,
                                                 DateTime?date = null) =>
 await LogOrganizationUserEventsAsync(new[] { (organizationUser, type, date) });
Ejemplo n.º 59
0
 public static void AddListener<T, X,Y>(EventType eventType, CallBack<T, X,Y> callBack)
 {
     OnListenerAdding(eventType, callBack);
     m_EventTable[eventType] = (CallBack<T, X,Y>)m_EventTable[eventType] + callBack;
 }
Ejemplo n.º 60
0
        public static void DoViewTool(SceneView view)
        {
            Init();

            s_CurrentSceneView = view;

            // If a SceneView is currently taking input, don't let other views accept input
            if (s_ActiveSceneView != null && s_CurrentSceneView != s_ActiveSceneView)
            {
                return;
            }

            Event evt = Event.current;

            // Ensure we always call the GetControlID the same number of times
            int id = s_ViewToolID;

            UpdateViewToolState(evt);
            UpdateViewToolMode(evt);

            EventType eventType = evt.GetTypeForControl(id);

            // In FPS mode we update the pivot for Orbit mode (see below and inside HandleMouseDrag)
            if (view && Tools.s_LockedViewTool == ViewTool.FPS)
            {
                view.FixNegativeSize();
            }

            using (var inputSamplingScope = new CameraFlyModeContext.InputSamplingScope(s_CameraFlyModeContext, Tools.s_LockedViewTool, id, view, view.orthographic))
            {
                if (inputSamplingScope.currentlyMoving)
                {
                    view.viewIsLockedToObject = false;
                }

                s_Motion = inputSamplingScope.currentInputVector;
            }

            switch (eventType)
            {
            case EventType.ScrollWheel:     HandleScrollWheel(view, view.in2DMode == evt.alt); break;     // Default to zooming to mouse position in 2D mode without alt

            case EventType.MouseDown:       HandleMouseDown(view, id, evt.button); break;

            case EventType.MouseUp:         HandleMouseUp(view, id, evt.button, evt.clickCount); break;

            case EventType.MouseDrag:       HandleMouseDrag(view, id); break;

            case EventType.KeyDown:         HandleKeyDown(view); break;

            case EventType.Layout:
            {
                if (GUIUtility.hotControl == id || s_FlySpeed.isAnimating || s_Moving)
                {
                    view.pivot = view.pivot + view.rotation * GetMovementDirection();
                    view.Repaint();
                }
            }
            break;

            case EventType.Used:
                // since FPS tool acts on right click, nothing prevents a regular control
                // from taking the control ID on left click, so some cleanup is necessary
                // to not get locked into FPS mode (case 777346)
                if (GUIUtility.hotControl != id && s_CurrentState != MotionState.kInactive)
                {
                    ResetDragState();
                }
                break;
            }
        }