|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MainMenuTestApp
{
public partial class MenuStripEnhancedForm : Form
{
public MenuStripEnhancedForm()
{
InitializeComponent();
}
private void MenuStripEnhanced_Load( object sender, EventArgs e )
{
menuStripEnhanced1.LoadDynamicMenu();
}
private void MenuItemOnClick_LoadFileXMLAnonymous( object sender, EventArgs e )
{
menuStripEnhanced1.XmlPath = System.IO.Path.Combine( Application.StartupPath, "MenuAnonymous.xml" );
menuStripEnhanced1.LoadDynamicMenu();
}
private void MenuItemOnClick_LoadFileXMLAdministrator( object sender, EventArgs e )
{
menuStripEnhanced1.XmlPath = System.IO.Path.Combine( Application.StartupPath, "MenuAdministrator.xml" );
menuStripEnhanced1.LoadDynamicMenu();
}
private void MenuItemOnClick_LoadResourceXML( object sender, EventArgs e )
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader( GetEmbeddedFile( System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, "MenuEmbeddedResource.xml" ) );
menuStripEnhanced1.LoadDynamicMenu( reader );
}
private System.IO.Stream GetEmbeddedFile( string assemblyName, string filename )
{
System.Reflection.Assembly assembly = System.Reflection.Assembly.Load( assemblyName );
System.IO.Stream stream = assembly.GetManifestResourceStream( string.Format( "{0}.{1}", assemblyName, filename ) );
if ( stream == null )
throw new Exception( "Could not locate the embedded resource." );
return stream;
}
private System.IO.Stream GetEmbeddedFile( System.Reflection.Assembly assembly, string filename )
{
string assemblyName = assembly.GetName().Name;
return GetEmbeddedFile( assemblyName, filename );
}
public System.Xml.XmlTextReader GetEmbeddedXml( Type type, string filename )
{
System.IO.Stream stream = GetEmbeddedFile( type.Assembly.GetName().Name, filename );
System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader( stream );
return xmlReader;
}
private void MenuItemOnClick_Open( object sender, EventArgs e )
{
MessageBox.Show( "Open Clicked" );
}
private void MenuItemOnClick_Close( object sender, EventArgs e )
{
MessageBox.Show( "Close Clicked" );
}
private void MenuItemOnClick_Exit( object sender, EventArgs e )
{
Application.Exit();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been working with C# since .NET Beta 1 and have been in the development scene since VB3.
I've always had a passion for development, technology, and computer as a whole. I consider myself one of the lucky few who actually love their job.
I've mostly been involed with web development in the corporate world, but I also work with Windows Forms development at home. Over the past 3 years or so the .NET applications I've developed have been backend maintenance applications. Transfering data, manipulating data, or doing some other back-end processes.