Click here to Skip to main content
15,907,281 members
Home / Discussions / C#
   

C#

 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Bryan White29-Dec-03 22:30
Bryan White29-Dec-03 22:30 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Colin Angus Mackay31-Dec-03 5:37
Colin Angus Mackay31-Dec-03 5:37 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Colin Angus Mackay31-Dec-03 5:39
Colin Angus Mackay31-Dec-03 5:39 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
SherKar1-Jan-04 13:32
SherKar1-Jan-04 13:32 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? - some code to help you Pin
Bryan White1-Jan-04 21:48
Bryan White1-Jan-04 21:48 
Generalvoice Pin
heba_zien27-Dec-03 10:06
heba_zien27-Dec-03 10:06 
GeneralRe: voice Pin
Wizard_0127-Dec-03 10:36
Wizard_0127-Dec-03 10:36 
GeneralRe: voice Pin
Nick Parker27-Dec-03 10:38
protectorNick Parker27-Dec-03 10:38 
GeneralProblem adding web reference to Visual c++ application Pin
Anonymous27-Dec-03 9:56
Anonymous27-Dec-03 9:56 
GeneralConditional Xml Document Reading Pin
LokiSD27-Dec-03 6:04
LokiSD27-Dec-03 6:04 
GeneralRe: Conditional Xml Document Reading Pin
Nick Parker27-Dec-03 8:14
protectorNick Parker27-Dec-03 8:14 
Generalread jpeg into memory Pin
Leon Radley27-Dec-03 5:30
Leon Radley27-Dec-03 5:30 
GeneralRe: read jpeg into memory Pin
Nick Parker27-Dec-03 8:33
protectorNick Parker27-Dec-03 8:33 
GeneralRe: read jpeg into memory Pin
Wizard_0127-Dec-03 8:40
Wizard_0127-Dec-03 8:40 
GeneralRe: read jpeg into memory Pin
Nick Parker27-Dec-03 8:54
protectorNick Parker27-Dec-03 8:54 
GeneralRe: read jpeg into memory Pin
Leon Radley29-Dec-03 1:49
Leon Radley29-Dec-03 1:49 
GeneralADS Pin
realaravind27-Dec-03 2:59
realaravind27-Dec-03 2:59 
GeneralRe: ADS Pin
Wizard_0127-Dec-03 3:12
Wizard_0127-Dec-03 3:12 
QuestionHow to create menuItems dynamic on Popup event? Pin
Chris Richner27-Dec-03 2:02
Chris Richner27-Dec-03 2:02 
AnswerRe: How to create menuItems dynamic on Popup event? Pin
Wizard_0127-Dec-03 3:05
Wizard_0127-Dec-03 3:05 
GeneralRe: How to create menuItems dynamic on Popup event? Pin
Chris Richner27-Dec-03 3:29
Chris Richner27-Dec-03 3:29 
GeneralRe: How to create menuItems dynamic on Popup event? Pin
Heath Stewart27-Dec-03 5:29
protectorHeath Stewart27-Dec-03 5:29 
GeneralRe: How to create menuItems dynamic on Popup event? - what I did with a couple of classes Pin
Bryan White1-Jan-04 22:20
Bryan White1-Jan-04 22:20 
This is how I do it:
- create a ContextMenuPopup in the application (I do this in the base form, but use it for multiple forms in the same application). I think that I used the GUI designer originally:
this.contextMenuPopup = new System.Windows.Forms.ContextMenu();
- the GUI designer threw this code in; how much is actually used? dunno!
this.contextMenuPopup.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemTitle,
this.menuItemSep1,
this.menuItemOpt1,
this.menuItemOpt2,
this.menuItemOpt3});
this.contextMenuPopup.Popup += new System.EventHandler(this.contextMenuPopup_Popup);
- In the form you want it to apply to, add:
newWindowL.GraphicControl.ContextMenu = contextMenuPopup;
- Write a menu builder
This is tricky; you need to remember that:
- each MenuItem has to be a clone, not an original, if you are "mix'n'match"ing a menu. Well, I found that it helped 'cos some items are duplicated.
- each MenuItem needs an event handler. I use a recursive method to allow multi-level context menus
-MenuItemCommand is derived from MenuItem & does a few fancy things like storing a command object (cf "Command Patterns")
The code has just been copied & pasted. Use it more for ideas/principles than 'as is'; here goes:
#region ContextMenuPopup stuff
private void contextMenuPopup_Popup(object sender, System.EventArgs e)
{
ContextMenu ctxMenu = sender as ContextMenu;
if(ctxMenu == null)
return;
Control ctl = ctxMenu.SourceControl;
if(ctl == null)
return;
// blah blah
contextMenuBuilder.SetContextOptionNames(GarageSystem.Garage, hitStruct4ContextMenu, mEditingMenus, contextMenuPopup);
}

public void SetContextOptionNames(SEComponentMaster topLevel, Structure hitStruct, Menu.MenuItemCollection theMenuCollection,
ContextMenu theContextMenu)//, MenuClicker theEventHandler)
{

MenuClicker theEventHandler = new ContextMenuBuilder.MenuClicker(menuItemDynamicContextEntry_Click);
theContextMenu.MenuItems.Clear();
MenuPlusCommand theFilteredMenu = null;
if(mHitStructure.Owner is IWall)
{
theFilteredMenu = MenuBuilderFromXML.ReturnFirstMenuItemOwnerLike(theMenuCollection[0].MenuItems, "Wall");
}
theContextMenu.MenuItems.Add(mHitStructure.Name);
theContextMenu.MenuItems.Add("-");
if(theFilteredMenu != null)
{
MenuPlusCommand theFilteredMenuCopy = theFilteredMenu;
foreach(MenuItem I in theFilteredMenuCopy.MenuItems)
theContextMenu.MenuItems.Add(I.CloneMenu());
RecursiveSetContextMenuClickEventHandler(theContextMenu.MenuItems, theContextMenu, theEventHandler);
}
}

public static void RecursiveSetContextMenuClickEventHandler(Menu.MenuItemCollection theMenuItems, ContextMenu theContextMenu, MenuClicker theEventHandler)
{
if(theMenuItems != null)
{
foreach(MenuItem I in theMenuItems)
{
MenuPlusCommand thisSubItem = I as MenuPlusCommand;
if(thisSubItem != null)
{
if(thisSubItem.Command.ToString().Length > 1)
{
thisSubItem.Click += new System.EventHandler(theEventHandler);
}
else
{
if(thisSubItem.MenuItems.Count > 0)
{
RecursiveSetContextMenuClickEventHandler(thisSubItem.MenuItems, theContextMenu, theEventHandler);
}
}
}
}
}
}
Hope this helps


Regards

Brewman
GeneralC# and COM - Further information Pin
Tristan Rhodes27-Dec-03 1:17
Tristan Rhodes27-Dec-03 1:17 
GeneralRe: C# and COM - Further information Pin
Nick Parker27-Dec-03 4:30
protectorNick Parker27-Dec-03 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.