Esempio n. 1
0
        protected void CreateControlWidget(MenuItem menu, ChoiceBase control)
        {
            string label = control.Label;

            label = label.Replace("_", "&");
            MenuItem menuItem = new MenuItem(label);

            menuItem.Click += new System.EventHandler(control.OnClick);


            //note that we could handle the details of display in two different ways.
            //either weekend of this up to the normal display mechanism, which will do its own polling,
            //or we could just build the menu in the desired state right here (enable checked etc.)

            //for now, I am going to do the latter because with the sidebar code we are using
            //that kind of polling will not be done automatically. so we do it this way here so that
            //the sidebar adapter can be written parallel to this one.
            UIItemDisplayProperties display = control.GetDisplayProperties();

            menuItem.Checked = display.Checked;
            menuItem.Enabled = display.Enabled;
            menuItem.Text    = display.Text;

            control.ReferenceWidget = menuItem;
            menu.MenuItems.Add(menuItem);
        }
Esempio n. 2
0
        /// <summary>
        /// do a limited update of the toolbar
        /// </summary>
        /// <remarks>when the user's cursor is hovering over a button and we do a redraw,
        /// this method is called. This allows us to update the enabled state of the button
        /// without getting flashing tool tips,
        /// which is what we get if we were to clear the toolbar and rebuild the buttons,
        /// as is normally done at idle time.
        /// </remarks>
        /// <param name="group"></param>
        protected void UpdateToolbar(ChoiceGroup group)
        {
            Bar toolbar = (Bar)group.ReferenceWidget;

            foreach (BaseItem item in toolbar.Items)
            {
                if (item.Tag == null)
                {
                    continue;
                }
                ChoiceBase choice = item.Tag as ChoiceBase;
                if (choice != null)
                {
                    UIItemDisplayProperties display = choice.GetDisplayProperties();

                    // If what should be displayed has changed, refill the toolbar.
                    if (item.Visible && !display.Visible)
                    {
                        FillToolbar(group, toolbar);
                        return;
                    }
                    item.Enabled = display.Enabled;
                }
                //update combo box
                ChoiceGroup comboGroup = item.Tag as ChoiceGroup;
                if (comboGroup != null)
                {
                    //UIItemDisplayProperties display = group.GetDisplayProperties();

                    //item.Enabled = display.Enabled;
                    comboGroup.PopulateNow();                 // make sure list of items is up to date.
                    FillCombo(comboGroup);                    //maybe too drastic
                }
            }
        }
Esempio n. 3
0
        protected void  AddHotlink(ChoiceBase choice)
        {
            PanelButton button = new PanelButton(choice, m_smallImages);

            m_panelMain.Controls.Add(button);
            button.Dock = DockStyle.Right;

            WatchPropertyOfButton(button);
        }
Esempio n. 4
0
        public void OnClick(object something, System.EventArgs args)
        {
            CommandBarItem item = (CommandBarItem)something;

            //			ToolBarButton button = args.Button;
            ChoiceBase control = (ChoiceBase)item.Tag;

            Debug.Assert(control != null);
            control.OnClick(item, null);
        }
Esempio n. 5
0
        /// <summary>
        /// Handle the Button Click event.
        /// </summary>
        /// <param name="something">The button that was clicked.</param>
        /// <param name="args">Unused event arguments.</param>
        private void OnClickAreaButton(object something, System.EventArgs args)
        {
            ButtonItem item   = (ButtonItem)something;
            ChoiceBase choice = (ChoiceBase)item.Tag;

            Debug.Assert(choice != null);
            m_control.SuspendLayout();
            choice.OnClick(item, null);
            m_control.ResumeLayout(true);
        }
Esempio n. 6
0
        /// <summary>
        /// Create a button item for use on a menu or a toolbar.
        /// </summary>
        /// <param name="choice">The details for the new item.</param>
        /// <param name="reallyVisible">true if the item will be visible eventually
        /// (it never is right away, because the parent control isn't yet)</param>
        /// <exception cref="ConfigurationException"></exception>
        /// <returns>The new item.</returns>
        protected ToolStripItem CreateButtonItem(ChoiceBase choice, out bool reallyVisible)
        {
            UIItemDisplayProperties display = choice.GetDisplayProperties();
            reallyVisible = display.Visible;

            string label = display.Text;
            if (label == null)
                label = AdapterStrings.ErrorGeneratingLabel;

            label = label.Replace("_", "&");

            ToolStripButton  item = new ToolStripButton(label);

            item.AccessibilityObject.Name = choice.Id;
            item.Tag = choice.Id;

            if(choice is CommandChoice)
            {
                item.Click += OnClick;
            }
            else
            {
                item.Click += choice.OnClick;
            }

            Image image = null;
            if (display.ImageLabel!= "default")
                image = m_smallImages.GetImage(display.ImageLabel);
            item.Image = image;
            item.Checked = display.Checked;

            Debug.Assert(item != null);
            item.Tag = choice;
            item.Enabled = display.Enabled;
            item.Visible = display.Visible;

            object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

            if (helper != null)
            {
                String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
                if (choice.Shortcut != Keys.None)
                {

                    KeysConverter kc = new KeysConverter();
                    s += '(' + kc.ConvertToString(choice.Shortcut) + ')';
                    item.ToolTipText = s;
                }
            }
            else
                item.ToolTipText = item.Text.Replace("&",""); //useful for buttons.

            choice.ReferenceWidget = item;
            return item;
        }
Esempio n. 7
0
 protected object FindWidgetForItem(string id)
 {
     foreach (ChoiceGroup group in m_window.MenusChoiceGroupCollection)
     {
         ChoiceBase info = (ChoiceBase)group.FindById(id);
         if (info != null)
         {
             return(info.ReferenceWidget);
         }
     }
     return(null);
 }
Esempio n. 8
0
        private void OnSelectedIndexChanged(object sender, EventArgs e)
        {
            ListView list = (ListView)sender;

            if (list.SelectedIndices == null || list.SelectedIndices.Count == 0)
            {
                return;
            }

            ChoiceBase control = (ChoiceBase)list.SelectedItems[0].Tag;

            Debug.Assert(control != null);
            control.OnClick(this, null);
        }
Esempio n. 9
0
 protected object FindWidgetForItem(string id)
 {
     foreach (ChoiceGroup group in m_window.MenusChoiceGroupCollection)
     {
         ChoiceBase info = (ChoiceBase)group.FindById(id);
         if (info != null)
         {
             return(info.ReferenceWidget);
         }
     }
     //don't want to fail because sometimes we are making sure the item is *not* there
     //Assert.Fail( "Could not find a MenuItem with ID='"+id + "'.");
     return(null);
 }
Esempio n. 10
0
        protected CommandBarItem CreateMenuItem(ChoiceBase choice)
        {
            //note that we could handle the details of display in two different ways.
            //either we can leave this up to the normal display mechanism, which will do its own polling,
            //or we could just build the menu in the desired state right here (enable checked etc.)

            UIItemDisplayProperties display = choice.GetDisplayProperties();

            string label          = display.Text;
            bool   isSeparatorBar = (label == "-");

            label = label.Replace("_", "&");
            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            CommandBarItem menuItem;

            if (choice is CommandChoice)
            {
                if (isSeparatorBar)
                {
                    menuItem = new CommandBarSeparator();
                }
                else
                {
                    menuItem = new CommandBarButton(image, label, new EventHandler(OnClick));
                }
            }
            else
            {
                CommandBarCheckBox cb = new CommandBarCheckBox(image, label);
                cb.Click    += new System.EventHandler(choice.OnClick);
                cb.IsChecked = display.Checked;
                menuItem     = cb;
            }
            if (!isSeparatorBar)
            {
                ((CommandBarButtonBase)menuItem).Shortcut = choice.Shortcut;
            }

            menuItem.Tag           = choice;
            menuItem.IsEnabled     = !isSeparatorBar && display.Enabled;
            menuItem.IsVisible     = display.Visible;
            choice.ReferenceWidget = menuItem;
            return(menuItem);
        }
Esempio n. 11
0
        /// <summary>
        /// Handles the button item click event by passing it on to the ChoiceBase.
        /// </summary>
        /// <param name="something">The ButtonItem that was clicked.</param>
        /// <param name="args">Event arguments, which are not currently used.</param>
        protected virtual void OnClick(object something, EventArgs args)
        {
            ToolStripItem item    = (ToolStripItem)something;
            ChoiceBase    control = (ChoiceBase)item.Tag;

            if (control == null)
            {
                // Debug.Assert(control != null);
                // LT-2884 : this crash is infrequent, so for now just removing the assert
                MessageBox.Show(AdapterStrings.ErrorProcessingThatClick,
                                AdapterStrings.ProcessingError, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            control.OnClick(item, null);
        }
Esempio n. 12
0
        protected virtual void OnComboClick(object something, System.EventArgs args)
        {
            ComboBoxItem combo = (ComboBoxItem)something;

            ChoiceGroup group        = (ChoiceGroup)combo.Tag;
            ComboItem   selectedItem = combo.SelectedItem as ComboItem;

            if (selectedItem == null)
            {
                return;
            }

            ChoiceBase choice = selectedItem.Tag as ChoiceBase;

            choice.OnClick(combo, null);
        }
Esempio n. 13
0
        protected void MakeButton(OutlookBarBand band, ChoiceBase control)
        {
            UIItemDisplayProperties display = control.GetDisplayProperties();

            display.Text = display.Text.Replace("_", "");
            OutlookBarItem button;

            //			if(m_images!=null && m_images.ImageList.Images.Count>0)
            //			{
            //				button = new OutlookBarItem(display.Text,0,control);
            //			}
            //			else		//no images have been supplied to us!
            button     = new OutlookBarItem();
            button.Tag = control;
            control.ReferenceWidget = button;

            if (band.IconView == SidebarLibrary.WinControls.IconView.Large)
            {
                if (m_largeImages.ImageList.Images.Count > 0)
                {
                    button.ImageIndex = m_largeImages.GetImageIndex(display.ImageLabel);
                }
            }
            else
            {
                if (m_smallImages.ImageList.Images.Count > 0)
                {
                    button.ImageIndex = m_smallImages.GetImageIndex(display.ImageLabel);
                }
            }

            button.Selected = display.Checked;
            button.Text     = display.Text;
//			if(display.Checked)
//				button.Text = button.Text + " (X)";

            if (!display.Enabled)
            {
                button.Text = button.Text + " NA";
            }


            //note that this sidebar library we are using does not provide click events on individual items.
            //So we cannot wire them up here.
            band.Items.Add(button);
        }
Esempio n. 14
0
 /// <summary>
 /// we use the idle call here to update the enabled/disabled state of the buttons
 /// </summary>
 public void OnIdle()
 {
     if (m_commandBarManager == null || m_commandBarManager.CommandBars == null)
     {
         return;                //not really ready for an onIdle yet.
     }
     foreach (CommandBar bar in m_commandBarManager.CommandBars)
     {
         foreach (CommandBarItem button in bar.Items)
         {
             if (!(button is CommandBarButton))
             {
                 continue;
             }
             ChoiceBase control = (ChoiceBase)button.Tag;
             UpdateDisplay(control.GetDisplayProperties(), (CommandBarButton)button);
         }
     }
 }
Esempio n. 15
0
        protected virtual void OnSelectedIndexChanged(object something, System.EventArgs args)
        {
            ToolStripComboBox item    = (ToolStripComboBox)something;
            ChoiceGroup       control = (ChoiceGroup)item.Tag;

            if (control == null)
            {
                // Debug.Assert(control != null);
                // LT-2884 : this crash is infrequent, so for now just removing the assert
                MessageBox.Show(AdapterStrings.ErrorProcessingThatClick,
                                AdapterStrings.ProcessingError, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            //String idx =  item.SelectedItem.ToString();
            ChoiceBase tgt = (ChoiceBase)item.SelectedItem;

            tgt.OnClick(item, null);
        }
Esempio n. 16
0
        /// <summary>
        /// triggered when the user clicks on one of the list used in the navigation bar, e.g., the tools list.
        /// </summary>
        /// <param name="something"></param>
        /// <param name="args"></param>
        private void OnClickInPanelList(object something, System.EventArgs args)
        {
            if (m_suspendEvents)
            {
                return;
            }

            ListView list = (ListView)something;

            if (list.SelectedIndices == null || list.SelectedIndices.Count == 0)
            {
                return;
            }

            ChoiceBase control = (ChoiceBase)list.SelectedItems[0].Tag;

            Debug.Assert(control != null);
            control.OnClick(this, null);
        }
Esempio n. 17
0
        protected ComboItem  CreateComboItem(ChoiceBase choice, UIItemDisplayProperties display)
        {
            string label = display.Text;

            if (label == null)
            {
                label = AdapterStrings.ErrorGeneratingLabel;
            }

            if (!display.Visible)
            {
                return(null);
            }

            label = label.Replace("_", "&");
            DevComponents.Editors.ComboItem item = new DevComponents.Editors.ComboItem();
            item.Text = label;

            Debug.Assert(item != null);
            item.Tag = choice;
            choice.ReferenceWidget = item;
            return(item);
        }
Esempio n. 18
0
        protected void Populate(XmlNode node)
        {
            Debug.Assert(node != null);
            XmlNodeList items = node.SelectNodes("item | menu | group");

            foreach (XmlNode childNode in items)
            {
                switch (childNode.Name)
                {
                case "item":
                    ChoiceBase choice = ChoiceBase.Make(m_mediator, childNode, m_adapter, this);
                    this.Add(choice);
                    break;

                case "menu":
                    ChoiceGroup group = new ChoiceGroup(m_mediator, m_adapter, childNode, this);
                    group.Populate(childNode);
                    //Only add the submenu if it contains a list of items what will be visible.
                    //We do not want an empty submenu  LT-8791.
                    string hasList = XmlUtils.GetAttributeValue(childNode, "list");
                    if (hasList != null || ASubmenuItemIsVisible(group))
                    {
                        this.Add(group);
                    }
                    break;

                case "group":                           //for tree views in the sidebar
                    group = new ChoiceGroup(m_mediator, m_adapter, childNode, this);
                    this.Add(group);
                    break;

                default:
                    Debug.Fail("Didn't understand node type '" + childNode.Name + "' in this context." + node.OuterXml);
                    break;
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Create a button item for use on a menu or a toolbar.
        /// </summary>
        /// <param name="choice">The details for the new item.</param>
        /// <param name="wantsSeparatorBefore">True, if it should have a separator before it,
        /// otherwise false.</param>
        /// <returns>The new item.</returns>
        protected ButtonItem CreateButtonItem(ChoiceBase choice, bool wantsSeparatorBefore)
        {
            UIItemDisplayProperties display = choice.GetDisplayProperties();

            string label = display.Text;

            if (label == null)
            {
                label = AdapterStrings.ErrorGeneratingLabel;
            }

            label = label.Replace("_", "&");
            ButtonItem item = new ButtonItem(choice.Id, label);

//			if(choice is CommandChoice)
//			{
//				Image image = null;
//				if (display.ImageLabel!= "default")
//					image = m_smallImages.GetImage(display.ImageLabel);
//				item.Image = image;
//				item.Click += new EventHandler(OnClick);
//
//				// this is a bit odd to have checks on commands, but in at least one case
//				// (field visibility) the programmer expected this to work.  So let's make it work.
//				item.Checked = display.Checked;
//			}
//			else
//			{
//				item.Click += new EventHandler(choice.OnClick);
//				item.Checked = display.Checked;
//			}
            if (choice is CommandChoice)
            {
                item.Click += new EventHandler(OnClick);
            }
            else
            {
                item.Click += new EventHandler(choice.OnClick);
            }

            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            item.Image   = image;
            item.Checked = display.Checked;

            if (choice.Shortcut != System.Windows.Forms.Keys.None)
            {
                try
                {
                    //try just casting in the shortcut
                    item.Shortcuts.Add((eShortcut)choice.Shortcut);
                }
                catch
                {
                    throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: (" + choice.Shortcut.ToString() + ") for " + choice.Label);
                }
//					string s = choice.Shortcut.ToString().Replace("+","");//remove any +
//					//				System.Windows.Forms.Shortcut sc = (System.Windows.Forms.Shortcut) Enum.Parse(typeof(System.Windows.Forms.Shortcut), s);
//					//DevComponents.DotNetBar.e
//					if(s.IndexOf(", Shift")> -1)
//					{
//						s= "Shift"+s.Replace(", Shift","");
//					}
//					if(s.IndexOf(", Control")> -1)
//					{
//						s= "Ctrl"+s.Replace(", Control","");
//					}
//					if(s.IndexOf(", Alt")> -1)
//					{
//						s= "Alt"+s.Replace(", Alt","");
//					}
//					try
//					{
//						eShortcut e = (eShortcut) Enum.Parse(typeof(eShortcut), s);
//						item.Shortcuts.Add(e);
//						catch
//						{
//							item.Shortcuts.Add((eShortcut)choice.Shortcut);
//							//throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: "+s+" ("+choice.Shortcut.ToString()+") for "+choice.Label);
//						}
//					}
//					catch
//					{
//						item.Shortcuts.Add((eShortcut)choice.Shortcut);
//						//throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: "+s+" ("+choice.Shortcut.ToString()+") for "+choice.Label);
//					}
//				}
            }

            Debug.Assert(item != null);
            item.BeginGroup = wantsSeparatorBefore;
            item.Tag        = choice;
            item.Enabled    = display.Enabled;
            item.Visible    = display.Visible;
            object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

            if (helper != null)
            {
                item.Tooltip = ((IContextHelper)helper).GetToolTip(choice.HelpId);
            }
            else
            {
                item.Tooltip = item.Text.Replace("&", "");                //useful for buttons.
            }
            choice.ReferenceWidget = item;
            return(item);
        }
Esempio n. 20
0
        /// <summary>
        /// Create a button item for use on a menu or a toolbar.
        /// </summary>
        /// <param name="choice">The details for the new item.</param>
        /// <param name="wantsSeparatorBefore">True, if it should have a separator before it,
        /// otherwise false.</param>
        /// <returns>The new item.</returns>
        protected ToolStripMenuItem CreateButtonItem(ChoiceBase choice, bool wantsSeparatorBefore)
        {
            UIItemDisplayProperties display = choice.GetDisplayProperties();

            string label = display.Text;

            if (label == null)
            {
                label = AdapterStrings.ErrorGeneratingLabel;
            }

            label = label.Replace("_", "&");

            ToolStripMenuItem item = new ToolStripMenuItem(label);

            item.Tag = choice.Id;

            if (choice is CommandChoice)
            {
                item.Click += new EventHandler(OnClick);
            }
            else
            {
                item.Click += new EventHandler(choice.OnClick);
            }

            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            item.Image   = image;
            item.Checked = display.Checked;

            if (choice.Shortcut != System.Windows.Forms.Keys.None)
            {
                // TODO: Implement for this version of adapter.
                try
                {
                }
                catch
                {
                    throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: (" + choice.Shortcut.ToString() + ") for " + choice.Label);
                }
            }

            Debug.Assert(item != null);
            item.Tag     = choice;
            item.Enabled = display.Enabled;
            item.Visible = display.Visible;
            object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

            if (helper != null)
            {
                String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
                if (choice.Shortcut != Keys.None)
                {
                    KeysConverter kc = new KeysConverter();
                    s += '(' + kc.ConvertToString(choice.Shortcut) + ')';
                    item.ToolTipText = s;
                }
            }
            else
            {
                item.ToolTipText = item.Text.Replace("&", "");                //useful for buttons.
            }
            choice.ReferenceWidget = item;
            return(item);
        }
Esempio n. 21
0
        protected ToolStripItem CreateMenuItem(ChoiceBase choice, out bool reallyVisible)
        {
            if (choice is SeparatorChoice)
            {
                reallyVisible = true;
                return(new ToolStripSeparator());
            }
            UIItemDisplayProperties display = choice.GetDisplayProperties();

            reallyVisible = display.Visible;

            string label = display.Text;

            if (label == null)
            {
                label = AdapterStrings.ErrorGeneratingLabel;
            }

            label = label.Replace("_", "&");

            ToolStripMenuItem item = new ToolStripMenuItem(label);

            item.AccessibilityObject.Name = choice.Id;
            item.Tag = choice.Id;


            if (choice is CommandChoice)
            {
                item.Click += OnClick;
            }
            else
            {
                item.Click += choice.OnClick;
            }

            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            item.Image   = image;
            item.Checked = display.Checked;

            if (choice.Shortcut != Keys.None)
            {
                KeysConverter sc = new KeysConverter();

                try
                {
                    if (IsAcceptableShortcut(choice.Shortcut))
                    {
                        item.ShortcutKeys = choice.Shortcut;
                    }
                    // otherwise some other code must implement the shortcut, the built-in menu item code won't do it.
                }
                catch (Exception ex)
                {
                    if (!(ex is InvalidEnumArgumentException))
                    {
                        throw new ConfigurationException(
                                  "Software couldn't understand or doesn't support this shortcut: ("
                                  + choice.Shortcut + ") for " + choice.Label, ex);
                    }
                }
            }

            Debug.Assert(item != null);
            item.Tag     = choice;
            item.Enabled = display.Enabled;
            item.Visible = display.Visible;


            if (m_propertyTable.PropertyExists("ContextHelper"))
            {
                var    helper = m_propertyTable.GetValue <IContextHelper>("ContextHelper");
                String s      = helper.GetToolTip(choice.HelpId);
                item.ToolTipText = s;
                if (choice.Shortcut != Keys.None)
                {
                    KeysConverter kc = new KeysConverter();
                    item.ToolTipText += '(' + kc.ConvertToString(choice.Shortcut) + ')';
                }
            }
            else
            {
                item.ToolTipText = item.Text.Replace("&", "");                 //useful for buttons.
            }
            choice.ReferenceWidget = item;
            return(item);
        }
Esempio n. 22
0
		/// <summary>
		/// Create a button item for use on a menu or a toolbar.
		/// </summary>
		/// <param name="choice">The details for the new item.</param>
		/// <param name="wantsSeparatorBefore">True, if it should have a separator before it,
		/// otherwise false.</param>
		/// <returns>The new item.</returns>
		protected ToolStripMenuItem CreateButtonItem(ChoiceBase choice, bool wantsSeparatorBefore)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();

			string label = display.Text;
			if (label ==null)
				label = AdapterStrings.ErrorGeneratingLabel;

			label = label.Replace("_", "&");

			ToolStripMenuItem item = new ToolStripMenuItem(label);
			item.Tag = choice.Id;

			if(choice is CommandChoice)
			{
				item.Click += new EventHandler(OnClick);
			}
			else
			{
				item.Click += new EventHandler(choice.OnClick);
			}

			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			item.Image = image;
			item.Checked = display.Checked;

			if(choice.Shortcut != System.Windows.Forms.Keys.None)
			{
				// TODO: Implement for this version of adapter.
				try
				{

				}
				catch
				{
					throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: ("+choice.Shortcut.ToString()+") for "+choice.Label);
				}
			}

			Debug.Assert(item != null);
			item.Tag = choice;
			item.Enabled = display.Enabled;
			item.Visible = display.Visible;
			object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

			if (helper != null)
			{
				String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
				if (choice.Shortcut != Keys.None)
				{

					KeysConverter kc = new KeysConverter();
					s += '(' + kc.ConvertToString(choice.Shortcut) + ')';
					item.ToolTipText = s;
				}
			}
			else
				item.ToolTipText = item.Text.Replace("&",""); //useful for buttons.


			choice.ReferenceWidget = item;
			return item;
		}
Esempio n. 23
0
		/// <summary>
		/// Create a button item for use on a menu or a toolbar.
		/// </summary>
		/// <param name="choice">The details for the new item.</param>
		/// <param name="wantsSeparatorBefore">True, if it should have a separator before it,
		/// otherwise false.</param>
		/// <returns>The new item.</returns>
		protected ButtonItem CreateButtonItem(ChoiceBase choice, bool wantsSeparatorBefore)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();

			string label = display.Text;
			if (label ==null)
				label = AdapterStrings.ErrorGeneratingLabel;

			label = label.Replace("_", "&");
			ButtonItem item = new ButtonItem(choice.Id, label);
//			if(choice is CommandChoice)
//			{
//				Image image = null;
//				if (display.ImageLabel!= "default")
//					image = m_smallImages.GetImage(display.ImageLabel);
//				item.Image = image;
//				item.Click += new EventHandler(OnClick);
//
//				// this is a bit odd to have checks on commands, but in at least one case
//				// (field visibility) the programmer expected this to work.  So let's make it work.
//				item.Checked = display.Checked;
//			}
//			else
//			{
//				item.Click += new EventHandler(choice.OnClick);
//				item.Checked = display.Checked;
//			}
			if(choice is CommandChoice)
			{
				item.Click += new EventHandler(OnClick);
			}
			else
			{
				item.Click += new EventHandler(choice.OnClick);
			}

			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			item.Image = image;
			item.Checked = display.Checked;

			if(choice.Shortcut != System.Windows.Forms.Keys.None)
			{
				try
				{
					//try just casting in the shortcut
					item.Shortcuts.Add((eShortcut) choice.Shortcut);
				}
				catch
				{
					throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: ("+choice.Shortcut.ToString()+") for "+choice.Label);
				}
//					string s = choice.Shortcut.ToString().Replace("+","");//remove any +
//					//				System.Windows.Forms.Shortcut sc = (System.Windows.Forms.Shortcut) Enum.Parse(typeof(System.Windows.Forms.Shortcut), s);
//					//DevComponents.DotNetBar.e
//					if(s.IndexOf(", Shift")> -1)
//					{
//						s= "Shift"+s.Replace(", Shift","");
//					}
//					if(s.IndexOf(", Control")> -1)
//					{
//						s= "Ctrl"+s.Replace(", Control","");
//					}
//					if(s.IndexOf(", Alt")> -1)
//					{
//						s= "Alt"+s.Replace(", Alt","");
//					}
//					try
//					{
//						eShortcut e = (eShortcut) Enum.Parse(typeof(eShortcut), s);
//						item.Shortcuts.Add(e);
//						catch
//						{
//							item.Shortcuts.Add((eShortcut)choice.Shortcut);
//							//throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: "+s+" ("+choice.Shortcut.ToString()+") for "+choice.Label);
//						}
//					}
//					catch
//					{
//						item.Shortcuts.Add((eShortcut)choice.Shortcut);
//						//throw new ConfigurationException("DotNetBar Adapter couldn't understand or doesn't support this shortcut: "+s+" ("+choice.Shortcut.ToString()+") for "+choice.Label);
//					}
//				}
			}

			Debug.Assert(item != null);
			item.BeginGroup = wantsSeparatorBefore;
			item.Tag = choice;
			item.Enabled = display.Enabled;
			item.Visible = display.Visible;
			object helper = m_mediator.PropertyTable.GetValue("ContextHelper");
			if (helper != null)
				item.Tooltip =((IContextHelper)helper).GetToolTip(choice.HelpId);
			else
				item.Tooltip = item.Text.Replace("&",""); //useful for buttons.

			choice.ReferenceWidget = item;
			return item;
		}
Esempio n. 24
0
        /// <summary>
        /// Create a button item for use on a menu or a toolbar.
        /// </summary>
        /// <param name="choice">The details for the new item.</param>
        /// <param name="reallyVisible">true if the item will be visible eventually
        /// (it never is right away, because the parent control isn't yet)</param>
        /// <exception cref="ConfigurationException"></exception>
        /// <returns>The new item.</returns>
        protected ToolStripItem CreateButtonItem(ChoiceBase choice, out bool reallyVisible)
        {
            UIItemDisplayProperties display = choice.GetDisplayProperties();

            reallyVisible = display.Visible;

            string label = display.Text;

            if (label == null)
            {
                label = AdapterStrings.ErrorGeneratingLabel;
            }

            label = label.Replace("_", "&");

            ToolStripButton item = new ToolStripButton(label);

            item.AccessibilityObject.Name = choice.Id;
            item.Tag = choice.Id;


            if (choice is CommandChoice)
            {
                item.Click += OnClick;
            }
            else
            {
                item.Click += choice.OnClick;
            }

            Image image = null;

            if (display.ImageLabel != "default")
            {
                image = m_smallImages.GetImage(display.ImageLabel);
            }
            item.Image   = image;
            item.Checked = display.Checked;

            Debug.Assert(item != null);
            item.Tag     = choice;
            item.Enabled = display.Enabled;
            item.Visible = display.Visible;


            if (m_propertyTable.PropertyExists("ContextHelper"))
            {
                var    helper = m_propertyTable.GetValue <IContextHelper>("ContextHelper");
                String s      = helper.GetToolTip(choice.HelpId);
                if (choice.Shortcut != Keys.None)
                {
                    KeysConverter kc = new KeysConverter();
                    s += '(' + kc.ConvertToString(choice.Shortcut) + ')';
                    item.ToolTipText = s;
                }
            }
            else
            {
                item.ToolTipText = item.Text.Replace("&", "");                //useful for buttons.
            }

            choice.ReferenceWidget = item;
            return(item);
        }
Esempio n. 25
0
		protected ToolStripItem CreateMenuItem(ChoiceBase choice, out bool reallyVisible)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();
			reallyVisible = display.Visible;

			string label = display.Text;
			if (label == null)
				label = AdapterStrings.ErrorGeneratingLabel;

			label = label.Replace("_", "&");

			ToolStripMenuItem item = new ToolStripMenuItem(label);

			item.AccessibilityObject.Name = choice.Id;
			item.Tag = choice.Id;


			if (choice is CommandChoice)
			{
				item.Click += OnClick;
			}
			else
			{
				item.Click += choice.OnClick;
			}

			Image image = null;
			if (display.ImageLabel != "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			item.Image = image;
			item.Checked = display.Checked;

			if(choice.Shortcut != Keys.None)
			{
				KeysConverter sc = new KeysConverter();

				try
				{
					if (IsAcceptableShortcut(choice.Shortcut))
						item.ShortcutKeys = choice.Shortcut;
					// otherwise some other code must implement the shortcut, the built-in menu item code won't do it.
				}
				catch(Exception ex)
				{
					if (!(ex is InvalidEnumArgumentException))
						throw new ConfigurationException(
							"Software couldn't understand or doesn't support this shortcut: ("
							 + choice.Shortcut + ") for " + choice.Label, ex);
				}
			}

			Debug.Assert(item != null);
			item.Tag = choice;
			item.Enabled = display.Enabled;
			item.Visible = display.Visible;

			object helper = m_mediator.PropertyTable.GetValue("ContextHelper");

			if (helper != null)
			{
				String s = ((IContextHelper)helper).GetToolTip(choice.HelpId);
				item.ToolTipText = s;
				if (choice.Shortcut != Keys.None)
				{

					KeysConverter kc = new KeysConverter();
					item.ToolTipText += '(' + kc.ConvertToString(choice.Shortcut) + ')';
				}

			}
			else
				item.ToolTipText = item.Text.Replace("&", ""); //useful for buttons.


			choice.ReferenceWidget = item;
			return item;
		}
Esempio n. 26
0
        public void OnItemClicked(OutlookBarBand band, OutlookBarItem item)
        {
            ChoiceBase control = (ChoiceBase)item.Tag;

            control.OnClick(item, null);
        }
Esempio n. 27
0
		/// <summary>
		/// Create a ButtonItem for the sidebar.
		/// </summary>
		/// <param name="panelItem"></param>
		/// <param name="control"></param>
		protected void MakeButton(SideBarPanelItem panelItem, ChoiceBase control)
		{
			UIItemDisplayProperties display = control.GetDisplayProperties();
			display.Text = display.Text.Replace("_", "");
			ButtonItem button = new ButtonItem(control.Id, display.Text);
			button.Tag = control;
			control.ReferenceWidget = button;

			if(panelItem.ItemImageSize == eBarImageSize.Large)
			{
				if(m_largeImages.ImageList.Images.Count > 0)
					button.ImageIndex = m_largeImages.GetImageIndex(display.ImageLabel);
			}
			else
			{
				if(m_smallImages.ImageList.Images.Count > 0)
					button.ImageIndex = m_smallImages.GetImageIndex(display.ImageLabel);
			}

			button.Text = display.Text;
			button.ButtonStyle = eButtonStyle.ImageAndText;

			if(!display.Enabled)
				button.Text = button.Text + " NA";

			button.Click += new EventHandler(OnClick);
			panelItem.SubItems.Add(button);

			//a button in this framework not really a Control... so I don't know how to use
			//(the same company's) balloon tip control on a sidebar button!
		//	m_mediator.SendMessage("RegisterHelpTarget", button.ContainerControl);
		}
Esempio n. 28
0
		protected void CreateControlWidget(MenuItem menu , ChoiceBase control)
		{
			string label = control.Label;
			label = label.Replace("_", "&");
			MenuItem menuItem = new MenuItem(label);
			menuItem.Click += new System.EventHandler(control.OnClick);


			//note that we could handle the details of display in two different ways.
			//either weekend of this up to the normal display mechanism, which will do its own polling,
			//or we could just build the menu in the desired state right here (enable checked etc.)

			//for now, I am going to do the latter because with the sidebar code we are using
			//that kind of polling will not be done automatically. so we do it this way here so that
			//the sidebar adapter can be written parallel to this one.
			UIItemDisplayProperties display = control.GetDisplayProperties();
			menuItem.Checked = display.Checked;
			menuItem.Enabled= display.  Enabled;
			menuItem.Text = display.Text;

			control.ReferenceWidget = menuItem;
			menu.MenuItems.Add(menuItem);
		}
Esempio n. 29
0
		protected CommandBarItem CreateMenuItem(ChoiceBase choice)
		{
			//note that we could handle the details of display in two different ways.
			//either we can leave this up to the normal display mechanism, which will do its own polling,
			//or we could just build the menu in the desired state right here (enable checked etc.)

			UIItemDisplayProperties display = choice.GetDisplayProperties();

			string label = display.Text;
			bool isSeparatorBar = (label == "-");
			label = label.Replace("_", "&");
			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			CommandBarItem menuItem;
			if(choice is CommandChoice)
			{
				if (isSeparatorBar)
					menuItem = new CommandBarSeparator();
				else
					menuItem = new CommandBarButton(image, label, new EventHandler(OnClick));
			}
			else
			{
				CommandBarCheckBox cb = new CommandBarCheckBox(image, label);
				cb.Click += new System.EventHandler(choice.OnClick);
				cb.IsChecked = display.Checked;
				menuItem = cb;
			}
			if (!isSeparatorBar)
				((CommandBarButtonBase)menuItem).Shortcut = choice.Shortcut;

			menuItem.Tag = choice;
			menuItem.IsEnabled = !isSeparatorBar && display.Enabled;
			menuItem.IsVisible = display.Visible;
			choice.ReferenceWidget = menuItem;
			return menuItem;
		}
Esempio n. 30
0
        /// <summary>
        /// build (or rebuild) the toolbar
        /// </summary>
        /// <param name="group"></param>
        /// <param name="toolbar"></param>
        private void FillToolbar(ChoiceGroup group, Bar toolbar)
        {
            bool   wantsSeparatorBefore = false;
            string groupName            = group.Label;

            ClearOutToolbar(toolbar);
            foreach (ChoiceRelatedClass item  in group)
            {
                string itemName = item.Label;
                if (item is SeparatorChoice)
                {
                    wantsSeparatorBefore = true;
                }
                else if (item is ChoiceBase)
                {
                    ChoiceBase choice = (ChoiceBase)item;
                    UIItemDisplayProperties display = choice.GetDisplayProperties();

                    if (!display.Visible)
                    {
                        continue;
                    }
                    ButtonItem btn = CreateButtonItem(choice, wantsSeparatorBefore);
                    btn.Enabled  = display.Enabled;
                    btn.Category = group.Label;
                    toolbar.Items.Add(btn);
                    // DIDN'T WORK
                    //					if(!Manager.Items.Contains(btn.Name))
                    //							Manager.Items.Add(btn.Copy());
                    wantsSeparatorBefore = false;
                }
                else if (item is ChoiceGroup)                // Submenu
                {
                    ChoiceGroup choiceGroup = (ChoiceGroup)item;

                    //nb: the DNB class name, "ComboBoxItem" is very misleading. This is the box itself,
                    //not an item in the box.
                    ComboBoxItem combo = new ComboBoxItem(/*name*/ item.Id, /*text*/ item.Label);
                    toolbar.Items.Add(combo);
                    combo.Tag = item;
                    int width = 100;
                    // Make this configurable from the xml
                    XmlAttribute att = item.ConfigurationNode.Attributes["width"];
                    if (att != null)
                    {
                        width = Int32.Parse(att.Value);
                    }
                    combo.ComboWidth = width;
                    //combo.Stretch = true;//doesn't help

                    item.ReferenceWidget = combo;
                    //submenu.IsEnabled= true;
                    //the drop down the event seems to be ignored by the submenusof this package.
                    //submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
                    //therefore, we need to populate the submenu right now and not wait
                    choiceGroup.OnDisplay(m_window, null);

                    //hide if no sub items were added

                    //submenu.Visible = submenu.SubItems.Count>0;
                }
                else
                {
                    // TODO: Add support for other types of toolbar objects.
                }
            }
            toolbar.RecalcLayout();
            toolbar.RecalcSize();
        }
Esempio n. 31
0
		protected ComboItem  CreateComboItem(ChoiceBase choice, UIItemDisplayProperties display)
		{

			string label = display.Text;
			if (label ==null)
				label = AdapterStrings.ErrorGeneratingLabel;

			if(!display.Visible)
				return null;

			label = label.Replace("_", "&");
			DevComponents.Editors.ComboItem item = new DevComponents.Editors.ComboItem();
			item.Text=label;

			Debug.Assert(item != null);
			item.Tag = choice;
			choice.ReferenceWidget = item;
			return item;
		}
Esempio n. 32
0
		protected void MakeButton(OutlookBarBand band , ChoiceBase control)
		{
			UIItemDisplayProperties display = control.GetDisplayProperties();
			display.Text = display.Text.Replace("_", "");
			OutlookBarItem button;
			//			if(m_images!=null && m_images.ImageList.Images.Count>0)
			//			{
			//				button = new OutlookBarItem(display.Text,0,control);
			//			}
			//			else		//no images have been supplied to us!
			button = new OutlookBarItem();
			button.Tag = control;
			control.ReferenceWidget = button;

			if(band.IconView == SidebarLibrary.WinControls.IconView.Large)
			{
				if(m_largeImages.ImageList.Images.Count>0)
					button.ImageIndex = m_largeImages.GetImageIndex(display.ImageLabel);
			}
			else
			{
				if(m_smallImages.ImageList.Images.Count>0)
					button.ImageIndex = m_smallImages.GetImageIndex(display.ImageLabel);
			}

			button.Selected = display.Checked;
			button.Text = display.Text;
//			if(display.Checked)
//				button.Text = button.Text + " (X)";

			if(!display.Enabled)
				button.Text = button.Text + " NA";


			//note that this sidebar library we are using does not provide click events on individual items.
			//So we cannot wire them up here.
			band.Items.Add (button);
		}
Esempio n. 33
0
        public void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            foreach (ChoiceRelatedClass item  in group)
            {
                CommandBar toolbar = (CommandBar)group.ReferenceWidget;
                Debug.Assert(toolbar != null);

                if (item is SeparatorChoice)
                {
                    toolbar.Items.Add(new CommandBarSeparator());
                }
                else if (item is ChoiceBase)
                {
                    ChoiceBase control = (ChoiceBase)item;
                    //System.Windows.Forms.Keys shortcut = System.Windows.Forms.Keys.
                    UIItemDisplayProperties display = control.GetDisplayProperties();
                    display.Text = display.Text.Replace("_", "");

                    Image            image  = m_smallImages.GetImage(display.ImageLabel);
                    CommandBarButton button = new CommandBarButton(image, display.Text, new EventHandler(OnClick));
                    UpdateDisplay(display, button);
                    button.Tag = control;

                    control.ReferenceWidget = button;
                    toolbar.Items.Add(button);
                    button.IsEnabled = true;
                }
                //if this is a submenu

/*
 * I started playing with being able to have been used in here, but it. Complicated fast because
 * we would need to be referring over to the menubar adapter to fill in the menu items.
 *              else if(item is ChoiceGroup)
 *                              {
 *                                      if(((ChoiceGroup)item).IsSubmenu)
 *                                      {
 *                                              string label = item.Label.Replace("_", "&");
 *                                              CommandBarMenu submenu = new CommandBarMenu(label);// menu.Items.AddMenu(label);
 *                                              toolbar.Items.Add(submenu);
 *                                              submenu.Tag = item;
 *                                              item.ReferenceWidget = submenu;
 *                                              //submenu.IsEnabled= true;
 *                                              //the drop down the event seems to be ignored by the submenusof this package.
 *                                              //submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
 *                                              //therefore, we need to populate the submenu right now and not wait
 *                                              ((ChoiceGroup)item).OnDisplay(this, null);
 *                                              //this was enough to make the menu enabled, but not enough to trigger the drop down event when chosen
 *                                              //submenu.Items.Add(new CommandBarSeparator());
 *                                      }
 * //					else if(((ChoiceGroup)item).IsInlineChoiceList)
 * //					{
 * //						((ChoiceGroup)item).PopulateNow();
 * //						foreach(ChoiceRelatedClass inlineItem in ((ChoiceGroup)item))
 * //						{
 * //							Debug.Assert(inlineItem is ChoiceBase, "It should not be possible for a in line choice list to contain anything other than simple items!");
 * //							menu.Items.Add(CreateMenuItem ((ChoiceBase)inlineItem));
 * //						}
 * //					}
 *
 *                      }
 */         }
        }