public async Task VerifyInitialized() { using var a = new AObject(TimeSpan.FromMilliseconds(500)); Assert.IsFalse(a.IsInitialized); var init = await a.InitializeAsync(default);
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); }
public void NotifyObjectFocusChanged(AObject lObject, bool newFocus) { if (this.ObjectFocusChanged != null) { this.ObjectFocusChanged(lObject, newFocus); } }
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; } }
public void NotifyObjectTextChanged(AObject lObject, string newText) { if (this.ObjectTextChanged != null) { this.ObjectTextChanged(lObject, newText); } }
public void OnSpeedUpDialogue(AObject lObject) { if (lObject is BubbleObject) { this.NotifyInternalGameEvent(lObject, null, "speedUpDialogue"); } }
public void NotifyObjectTextStateChanged(AObject lObject, bool state) { if (this.ObjectTextStateChanged != null) { this.ObjectTextStateChanged(lObject, state); } }
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>()); }
public void NotifyTextPositionChanged(AObject lObject, AObject previousObject, Vector2f newPosition) { if (this.TextPositionChanged != null) { this.TextPositionChanged(lObject, previousObject, newPosition); } }
public void NotifyTextUpdated(AObject lObject, AObject previousObject, AObject associatedObject, Vector2f newPosition) { if (this.TextUpdated != null) { this.TextUpdated(lObject, previousObject, associatedObject, newPosition); } }
public void NotifyObjectAnimationChanged(AObject lObject, int animationIndex) { if (this.ObjectAnimationChanged != null) { this.ObjectAnimationChanged(lObject, animationIndex); } }
public void NotifyObjectPositionChanged(AObject lObject, Vector2f newPosition) { if (this.ObjectPositionChanged != null) { this.ObjectPositionChanged(lObject, newPosition); } }
public void NotifyObjectDestroyed(ALayer layer, AObject lObject) { if (this.ObjectDestroyed != null) { this.ObjectDestroyed(layer, lObject); } }
public void OnMouseDragOnObject(AObject lObject, Vector2f mousePosition, Vector2f objectOffset) { if (lObject is AnswerToken) { lObject.SetKinematicParameters(mousePosition - objectOffset, new Vector2f(0, 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"); } }
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); } }
public void NotifyInternalGameEvent(AObject lObject, AObject lObjectTo, string details) { if (this.InternalGameEvent != null) { this.InternalGameEvent(this, lObject, lObjectTo, details); } }
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(); }
public MainWindow() { this.officeWorld = new OfficeWorld(); this.object2DManager = new Object2DManager(this.officeWorld); this.objectFocused = null; }
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); }
public Notification(Notification.Types aType, AObject aObject1, AObject aObject2 = null) { _type = aType; _object1 = aObject1; _object2 = aObject2; _time = DateTime.Now; }
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; }
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"); } } }
public void TestInstanceId() { var a = new AObject(); var b = new BObject(); Assert.AreEqual <uint>(1, a.InstanceId); Assert.AreEqual <uint>(2, b.InstanceId); }
public void OnMouseDownOnObject(AObject lObject) { if (lObject is AnswerToken) { lObject.IsFocused = true; this.NotifyGameStateChanged(this.CurrentLevel.LevelName, new GameEvent(EventType.PICK_WORD, string.Empty)); } }
public void Enable(Guid aGuid) { AObject tObj = Helper.ApiKeys.WithGuid(aGuid); if (tObj != null) { tObj.Enabled = true; } }
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; } }
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); } }
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); } }
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; }; }
void TryRemoveFromList(List<AObject> aList, AObject aObject) { lock (aList) { if (aList.Contains(aObject)) { aList.Remove(aObject); } } }
void RemoveObject(AObject aObject) { TryAddToList(_objectsRemoved, aObject); TryRemoveFromList(_objectsAdded, aObject); TryRemoveFromList(_objectsChanged, aObject); }
protected override bool DuplicateChildExists(AObject aObject) { return Packet((aObject as Packet).Id) != null; }
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(); } } } }
protected override void ObjectRemoved(AObject aParent, AObject aObj) { var response = new Response { Type = Response.Types.ObjectRemoved, Data = aObj }; Broadcast(response); }
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); } }
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); } } }
protected override void FileRemoved(AObject aParent, AObject aObj) { ObjectRemoved(aParent, aObj); }
protected override void FileChanged(AObject aObj) { ObjectChanged(aObj); }
protected override void FileAdded(AObject aParent, AObject aObj) { ObjectAdded(aParent, aObj); }
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); } }
public static void FireNotificationAdded(Notification.Types aType, AObject aObject) { if (OnNotificationAdded != null) { OnNotificationAdded(null, new EventArgs<Notification>(new Notification(aType, aObject))); } }
protected override bool DuplicateChildExists(AObject aObject) { return Server(aObject.Name) != null; }
protected override void SearchAdded(AObject aParent, AObject aObj) { ObjectAdded(aParent, aObj); }
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; }
protected override void SearchChanged(AObject aObj) { ObjectChanged(aObj); }
protected override void SearchRemoved(AObject aParent, AObject aObj) { ObjectRemoved(aParent, aObj); }
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); } } } }
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)); }
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); }
protected override bool DuplicateChildExists(AObject aObject) { return Bot((aObject as Bot).Name) != null; }
void EnabledChanged(AObject aObj) { if (!aObj.Enabled) { RemovePart = true; Connection.Disconnect(); } }
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); } }
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); } } }