private void SelectRoom(string room) { int r; int.TryParse(room, out r); DrawingPage p = RoomManager.JoinRoom(page, r - 1); p.uscBasicDrawing.ignoreNextLines = true; }
private static void CreateChatRooms(int roomCount) { NumberOfChatRooms = roomCount; ChatRooms = new DrawingPage[roomCount]; for (int i = 0; i < roomCount; ++i) { ChatRooms[i] = new DrawingPage(false,mainWindow,username); } }
public static DrawingPage JoinRoom(DrawingPage sender,int roomNumber) { sender.Hide(); DrawingPage room = ChatRooms[roomNumber]; currRoom = roomNumber; room.Left = sender.Left; room.Top = sender.Top; room.Width = sender.ActualWidth; room.Height = sender.ActualHeight; room.Show(); return(ChatRooms[roomNumber]); }
private void showDrawingBoard(object sender, EventArgs e) { MenuItem mi = sender as MenuItem; if (mi != null) { DrawingPage page = mi.Tag as DrawingPage; if (page != null) { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host != null) { HostSurface surface = host.GetService(typeof(DesignSurface)) as HostSurface; if (surface != null) { ClassPointer root = surface.Loader.GetRootId(); DrawingLayerCollection layers = page.ShowDrawingsEditor(); if (layers != null) { //layers0 is the existing layer collections DrawingLayerCollection layers0 = page.DrawingLayers; //for layers0 if a drawing object's guid does not exist in layers then //the object has been deleted List <DrawingItem> deleted = new List <DrawingItem>(); foreach (DrawingLayer l0 in layers0) { DrawingItem d = null; for (int i = 0; i < l0.Count; i++) { DrawingItem d0 = l0[i]; d = layers.GetDrawingItemById(d0.DrawingId); if (d != null) { d0.Copy(d); //not deleted //move and resize the IDrawDesignControl foreach (Control c in page.Controls) { IDrawDesignControl dc0 = c as IDrawDesignControl; if (dc0 != null) { if (dc0.Item == d0) { c.Location = d0.Location; c.Size = d0.Bounds.Size; break; } } } } else { deleted.Add(d0); //deleted } } } if (deleted.Count > 0) { //check to see if each deleted item has usages List <DrawingItem> ls = new List <DrawingItem>(); foreach (DrawingItem d0 in deleted) { for (int i = 0; i < page.Controls.Count; i++) { IDrawDesignControl dc = page.Controls[i] as IDrawDesignControl; if (dc != null) { if (dc.DrawingId == d0.DrawingId) { uint id = root.ObjectList.GetObjectID(dc); if (id == 0) { DesignUtil.WriteToOutputWindow("id not found on deleting component {0}", dc.Name); } else { List <ObjectTextID> list = root.GetComponentUsage(id); if (list.Count > 0) { dlgObjectUsage dlg = new dlgObjectUsage(); dlg.LoadData("Cannot delete this component. It is being used by the following objects", string.Format("Component - {0}", dc.Name), list); dlg.ShowDialog(); ls.Add(d0); } } break; } } } } if (ls.Count > 0) { foreach (DrawingItem d0 in ls) { deleted.Remove(d0); } } foreach (DrawingItem d0 in deleted) { for (int i = 0; i < page.Controls.Count; i++) { IDrawDesignControl dc = page.Controls[i] as IDrawDesignControl; if (dc != null) { if (dc.DrawingId == d0.DrawingId) { surface.Loader.DeleteComponent(page.Controls[i]); break; } } } } } //for a drawing object in layers if its guid does not exist in layers0 then //it is a new object //reset zorder according to the new layers List <Control> ctrls = new List <Control>(); foreach (DrawingLayer l in layers) { int zOrder = 0; foreach (DrawingItem d in l) { DrawingItem d0 = layers0.GetDrawingItemById(d.DrawingId); if (d0 == null) { //add a new drawing string name = d.Name + Guid.NewGuid().GetHashCode().ToString("x"); Type designerType = TypeMappingAttribute.GetMappedType(d.GetType()); if (designerType == null) { throw new DesignerException("Drawing type {0} does not have a designer", d.GetType()); } Control dc = (Control)surface.Loader.CreateComponent(designerType, name); IDrawDesignControl ddc = (IDrawDesignControl)dc; ddc.Item = d; dc.Location = d.Location; dc.Size = d.Bounds.Size; ctrls.Add(dc); ddc.ZOrder = zOrder; } else { for (int k = 0; k < page.Controls.Count; k++) { IDrawDesignControl dc = page.Controls[k] as IDrawDesignControl; if (dc != null) { if (dc.Item == d0) { dc.ZOrder = zOrder; break; } } } } zOrder += 10; } } if (ctrls.Count > 0) { page.Controls.AddRange(ctrls.ToArray()); } page.LoadData(layers, false); page.Refresh(); surface.SetModified(); surface.Loader.NotifyChanges(); } } } } } }
/// This is called whenever the user right-clicks on a designer. It removes any local verbs /// added by a previous, different selection and adds the local verbs for the current (primary) /// selection. Then it displays the ContextMenu. public override void ShowContextMenu(CommandID menuID, int x, int y) { ISelectionService ss = this.GetService(typeof(ISelectionService)) as ISelectionService; if (ss == null || ss.PrimarySelection == null) { return; } IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); // if (host != null) { HostSurface surface = host.GetService(typeof(DesignSurface)) as HostSurface; if (surface != null) { ContextMenu menu = new ContextMenu(); if (host.RootComponent != ss.PrimarySelection && ss.PrimarySelection is Control) { MenuItem mi = new MenuItem("Bring to front", menu_bringToFront); mi.Tag = ss.PrimarySelection; menu.MenuItems.Add(mi); // mi = new MenuItem("Send to back", menu_sendToBack); mi.Tag = ss.PrimarySelection; menu.MenuItems.Add(mi); // menu.MenuItems.Add("-"); } if (host.RootComponent != ss.PrimarySelection) { MenuItem mi = new MenuItem("Copy", menu_cmd); mi.Tag = StandardCommands.Copy; menu.MenuItems.Add(mi); // mi = new MenuItem("Cut", menu_cmd); mi.Tag = StandardCommands.Cut; menu.MenuItems.Add(mi); // mi = new MenuItem("Delete", menu_cmd); mi.Tag = StandardCommands.Delete; menu.MenuItems.Add(mi); // if (ss.SelectionCount == 1) { MenuItem mi2 = new MenuItemWithBitmap("Add to toolbar", addToToolbar, Resource1._toolbar.ToBitmap()); IXType ix = ss.PrimarySelection as IXType; if (ix != null) { mi2.Tag = ix.ValueType; } else { mi2.Tag = ss.PrimarySelection.GetType(); } menu.MenuItems.Add(mi2); } } else { MenuItem mi = new MenuItem("Undo", menu_cmd); mi.Tag = StandardCommands.Undo; menu.MenuItems.Add(mi); // mi = new MenuItem("Redo", menu_cmd); mi.Tag = StandardCommands.Redo; menu.MenuItems.Add(mi); // mi = new MenuItem("Paste", menu_cmd); mi.Tag = StandardCommands.Paste; menu.MenuItems.Add(mi); } // DrawingPage dp = ss.PrimarySelection as DrawingPage; if (dp != null) { MenuItem mi2 = new MenuItem("-"); menu.MenuItems.Add(mi2); // mi2 = new MenuItemWithBitmap("Drawing Board", showDrawingBoard, Resource1._paint.ToBitmap()); mi2.Tag = dp; menu.MenuItems.Add(mi2); } else { IDrawDesignControl drc = ss.PrimarySelection as IDrawDesignControl; if (drc != null) { MenuItem midrc = new MenuItemWithBitmap("Copy to Clipboard as bitmap image", mi_copyDrawing, Resource1._copy.ToBitmap()); midrc.Tag = drc; menu.MenuItems.Add(midrc); midrc = new MenuItemWithBitmap("Save to XML file", mi_savedrawing, Resource1._savefile.ToBitmap()); midrc.Tag = drc; menu.MenuItems.Add(midrc); midrc = new MenuItemWithBitmap("Load from XML file", mi_loadDrawing, Resource1._loadfile.ToBitmap()); midrc.Tag = drc; menu.MenuItems.Add(midrc); } } MenuItem mi20 = new MenuItem("-"); menu.MenuItems.Add(mi20); MenuItem miAddComponent = new MenuItemWithBitmap("Add component", mi_addComponent, Resource1._newIcon.ToBitmap()); menu.MenuItems.Add(miAddComponent); // LimnorContextMenuCollection mdata = surface.GetObjectMenuData(ss.PrimarySelection); if (mdata != null) { if (menu.MenuItems.Count > 0) { menu.MenuItems.Add("-"); } mdata.CreateContextMenu(menu, new Point(0, 0), surface.Loader.ViewerHolder); } if (menu.MenuItems.Count > 0) { Control ps = surface.View as Control; if (ps != null) { LimnorXmlDesignerLoader2.MenuPoint = new Point(x, y); Point s = ps.PointToClient(LimnorXmlDesignerLoader2.MenuPoint); menu.Show(ps, s); } else { ps = ss.PrimarySelection as Control; if (ps != null) { LimnorXmlDesignerLoader2.MenuPoint = new Point(x, y); Point s = ps.PointToScreen(new Point(0, 0)); menu.Show(ps, new Point(x - s.X, y - s.Y)); } } } } } }