Esempio n. 1
0
 public void AddOtherRoom(string room_name, WhiteboardRoom wbRoom)
 {
     lock (otherWBRoomLock)
     {
         if (!otherWBRooms.ContainsKey(room_name))
         {
             otherWBRooms.Add(room_name, wbRoom);
         }
     }
 }
Esempio n. 2
0
        public WhiteboardDialog(Form mainForm, GUIController controller, WhiteboardRoom wbRoom)
        {
            InitializeComponent();
            if (controller == null)
            {
                throw new ArgumentNullException("Cannot pass a null GUIController");
            }
            _MainForm = mainForm;
            _Controller = controller;
            WBRoom = wbRoom;
            this.Dock = DockStyle.Fill;

            if (WBRoom != null)
            {
                wbColorB.BackColor = Color.FromArgb(WBRoom.DrawColor);
                wbRoom.DrawPointSize = wbPointSize.Value;
            }

            // Turn off the gradient in toolstrip
            ProfessionalColorTable professionalColorTable = new ProfessionalColorTable();
            professionalColorTable.UseSystemColors = true;
            toolStrip1.Renderer = new ToolStripProfessionalRenderer(professionalColorTable);

            // Set the default image for tool button drop down
            if (WBRoom != null)
            {
                SetWhiteboardToolImage(WBRoom.DrawMode);
            }

            // Setup tooltips
            wbTooltip.SetToolTip (textDD, "Enter text for use in text or line drawing control");
            wbTooltip.SetToolTip(wbColorB, "Click to choose drawing color");
            wbTooltip.SetToolTip(wbPointSize, "Use to set size for drawing objects or text");
            wbTooltip.SetToolTip(undoB, "Click to undo your last drawing operation");
            wbTooltip.SetToolTip(clearB, "Click to clear all of your drawing in this Whiteboard room");
            wbTooltip.SetToolTip(clearAllB, "Click to clear entire Whiteboard room");
            wbTooltip.SetToolTip(playerListDD, "Select a player to synchronize your map view with");
            wbTooltip.SetToolTip(viewUndoB, "Revert to your previous view");
            wbTooltip.SetToolTip(otherWBRoomsLB, "Select additional Whiteboard rooms to overlay with this room");

        }
Esempio n. 3
0
        public void DrawWhiteboardRoomObjects(WhiteboardRoom wbRoom, Canvas canvas)
        {
            if (wbRoom == null)
            {
                return;
            }

            // Draw all whiteboard commands
            Array drawingCommands = wbRoom.GetCurrentDrawingCommands();

            foreach (object obj in drawingCommands)
            {
                if (obj is LineObject)
                {
                    LineObject line = (LineObject)obj;
                    LocationValue start = new LocationValue();
                    LocationValue end = new LocationValue();
                    int drawPointSize = (int)(line.Width * _playfield.Scale);

                    if ((drawPointSize == 0) && (line.Width > 0))
                    {
                        drawPointSize = 1;
                    }

                    if ((line.Mode == DrawModes.Line) || (line.Mode == DrawModes.Circle) ||
                        (line.Mode == DrawModes.Arrow))
                    {
                        start.X = line.Start.X * _playfield.Scale + Map.Position.X;
                        start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y;

                        end.X = line.End.X * _playfield.Scale + Map.Position.X;
                        end.Y = line.End.Y * _playfield.Scale + Map.Position.Y;

                        if (line.Mode == DrawModes.Line)
                        {
                            if ((line.Text != null) && (line.Text.Length > 0))
                            {
                                int lineTextSize = (int) ((LineTextSize / line.OriginalScale) * _playfield.Scale);

                                DrawShortenedLine(canvas, line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                    (float)end.X, (float)end.Y, (float) (_playfield.Scale / line.OriginalScale));

                                if (lineTextSize > MaxFontSize)
                                {
                                    lineTextSize = MaxFontSize;
                                }
                                if (lineTextSize < 1)
                                {
                                    lineTextSize = 1;
                                }
                                if (wbFonts[lineTextSize] == null)
                                {
                                    wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel));
                                }
                                DrawCenteredText(wbFonts[lineTextSize], line.Text, (int)end.X, (int)end.Y, line.Color);
                            }
                            else
                            {
                                canvas.DrawLine(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                    (float)end.X, (float)end.Y);
                            }
                        }
                        else if (line.Mode == DrawModes.Circle)
                        {
                            canvas.DrawCircle(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                (float)end.X, (float)end.Y);
                        }
                        else if (line.Mode == DrawModes.Arrow)
                        {
                            canvas.DrawArrow(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                (float)end.X, (float)end.Y);
                        }
                    }
                    else if ((line.Mode == DrawModes.Text) && (line.Text != null) &&
                        (line.Text.Length > 0))
                    {
                        start.X = line.Start.X * _playfield.Scale + Map.Position.X;
                        start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y;

                        if (drawPointSize > MaxFontSize)
                        {
                            drawPointSize = MaxFontSize;
                        }
                        if (wbFonts[drawPointSize] == null)
                        {
                            wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel));
                        }
                        DrawCenteredText(wbFonts[drawPointSize], line.Text, (int)start.X, (int)start.Y, line.Color);

                        // Update the bounding box if needed
                        if ((line.BoundingPolygon == null) || (wbRoom == WBRoom))
                        {
                            RectangleF textRect;
                            Polygon textPoly;
                            float width;
                            float height;
                            PointF boundStart = new PointF();

                            textRect = wbFonts[drawPointSize].MeasureString(null, line.Text, DrawTextFormat.None, line.Color);

                            width = textRect.Right / _playfield.Scale;
                            if ((width * line.OriginalScale) < 5)
                            {
                                width = 5 / (float) line.OriginalScale;
                            }
                            height = textRect.Bottom / _playfield.Scale;
                            if ((height * line.OriginalScale) < 5)
                            {
                                height = 5 / (float) line.OriginalScale;
                            }
                            boundStart.X = (float)line.Start.X - (width / 2);
                            boundStart.Y = (float)line.Start.Y - (height / 2);

                            textPoly = new Polygon();
                            textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y));
                            textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y));
                            textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y + height));
                            textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y + height));
                            textPoly.Offset(0, 0);
                            textPoly.BuildEdges();

                            line.BoundingPolygon = textPoly;
                        }
                    }

                    // Draw Bounding rectable if object is selected
                    if ((line.ObjectSelected) && (line.BoundingPolygon != null) && (line.BoundingPolygon.Points.Count >= 2))
                    {
                        LocationValue boundStart = new LocationValue();
                        LocationValue boundEnd = new LocationValue();
                        Vector prevPoint = line.BoundingPolygon.Points[line.BoundingPolygon.Points.Count - 1]; 
                        foreach (Vector curPoint in line.BoundingPolygon.Points)
                        {
                            boundStart.X = prevPoint.X * _playfield.Scale + Map.Position.X;
                            boundStart.Y = prevPoint.Y * _playfield.Scale + Map.Position.Y;

                            boundEnd.X = curPoint.X * _playfield.Scale + Map.Position.X;
                            boundEnd.Y = curPoint.Y * _playfield.Scale + Map.Position.Y;

                            canvas.DrawLine(Color.Black.ToArgb(), 1, (float)boundStart.X, (float)boundStart.Y,
                                (float)boundEnd.X, (float)boundEnd.Y);

                            prevPoint = curPoint;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void AddOtherRoom(string room_name, WhiteboardRoom wbRoom)
        {
            // Add the room to the checkbox list
            otherWBRoomsLB.Items.Add(room_name);

            // Add a link to this whiteboard room
            lock (otherWBRoomLock)
            {
                if (!otherWBRooms.ContainsKey(room_name))
                {
                    otherWBRooms.Add(room_name, wbRoom);
                }
            }
        }
Esempio n. 5
0
        public void CreateWhiteboardRoom(string tab_name, string room_name, List<string> membership_list, string senderDM)
        {
            try
            {
                if (!IsDisposed)
                {
                    if (!InvokeRequired)
                    {
                        try
                        {
                            if (_Controller != null && !(TabControls.TabPages.ContainsKey(room_name)))
                            {
                                // Create new whiteboard room
                                WhiteboardRoom wbRoom = new WhiteboardRoom(room_name, membership_list, _Controller);

                                // Create new whiteboard tab
                                WhiteboardDialog c = new WhiteboardDialog(this, _Controller, wbRoom);
                                c.GroupId = tab_name;
                                c.Channel = room_name;
                                c.Members = membership_list;
                                c.AllowPropertyChanges = false;
                                c.EnableRoomOwnerControls(senderDM == DDD_Global.Instance.PlayerID);
                                TabControls.TabPages.Add(room_name, tab_name);
                                TabControls.TabPages[room_name].Controls.Add(c);

                                // Add this whiteboard to the other whiteboard rooms listbox
                                foreach (TabPage tabPage in TabControls.TabPages)
                                {
                                    if (tabPage.Controls[0] is WhiteboardDialog)
                                    {
                                        if (((WhiteboardDialog)tabPage.Controls[0]).WBRoom != null)
                                        {
                                            WhiteboardRoom otherWBRoom = ((WhiteboardDialog)tabPage.Controls[0]).WBRoom;

                                            if (string.Compare(otherWBRoom.Name, room_name) != 0)
                                            {
                                                // Add new room to listbox
                                                ((WhiteboardDialog)tabPage.Controls[0]).AddOtherRoom(room_name, wbRoom);

                                                // Add existing room to new room's listbox
                                                c.AddOtherRoom(otherWBRoom.Name, otherWBRoom);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "Unable to create whiteboard room.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    }
                    else
                    {
                        BeginInvoke(new CreateWhiteboardRoomDelegate(CreateWhiteboardRoom), tab_name, room_name, membership_list, senderDM);
                    }
                }
            }
            catch (Exception exc)
            {
                throw new Exception(exc.Message);
            }
        }
Esempio n. 6
0
 public void AddOtherRoom(string room_name, WhiteboardRoom wbRoom)
 {
     lock (otherWBRoomLock)
     {
         if (!otherWBRooms.ContainsKey(room_name))
         {
             otherWBRooms.Add(room_name, wbRoom);
         }
     }
 }