Example #1
0
        private void ServerControl_Load(object sender, EventArgs e)
        {
            initialSelectToolColor = btnSelectTool.BackColor;
            initialFogToolColor    = btnFogTool.BackColor;
            initialBlackoutColor   = btnToggleBlackout.BackColor;

            initialParentFormText = this.ParentForm.Text;
            this.ParentForm.Text  = initialParentFormText + " (0 clients connected)";

            pbxMap.Paint  += new PaintEventHandler(pbxMap_Paint);
            this.Disposed += new EventHandler(ServerControl_Disposed);

            connection = new ServerSocketConnection(ConfigValues.DefaultServerPort);
            connection.OnClientConnected    += connection_OnClientConnected;
            connection.OnClientCountChanged += new Action <int>(connection_OnClientCountChanged);
            connection.OnSocketEvent        += new Action <ServerEvent>(connection_OnSocketEvent);

            var serverData = Persistence.LoadServerData();

            realTimeFogUpdates  = serverData.RealTimeFogUpdates;
            btnSyncFog.Visible  = !realTimeFogUpdates;
            gbxLog.Visible      = serverData.ShowLog;
            pbxMap.SizeMode     = serverData.FitMapToScreen ? PictureBoxSizeMode.StretchImage : PictureBoxSizeMode.AutoSize;
            gbxGridSize.Visible = serverData.ShowGridValues;
            chkShowGrid.Checked = serverData.ShowGrid;
            nudGridSize.Minimum = ConfigValues.MinimumGridSize;
            nudGridSize.Maximum = ConfigValues.MaximumGridSize;
            nudGridSize.Value   = Math.Min(nudGridSize.Maximum, Math.Max(nudGridSize.Minimum, serverData.GridSize));

            gridPen = (serverData.IsGridColorSet) ? new Pen(Color.FromArgb(serverData.GridColorA, serverData.GridColorR, serverData.GridColorG, serverData.GridColorB)) : new Pen(Color.Aqua);

            FogBrushColor = Color.FromArgb(DEFAULT_FOG_BRUSH_ALPHA, Color.Black);
        }
Example #2
0
        public static void WriteFog(this ServerSocketConnection connection, Image fog)
        {
            if (connection.ClientsCount == 0)
            {
                return;
            }

            connection.WriteFog(fog.Width, fog.Height, fog.ToBytes());
        }
Example #3
0
        public static void WriteMap(this ServerSocketConnection connection, Image map)
        {
            if (connection.ClientsCount == 0)
            {
                return;
            }

            connection.WriteMap(map.Width, map.Height, map.ToBytes());
        }
Example #4
0
        private void ServerControl_Load(object sender, EventArgs e)
        {
            initialParentFormText = this.ParentForm.Text;

            this.Disposed += new EventHandler(ServerControl_Disposed);

            this.ctlDnDMap.AllowZoom                = false;
            this.ctlDnDMap.PerformCenterMap        += new Action <SimplePoint>(ctlDnDMap_PerformCenterMap);
            this.ctlDnDMap.OnOneFogUpdatesChanged  += new Action <FogUpdate>(ctlDnDMap_OnOneFogUpdatesChanged);
            this.ctlDnDMap.OnManyFogUpdatesChanged += new Action(ctlDnDMap_OnManyFogUpdatesChanged);
            this.ctlDnDMap.FogAlpha             = DnDMapConstants.DEFAULT_FOG_BRUSH_ALPHA;
            this.ctlDnDMap.TryToggleFullScreen += new Action <Keys>(ctlDnDMap_TryToggleFullScreen);
            this.ctlDnDMap.Init();

            var serverData = Persistence.LoadServerData();

            this.ctlDnDMap.UseFogAlphaEffect = serverData.UseFogAlphaEffect;
            if (serverData.IsGridColorSet)
            {
                this.ctlDnDMap.SetGridColor(new SimpleColor((byte)serverData.GridColorA, (byte)serverData.GridColorR, (byte)serverData.GridColorG, (byte)serverData.GridColorB));
            }

            if (serverData.ShowGrid)
            {
                this.ctlDnDMap.SetGridSize(true, Math.Min(ConfigValues.MaximumGridSize, Math.Max(ConfigValues.MinimumGridSize, serverData.GridSize)));
            }
            else
            {
                this.ctlDnDMap.SetGridSize(false, 0);
            }

            connection = new ServerSocketConnection(ConfigValues.DefaultServerNetSocketPort, ConfigValues.DefaultServerWebSocketPort);
            connection.OnClientConnected    += connection_OnClientConnected;
            connection.OnClientCountChanged += new Action <int>(connection_OnClientCountChanged);
            connection.OnSocketEvent        += new Action <ServerEvent>(connection_OnSocketEvent);

            this.SetIPStringOnTitle();

            this.ctlControlPanel.Connection                = connection;
            this.ctlControlPanel.DnDMapControl             = this.ctlDnDMap;
            this.ctlControlPanel.LoadImageMenuItem         = this.loadImage;
            this.ctlControlPanel.UndoLastFogActionMenuItem = this.undoLastFogAction;
            this.ctlControlPanel.RedoLastFogActionMenuItem = this.redoLastFogAction;
            this.ctlControlPanel.Init();

            saveFogTimer          = new Timer();
            saveFogTimer.Interval = ConfigValues.FogSaveInterval;
            saveFogTimer.Tick    += new EventHandler(saveFogTimer_Tick);
        }
Example #5
0
        public MainPage()
        {
            this.InitializeComponent();

            //_goPiGo = DeviceFactory.Build.BuildGoPiGo();

            //_goPiGo.MotorController().EnableServo();

            //_devices = DeviceFactory.Build.BuildUltraSonicSensor(Pin.Trigger);

            System.Diagnostics.Debug.WriteLine("Start Listener");
            ServerSocketConnection.StartListener();
            ServerSocketConnection.NewMessageReady += SendCommand;

            Loaded += MainPage_Loaded;
        }