示例#1
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);
        }
示例#2
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);
        }