当前位置: 首页>>代码示例>>C#>>正文


C# XCore.ChoiceGroup类代码示例

本文整理汇总了C#中XCore.ChoiceGroup的典型用法代码示例。如果您正苦于以下问题:C# ChoiceGroup类的具体用法?C# ChoiceGroup怎么用?C# ChoiceGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ChoiceGroup类属于XCore命名空间,在下文中一共展示了ChoiceGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateComboBox

		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;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:35,代码来源:BarAdapterBase.cs

示例2: ChoiceGroup

        /// -----------------------------------------------------------------------------------
        /// <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);
            }
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:18,代码来源:ChoiceGroup.cs

示例3: MakeMenu

		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;
		}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:19,代码来源:MenuAdapter.cs

示例4: CreateUIForChoiceGroup

        /// <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);
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:34,代码来源:ToolbarAdapter.cs

示例5: Make

		/// <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);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:25,代码来源:Choice.cs

示例6: MakeTree

		/// <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);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:18,代码来源:SidebarAdapter.cs

示例7: PopulateList

        /// <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;
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:28,代码来源:NavBarAdapter.cs

示例8: LoadAreaButtons

 /// <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);
     }
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:12,代码来源:NavBarAdapter.cs

示例9: CreateUIForChoiceGroup

		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));
//						}
//					}

			}
*/			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:61,代码来源:ReBarAdapter.cs

示例10: ListPropertyChoice

        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;
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:11,代码来源:Choice.cs

示例11: CommandChoice

 /// <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);
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:18,代码来源:Choice.cs

示例12: ChoiceBase

 public ChoiceBase( Mediator mediator, IUIAdapter adapter, ChoiceGroup parent)
     : base(mediator, adapter,null)
 {
     m_parent  = parent;
 }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:5,代码来源:Choice.cs

示例13: CreateUIForChoiceGroup

		/// <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);
				}
			}
		}
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:23,代码来源:MenuAdapter.cs

示例14: FillToolbar

        /// <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;
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:65,代码来源:ToolbarAdapter.cs

示例15: DoesToolStripNeedRegenerating

        /// <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;
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:98,代码来源:ToolbarAdapter.cs


注:本文中的XCore.ChoiceGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。