Exemplo n.º 1
0
		protected ToolStripComboBox CreateComboBox(ChoiceGroup choice, bool wantsSeparatorBefore)
		{
			UIItemDisplayProperties display = choice.GetDisplayProperties();
			string label = display.Text;
			choice.PopulateNow();


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

			if (!display.Visible)
				return null;


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

			ToolStripComboBox combo = new ToolStripComboBox();
			combo.Text = label;


			//foreach(ChoiceBase s in choice)
			//{
			//    item.Items.Add(s.Label);
			//}
			//item.Tag = choice;
			choice.ReferenceWidget = combo;
			combo.Tag = choice;
			FillCombo(choice);
			combo.SelectedIndexChanged += new EventHandler(OnSelectedIndexChanged);
			combo.Enabled = display.Enabled;
			combo.Visible = display.Visible;


			return combo;
		}
Exemplo n.º 2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlGroup"/> class.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public ChoiceGroup(Mediator mediator, IUIAdapter adapter, XmlNode configurationNode, ChoiceGroup parent)
            : base(mediator, adapter, configurationNode)
        {
            m_parent = parent;

            //allow for a command to be attached to a group (todo: should be for tree groups only)
            //as it doesn't make sense for some menus or command bars to have an associated command.
            //for now, leave it to the schema to prevent anything but the right element from having the command attribute.
            if (XmlUtils.GetAttributeValue(m_configurationNode,"command") != null)
            {
                m_treeGroupCommandChoice = new CommandChoice(mediator, configurationNode, adapter, this);
            }
        }
Exemplo n.º 3
0
        //public bool Radio   { get; set; } // use radio button, not checkbox
        #endregion

        public UIItemDisplayProperties(ChoiceGroup group, string text, bool enabled, string imageLabel, bool defaultVisible)
        {
            m_group   = group;
            m_text    = text;
            m_enabled = enabled;
            m_checked = false;
            m_visible = defaultVisible;
            //TODO: RickM See 'Note' for Visible and Enabled properties.
            //I think to handle the defaultVisible XML attribute better we might want to change
            //the preceeding statement to look like this
            //m_visible = defaultVisible || m_enabled;
            m_imageLabel = imageLabel;
        }
Exemplo n.º 4
0
        /// <summary>
        /// take the opportunity to read draw this band, so that these selected and enabled items are up to date.
        /// </summary>
        public void OnIdle()
        {
            OutlookBarBand band = this.m_bar.Bands[this.m_bar.GetCurrentBand()];

            if (band == null)
            {
                return;
            }

            ChoiceGroup group = (ChoiceGroup)band.Tag;

            CreateUIForChoiceGroup(group);
            m_bar.Refresh();
        }
Exemplo n.º 5
0
        /// <summary>
        /// When something changes the property areaChoice (via something like a menubar),
        /// this ensures that the matching button
        /// is highlighted.
        /// </summary>
        public void OnPropertyChanged(string propertyName)
        {
            switch (propertyName)
            {
            //nb:  this is a complete hack (and even this doesn't work right now)
            //this adapter should not need to know about the specifics like that there is a
            //property with his name.

            //NB:this processing could be moved to be on idle eventrather than
            //waiting for this property to change, but then it will
            //waste this time even more often.
            case "currentContentControl":
                if (m_populatingList)
                {
                    break;
                }

                //NB: this is a huge waste of effort, but believe it or not
                //I cannot find out
                // 1) which controls are currently visible, nor
                // 2)which controls belong to the current button, nor
                // 3) which list box belongs to the current control
                //	(having a very bad day here).
                //Therefore I have to service all of them!!!
                foreach (Control control in m_panelSubControls)
                {
//						if(control.Visible == false)
//							break;
                    ChoiceGroup g = (ChoiceGroup)control.Tag;
                    g.OnDisplay(this, null);
                }
                break;

            case "areaChoice":
                string areaName = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
                //	((ChoiceGroup)this.NavPane.NavigationBar.Tag).OnDisplay(null, null);//!!!!  test
                //RefreshPanel(this.NavPane.SelectedPanel);
                foreach (ButtonItem button in this.NavPane.Items)
                {
                    if (button.Name == areaName)
                    {
                        button.Checked = true;
                        break;
                    }
                }
                break;

            default: break;
            }
        }
Exemplo n.º 6
0
        protected CommandBarItem MakeMenu(CommandBar parent, ChoiceGroup group)
        {
            string         label = group.Label.Replace("_", "&");
            CommandBarMenu menu  = parent.Items.AddMenu(label);

            menu.Tag = group;
            group.ReferenceWidget = menu;
            menu.DropDown        += new System.EventHandler(group.OnDisplay);

#if DEBUG
            //needed for unit testing
            //menu.Click += new System.EventHandler(group.OnDisplay);
#endif
            return(menu);
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        protected void CheckSubMenuCount(string menuId, string subMenuId, int expectedCount)
        {
            Application.DoEvents();
            ChoiceGroup menuGroup = FindControlGroupById("menu", menuId);
            MenuItem    menu      = (MenuItem)menuGroup.ReferenceWidget;

            //this is needed to populate the menu
            menu.PerformClick();

            ChoiceGroup group   = (ChoiceGroup)menuGroup.FindById(subMenuId);
            MenuItem    submenu = (MenuItem)group.ReferenceWidget;

            //this is needed to populate the menu
            submenu.PerformClick();
            Assert.AreEqual(expectedCount, submenu.MenuItems.Count);
        }
Exemplo n.º 9
0
 private void SetToolForCurrentArea(string tool)
 {
     foreach (Control control in m_panelSubControls)
     {
         ChoiceGroup group = (ChoiceGroup)control.Tag;
         foreach (ListPropertyChoice choice in group)
         {
             if (choice.Value == tool)
             {
                 var item = choice.ReferenceWidget as Item;
                 var tab  = m_sidepane.GetTabByName(group.ListId);
                 m_sidepane.SelectItem(tab, item.Name);
                 break;
             }
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Create tabs on sidebar
        /// </summary>
        protected void LoadAreaButtons(ChoiceGroup group)
        {
#if USE_DOTNETBAR
            NavPane.SuspendLayout();
            NavPane.Items.Clear();
#endif
            foreach (ChoiceRelatedClass tab in group)
            {
                //Debug.Assert(item is ChoiceBase, "Only things that can be made into buttons should be appearing here.");
                Debug.Assert(tab is ListPropertyChoice, "Only things that can be made into buttons should be appearing here.");
                MakeAreaButton((ListPropertyChoice)tab);
            }

#if USE_DOTNETBAR
            NavPane.ResumeLayout(true);
#endif
        }
Exemplo n.º 11
0
        /// <summary>
        /// Overrides method to add itmes to the selected main itme in the sidebar.
        /// </summary>
        /// <param name="group">The group that defines this part of the sidebar.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            if (group.ReferenceWidget == this.NavPane.NavigationBar)
            {
                LoadAreaButtons(group);
            }
            else if (group.ReferenceWidget is ListView)
            {
                PopulateList(group);
            }

            if (m_firstLoad)
            {
                m_firstLoad = false;
                DepersistLayout();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// When something changes the property areaChoice (via something like a menubar),
        /// this ensures that the matching button
        /// is highlighted.
        /// </summary>
        public void OnPropertyChanged(string propertyName)
        {
            switch (propertyName)
            {
            //nb:  this is a complete hack (and even this doesn't work right now)
            //this adapter should not need to know about the specifics like that there is a
            //property with his name.

            //NB:this processing could be moved to be on idle eventrather than
            //waiting for this property to change, but then it will
            //waste this time even more often.
            case "currentContentControl":
                string contentControl = m_mediator.PropertyTable.GetStringProperty("currentContentControl", null);
                foreach (Control control in m_panelSubControls)
                {
//						if(control.Visible == false)
//							break;
                    ChoiceGroup g = (ChoiceGroup)control.Tag;
                    foreach (ListPropertyChoice c in g)
                    {
                        if (c.Value == contentControl)
                        {
                            (c.ReferenceWidget as ListViewItem).Selected = true;
                            return;
                        }
                    }
                }
                break;

            case "areaChoice":
                string areaName = m_mediator.PropertyTable.GetStringProperty("areaChoice", null);
                //	((ChoiceGroup)this.NavPane.NavigationBar.Tag).OnDisplay(null, null);//!!!!  test
                //RefreshPanel(this.NavPane.SelectedPanel);
                foreach (ButtonItem button in this.NavPane.Items)
                {
                    if (button.Name == areaName)
                    {
                        button.Checked = true;
                        break;
                    }
                }
                break;

            default: break;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Make sidebar tabs from group. Cache other information we receive to help
        /// make items later.
        /// </summary>
        /// <param name="group">The group that defines this part of the sidebar.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            if (group.ReferenceWidget == this.MyPanel)             // Is this an "Areas" group?
            {
                LoadAreaButtons(group);
            }
            else
            {
                PopulateList(group);
            }

            if (m_firstLoad)
            {
                m_firstLoad = false;
                DepersistLayout();
            }
        }
Exemplo n.º 14
0
        //this did not work out well because this event, though it is a result of clicking and
        //area button, actually comes before the event that tells us the button was changed!
        //therefore, stuff that would set up the list dynamically depending on the area will get it wrong.
        //therefore, we stopped using this and moved to putting all of the handling into the
        //OnClick event for the Area button.
        private void OnPanelVisibleChanged(object sender, EventArgs e)
        {
            NavigationPanePanel panel = (NavigationPanePanel)sender;

            if (!panel.Visible)
            {
                return;
            }
            foreach (Control control in panel.Controls)
            {
                if (control.Tag == null)
                {
                    continue;
                }
                ChoiceGroup group = (ChoiceGroup)control.Tag;
                group.OnDisplay(this, null);
            }
        }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks> the first time this is called, the group will be the
 /// band.  It will then be called recursively for each note that contains other nodes.</remarks>
 /// <param name="tree"></param>
 /// <param name="group"></param>
 protected void FillTreeNodes(TreeNodeCollection nodes, ChoiceGroup group)
 {
     if (nodes.Count > 0)           //hack...without this, we were losing expansion during OnIdle()
     {
         return;
     }
     nodes.Clear();
     group.PopulateNow();
     foreach (ChoiceRelatedClass item in group)
     {
         TreeNode node = MakeTreeNode(item);
         nodes.Add(node);
         if (item is ChoiceGroup)
         {
             FillTreeNodes(node.Nodes, (ChoiceGroup)item);
         }
     }
 }
Exemplo n.º 16
0
        protected ToolStripComboBox CreateComboBox(ChoiceGroup choice, bool wantsSeparatorBefore)
        {
            UIItemDisplayProperties display = choice.GetDisplayProperties();
            string label = display.Text;

            choice.PopulateNow();


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

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


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

            ToolStripComboBox combo = new ToolStripComboBox();

            combo.AccessibilityObject.Name = choice.Id;
            combo.Text = label;


            //foreach(ChoiceBase s in choice)
            //{
            //    item.Items.Add(s.Label);
            //}
            //item.Tag = choice;
            choice.ReferenceWidget = combo;
            combo.Tag = choice;
            FillCombo(choice);
            combo.SelectedIndexChanged += OnSelectedIndexChanged;

            combo.Enabled = display.Enabled;
            combo.Visible = display.Visible;



            return(combo);
        }
Exemplo n.º 17
0
        public void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            OutlookBarBand band = (OutlookBarBand)group.ReferenceWidget;

            if (band.ChildControl != null)
            {
                FillTreeNodes(((TreeView)(band.ChildControl)).Nodes, group);
            }
            else
            {
                band.Items.Clear();
                //doesn't make a difference: band.Click += new System.  EventHandler(group.OnDisplay);
                foreach (ChoiceRelatedClass item in group)
                {
                    Debug.Assert(item is ChoiceBase, "only things that can be made into buttons should be appearing here.else, we should have a tree.");
                    MakeButton(band, (ChoiceBase)item);
                }
            }
        }
Exemplo n.º 18
0
		protected MenuItem MakeMenu (Menu parent, ChoiceGroup group)
		{
			string label = group.Label.Replace("_", "&");
			MenuItem menu = new MenuItem(label);
			group.ReferenceWidget = menu;
			//although we put off populating the menu until it is actually displayed,
			//we have to put a dummy menu item in there in order to get the system to fire the right event.
			menu.MenuItems.Add(new MenuItem("dummy"));
			parent.MenuItems.Add(menu);

			//needed for mousing around
			menu.Popup += new System.EventHandler(group.OnDisplay);

#if DEBUG
			//needed for unit testing
			menu.Click += new System.EventHandler(group.OnDisplay);
#endif
			return menu;
		}
Exemplo n.º 19
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>
        /// <summary>
        /// Create or update the toolbar or a combobox owned by the toolbar
        /// </summary>
        /// <param name="group">
        ///   The group that is the basis for this toolbar.
        /// </param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            // The following two if clauses may be testing the same thing

            ToolStrip toolbar = group.ReferenceWidget as ToolStrip;
            if(toolbar.Focused)
                    return;

            //don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
            if (toolbar.Bounds.Contains(m_window.PointToClient(Control.MousePosition))
                            || InCombo(toolbar))
            {
                   //UpdateToolbar(group);
                            return;
            }

            //FillToolbar(group, toolbar);
            FillToolbar(group, group.ReferenceWidget as ToolStrip);
        }
Exemplo n.º 20
0
        protected virtual void OnSelectedIndexChanged(object something, 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;
            }


            var tgt = (ListPropertyChoice)(item.SelectedItem);

            control.HandleItemClick(tgt);
        }
Exemplo n.º 21
0
 private bool ASubmenuItemIsVisible(ChoiceGroup group)
 {
     foreach (object cb in group)
     {
         if (cb is ChoiceBase && !(cb is SeparatorChoice))
         {
             UIItemDisplayProperties display = (cb as ChoiceBase).GetDisplayProperties();
             if (display.Visible == true)
             {
                 return(true);
             }
         }
         if (cb is ChoiceGroup && ASubmenuItemIsVisible(cb as ChoiceGroup))
         {
             return(true);
         }
     }
     return(group.IsAListGroup);            // assume a list has at least one viable choice
 }
Exemplo n.º 22
0
        /// <summary>
        /// Create or update the toolbar or a combobox owned by the toolbar
        /// </summary>
        /// <param name="group">The group that is the basis for this toolbar.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
#if USE_DOTNETBAR
            if (group.ReferenceWidget is ComboBoxItem)
            {
                FillCombo(group);
                return;
            }

            Bar toolbar = group.ReferenceWidget as Bar;
//			if(toolbar.Focused)
//				return;

            //don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
            if (toolbar.Bounds.Contains(m_window.PointToClient(System.Windows.Forms.Form.MousePosition)) ||
                InCombo(toolbar) || ToolbarLocked(toolbar))
            {
                UpdateToolbar(group);
                return;
            }

            FillToolbar(group, toolbar);
#else
            // The following two if clauses may be testing the same thing

            ToolStrip toolbar = group.ReferenceWidget as ToolStrip;
            if (toolbar.Focused)
            {
                return;
            }

            //don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
            if (toolbar.Bounds.Contains(m_window.PointToClient(System.Windows.Forms.Form.MousePosition)) ||
                InCombo(toolbar))
            {
                //UpdateToolbar(group);
                return;
            }

            //FillToolbar(group, toolbar);
            FillToolbar(group, group.ReferenceWidget as ToolStrip);
#endif
        }
Exemplo n.º 23
0
 private bool ASubmenuItemIsVisible(ChoiceGroup group)
 {
     foreach (object cb in group)
     {
         if (cb is ChoiceBase && !(cb is SeparatorChoice))
         {
             UIItemDisplayProperties display = (cb as ChoiceBase).GetDisplayProperties();
             if (display.Visible == true)
             {
                 return(true);
             }
         }
         if (cb is ChoiceGroup && ASubmenuItemIsVisible(cb as ChoiceGroup))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        protected MenuItem MakeMenu(Menu parent, ChoiceGroup group)
        {
            string   label = group.Label.Replace("_", "&");
            MenuItem menu  = new MenuItem(label);

            group.ReferenceWidget = menu;
            //although we put off populating the menu until it is actually displayed,
            //we have to put a dummy menu item in there in order to get the system to fire the right event.
            menu.MenuItems.Add(new MenuItem("dummy"));
            parent.MenuItems.Add(menu);

            //needed for mousing around
            menu.Popup += new System.EventHandler(group.OnDisplay);

#if DEBUG
            //needed for unit testing
            menu.Click += new System.EventHandler(group.OnDisplay);
#endif
            return(menu);
        }
Exemplo n.º 26
0
        public void menu_PopupOpen(Object sender, DevComponents.DotNetBar.PopupOpenEventArgs args)
        {
            ButtonItem  b     = (ButtonItem)sender;
            ChoiceGroup group = (ChoiceGroup)b.Tag;

            group.OnDisplay(sender, null);
            // If none of the menu items are visible, cancel the popup altogether.  See LT-4342.
            int cVisible = 0;

            for (int i = 0; i < b.SubItems.Count; ++i)
            {
                if (b.SubItems[i].Visible)
                {
                    ++cVisible;
                }
            }
            if (cVisible == 0)
            {
                args.Cancel = true;
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Populate a main menu, directly contained by the menubar.
        /// This is called by the OnDisplay() method of some ChoiceGroup
        /// </summary>
        /// <param name="group">The group that is the basis for this menu</param>
        public void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            MenuItem menu = (MenuItem)group.ReferenceWidget;

            menu.MenuItems.Clear();

            foreach (ChoiceRelatedClass item in group)
            {
                if (item is ChoiceBase)
                {
                    CreateControlWidget(menu, (ChoiceBase)item);
                }
                //if this is a submenu
                else if (item is ChoiceGroup)
                {
                    MakeMenu(menu, (ChoiceGroup)item);
                    //Notice that we do not need to populate this menu now; it will be populated when its contents are displayed.
                    //NO! PopulateMenu(group);
                }
            }
        }
Exemplo n.º 28
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();
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="group"></param>
        /// <param name="location"></param>
        /// <param name="temporaryColleagueParam"></param>
        /// <param name="sequencer"></param>
        public void ShowContextMenu(ChoiceGroup group, Point location,
                                    TemporaryColleagueParameter temporaryColleagueParam,
                                    MessageSequencer sequencer)
        {
            // Store optional parameter values.
            m_temporaryColleagueParam = temporaryColleagueParam; // Nulls are just fine.
            m_sequencer = sequencer;                             // Nulls are just fine.

            ButtonItem b = new ButtonItem();

            b.PopupType = DevComponents.DotNetBar.ePopupType.Menu;
            //ContextMenu menu = new ContextMenu();

            b.Tag = group;
            group.ReferenceWidget = b;
            b.SubItems.Add(new ButtonItem("just to make popup happen"));

            Manager.RegisterPopup(b);
            // This will be populated when this event fires, just to make it parallel to how menubar menus work.
            b.PopupOpen += new DevComponents.DotNetBar.DotNetBarManager.PopupOpenEventHandler(menu_PopupOpen);
            // It's too early to remove the temporary colleague, even in these event handlers,
            // since the Mediator hasn't invoked anything on it yet.
            // b.PopupClose += new EventHandler(OnContextMenuClose);
            // b.PopupFinalized += new EventHandler(b_PopupFinalized);

            // 'b' is not modal, so if we have either a temporaryColleagueParam,
            // or a sequecner, or both, we need to preprocess them, before showing the menu.
            // We also need to do some post-processing with them, after the menu closes.
            // That is done in the OnContextMenuClose handler.
            if (m_temporaryColleagueParam != null)
            {
                m_temporaryColleagueParam.Mediator.AddTemporaryColleague(m_temporaryColleagueParam.TemporaryColleague);
            }
            m_sequencerIsPaused = false;
            //if (m_sequencer != null)
            //	m_sequencerIsPaused = m_sequencer.PauseMessageQueueing();

            b.Popup(location.X, location.Y);
        }
Exemplo n.º 30
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>
        /// <summary>
        /// Create or update the toolbar or a combobox owned by the toolbar
        /// </summary>
        /// <param name="group">
        ///   The group that is the basis for this toolbar.
        /// </param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            // The following two if clauses may be testing the same thing

            ToolStrip toolbar = group.ReferenceWidget as ToolStrip;

            if (toolbar.Focused)
            {
                return;
            }

            //don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
            if (toolbar.Bounds.Contains(m_window.PointToClient(Control.MousePosition)) ||
                InCombo(toolbar))
            {
                //UpdateToolbar(group);
                return;
            }

            //FillToolbar(group, toolbar);
            FillToolbar(group, group.ReferenceWidget as ToolStrip);
        }
Exemplo n.º 31
0
 private void SetToolForCurrentArea(string tool)
 {
     foreach (Control control in m_panelSubControls)
     {
         ChoiceGroup group = (ChoiceGroup)control.Tag;
         foreach (ListPropertyChoice choice in group)
         {
             if (choice.Value == tool)
             {
                 var item = choice.ReferenceWidget as Item;
                 var tab  = m_sidepane.GetTabByName(group.ListId);
                 // Selecting an item in the sidepane has side effects, so avoid
                 // calling the SelectItem if it is already the CurrentItem.
                 if (m_sidepane.CurrentItem != item)
                 {
                     m_sidepane.SelectItem(tab, item.Name);
                 }
                 break;
             }
         }
     }
 }
Exemplo n.º 32
0
		/// <summary>
		/// Factory method. Will make the appropriate class, based on the configurationNode.
		/// </summary>
		static public ChoiceBase Make( Mediator mediator,  XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
		{
			if (XmlUtils.GetAttributeValue(configurationNode, "command","") == "")
			{
				if (XmlUtils.GetAttributeValue(configurationNode, "boolProperty", "") != "")
					return new BoolPropertyChoice(  mediator,    configurationNode,  adapter,  parent);
				else if (XmlUtils.GetAttributeValue(configurationNode, "label", "") == "-")
					return new SeparatorChoice(  mediator,    configurationNode,  adapter,  parent);

					//the case where we want a choice based on a single member of the list
					//e.g. a single view in a list of views, to use on the toolbar.
				else if (XmlUtils.GetAttributeValue(configurationNode, "property", "") != "")
				{
					return MakeListPropertyChoice(mediator, configurationNode, adapter, parent);
				}

				else
					throw new ConfigurationException("Don't know what to do with this item. At least give it a dummy 'boolProperty='foo''.", configurationNode);
			}
			else
				return new CommandChoice(  mediator,    configurationNode,  adapter,  parent);
		}
Exemplo n.º 33
0
        /// <summary>
        /// Create or update the toolbar or a combobox owned by the toolbar
        /// </summary>
        /// <param name="group">The group that is the basis for this toolbar.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            if (group.ReferenceWidget is ComboBoxItem)
            {
                FillCombo(group);
                return;
            }

            Bar toolbar = group.ReferenceWidget as Bar;

//			if(toolbar.Focused)
//				return;

            //don't refresh the toolbar if the mouse is hovering over the toolbar. Doing that caused the tool tips to flash.
            if (toolbar.Bounds.Contains(m_window.PointToClient(System.Windows.Forms.Form.MousePosition)) ||
                InCombo(toolbar) || ToolbarLocked(toolbar))
            {
                UpdateToolbar(group);
                return;
            }

            FillToolbar(group, toolbar);
        }
Exemplo n.º 34
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;
                }
            }
        }
Exemplo n.º 35
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)
        {
#if USE_DOTNETBAR
            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
                }
            }
#endif
        }
Exemplo n.º 36
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));
//						}
//					}

			}
*/			}
		}
Exemplo n.º 37
0
 public StringPropertyChoice( Mediator mediator,  XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
     : base(mediator,  configurationNode,  adapter, parent)
 {
 }
Exemplo n.º 38
0
        static bool m_fHandlingClick = false; // prevent multiple simultaneous OnClick operations.

        #endregion Fields

        #region Constructors

        public ListPropertyChoice( Mediator mediator, ListItem listItem, IUIAdapter adapter, ChoiceGroup parent)
            : base(mediator,  adapter, parent)
        {
            m_listItem = listItem;
        }
Exemplo n.º 39
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="group"></param>
        /// <param name="location"></param>
        /// <param name="temporaryColleagueParam"></param>
        /// <param name="sequencer"></param>
        public void ShowContextMenu(ChoiceGroup group, Point location,
			TemporaryColleagueParameter temporaryColleagueParam,
			MessageSequencer sequencer)
        {
            // Store optional parameter values.
            m_TemporaryColleagueParameter = temporaryColleagueParam; // Nulls are just fine.

            // TODO-Linux FWNX-345: Review - don't use TemporaryColleague's
            // This needs to be done before PopulateNow
            if (m_TemporaryColleagueParameter != null)
                m_TemporaryColleagueParameter.Mediator.AddTemporaryColleague(m_TemporaryColleagueParameter.TemporaryColleague);

            // item is used in calling CreateUIForChoiceGroup to attach the choiceGroup
            // menu items to. It is not added to the shown contextMenu.
            ToolStripMenuItem item = new ToolStripMenuItem();
            item.AccessibilityObject.Name = group.Id;
                //item.GetType().Name;
            item.Tag = group;
            group.ReferenceWidget = item;
            group.PopulateNow();
            CreateUIForChoiceGroup(group);

            // NOTE: we intentionally leave contextMenu undisposed. If we dispose it after
            // contextMenu.Show then the mouse clicks on the menu items don't get handled.
            // We would have to add an Application.DoEvents() after the Show (which might
            // causes other problems), or implement IDisposable.
            var contextMenu = new ContextMenuStrip();
            contextMenu.AccessibilityObject.Name = group.Id;

            // Without building this collection first, somehow we modify the Items collection while
            // iterating.
            var items = new System.Collections.Generic.List<ToolStripItem>();
            foreach (var menuItem in item.DropDown.Items)
            {
                if (menuItem is ToolStripMenuItem )
                    items.Add(menuItem as ToolStripMenuItem);
                else if ( menuItem is ToolStripButton)
                    items.Add(menuItem as ToolStripButton);
                else if (menuItem is ToolStripSeparator)
                    items.Add(menuItem as ToolStripSeparator);
            }
            foreach (var menuItem in items)
            {
                contextMenu.Items.Add(menuItem);
            }
            MakeAcceleratorsVisible(contextMenu);
            contextMenu.Show(location);
        }
Exemplo n.º 40
0
		/// <summary>
		/// Implement a do-nothing method to keep the compiler happy.
		/// </summary>
		/// <param name="group">The group that is the basis for this menu</param>
		public virtual void CreateUIForChoiceGroup(ChoiceGroup group)
		{
		}
Exemplo n.º 41
0
		/// <summary>
		/// populate a combo box on the toolbar
		/// </summary>
		/// <param name="choice">The group that is the basis for this combo box.</param>
		private void FillCombo(ChoiceGroup choice)
		{
			UIItemDisplayProperties groupDisplay = choice.GetDisplayProperties();

			ToolStripComboBox combo = choice.ReferenceWidget as ToolStripComboBox;
			if (combo.Focused)
				return;//don't mess while we're in the combo

			// Disable if needed, but still show what's current, as for unicode fields where you can't change it, but you want to see what it is set to.
			combo.Enabled = groupDisplay.Enabled;

			ArrayList newItems = new ArrayList();
			bool fDifferent = false;
			var selectedItem = (ChoiceBase) null;
			foreach (ChoiceRelatedClass item in choice)
			{
				if (item is SeparatorChoice)
				{
					//TODO
				}
				else if (item is ChoiceBase)
				{
					newItems.Add(item);
					//if (groupDisplay.Checked)
					   // selectedItem = (ChoiceBase) item;

				  if (choice.SinglePropertyValue == (item as ListPropertyChoice).Value)
						selectedItem = (ChoiceBase) item;
					if (combo.Items.Count < newItems.Count || combo.Items[newItems.Count - 1] != item)
							fDifferent = true;

				}

			}

			// let it take the default
			// combo.AccessibleName = choice.Label;
			if (fDifferent || selectedItem != (combo.SelectedItem))
			{
				//combo.Click -= new EventHandler(OnComboClick);	//don't generate clicks (which end up being onpropertychanged() calls)
				combo.Items.Clear();
				combo.Items.AddRange(newItems.ToArray());

				combo.DropDownStyle = ComboBoxStyle.DropDownList;

				combo.SelectedItem = selectedItem;

				//combo.SuspendLayout = false;
			}

			////Set the ComboWidth of the combo box so that is is wide enough to show
			////the text of all items in the list.
			//int maxStringLength = 0;
			//for (int i = 0; i < combo.Items.Count; i++)
			//{
			//    if (combo.Items[i].ToString().Length > maxStringLength)
			//    {
			//        maxStringLength = combo.Items[i].ToString().Length;
			//    }
			//}
			//int factor = 6;
			//if (maxStringLength > 0 && combo.ComboWidth < maxStringLength * factor)
			//    combo.ComboWidth = maxStringLength * factor;
			//combo.Tooltip = combo.ToString();

		}
Exemplo n.º 42
0
        /// <summary>
        /// Make sidebar tabs from group. Cache other information we receive to help
        /// make items later.
        /// </summary>
        /// <param name="group">The group that defines this part of the sidebar.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            if (group.ReferenceWidget == this.MyPanel) // Is this an "Areas" group?
                LoadAreaButtons(group);
            else
                PopulateList(group);

            if(m_firstLoad)
            {
                m_firstLoad = false;
                DepersistLayout();
            }
        }
Exemplo n.º 43
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;
                }

            }
        }
Exemplo n.º 44
0
        /// <summary>
        /// The ToolStrip is out of date if it doesn't match the ChoiceGroup
        /// eg. are the number of visible items different?
        ///
        /// A better way of doing this would be asking the choiceGroup if it has changed
        /// or deep coping storing the choicegroup and caching it in the UI adapter, then
        /// comparing the difference.
        /// </summary>
        /// <returns>
        /// Returns true if the ToolStrip is out of date.
        /// </returns>
        private bool DoesToolStripNeedRegenerating(ChoiceGroup choiceGroup, ToolStrip toolStrip)
        {
            if (m_fullRengenerateRequired)
            {
                m_fullRengenerateRequired = false;
                return true;
            }
            if (toolStrip == null)
                return true;

            int counter = 0;
            foreach(ChoiceRelatedClass item in choiceGroup)
            {
                UIItemDisplayProperties displayProperties = null;
                if (item is SeparatorChoice == false)
                    displayProperties = item.GetDisplayProperties();

                // toolStrip has less items then visiable items in the ChoiceGroup so regenerate
                if (toolStrip.Items.Count <= counter)
                    return true;

                // skip over seperators
                // Note: sepeartors contained in the ChoiceGroup are only always added to the ToolStrip
                // if they are followed by a visiable non sepeartor item.
                // So a missing sepeartor doesn't necessary mean the toolbar needs regenerating.
                if (displayProperties == null)
                {
                    if (toolStrip.Items[counter] is ToolStripSeparator)
                    {
                        counter++;
                    }
                    continue;
                }

                // InVisible items are not added to the toolStrip
                //if (displayProperties.Visible == false)
                //	continue;

                var toolStripItem = toolStrip.Items[counter];

                if (displayProperties.Enabled != toolStripItem.Enabled)
                    return true;

                // if the text doesn't match then needs regenerating
                // TODO duplicating Text.Replace here and in (CreateButtonItem)BarAdapterBase.cs is a bit horrible.
                if (item is ChoiceGroup)
                {
                    ChoiceGroup group = item as ChoiceGroup;
                    group.PopulateNow();
                    string groupPropValue = group.SinglePropertyValue;
                    foreach (ChoiceRelatedClass candidate in group)
                    {
                        if (candidate is SeparatorChoice)
                        {
                            //TODO
                        }
                        else if (candidate is ChoiceBase)
                        {
                            if (groupPropValue == (candidate as ListPropertyChoice).Value)
                            {
                                if (candidate.ToString() != toolStripItem.Text)
                                    return true;
                            }
                        }
                    }
                    // This handles displaying a blank value in the toolbar Styles combobox when
                    // the selection covers multiple Style settings.  Without it, the last valid
                    // style setting is still shown when the selection is extended to include
                    // another style.  See FWR-824.
                    if (groupPropValue == displayProperties.Text &&
                        displayProperties.Text != toolStripItem.Text)
                    {
                        return true;
                    }
                }
                else
                {
                    if (displayProperties.Text.Replace("_", "&") != toolStripItem.Text)
                        return true;
                }

                counter++;
            }

            // nothing has been detected that needs changing.
            return false;
        }
Exemplo n.º 45
0
        /// <summary>
        /// returns true if it made any changes.
        /// </summary>
        private void FillToolbar(ChoiceGroup choiceGroup, ToolStrip toolStrip)
        {
            bool wantsSeparatorBefore = false;

            choiceGroup.PopulateNow();

            if (!DoesToolStripNeedRegenerating(choiceGroup, toolStrip))
                return;

            // Don't let the GC run dispose.
            for(int i = toolStrip.Items.Count - 1; i >= 0; --i)
            {
                toolStrip.Items[i].Dispose();
            }

            toolStrip.Items.Clear();
            foreach(ChoiceRelatedClass item in choiceGroup)
            {
                if(item is SeparatorChoice)
                {
                    wantsSeparatorBefore = true;
                }
                else if (item is ChoiceBase)
                {
                    UIItemDisplayProperties displayProperties = item.GetDisplayProperties();

                    bool reallyVisible;
                    ToolStripItem toolStripItem = CreateButtonItem(item as ChoiceBase, out reallyVisible);

                    //toolStripItem.ToolTipText = item.Label; // TODO-Linux: add shortcut accessolrator here. // choiceBase.Shortcut. //maybe this should be done by CreateButtonItem?

                    toolStripItem.DisplayStyle = ToolStripItemDisplayStyle.Image;

                    if (wantsSeparatorBefore && displayProperties != null && displayProperties.Visible)
                    {
                        var separator = new ToolStripSeparator();
                        separator.AccessibilityObject.Name = "separator";
                        // separator.GetType().Name;
                        toolStrip.Items.Add(separator);
                    }
                    wantsSeparatorBefore = false;
                    toolStrip.Items.Add(toolStripItem);
                }
                else if (item is ChoiceGroup)
                {

                    ToolStripComboBox toolStripItem = CreateComboBox(item as ChoiceGroup, true);

                    toolStrip.Items.Add(toolStripItem);
                }
                else
                {
                    //debugging
                    continue;
                }

            }

            toolStrip.PerformLayout();

            return;
        }
Exemplo n.º 46
0
		/// <summary>
		/// Populate a main menu, directly contained by the menubar.
		/// This is called by the OnDisplay() method of some ChoiceGroup
		/// </summary>
		/// <param name="group">The group that is the basis for this menu</param>
		public void CreateUIForChoiceGroup (ChoiceGroup group)
		{
			MenuItem menu = (MenuItem) group.ReferenceWidget;
			menu.MenuItems.Clear();

			foreach(ChoiceRelatedClass item in group)
			{
				if(item is ChoiceBase)
					CreateControlWidget (menu, (ChoiceBase)item);
					//if this is a submenu
				else if(item is ChoiceGroup)
				{
					MakeMenu (menu, (ChoiceGroup)item);
					//Notice that we do not need to populate this menu now; it will be populated when its contents are displayed.
					//NO! PopulateMenu(group);
				}
			}
		}
Exemplo n.º 47
0
 private bool ASubmenuItemIsVisible(ChoiceGroup group)
 {
     foreach (object cb in group)
     {
         if (cb is ChoiceBase && !(cb is SeparatorChoice))
         {
             UIItemDisplayProperties display = (cb as ChoiceBase).GetDisplayProperties();
             if (display.Visible == true)
                 return true;
         }
         if (cb is ChoiceGroup && ASubmenuItemIsVisible(cb as ChoiceGroup))
             return true;
     }
     return group.IsAListGroup; // assume a list has at least one viable choice
 }
Exemplo n.º 48
0
        /// <summary>
        /// make a control to show, for example, the list of tools, or the list of filters.
        /// </summary>
        /// <param name="group"></param>
        protected void MakeListControl(ChoiceGroup group)
        {
            ListView list= new ListView();
            list.View = View.List;
            list.Name = group.ListId;
            list.Dock = System.Windows.Forms.DockStyle.Top;
            list.MultiSelect = false;
            list.Tag = group;
            list.SmallImageList = m_smallImages.ImageList;
            list.LargeImageList = m_largeImages.ImageList;
            list.HideSelection = false;
            group.ReferenceWidget = list;
            //			foreach(ChoiceRelatedClass choice in group)
            //			{
            //				//Debug.Assert(item is ChoiceBase, "Only things that can be made into buttons should be appearing here.");
            //				Debug.Assert(choice is ListPropertyChoice, "Only things that can be made into buttons should be appearing here.");
            //				ListViewItem x =list.Items.Add(choice.Label,1);
            //				x.Tag = choice;
            //			}

            group.OnDisplay(this, null);

            list.SelectedIndexChanged += new EventHandler(OnClickInPanelList);
            list.SizeChanged += new EventHandler(list_SizeChanged);

            m_panelSubControls.Add(list);
        }
Exemplo n.º 49
0
		/// <summary>
		/// Add the nodes to the tree.
		/// </summary>
		/// <remarks>The first time this is called, the group will be the
		/// maikn element of the sidebar.
		/// It will then be called recursively for each node that contains other nodes.</remarks>
		/// <param name="nodes">Collections of tree view nodes.</param>
		/// <param name="group">Definition of current set of nodes.</param>
		protected void FillTreeNodes(TreeNodeCollection nodes, ChoiceGroup group)
		{
			if (nodes.Count > 0)//hack...without this, we were losing expansion during OnIdle()
				return;
			nodes.Clear();
			group.PopulateNow();
			foreach(ChoiceRelatedClass item in group)
			{
				TreeNode node = MakeTreeNode(item);
				nodes.Add(node);
				if (item is ChoiceGroup)
					FillTreeNodes(node.Nodes, (ChoiceGroup)item);
			}
		}
Exemplo n.º 50
0
 protected override void Populate()
 {
     XmlNodeList groups =m_configurationNode.SelectNodes(NodeSelector);
     foreach (XmlNode node in groups)
     {
         ChoiceGroup group = new ChoiceGroup(m_mediator, m_adapter, node, null);
         this.Add(group);
     }
 }
Exemplo n.º 51
0
		/// <summary>
		/// Create a tree view for the sidebar.
		/// </summary>
		/// <param name="group">The definition for the tree view.</param>
		/// <param name="label"></param>
		/// <param name="panelItem"></param>
		protected void MakeTree(ChoiceGroup group, string label, ref SideBarPanelItem panelItem)
		{
			// TODO: This tree isn't the right size, when the window opens.
			// Figure out how to make it right.
			TreeView tree = new TreeView();
			tree.Tag = group;
			tree.AfterSelect += new TreeViewEventHandler(OnTreeNodeSelected);
			ControlContainerItem containerItem = new ControlContainerItem(group.Id, label);
			containerItem.AllowItemResize = true;
			containerItem.Control = tree;
			panelItem.SubItems.Add(containerItem);
		}
Exemplo n.º 52
0
 public ChoiceBase( Mediator mediator,  XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
     : base(mediator, adapter,configurationNode)
 {
     m_parent  = parent;
 }
Exemplo n.º 53
0
 /// <summary>
 /// Create tabs on sidebar
 /// </summary>
 protected void LoadAreaButtons(ChoiceGroup group)
 {
     foreach (ChoiceRelatedClass tab in group)
     {
         //Debug.Assert(item is ChoiceBase, "Only things that can be made into buttons should be appearing here.");
         Debug.Assert(tab is ListPropertyChoice, "Only things that can be made into buttons should be appearing here.");
         MakeAreaButton((ListPropertyChoice)tab);
     }
 }
Exemplo n.º 54
0
 public ChoiceBase( Mediator mediator, IUIAdapter adapter, ChoiceGroup parent)
     : base(mediator, adapter,null)
 {
     m_parent  = parent;
 }
Exemplo n.º 55
0
        /// <summary>
        /// Populate a control to show, for example, the list of tools, or the list of filters.
        /// </summary>
        /// <param name="group"></param>
        protected void PopulateList(ChoiceGroup group)
        {
            bool wasSuspended = m_suspendEvents;
            m_suspendEvents = true;

            if(m_populatingList)
                return;

            m_populatingList=true;
            ListView list = (ListView) group.ReferenceWidget;
            //			if(list.Items.Count == group.Count)
            //				UpdateList(group);
            //			else
            {
                list.BeginUpdate();
                list.Clear();

                m_choiceGroupCache.Add(group); // cache group to defer adding it to the sidepane until we definitely have tabs already

                list.EndUpdate();
            }
            m_populatingList=false;
            m_suspendEvents = wasSuspended;
        }
Exemplo n.º 56
0
        /// <summary>
        /// find the matching list and list item referred to buy this note, and create a ListPropertyChoice
        /// to access that item. This is used in the special case where we want a toolbar button or two
        /// instead of showing every item in the list.
        /// </summary>
        /// <param name="mediator"></param>
        /// <param name="configurationNode"></param>
        /// <param name="adapter"></param>
        /// <returns></returns>
        public static StringPropertyChoice MakeListPropertyChoice(Mediator mediator,  XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
        {
            //string listId=XmlUtils.GetAttributeValue(configurationNode, "list", "");
            //			ListItem item = new ListItem();
            //			item.label = "xxxxxx";
            //			item.value = XmlUtils.GetAttributeValue(configurationNode, "value", "");
            //			item.imageName = XmlUtils.GetAttributeValue(configurationNode, "icon", "default");
            //item.parameterNode = parameterNode;

            return new StringPropertyChoice(mediator,configurationNode, adapter, parent);
            //			if(li!=null)
            //				return new ListPropertyChoice( mediator, li,  adapter,  parent);
            //			else
            //	throw new ConfigurationException ("Could not find the list item for '"+val+"' in a list with the id '"+listId+"'.",configurationNode);
        }
Exemplo n.º 57
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mediator"></param>
 /// <param name="listSet"></param>
 /// <param name="configurationNode"></param>
 /// <param name="adapter"></param>
 /// <param name="parent"></param>
 public CommandChoice( Mediator mediator,  XmlNode configurationNode, IUIAdapter adapter, ChoiceGroup parent)
     : base(mediator,  configurationNode, adapter, parent)
 {
     m_idOfCorrespondingCommand = XmlUtils.GetAttributeValue(m_configurationNode, "command");
     StringTable tbl = null;
     if (mediator != null && mediator.HasStringTable)
         tbl = mediator.StringTbl;
     m_defaultLabelOverride = XmlUtils.GetLocalizedAttributeValue(tbl,
         m_configurationNode, "label", null);
 }
Exemplo n.º 58
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="group">This provides more context for colleagues to know whether to add a command to a menu.
        /// colleagues who want to support short-cut keys should be able to handle <c>null</c>, apart from a context menu group.</param>
        /// <param name="mediator"></param>
        /// <param name="command"></param>
        /// <param name="defaultVisible"></param>
        /// <param name="label"></param>
        /// <returns></returns>
        private static UIItemDisplayProperties QueryDisplayProperties(ChoiceGroup group, Mediator mediator, Command command, bool defaultVisible, string label)
        {
            // Let the default be that it is enabled if we know that it has
            //at least one potential receiver, based on the method signatures of the
            //current set of colleagues.
            //If one of those colleagues thinks that it should be disabled at the moment,
            //then it needs to implement the corresponding Display method
            //and disable it from there.
            bool hasReceiver = mediator.HasReceiver(command.MessageString);
            UIItemDisplayProperties display = new UIItemDisplayProperties(group, label, hasReceiver, command.IconName, defaultVisible);

            //OK, this is a little non-obvious
            //first we allow anyone who knows about this specific command to influence how it is displayed
            //why was it this way?			m_mediator.SendMessage("Display"+this.m_idOfCorrespondingCommand, CommandObject, ref display);
            mediator.SendMessage("Display" + command.Id, command, ref display);

            //but then, we also allow anyone who knows about this specific message that would be sent
            //to control how it is displayed.  What's the difference?
            //Well, it is not uncommon for a single message, e.g. "InsertRecord", to be associated with
            //multiple commands, e.g. "CmdInsertPersonRecord", "CmdInsertCompanyRecord".
            //And in this case, there may not be any actual code which knows about one of these commands,
            //instead the code may be written to just listen  for the "InsertRecord" message and then act
            //upon its arguments which, in this example, would cause it to either insert a person or a company.
            mediator.SendMessage("Display" + command.MessageString, command, ref display);
            return display;
        }
Exemplo n.º 59
0
 //hack; just give it the first one
 /// <summary>
 /// Group made of multiple menus.
 /// </summary>
 /// <param name="mediator"></param>
 /// <param name="adapter"></param>
 /// <param name="configurationNodes"></param>
 /// <param name="parent"></param>
 public ChoiceGroup(Mediator mediator, IUIAdapter adapter, List<XmlNode> configurationNodes, ChoiceGroup parent)
     : base(mediator, adapter, configurationNodes[0])
 {
     m_parent = parent;
     m_configurationNodes = configurationNodes;
 }
Exemplo n.º 60
0
        /// <summary>
        /// Populate a menu.
        /// This is called by the OnDisplay() method of some ChoiceGroup
        /// </summary>
        /// <param name="group">The group that defines this menu item.</param>
        public override void CreateUIForChoiceGroup(ChoiceGroup group)
        {
            //m_control.SuspendLayout();//doesn't help

            ToolStripMenuItem  toolStripItem = group.ReferenceWidget as ToolStripMenuItem;
            toolStripItem.DropDown.Items.Clear();

            bool somethingVisibleAlready = false;
            bool wantsSeparatorBefore = false;
            foreach(ChoiceRelatedClass item in group)
            {
                if(item is SeparatorChoice)
                {
                    // don't just add one, we don't want it unless another visible item gets
                    // added, and one has already been added
                    wantsSeparatorBefore = somethingVisibleAlready;
                }
                else if(item is ChoiceBase)
                {
                    bool reallyVisible;
                    ToolStripItem newItem = (ToolStripItem)CreateMenuItem(item as ChoiceBase, out reallyVisible);
                    if (reallyVisible)
                    {
                        somethingVisibleAlready = true;
                        if (wantsSeparatorBefore)
                    {
                        wantsSeparatorBefore = false;
                        toolStripItem.DropDown.Items.Add(new ToolStripSeparator());
                    }
                    }
                    newItem.AccessibilityObject.Name = item.Id;

                    //newItem.GetType().Name;
                    toolStripItem.DropDown.Items.Add(newItem);
                    //toolStripItem.
                }
                else if(item is ChoiceGroup) // Submenu
                {
                    ChoiceGroup choiceGroup = (ChoiceGroup)item;
                    if (choiceGroup.IsSubmenu)
                    {
                        string label = item.Label.Replace("_", "&");
                        UIItemDisplayProperties display = choiceGroup.GetDisplayProperties();
                        if (display.Visible)
                        {
                            somethingVisibleAlready = true;
                            if (wantsSeparatorBefore)
                            {
                                wantsSeparatorBefore = false;
                                toolStripItem.DropDown.Items.Add(new ToolStripSeparator());
                            }
                        }
                        var submenu = new ToolStripMenuItem
                            {
                                Tag = item,
                                Text = label
                            };
                        submenu.AccessibilityObject.Name = item.Id;
                        // Have the submenu display characteristics behave as desired.  See FWR-3104.
                        submenu.Visible = display.Visible;
                        submenu.Enabled = display.Enabled;
                        //submenu.GetType().Name;
                        item.ReferenceWidget = submenu;

                        toolStripItem.DropDown.Items.Add(submenu);

                        if (display.Visible && display.Enabled)
                        {
                            choiceGroup.OnDisplay(m_window, null);
                        }

                    }
                    else if (choiceGroup.IsInlineChoiceList)
                    {
                        choiceGroup.PopulateNow();
                        foreach(ChoiceRelatedClass inlineItem in choiceGroup)
                        {
                            Debug.Assert(inlineItem is ChoiceBase, "It should not be possible for an in line choice list to contain anything other than simple items!");
                            bool reallyVisible;
                            ToolStripItem newItem = CreateMenuItem((ChoiceBase)inlineItem, out reallyVisible);
                            if (reallyVisible)
                            {
                                somethingVisibleAlready = true;
                                if (wantsSeparatorBefore)
                                {
                                    wantsSeparatorBefore = false;
                                    toolStripItem.DropDown.Items.Add(new ToolStripSeparator());
                                }
                            }
                            toolStripItem.DropDown.Items.Add(newItem);

                        }
                    }
                }
            }
            m_control.ResumeLayout();//doesn't help
        }