void adapter_ReceiveObservers(object sender, NetPackageReceived e)
 {
     mainwindow.Dispatcher.Invoke((Action)(() => {
         if (e.pack.contentType == NetPackageTypes.Tactic) {
             using (MemoryStream stream = new MemoryStream((byte[])e.pack.content)) {
                 stream.Position = 0;
                 tactics.getTactic().unserialize(stream);
             }
             tactics.initFromTactics();
         } else if (e.pack.contentType == NetPackageTypes.ClientList) {
             mainwindow.setClients((string[])e.pack.content);
         } else if (e.pack.contentType == NetPackageTypes.Settings) {
             mainwindow.setClientsPing(adapter.canPing());
             mainwindow.setClientsDraw(adapter.canDraw());
         } else if (e.pack.contentType == NetPackageTypes.Ping) {
             byte[] cell = (byte[])e.pack.content;
             mainwindow.pingCell(cell[0], cell[1]);
         } else if (e.pack.contentType == NetPackageTypes.SetTimer) {
             mainwindow.setTime((int)e.pack.content);
         } else if (e.pack.contentType == NetPackageTypes.SetBattletype) {
             object[] data = (object[])e.pack.content;
             tactics.setBattleType((BattleType)data[0], (string)data[1]);
         } else if (e.pack.contentType == NetPackageTypes.ShowStatic) {
             mainwindow.showStatic();
         } else if (e.pack.contentType == NetPackageTypes.ShowDynamic) {
             mainwindow.showDynamic();
         } else if (e.pack.contentType == NetPackageTypes.ShowPlayStatic) {
             mainwindow.showPlayStatic();
         } else if (e.pack.contentType == NetPackageTypes.ShowPlayDynamic) {
             mainwindow.showPlayDynamic();
         } else if (e.pack.contentType == NetPackageTypes.DrawPoints) {
             PointsPacket pack = (PointsPacket)e.pack.content;
             tactics.drawPoints(pack.ps, pack.getColor(), pack.thickness, pack.time);
         } else if (e.pack.contentType == NetPackageTypes.DrawEraserPoints) {
             PointsPacket pack = (PointsPacket)e.pack.content;
             tactics.drawEraserPoints(pack.ps, pack.thickness, pack.time);
         } else if (e.pack.contentType == NetPackageTypes.DrawLine) {
             LinesPacket pack = (LinesPacket)e.pack.content;
             tactics.drawLine(pack.from, pack.to, pack.getColor(), pack.thickness, pack.getDashStyle(), pack.time);
         } else if (e.pack.contentType == NetPackageTypes.DrawArrow) {
             LinesPacket pack = (LinesPacket)e.pack.content;
             tactics.drawArrow(pack.from, pack.to, pack.getColor(), pack.thickness, pack.getDashStyle(), pack.time);
         } else if (e.pack.contentType == NetPackageTypes.DrawStamp) {
             StampPackage pack = (StampPackage)e.pack.content;
             tactics.drawStamp(pack.p, pack.getImage(), pack.size, pack.time);
         } else if (e.pack.contentType == NetPackageTypes.ResetDrawAt) {
             tactics.removeDraw((int)e.pack.content);
         } else if (e.pack.contentType == NetPackageTypes.CloneDrawAt) {
             tactics.cloneTactic((int)e.pack.content + 30, (int)e.pack.content);
         } else if (e.pack.contentType == NetPackageTypes.ReloadDynamic) {
             Stream stream = unzip((byte[])e.pack.content);
             tactics.unserializeDynamicTactic(stream);
         } else if (e.pack.contentType == NetPackageTypes.StaticTimer) {
             tactics.setStaticTimer((bool)e.pack.content);
         } else if (e.pack.contentType == NetPackageTypes.DynamicTimer) {
             tactics.setDynamicTimer((bool)e.pack.content);
         }
     }));
 }
Пример #2
0
 void Briefing_ReceiveObservers(object sender, NetPackageReceived e)
 {
     if (e.pack.contentType == NetPackageTypes.Settings) {
         BriefingSettings sets = (BriefingSettings)e.pack.content;
         clientsPing = sets.clientsPing;
         clientsDraw = sets.clientsDraw;
     } else if (isServer() && (
         e.pack.contentType == NetPackageTypes.Tactic ||
         e.pack.contentType == NetPackageTypes.Ping ||
         e.pack.contentType == NetPackageTypes.DrawPoints ||
         e.pack.contentType == NetPackageTypes.DrawEraserPoints ||
         e.pack.contentType == NetPackageTypes.DrawLine ||
         e.pack.contentType == NetPackageTypes.DrawArrow ||
         e.pack.contentType == NetPackageTypes.DrawStamp ||
         e.pack.contentType == NetPackageTypes.SetTimer ||
         e.pack.contentType == NetPackageTypes.SetBattletype ||
         e.pack.contentType == NetPackageTypes.ShowStatic ||
         e.pack.contentType == NetPackageTypes.ShowDynamic ||
         e.pack.contentType == NetPackageTypes.ShowPlayStatic ||
         e.pack.contentType == NetPackageTypes.ShowPlayDynamic ||
         e.pack.contentType == NetPackageTypes.ResetDrawAt ||
         e.pack.contentType == NetPackageTypes.CloneDrawAt ||
         e.pack.contentType == NetPackageTypes.ReloadDynamic ||
         e.pack.contentType == NetPackageTypes.StaticTimer ||
         e.pack.contentType == NetPackageTypes.DynamicTimer
         )) {
             sendExclude(e.pack, e.pack.sender);
     }
 }
Пример #3
0
 private void dispatchPackageEvent(NetPackageReceived e)
 {
     if (ReceiveObservers != null) {
         ReceiveObservers(this, e);
     }
 }