Example #1
0
        public async Task VerifyInitialized()
        {
            using var a = new AObject(TimeSpan.FromMilliseconds(500));

            Assert.IsFalse(a.IsInitialized);

            var init = await a.InitializeAsync(default);
Example #2
0
        Type GetHubForObject(AObject aObject)
        {
            if (aObject is Server)
            {
                return(typeof(ServerHub));
            }
            else if (aObject is Channel)
            {
                return(typeof(ChannelHub));
            }
            else if (aObject is Packet)
            {
                return(typeof(PacketHub));
            }
            else if (aObject is File)
            {
                return(typeof(FileHub));
            }
            else if (aObject is XG.Model.Domain.Search)
            {
                return(typeof(SearchHub));
            }
            else if (aObject is Notification)
            {
                return(typeof(NotificationHub));
            }
            else if (aObject is ApiKey)
            {
                return(typeof(ApiHub));
            }

            return(null);
        }
Example #3
0
 public void NotifyObjectFocusChanged(AObject lObject, bool newFocus)
 {
     if (this.ObjectFocusChanged != null)
     {
         this.ObjectFocusChanged(lObject, newFocus);
     }
 }
Example #4
0
        protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details)
        {
            if (details.Equals("endDialogue"))
            {
                DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject;

                if (dialogue == lObject)
                {
                    AObject patient = world.GetObjectFromId("patient main");
                    if (this.isSuccess)
                    {
                        patient.SetAnimationIndex(8);
                    }
                    else
                    {
                        patient.SetAnimationIndex(7);
                    }

                    this.timeElapsed = Time.Zero;
                    this.periodPhase = Time.FromSeconds(2);
                    this.moment      = ExposePhaseMoment.END_DIALOGUE;
                }
            }
            else if (details.Equals("speedUpDialogue"))
            {
                DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject;

                dialogue.SpeedFactor = 10;
            }
        }
Example #5
0
 public void NotifyObjectTextChanged(AObject lObject, string newText)
 {
     if (this.ObjectTextChanged != null)
     {
         this.ObjectTextChanged(lObject, newText);
     }
 }
Example #6
0
 public void OnSpeedUpDialogue(AObject lObject)
 {
     if (lObject is BubbleObject)
     {
         this.NotifyInternalGameEvent(lObject, null, "speedUpDialogue");
     }
 }
Example #7
0
 public void NotifyObjectTextStateChanged(AObject lObject, bool state)
 {
     if (this.ObjectTextStateChanged != null)
     {
         this.ObjectTextStateChanged(lObject, state);
     }
 }
Example #8
0
        HashSet <Client> GetClientsForObject(AObject aObject)
        {
            if (aObject is Server)
            {
                return(ServerHub.ConnectedClients);
            }
            else if (aObject is Channel)
            {
                return(ChannelHub.ConnectedClients);
            }
            else if (aObject is Packet)
            {
                return(PacketHub.ConnectedClients);
            }
            else if (aObject is File)
            {
                return(FileHub.ConnectedClients);
            }
            else if (aObject is XG.Model.Domain.Search)
            {
                return(SearchHub.ConnectedClients);
            }
            else if (aObject is Notification)
            {
                return(NotificationHub.ConnectedClients);
            }
            else if (aObject is ApiKey)
            {
                return(ApiHub.ConnectedClients);
            }

            return(new HashSet <Client>());
        }
Example #9
0
 public void NotifyTextPositionChanged(AObject lObject, AObject previousObject, Vector2f newPosition)
 {
     if (this.TextPositionChanged != null)
     {
         this.TextPositionChanged(lObject, previousObject, newPosition);
     }
 }
Example #10
0
 public void NotifyTextUpdated(AObject lObject, AObject previousObject, AObject associatedObject, Vector2f newPosition)
 {
     if (this.TextUpdated != null)
     {
         this.TextUpdated(lObject, previousObject, associatedObject, newPosition);
     }
 }
Example #11
0
 public void NotifyObjectAnimationChanged(AObject lObject, int animationIndex)
 {
     if (this.ObjectAnimationChanged != null)
     {
         this.ObjectAnimationChanged(lObject, animationIndex);
     }
 }
Example #12
0
 public void NotifyObjectPositionChanged(AObject lObject, Vector2f newPosition)
 {
     if (this.ObjectPositionChanged != null)
     {
         this.ObjectPositionChanged(lObject, newPosition);
     }
 }
Example #13
0
 public void NotifyObjectDestroyed(ALayer layer, AObject lObject)
 {
     if (this.ObjectDestroyed != null)
     {
         this.ObjectDestroyed(layer, lObject);
     }
 }
Example #14
0
 public void OnMouseDragOnObject(AObject lObject, Vector2f mousePosition, Vector2f objectOffset)
 {
     if (lObject is AnswerToken)
     {
         lObject.SetKinematicParameters(mousePosition - objectOffset, new Vector2f(0, 0));
     }
 }
Example #15
0
        public void OnMouseUpOnObject(AObject lAnswer, AObject lField)
        {
            if (lAnswer is AnswerToken)
            {
                AnswerToken answerToken = lAnswer as AnswerToken;

                // test field token
                if (lField != null)
                {
                    FieldToken fieldToken = lField as FieldToken;

                    fieldToken.AssociatedToken = answerToken;

                    fieldToken.ChangeDisplayText(answerToken.Text);

                    this.NotifyGameStateChanged(this.CurrentLevel.LevelName, new GameEvent(EventType.INSERT_WORD, string.Empty));
                }
                else
                {
                    this.NotifyGameStateChanged(this.CurrentLevel.LevelName, new GameEvent(EventType.DROP_WORD, string.Empty));
                }

                answerToken.IsFocused = false;
                answerToken.SetKinematicParameters(answerToken.InitialPosition, new Vector2f(0, 0));
            }
            else if (lField is TimerObject)
            {
                this.NotifyInternalGameEvent(lAnswer, null, "timerPassed");
            }
        }
Example #16
0
        private void OnTextUpdated(AObject arg1, AObject arg2, AObject arg3, Vector2f arg4)
        {
            AObject2D object2D = this.mappingObjectToObject2D[arg1];

            if (arg2 == null)
            {
                object2D.SetPosition(arg4);
            }
            else
            {
                AObject2D previousObject2D  = this.mappingObjectToObject2D[arg2];
                AObject2D associtedObject2D = null;
                if (arg3 != null)
                {
                    associtedObject2D = this.mappingObjectToObject2D[arg3];
                }

                FloatRect boundsPrevious = previousObject2D.TextGlobalBounds;

                float width = previousObject2D.TextGlobalBounds.Width;
                if (associtedObject2D != null)
                {
                    width = associtedObject2D.TextGlobalBounds.Width;
                }

                float newPositionX = width + previousObject2D.Position.X;
                float newPositionY = arg4.Y;

                Vector2f newPosition = new Vector2f(newPositionX, newPositionY);

                object2D.SetPosition(newPosition);
            }
        }
Example #17
0
 public void NotifyInternalGameEvent(AObject lObject, AObject lObjectTo, string details)
 {
     if (this.InternalGameEvent != null)
     {
         this.InternalGameEvent(this, lObject, lObjectTo, details);
     }
 }
Example #18
0
        void SendRemoved(AObject aObject)
        {
            var hub = GetHubForObject(aObject);

            if (hub == null)
            {
                return;
            }

            var hubObject = Hub.Helper.XgObjectToHubObject(aObject);

            if (hubObject == null)
            {
                return;
            }

            var clients = GetClientsForObject(aObject);

            foreach (var client in clients)
            {
                lock (client.LoadedObjects)
                {
                    if (!client.LoadedObjects.Contains(hubObject.Guid))
                    {
                        continue;
                    }

                    Log.Debug("SendRemoved()" + aObject);
                    GlobalHost.ConnectionManager.GetHubContext(hub.Name).Clients.Client(client.ConnectionId).OnRemoved(hubObject);
                    client.LoadedObjects.Remove(hubObject.Guid);
                }
            }
        }
 public override void MouseDown(object sender, MouseEventArgs e, Panel panel1, LinkedList <AObject> listObject)
 {
     initial = e.Location;
     if (ObjectGroup.Any())
     {
     }
     else
     {
         //System.Diagnostics.Debug.WriteLine("Inini");
         if (objectSelected == null)
         {
             //System.Diagnostics.Debug.WriteLine("Gak ada");
             foreach (AObject Object in listObject)
             {
                 if (Object.Select(e.Location) == true)
                 {
                     System.Diagnostics.Debug.WriteLine("Masuk");
                     shouldPaint    = true;
                     objectSelected = Object;
                     Object.DrawEdit();
                     Object.DrawHandle();
                     break;
                 }
             }
         }
         else
         {
             posisiClick = objectSelected.GetClickHandle(e.Location);
             //System.Diagnostics.Debug.WriteLine(posisiClick);
         }
     }
     panel1.Invalidate();
 }
Example #20
0
        public MainWindow()
        {
            this.officeWorld     = new OfficeWorld();
            this.object2DManager = new Object2DManager(this.officeWorld);

            this.objectFocused = null;
        }
Example #21
0
        public static object GetCellObjectProperty(Form AForm, DataGrid Grid, string PropertyName)
        {
            // DataGridCell myDataGridCell = Grid.CurrentCell;
            BindingManagerBase bm = AForm.BindingContext[Grid.DataSource, Grid.DataMember];
            object             AObject;
            object             Result = null;

            try
            {
                AObject = bm.Current;
                System.Type    myTypeA        = AObject.GetType();
                PropertyInfo[] myPropertyInfo = myTypeA.GetProperties();
                foreach (PropertyInfo PropI in myPropertyInfo)
                {
                    if (PropI.Name == PropertyName)
                    {
                        Result = PropI.GetValue(AObject, null);
                        break;
                    }
                }
            }
            catch
            {
                Result = CommonConsts.Messages.Exception.InvalidObject;
            }

            return(Result);
        }
        public override bool MouseClick(object sender, MouseEventArgs e, LinkedList <AObject> listObject)
        {
            initial = e.Location;
            if (controlClick == true || ObjectGroup.Any())
            {
                AObject objectdipilih = getObject(listObject, e);
                if (objectdipilih == null)
                {
                    System.Diagnostics.Debug.WriteLine("Salah");
                    foreach (AObject Object in ObjectGroup)
                    {
                        Object.Deselect();
                        Object.Draw();
                    }
                    ObjectGroup  = new LinkedList <AObject>();
                    controlClick = false;
                }
                else if (objectdipilih != null && checkchild(objectdipilih))
                {
                    //System.Diagnostics.Debug.WriteLine("Benar");
                    objectdipilih.Select();
                    objectdipilih.Draw();
                    ObjectGroup.AddLast(objectdipilih);
                    if (objectSelected != null && checkchild(objectSelected))
                    {
                        ObjectGroup.AddLast(objectSelected);
                        objectSelected.Select();
                        objectSelected.Draw();
                        objectSelected = null;
                    }
                    controlClick = false;
                    //banyakObject();
                }
                return(true);
            }
            else
            {
                objectSelected = null;
                objectSelected = getObject(listObject, e);
                if (objectSelected != null)
                {
                    System.Diagnostics.Debug.WriteLine("Masuk");
                    objectSelected.DrawEdit();
                    objectSelected.DrawHandle();
                    return(true);
                }
            }

            /*if (ObjectGroup!=null)
             * {
             *  System.Diagnostics.Debug.WriteLine("salah");
             *  foreach (AObject Object in ObjectGroup)
             *  {
             *      Object.Deselect();
             *      Object.Draw();
             *  }
             *  ObjectGroup = new LinkedList<AObject>();
             * }*/
            return(false);
        }
Example #23
0
 public Notification(Notification.Types aType, AObject aObject1, AObject aObject2 = null)
 {
     _type = aType;
     _object1 = aObject1;
     _object2 = aObject2;
     _time = DateTime.Now;
 }
Example #24
0
		protected bool Add(AObject aObject)
		{
			bool result = false;
			if (aObject != null)
			{
				lock (_children)
				{
					if (!DuplicateChildExists(aObject))
					{
						Activate(ActivationPurpose.Write);
						_children.Add(aObject);
						result = true;
					}
				}

				if (result)
				{
					aObject.Parent = this;

					aObject.OnEnabledChanged += FireEnabledChanged;
					aObject.OnChanged += FireChanged;

					var aObjects = aObject as AObjects;
					if (aObjects != null)
					{
						aObjects.OnAdded += FireAdded;
						aObjects.OnRemoved += FireRemoved;
					}
					FireAdded(this, new EventArgs<AObject, AObject>(this, aObject));
				}
			}
			return result;
		}
Example #25
0
        public void LinkConsistencyTest()
        {
            var openables = GameMap.Objects.Where(x => x.IsOpenable);

            foreach (AObject obj in openables)
            {
                AObject side = null, side2 = null;
                try
                {
                    side = obj.LinkedSide();
                    if (side == null || obj.SkipConsistencyTest || side.SkipConsistencyTest)
                    {
                        continue;
                    }
                    side2 = side.LinkedSide();
                    if (side2 == null)
                    {
                        Assert.Fail($"Inconsistent door-linking: {obj.Name} => {side.Name} but {side.Name} => null");
                    }
                    if (side2 != obj)
                    {
                        Assert.Fail($"Inconsistent door-linking: {obj.Name} => {side.Name} but {side.Name} => {side2.Name}");
                    }
                } catch (AssertFailedException e)
                {
                    throw e;
                } catch (Exception e)
                {
                    // use sideOk to determine whether obj.LinkedSide threw or side.LinkedSide threw.
                    Assert.Fail($"{(side ?? obj).Name} threw {e.Message} when LinkedSide being called");
                }
            }
        }
Example #26
0
        public void TestInstanceId()
        {
            var a = new AObject();
            var b = new BObject();

            Assert.AreEqual <uint>(1, a.InstanceId);
            Assert.AreEqual <uint>(2, b.InstanceId);
        }
Example #27
0
        public void OnMouseDownOnObject(AObject lObject)
        {
            if (lObject is AnswerToken)
            {
                lObject.IsFocused = true;

                this.NotifyGameStateChanged(this.CurrentLevel.LevelName, new GameEvent(EventType.PICK_WORD, string.Empty));
            }
        }
Example #28
0
        public void Enable(Guid aGuid)
        {
            AObject tObj = Helper.ApiKeys.WithGuid(aGuid);

            if (tObj != null)
            {
                tObj.Enabled = true;
            }
        }
Example #29
0
        private void OnObjectTextStateChanged(AObject arg1, bool arg2)
        {
            AObject2D object2D = this.mappingObjectToObject2D[arg1];

            if (object2D != null && object2D is ATokenObject2D)
            {
                object2D.SetTextState(arg2);
            }
        }
        public void Disable(Guid aGuid)
        {
            AObject tObj = Helper.Servers.WithGuid(aGuid);

            if (tObj != null)
            {
                tObj.Enabled = false;
            }
        }
Example #31
0
        public void ThrowIfDisposedTest()
        {
            using var dobject = new AObject(TimeSpan.FromMilliseconds(500));
            dobject.Foo();

            dobject.Dispose();

            dobject.Foo();
        }
        public void Remove(Guid aGuid)
        {
            AObject tObj = Helper.Servers.WithGuid(aGuid);

            if (tObj != null)
            {
                Helper.Servers.Remove(tObj as Server);
            }
        }
Example #33
0
 protected new void FileChanged(AObject aObj)
 {
     if (aObj is FilePart)
     {
         double speed;
         try
         {
             speed = (from file in Files.All from part in file.Parts select part.Speed).Sum();
         }
         catch (Exception)
         {
             speed = 0;
         }
         UpdateState(speed);
     }
 }
Example #34
0
        public void RegisterParser(Server.Irc.AParser aParser)
        {
            IrcParser = aParser;

            IrcParser.ParsingError += delegate(string aData) { EventParsingError = aData; };

            IrcParser.AddDownload += delegate(Packet aPack, long aChunk, IPAddress aIp, int aPort)
            {
                EventPacket = aPack;
                EventChunk = aChunk;
                EventIp = aIp;
                EventPort = aPort;
            };
            IrcParser.RemoveDownload += delegate(Bot aBot) { EventBot = aBot; };

            IrcParser.SendData += delegate(Core.Server aServer, string aData)
            {
                Assert.AreEqual(Server, aServer);
                EventData = aData;
            };
            IrcParser.JoinChannel += delegate(Core.Server aServer, Channel aChannel)
            {
                Assert.AreEqual(Server, aServer);
                EventChannel = aChannel;
            };
            IrcParser.CreateTimer += delegate(Core.Server aServer, AObject aObject, int aTime, bool aOverride)
            {
                Assert.AreEqual(Server, aServer);
                EventObject = aObject;
                EventTime = aTime;
                EventOverride = aOverride;
            };

            IrcParser.RequestFromBot += delegate(Core.Server aServer, Bot aBot)
            {
                Assert.AreEqual(Server, aServer);
                EventBot = aBot;
            };
            IrcParser.UnRequestFromBot += delegate(Core.Server aServer, Bot aBot)
            {
                Assert.AreEqual(Server, aServer);
                EventBot = aBot;
            };
        }
Example #35
0
 void TryRemoveFromList(List<AObject> aList, AObject aObject)
 {
     lock (aList)
     {
         if (aList.Contains(aObject))
         {
             aList.Remove(aObject);
         }
     }
 }
Example #36
0
 void RemoveObject(AObject aObject)
 {
     TryAddToList(_objectsRemoved, aObject);
     TryRemoveFromList(_objectsAdded, aObject);
     TryRemoveFromList(_objectsChanged, aObject);
 }
Example #37
0
 protected override bool DuplicateChildExists(AObject aObject)
 {
     return Packet((aObject as Packet).Id) != null;
 }
Example #38
0
        void SendAdded(AObject aObject, bool reloadTable = false)
        {
            var hub = GetHubForObject(aObject);
            if (hub == null)
            {
                return;
            }

            var hubObject = Hub.Helper.XgObjectToHubObject(aObject);
            if (hubObject == null)
            {
                return;
            }

            var clients = GetClientsForObject(aObject);
            foreach (var client in clients)
            {
                lock (client.LoadedObjects)
                {
                    if ((client.LoadedObjects.Count < client.MaxObjects || client.MaxObjects == 0) && hub != typeof(PacketHub).Name)
                    {
                        Log.Debug("SendAdded() " + aObject);
                        GlobalHost.ConnectionManager.GetHubContext(hub).Clients.Client(client.ConnectionId).OnAdded(hubObject);
                        client.LoadedObjects.Add(hubObject.Guid);
                    }
                    else if (reloadTable)
                    {
                        Log.Debug("SendChanged() RELOAD");
                        GlobalHost.ConnectionManager.GetHubContext(hub).Clients.Client(client.ConnectionId).OnReloadTable();
                    }
                }
            }
        }
Example #39
0
 protected override void ObjectRemoved(AObject aParent, AObject aObj)
 {
     var response = new Response
     {
         Type = Response.Types.ObjectRemoved,
         Data = aObj
     };
     Broadcast(response);
 }
Example #40
0
        protected override void ObjectEnabledChanged(AObject aObj)
        {
            ObjectChanged(aObj);

            // if a packet changed dispatch the bot, too
            if (aObj is Packet)
            {
                var part = aObj as Packet;
                ObjectChanged(part.Parent);
            }
        }
Example #41
0
        protected override void ObjectChanged(AObject aObj)
        {
            var response = new Response
            {
                Type = Response.Types.ObjectChanged,
                Data = aObj
            };
            Broadcast(response);

            // if a part changed dispatch the file, packet and bot, too
            if (aObj is FilePart)
            {
                var part = aObj as FilePart;
                ObjectChanged(part.Parent);
                if (part.Packet != null)
                {
                    ObjectChanged(part.Packet);
                    ObjectChanged(part.Packet.Parent);
                }
            }
        }
Example #42
0
 protected override void FileRemoved(AObject aParent, AObject aObj)
 {
     ObjectRemoved(aParent, aObj);
 }
Example #43
0
 protected override void FileChanged(AObject aObj)
 {
     ObjectChanged(aObj);
 }
Example #44
0
 protected override void FileAdded(AObject aParent, AObject aObj)
 {
     ObjectAdded(aParent, aObj);
 }
Example #45
0
        protected override void ObjectAdded(AObject aParent, AObject aObj)
        {
            if (aObj is Core.Server)
            {
                var aServer = aObj as Core.Server;

                Log.Info("ServerObjectAdded(" + aServer + ")");
                _servers.ServerConnect(aServer);
            }
        }
Example #46
0
 public static void FireNotificationAdded(Notification.Types aType, AObject aObject)
 {
     if (OnNotificationAdded != null)
     {
         OnNotificationAdded(null, new EventArgs<Notification>(new Notification(aType, aObject)));
     }
 }
Example #47
0
 protected override bool DuplicateChildExists(AObject aObject)
 {
     return Server(aObject.Name) != null;
 }
Example #48
0
 protected override void SearchAdded(AObject aParent, AObject aObj)
 {
     ObjectAdded(aParent, aObj);
 }
Example #49
0
        string GetHubForObject(AObject aObject)
        {
            if (aObject is Server)
            {
                return typeof(ServerHub).Name;
            }
            else if (aObject is Channel)
            {
                return typeof(ChannelHub).Name;
            }
            else if (aObject is Packet)
            {
                return typeof(PacketHub).Name;
            }
            else if (aObject is File)
            {
                return typeof(FileHub).Name;
            }
            else if (aObject is Search)
            {
                return typeof(SearchHub).Name;
            }
            else if (aObject is Notification)
            {
                return typeof(NotificationHub).Name;
            }
            else if (aObject is ApiKey)
            {
                return typeof(ApiHub).Name;
            }

            return null;
        }
Example #50
0
 protected override void SearchChanged(AObject aObj)
 {
     ObjectChanged(aObj);
 }
Example #51
0
 protected override void SearchRemoved(AObject aParent, AObject aObj)
 {
     ObjectRemoved(aParent, aObj);
 }
Example #52
0
        void SendRemoved(AObject aObject)
        {
            var hub = GetHubForObject(aObject);
            if (hub == null)
            {
                return;
            }

            var hubObject = Hub.Helper.XgObjectToHubObject(aObject);
            if (hubObject == null)
            {
                return;
            }

            var clients = GetClientsForObject(aObject);
            foreach (var client in clients)
            {
                lock (client.LoadedObjects)
                {
                    if (client.LoadedObjects.Contains(hubObject.Guid))
                    {
                        Log.Debug("SendRemoved()" + aObject);
                        GlobalHost.ConnectionManager.GetHubContext(hub).Clients.Client(client.ConnectionId).OnRemoved(hubObject);
                        client.LoadedObjects.Remove(hubObject.Guid);
                    }
                }
            }
        }
Example #53
0
 void ChangeObject(AObject aObject)
 {
     if (_objectsAdded.Contains(aObject) || _objectsRemoved.Contains(aObject))
     {
         return;
     }
     TryAddToList(_objectsChanged, aObject);
 }
 protected virtual Node_Object parseObject(AObject node)
 {
     return new Node_Object(
     parseMult1<AWorker,Node_Worker>(parseWorker, node.GetWorker()),
     getSource(node));
 }
Example #55
0
 void TryAddToList(List<AObject> aList, AObject aObject)
 {
     lock (aList)
     {
         if (!aList.Contains(aObject))
         {
             aList.Add(aObject);
         }
     }
 }
		public void SubscribeToEvent(AObject sender, string eventType, AtomicEventDelegate function)
		{
			EventCore.SubscribeToEvent (this, sender, eventType, function);
		}
Example #57
0
 protected override bool DuplicateChildExists(AObject aObject)
 {
     return Bot((aObject as Bot).Name) != null;
 }
Example #58
0
 void EnabledChanged(AObject aObj)
 {
     if (!aObj.Enabled)
     {
         RemovePart = true;
         Connection.Disconnect();
     }
 }
Example #59
0
        protected override void ObjectRemoved(AObject aParent, AObject aObj)
        {
            if (aObj is Core.Server)
            {
                var aServer = aObj as Core.Server;

                aServer.Enabled = false;
                aServer.Commit();

                Log.Info("ServerObjectRemoved(" + aServer + ")");
                _servers.ServerDisconnect(aServer);
            }
        }
Example #60
0
        protected override void ObjectEnabledChanged(AObject aObj)
        {
            if (aObj is Core.Server)
            {
                var aServer = aObj as Core.Server;

                if (aObj.Enabled)
                {
                    _servers.ServerConnect(aServer);
                }
                else
                {
                    _servers.ServerDisconnect(aServer);
                }
            }
        }