Esempio n. 1
0
        public void CreateContextMenuUIForChoiceGroup(ChoiceGroup group)
        {
            CommandBarContextMenu menu = (CommandBarContextMenu)group.ReferenceWidget;

            foreach (CommandBarItem item in menu.Items)
            {
                item.Dispose();
            }
            menu.Items.Clear();

            foreach (ChoiceRelatedClass item in group)
            {
                if (item is ChoiceBase)
                {
                    menu.Items.Add(CreateMenuItem((ChoiceBase)item));
                }
                //if this is a submenu
                else if (item is ChoiceGroup)
                {
                    //					MakeMenu (menu, (ChoiceGroup)item);
                    string         label   = item.Label.Replace("_", "&");
                    CommandBarMenu submenu = menu.Items.AddMenu(label);
                    submenu.Tag          = item;
                    item.ReferenceWidget = submenu;
                    submenu.DropDown    += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
                    //Notice that we do not need to populate this menu now; it will be populated when its contents are displayed.
                }
            }
        }
Esempio n. 2
0
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				this.items.Clear();
				this.items = null;

				this.contextMenu = null;
			}

			base.Dispose(disposing);
		}
Esempio n. 3
0
        public Document(CommandManager commandManager, string url)
        {
            this.url          = url;
            this.permanentUrl = url;

            this.commandManager = commandManager;

            this.timer          = new Timer();
            this.timer.Interval = 500;
            this.timer.Tick    += new EventHandler(this.Timer_Tick);
            this.timer.Start();

            this.htmlControl              = new HtmlControl();
            this.htmlControl.Dock         = DockStyle.Fill;
            this.htmlControl.TabIndex     = 0;
            this.htmlControl.IsDesignMode = true;

            if (this.url == null)
            {
                string tempPath = Path.GetTempFileName();
                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                Directory.CreateDirectory(tempPath);

                string tempFileName = Path.ChangeExtension("Document" + documentIndex, ".htm");
                documentIndex++;

                this.url = Path.Combine(tempPath, tempFileName);

                StreamWriter writer = new StreamWriter(this.url);
                writer.Write("<html><body></body></html>");
                writer.Close();
            }

            StreamReader reader = File.OpenText(this.url);

            this.htmlControl.LoadHtml(reader.ReadToEnd(), this.url);
            reader.Close();

            CommandBarContextMenu contextMenu = new CommandBarContextMenu();

            this.commandManager.Add("Edit.Undo", contextMenu.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z));
            this.commandManager.Add("Edit.Redo", contextMenu.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y));
            contextMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.Cut", contextMenu.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X));
            this.commandManager.Add("Edit.Copy", contextMenu.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C));
            this.commandManager.Add("Edit.Paste", contextMenu.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V));
            this.commandManager.Add("Edit.Delete", contextMenu.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete));
            this.htmlControl.ContextMenu = contextMenu;
        }
Esempio n. 4
0
        public Document(CommandManager commandManager, string url)
        {
            this.url = url;
            this.permanentUrl = url;

            this.commandManager = commandManager;

            this.timer = new Timer();
            this.timer.Interval = 500;
            this.timer.Tick += new EventHandler(this.Timer_Tick);
            this.timer.Start();

            this.htmlControl = new HtmlControl();
            this.htmlControl.Dock = DockStyle.Fill;
            this.htmlControl.TabIndex = 0;
            this.htmlControl.IsDesignMode = true;

            if (this.url == null)
            {
                string tempPath = Path.GetTempFileName();
                if (File.Exists(tempPath))
                {
                    File.Delete(tempPath);
                }

                Directory.CreateDirectory(tempPath);

                string tempFileName = Path.ChangeExtension("Document" + documentIndex, ".htm");
                documentIndex++;

                this.url = Path.Combine(tempPath, tempFileName);

                StreamWriter writer = new StreamWriter(this.url);
                writer.Write("<html><body></body></html>");
                writer.Close();
            }

            StreamReader reader = File.OpenText(this.url);
            this.htmlControl.LoadHtml(reader.ReadToEnd(), this.url);
            reader.Close();

            CommandBarContextMenu contextMenu = new CommandBarContextMenu();
            this.commandManager.Add("Edit.Undo", contextMenu.Items.AddButton(CommandBarImageResource.Undo, "&Undo", null, Keys.Control | Keys.Z));
            this.commandManager.Add("Edit.Redo", contextMenu.Items.AddButton(CommandBarImageResource.Redo, "&Redo", null, Keys.Control | Keys.Y));
            contextMenu.Items.AddSeparator();
            this.commandManager.Add("Edit.Cut", contextMenu.Items.AddButton(CommandBarImageResource.Cut, "Cu&t", null, Keys.Control | Keys.X));
            this.commandManager.Add("Edit.Copy", contextMenu.Items.AddButton(CommandBarImageResource.Copy, "&Copy", null, Keys.Control | Keys.C));
            this.commandManager.Add("Edit.Paste", contextMenu.Items.AddButton(CommandBarImageResource.Paste, "&Paste", null, Keys.Control | Keys.V));
            this.commandManager.Add("Edit.Delete", contextMenu.Items.AddButton(CommandBarImageResource.Delete, "&Delete", null, Keys.Delete));
            this.htmlControl.ContextMenu = contextMenu;
        }
Esempio n. 5
0
        //from IUIMenuAdapter
//		public ContextMenu MakeContextMenu (ChoiceGroup group)
//		{
//			CommandBarContextMenu menu= new CommandBarContextMenu();
//			menu.Tag = group;
//			group.ReferenceWidget = menu;
//			menu.Popup += new System.EventHandler(group.OnDisplay);
//
//			return (ContextMenu)menu;
//		}

        public void ShowContextMenu(ChoiceGroup group, Point location,
                                    TemporaryColleagueParameter temporaryColleagueParam,
                                    MessageSequencer sequencer)
        {
            using (CommandBarContextMenu menu = new CommandBarContextMenu())
            {
                menu.Tag = group;
                group.ReferenceWidget = menu;
                menu.Popup           += new System.EventHandler(group.OnDisplay);

                // Pre-menu process two optional paremeters.
                if (temporaryColleagueParam != null)
                {
                    temporaryColleagueParam.Mediator.AddColleague(temporaryColleagueParam.TemporaryColleague);
                }
                bool resume = false;
                if (sequencer != null)
                {
                    resume = sequencer.PauseMessageQueueing();
                }

                // NB: This is *always* modal, as it doesn't return until it closes.
                menu.Show(null, location);

                // Post-menu process two optional paremeters.s
                if (temporaryColleagueParam != null)
                {
                    IxCoreColleague colleague = temporaryColleagueParam.TemporaryColleague;
                    temporaryColleagueParam.Mediator.RemoveColleague(colleague);
                    if (temporaryColleagueParam.ShouldDispose && colleague is IDisposable)
                    {
                        (colleague as IDisposable).Dispose();
                    }
                }
                if (sequencer != null && resume)
                {
                    sequencer.ResumeMessageQueueing();
                }
            }
        }
Esempio n. 6
0
		//from IUIMenuAdapter
//		public ContextMenu MakeContextMenu (ChoiceGroup group)
//		{
//			CommandBarContextMenu menu= new CommandBarContextMenu();
//			menu.Tag = group;
//			group.ReferenceWidget = menu;
//			menu.Popup += new System.EventHandler(group.OnDisplay);
//
//			return (ContextMenu)menu;
//		}

		public void ShowContextMenu(ChoiceGroup group, Point location,
			TemporaryColleagueParameter temporaryColleagueParam,
			MessageSequencer sequencer)
		{
			using (CommandBarContextMenu menu= new CommandBarContextMenu())
			{
				menu.Tag = group;
				group.ReferenceWidget = menu;
				menu.Popup += new System.EventHandler(group.OnDisplay);

				// Pre-menu process two optional paremeters.
				if (temporaryColleagueParam != null)
					temporaryColleagueParam.Mediator.AddColleague(temporaryColleagueParam.TemporaryColleague);
				bool resume = false;
				if (sequencer != null)
					resume = sequencer.PauseMessageQueueing();

				// NB: This is *always* modal, as it doesn't return until it closes.
				menu.Show(null, location);

				// Post-menu process two optional paremeters.s
				if (temporaryColleagueParam != null)
				{
					IxCoreColleague colleague = temporaryColleagueParam.TemporaryColleague;
					temporaryColleagueParam.Mediator.RemoveColleague(colleague);
					if (temporaryColleagueParam.ShouldDispose && colleague is IDisposable)
						(colleague as IDisposable).Dispose();
				}
				if (sequencer != null && resume)
					sequencer.ResumeMessageQueueing();
			}
		}
Esempio n. 7
0
    public HelloWorld()
    {
        this.Icon = SystemIcons.Application;
        this.Text = "Hello World";
        this.Size = new Size(500, 500);
        this.Controls.Add(new StatusBar());

        this.commandBarManager = new CommandBarManager();
        this.menuBar           = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
        this.toolBar           = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);

        // Menu and toolbar
        CommandBarButton newButton  = new CommandBarButton(Images.New, "&New", null, Keys.Control | Keys.N);
        CommandBarButton openButton = new CommandBarButton(Images.Open, "&Open...", null, Keys.Control | Keys.O);
        CommandBarButton saveButton = new CommandBarButton(Images.Save, "&Save", null, Keys.Control | Keys.S);

        toolBar.Items.Add(newButton);
        toolBar.Items.Add(openButton);
        toolBar.Items.Add(saveButton);
        toolBar.Items.AddSeparator();

        CommandBarButton cutButton    = new CommandBarButton(Images.Cut, "Cu&t", null, Keys.Control | Keys.X);
        CommandBarItem   copyButton   = new CommandBarButton(Images.Copy, "&Copy", null, Keys.Control | Keys.C);
        CommandBarItem   pasteButton  = new CommandBarButton(Images.Paste, "&Paste", null, Keys.Control | Keys.V);
        CommandBarItem   deleteButton = new CommandBarButton(Images.Delete, "&Delete", null, Keys.Delete);

        this.toolBar.Items.Add(cutButton);
        this.toolBar.Items.Add(copyButton);
        this.toolBar.Items.Add(pasteButton);
        this.toolBar.Items.Add(deleteButton);
        this.toolBar.Items.AddSeparator();

        CommandBarButton undoButton = new CommandBarButton(Images.Undo, "&Undo", null, Keys.Control | Keys.Z);
        CommandBarButton redoButton = new CommandBarButton(Images.Redo, "&Redo", null, Keys.Control | Keys.Y);

        this.toolBar.Items.Add(undoButton);
        this.toolBar.Items.Add(redoButton);
        this.toolBar.Items.AddSeparator();

        CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");

        fileMenu.Items.Add(newButton);
        fileMenu.Items.Add(openButton);
        fileMenu.Items.Add(saveButton);
        fileMenu.Items.AddButton("&Save As...", null);
        fileMenu.Items.AddSeparator();
        fileMenu.Items.AddButton(Images.Preview, "Print Pre&view", null);
        fileMenu.Items.AddButton(Images.Print, "&Print", null, Keys.Control | Keys.P);
        fileMenu.Items.AddSeparator();
        fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

        CommandBarMenu editMenu = this.menuBar.Items.AddMenu("&Edit");

        editMenu.Items.Add(undoButton);
        editMenu.Items.Add(redoButton);
        editMenu.Items.AddSeparator();
        editMenu.Items.Add(cutButton);
        editMenu.Items.Add(copyButton);
        editMenu.Items.Add(pasteButton);
        editMenu.Items.Add(deleteButton);
        editMenu.Items.AddSeparator();
        editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A);

        CommandBarMenu viewMenu = this.menuBar.Items.AddMenu("&View");
        CommandBarMenu goToMenu = viewMenu.Items.AddMenu("&Go To");

        goToMenu.Items.AddButton(Images.Back, "&Back", null, Keys.Alt | Keys.Left);
        goToMenu.Items.AddButton(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right);
        goToMenu.Items.AddSeparator();
        goToMenu.Items.AddButton(Images.Home, "&Home", null);

        viewMenu.Items.AddButton(Images.Stop, "&Stop", null, Keys.Escape);
        viewMenu.Items.AddButton(Images.Refresh, "&Refresh", null, Keys.F5);

        this.enabledButton         = new CommandBarButton(Images.Tiles, "&Enabled", null);
        this.enabledButton.Enabled = false;
        this.visibleButton         = new CommandBarButton(Images.Icons, "&Visible", null);
        this.visibleButton.Visible = false;
        CommandBarCheckBox checkedPlainCheckBox = new CommandBarCheckBox("&Checked Plain");

        checkedPlainCheckBox.IsChecked = true;
        CommandBarCheckBox checkedBitmapCheckBox = new CommandBarCheckBox(Images.List, "&Checked Bitmap");

        checkedBitmapCheckBox.IsChecked = true;

        toolBar.Items.Add(enabledButton);
        toolBar.Items.Add(visibleButton);
        toolBar.Items.Add(checkedPlainCheckBox);
        toolBar.Items.Add(checkedBitmapCheckBox);

        toolBar.Items.AddSeparator();

        ComboBox comboBox = new ComboBox();

        comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
        comboBox.Width         = 100;
        toolBar.Items.AddComboBox("Combo Box", comboBox);

        toolBar.Items.AddSeparator();

        CommandBarMenu testMenu = menuBar.Items.AddMenu("&Test");

        testMenu.Items.AddButton("&Enabled On/Off", new EventHandler(ToggleEnabled_Click));
        testMenu.Items.Add(this.enabledButton);
        testMenu.Items.AddSeparator();
        testMenu.Items.AddButton("&Visible On/Off", new EventHandler(ToggleVisible_Click));
        testMenu.Items.Add(this.visibleButton);
        testMenu.Items.AddSeparator();
        testMenu.Items.Add(checkedPlainCheckBox);
        testMenu.Items.Add(checkedBitmapCheckBox);
        testMenu.Items.AddSeparator();
        testMenu.Items.AddButton("Change Font", new EventHandler(this.ChangeFont_Click));

        CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");

        helpMenu.Items.AddButton(Images.Mail, "&Your Feedback", null);
        helpMenu.Items.AddSeparator();
        helpMenu.Items.AddButton("&About", null);

        this.commandBarManager.CommandBars.Add(this.menuBar);
        this.commandBarManager.CommandBars.Add(this.toolBar);
        this.Controls.Add(this.commandBarManager);

        // Context menu
        CommandBarContextMenu contextMenu = new CommandBarContextMenu();

        contextMenu.Items.Add(undoButton);
        contextMenu.Items.Add(redoButton);
        contextMenu.Items.AddSeparator();
        contextMenu.Items.Add(cutButton);
        contextMenu.Items.Add(copyButton);
        contextMenu.Items.Add(pasteButton);
        contextMenu.Items.Add(deleteButton);
        this.ContextMenu = contextMenu;
    }
Esempio n. 8
0
		protected override void Dispose(bool disposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			if (disposing)
			{
				IsDisposing = true;
				try
				{
					if (contextMenu != null)
						contextMenu.Dispose();

					if (items != null)
					{
						// Disposing the item might remove it from the collection, so we better work on
						// a copy of the collection.
						var copiedItems = new CommandBarItem[items.Count];
						items.CopyTo(copiedItems, 0);
						foreach (var item in copiedItems)
							item.Dispose();

						this.items.Clear();
					}
				}
				finally
				{
					IsDisposing = false;
				}
			}
			this.items = null;
			this.contextMenu = null;

			base.Dispose(disposing);
		}
Esempio n. 9
0
        protected override void Dispose(bool disposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            if (disposing)
            {
                this.items.Clear();
                this.items = null;

                this.contextMenu = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 10
0
    public HelloWorld()
    {
        this.Icon = SystemIcons.Application;
            this.Text = "Hello World";
            this.Size = new Size(500, 500);
            this.Controls.Add(new StatusBar());

            this.commandBarManager = new CommandBarManager();
            this.menuBar = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
            this.toolBar = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);

            // Menu and toolbar
            CommandBarButton newButton = new CommandBarButton(Images.New, "&New", null, Keys.Control | Keys.N);
            CommandBarButton openButton = new CommandBarButton(Images.Open, "&Open...", null, Keys.Control | Keys.O);
            CommandBarButton saveButton = new CommandBarButton(Images.Save, "&Save", null, Keys.Control | Keys.S);

            toolBar.Items.Add(newButton);
            toolBar.Items.Add(openButton);
            toolBar.Items.Add(saveButton);
            toolBar.Items.AddSeparator();

            CommandBarButton cutButton = new CommandBarButton(Images.Cut, "Cu&t", null, Keys.Control | Keys.X);
            CommandBarItem copyButton = new CommandBarButton(Images.Copy, "&Copy", null, Keys.Control | Keys.C);
            CommandBarItem pasteButton = new CommandBarButton(Images.Paste, "&Paste", null, Keys.Control | Keys.V);
            CommandBarItem deleteButton = new CommandBarButton(Images.Delete, "&Delete", null, Keys.Delete);

            this.toolBar.Items.Add(cutButton);
            this.toolBar.Items.Add(copyButton);
            this.toolBar.Items.Add(pasteButton);
            this.toolBar.Items.Add(deleteButton);
            this.toolBar.Items.AddSeparator();

            CommandBarButton undoButton = new CommandBarButton(Images.Undo, "&Undo", null, Keys.Control | Keys.Z);
            CommandBarButton redoButton = new CommandBarButton(Images.Redo, "&Redo", null, Keys.Control | Keys.Y);

            this.toolBar.Items.Add(undoButton);
            this.toolBar.Items.Add(redoButton);
            this.toolBar.Items.AddSeparator();

            CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");
            fileMenu.Items.Add(newButton);
            fileMenu.Items.Add(openButton);
            fileMenu.Items.Add(saveButton);
            fileMenu.Items.AddButton("&Save As...", null);
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton(Images.Preview, "Print Pre&view", null);
            fileMenu.Items.AddButton(Images.Print, "&Print", null, Keys.Control | Keys.P);
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

            CommandBarMenu editMenu = this.menuBar.Items.AddMenu("&Edit");
            editMenu.Items.Add(undoButton);
            editMenu.Items.Add(redoButton);
            editMenu.Items.AddSeparator();
            editMenu.Items.Add(cutButton);
            editMenu.Items.Add(copyButton);
            editMenu.Items.Add(pasteButton);
            editMenu.Items.Add(deleteButton);
            editMenu.Items.AddSeparator();
            editMenu.Items.AddButton("Select &All", null, Keys.Control | Keys.A);

            CommandBarMenu viewMenu = this.menuBar.Items.AddMenu("&View");
            CommandBarMenu goToMenu = viewMenu.Items.AddMenu("&Go To");
            goToMenu.Items.AddButton(Images.Back, "&Back", null, Keys.Alt | Keys.Left);
            goToMenu.Items.AddButton(Images.Forward, "&Forward", null, Keys.Alt | Keys.Right);
            goToMenu.Items.AddSeparator();
            goToMenu.Items.AddButton(Images.Home, "&Home", null);

            viewMenu.Items.AddButton(Images.Stop, "&Stop", null, Keys.Escape);
            viewMenu.Items.AddButton(Images.Refresh, "&Refresh", null, Keys.F5);

            this.enabledButton = new CommandBarButton(Images.Tiles, "&Enabled", null);
            this.enabledButton.Enabled = false;
            this.visibleButton = new CommandBarButton(Images.Icons, "&Visible", null);
            this.visibleButton.Visible = false;
            CommandBarCheckBox checkedPlainCheckBox = new CommandBarCheckBox("&Checked Plain");
            checkedPlainCheckBox.IsChecked = true;
            CommandBarCheckBox checkedBitmapCheckBox = new CommandBarCheckBox(Images.List, "&Checked Bitmap");
            checkedBitmapCheckBox.IsChecked = true;

            toolBar.Items.Add(enabledButton);
            toolBar.Items.Add(visibleButton);
            toolBar.Items.Add(checkedPlainCheckBox);
            toolBar.Items.Add(checkedBitmapCheckBox);

            toolBar.Items.AddSeparator();

            ComboBox comboBox = new ComboBox();
            comboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            comboBox.Width = 100;
            toolBar.Items.AddComboBox("Combo Box", comboBox);

            toolBar.Items.AddSeparator();

            CommandBarMenu testMenu = menuBar.Items.AddMenu("&Test");
            testMenu.Items.AddButton("&Enabled On/Off", new EventHandler(ToggleEnabled_Click));
            testMenu.Items.Add(this.enabledButton);
            testMenu.Items.AddSeparator();
            testMenu.Items.AddButton("&Visible On/Off", new EventHandler(ToggleVisible_Click));
            testMenu.Items.Add(this.visibleButton);
            testMenu.Items.AddSeparator();
            testMenu.Items.Add(checkedPlainCheckBox);
            testMenu.Items.Add(checkedBitmapCheckBox);
            testMenu.Items.AddSeparator();
            testMenu.Items.AddButton("Change Font", new EventHandler(this.ChangeFont_Click));

            CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");
            helpMenu.Items.AddButton(Images.Mail, "&Your Feedback", null);
            helpMenu.Items.AddSeparator();
            helpMenu.Items.AddButton("&About", null);

            this.commandBarManager.CommandBars.Add(this.menuBar);
            this.commandBarManager.CommandBars.Add(this.toolBar);
            this.Controls.Add(this.commandBarManager);

            // Context menu
            CommandBarContextMenu contextMenu = new CommandBarContextMenu();
            contextMenu.Items.Add(undoButton);
            contextMenu.Items.Add(redoButton);
            contextMenu.Items.AddSeparator();
            contextMenu.Items.Add(cutButton);
            contextMenu.Items.Add(copyButton);
            contextMenu.Items.Add(pasteButton);
            contextMenu.Items.Add(deleteButton);
            this.ContextMenu = contextMenu;
    }