/// <summary>
		/// decide whether to enable this tree delete Menu Item
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public override bool OnDisplayDataTreeMerge(object commandObject, ref UIItemDisplayProperties display)
		{
			display.Enabled = CanMergeOrMove;
			if(!display.Enabled)
				display.Text += StringTbl.GetString("(cannot merge this)");

			return true;//we handled this, no need to ask anyone else.
		}
Example #2
0
        public bool OnDisplayContextSetOccurrence(object commandObject, ref XCore.UIItemDisplayProperties display)
        {
            CheckDisposed();
            bool enable = RegRuleFormulaControl.CanModifyContextOccurrence;

            display.Enabled = enable;
            display.Visible = enable;
            return(true);
        }
Example #3
0
        public virtual bool OnDisplayContextJumpToPhoneme(object commandObject, ref XCore.UIItemDisplayProperties display)
        {
            CheckDisposed();
            bool enable = RuleFormulaControl.IsPhonemeContextCurrent;

            display.Enabled = enable;
            display.Visible = enable;
            return(true);
        }
		/// <summary>
		/// This menu item is turned off if a slash already exists in the environment string.
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayShowEnvironmentError(object commandObject,
			ref UIItemDisplayProperties display)
		{
			CheckDisposed();
			StringRepSliceView view = Control as StringRepSliceView;
			if (view == null)
				return false;
			display.Enabled = view.CanShowEnvironmentError();
			return true;
		}
Example #5
0
 public void DoDisplayMacro_NoMacro_HidesCommand()
 {
     var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false);
     var ml = new MacroListener();
     using (var command = GetF4CommandObject())
     {
         ml.DoDisplayMacro(command, props, null);
         Assert.That(props.Visible, Is.False); // no implementation of F4, hide it altogether.
     }
 }
Example #6
0
 protected override bool ShouldDisplayMenuForClass(uint specifiedClsid,
                                                   XCore.UIItemDisplayProperties display)
 {
     if (LexEntry.kClassId == specifiedClsid)
     {
         return(true);
     }
     else                // the else clause here may be superflous...
     {
         return(base.ShouldDisplayMenuForClass(specifiedClsid, display));
     }
 }
Example #7
0
 public void DoDisplayMacro_NoSelection_ShowsDisabledCommand()
 {
     var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false);
     var ml = new MacroListener();
     SetupF4Implementation(ml);
     using (var command = GetF4CommandObject())
     {
         ml.DoDisplayMacro(command, props, null);
         Assert.That(props.Visible, Is.True);
         Assert.That(props.Enabled, Is.False); // can't do it without a selection
         Assert.That(props.Text, Is.EqualTo("F4test"));
     }
 }
Example #8
0
		/// <summary>
		/// decide whether to display this tree insert Menu Item
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public override bool OnDisplayDataTreeInsert(object commandObject, ref UIItemDisplayProperties display)
		{
			Slice slice = m_dataEntryForm.CurrentSlice;
			if (slice == null && m_dataEntryForm.Controls.Count > 0)
				slice = m_dataEntryForm.FieldAt(0);
			if (slice == null
				|| (m_dataEntryForm.Mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk).ListSize == 0)
			{
				// don't display the datatree menu/toolbar items when we don't have a data tree slice.
				display.Visible = false;
				display.Enabled = false;
				return true;
			}

			base.OnDisplayDataTreeInsert(commandObject, ref display);

			if (!(slice.Object is LexEntry) && !(slice.ContainingDataTree.Root is LexEntry))
				return false;
			FDO.Ling.LexEntry entry = slice.Object as LexEntry;
			if (entry == null)
				entry = slice.ContainingDataTree.Root as LexEntry;
			XCore.Command command = (XCore.Command)commandObject;

			if (command.Id.EndsWith("AffixProcess"))
			{
				bool enable = MoMorphType.IsAffixType(entry.MorphType);
				display.Enabled = enable;
				display.Visible = enable;
				return true;
			}

			//if there aren't any alternate forms, go ahead and let the user choose either kind
			if (entry.AlternateFormsOS.Count==0)
				return true;

			if (command.Id.EndsWith("AffixAllomorph"))
			{
				if (!(entry.AlternateFormsOS.FirstItem is MoAffixAllomorph))
					display.Visible = false;
				return true;
			}

			if (command.Id.EndsWith("StemAllomorph"))
			{
				if (!(entry.AlternateFormsOS.FirstItem is MoStemAllomorph))
					display.Visible = false;
				return true;
			}

			return true;//we handled this, no need to ask anyone else.
		}
Example #9
0
		/// <summary>
		/// handle the message to see if the menu item should be enabled
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayMoveReversalPOS(object commandObject,
			ref UIItemDisplayProperties display)
		{
			Slice slice = m_dataEntryForm.CurrentSlice;
			if (slice == null || slice.Object == null)
			{
				display.Enabled = false;
			}
			else
			{
				display.Enabled = CanMergeOrMove;
				display.Visible = InFriendlyArea;
			}
			if(!display.Enabled)
				display.Text += StringTbl.GetString("(cannot move this)");
			return true; //we've handled this
		}
Example #10
0
		public bool OnDisplayLexiconLookup(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Visible = true;
			display.Enabled = false;
			// Enable the command if the selection exists and we actually have a word.
			int ichMin;
			int ichLim;
			int hvo;
			int tag;
			int ws;
			ITsString tss;
			GetWordLimitsOfSelection(out ichMin, out ichLim, out hvo, out tag, out ws, out tss);
			if (ichLim > ichMin)
				display.Enabled = true;
			return true;
		}
Example #11
0
        /// <summary>
        /// Override to handle case of improper menu in the reversal cat list tool.
        /// </summary>
        /// <param name="commandObject"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public override bool OnDisplayJumpToTool(object commandObject, ref XCore.UIItemDisplayProperties display)
        {
            CheckDisposed();

            XCore.Command command    = (XCore.Command)commandObject;
            string        tool       = SIL.Utils.XmlUtils.GetManditoryAttributeValue(command.Parameters[0], "tool");
            string        toolChoice = m_mediator.PropertyTable.GetStringProperty("currentContentControl", null);

            if (tool == "posEdit" && toolChoice == "reversalToolReversalIndexPOS")
            {
                display.Visible = display.Enabled = false;                 // we're already there!
                return(true);
            }
            else
            {
                return(base.OnDisplayJumpToTool(commandObject, ref display));
            }
        }
Example #12
0
        public void DoDisplayMacro_WithSafeToDo_ResultDependsOnMacro()
        {
            var props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false);
            var ml = MakeMacroListenerWithCache();
            var macro = SetupF4Implementation(ml);
            var entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create();
            var sel = GetValidMockSelection(entry);
            using (var command = GetF4CommandObject())
            {
                ml.DoDisplayMacro(command, props, sel);
                Assert.That(props.Visible, Is.True);
                Assert.That(props.Enabled, Is.True);
                Assert.That(props.Text, Is.EqualTo("F4test"));

                props = new UIItemDisplayProperties(null, "SomeMacro", true, null, false);
                macro.BeEnabled = false;
                ml.DoDisplayMacro(command, props, sel);
                Assert.That(props.Visible, Is.True);
                Assert.That(props.Enabled, Is.False); // can't do it if the macro says no good.
                Assert.That(props.Text, Is.EqualTo("F4test"));
            }
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Disables/enables the Edit/Redo menu item
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns><c>true</c></returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnDisplayRedo(object commandObject, ref UIItemDisplayProperties display)
		{
			if (m_silCache.GetActionHandler().CanRedo())
			{
				display.Enabled = true;
				return true;
			}
			return false; // we don't want to handle the command.
		}
Example #14
0
		/// <summary>
		/// Enable the spelling tool always. Correct the property value if need be to match whether
		/// we are actually showing vernacular spelling.
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayUseVernSpellingDictionary(object commandObject,
			ref UIItemDisplayProperties display)
		{
			CheckDisposed();

			display.Enabled = display.Visible = Cache != null;
			if (Cache == null)
				return true;
			display.Checked = IsVernacularSpellingEnabled();
			return true; //we've handled this
		}
Example #15
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);
        }
Example #16
0
        // The body of OnDisplayMacro is isolated so we don't have to fake all the objects needed to get the (typically mock) selection in testing.
        internal bool DoDisplayMacro(object commandObject, UIItemDisplayProperties display, IVwSelection sel)
        {
            var macro = GetMacro(commandObject);
            int ichA, hvoA, flid, ws, ichE, start, length;
            ICmObject obj;
            if (macro == null)
            {
                display.Enabled = display.Visible = false;
                return true;
            }
            display.Visible = true;
            display.Text = macro.CommandName;
            if (!SafeToDoMacro(sel, out obj, out flid, out ws, out start, out length))
            {
                display.Enabled = false;
                return true;
            }
            display.Enabled = macro.Enabled(obj, flid, ws, start, length);

            return true;
        }
Example #17
0
		//

		public virtual bool OnDisplayAddApprovedAnalysis(object commandObject,
			ref UIItemDisplayProperties display)
		{
			// The null test covers cases where there is no current object because the list (as filtered) is empty.
			if (InFriendlyArea && m_mediator != null && m_dataEntryForm.Root != null)
			{
#pragma warning disable 0219
				FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
				display.Visible = true;
				display.Enabled = Wordform != null;
#pragma warning restore 0219
			}
			else
			{
				display.Enabled = display.Visible = false;
			}
			return true; //we've handled this
		}
Example #18
0
		public virtual bool OnDisplayEditPaste(object commandObject,
			ref UIItemDisplayProperties display)
		{
			Focus();
			display.Enabled = m_root.CanPaste();
			return true;
		}
Example #19
0
        /// <summary>
        /// see if it makes sense to display a menu controlling the "ShowRecordList" property
        /// </summary>
        /// <param name="commandObject">The command object.</param>
        /// <param name="display">The display.</param>
        /// <returns></returns>
        public bool OnDisplayShowTreeBar(object commandObject, ref UIItemDisplayProperties display)
        {
            CheckDisposed();

            display.Enabled = false;
            return true;//we handled this, no need to ask anyone else.
        }
Example #20
0
        private void SetLabel()
        {
            XCore.ChoiceRelatedClass choice  = (XCore.ChoiceRelatedClass) this.Tag;
            UIItemDisplayProperties  display = choice.GetDisplayProperties();

            const int checkBoxWidth = 17;
            string    s             = display.Text.Replace("_", "&");

            this.Text = s;

            using (Graphics g = this.CreateGraphics())
            {
                int labelWidth = (int)(g.MeasureString(s + "_", this.Font).Width);
                this.Width = labelWidth;
            }

            // Simulate a mouse enter or leave event to get the correct highlighting
            if (mouseOverControl)
            {
                this.panelButton_MouseEnter(null, null);
            }
            else
            {
                this.panelButton_MouseLeave(null, null);
            }

            this.Controls.Clear();             // Clear out any previous checkboxes and images

            // Add in a checkbox that reflects the "checked" status of the button
            CheckBox checkBox = new CheckBox();

            checkBox.Checked     = display.Checked;
            checkBox.Click      += new EventHandler(PanelButton_Click);
            checkBox.Location    = new Point(0, 0);
            checkBox.Anchor      = System.Windows.Forms.AnchorStyles.Left;
            checkBox.Dock        = System.Windows.Forms.DockStyle.Left;
            checkBox.Width       = checkBoxWidth;
            checkBox.MouseEnter += new EventHandler(panelButton_MouseEnter);
            checkBox.MouseLeave += new EventHandler(panelButton_MouseLeave);
            checkBox.MouseDown  += new MouseEventHandler(panelButton_MouseDown);
            checkBox.BackColor   = Color.Transparent;
            this.Controls.Add(checkBox);

            this.Width += checkBox.Width;


            if (display.ImageLabel != null && display.ImageLabel != "" && display.ImageLabel != "default")
            {
                PanelEx p = new PanelEx();
                Image   i = m_images.GetImage(display.ImageLabel);
                p.BackgroundImage       = i;
                p.BackgroundImageLayout = ImageLayout.Center;
                p.Location  = new Point(checkBox.Width, 0);
                p.Anchor    = System.Windows.Forms.AnchorStyles.Left;
                p.Dock      = System.Windows.Forms.DockStyle.None;
                p.Size      = new Size(17, this.Height);
                this.Width += p.Size.Width;
                this.Controls.Add(p);
                p.Click      += new EventHandler(PanelButton_Click);
                p.MouseEnter += new EventHandler(panelButton_MouseEnter);
                p.MouseLeave += new EventHandler(panelButton_MouseLeave);
                p.MouseDown  += new MouseEventHandler(panelButton_MouseDown);
            }
            this.Refresh();
        }
Example #21
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);
        }
        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);
        }
Example #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);
        }
        /// <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);
        }
        /// <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();
        }
Example #26
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();
        }
Example #27
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

            ButtonItem menu = (ButtonItem)group.ReferenceWidget;

            if (menu.SubItems.Count > 0)
            {
                Debug.WriteLine("CreateUIForChoiceGroup " + group.Label);
            }

            menu.SubItems.Clear();
            bool wantsSeparatorBefore = false;

            foreach (ChoiceRelatedClass item in group)
            {
                if (item is SeparatorChoice)
                {
                    wantsSeparatorBefore = true;
                }
                else if (item is ChoiceBase)
                {
                    menu.SubItems.Add(CreateButtonItem((ChoiceBase)item, wantsSeparatorBefore));
                    wantsSeparatorBefore = false;
                }
                else if (item is ChoiceGroup)                // Submenu
                {
                    ChoiceGroup choiceGroup = (ChoiceGroup)item;
                    if (choiceGroup.IsSubmenu)
                    {
                        UIItemDisplayProperties display = choiceGroup.GetDisplayProperties();

                        string     label   = item.Label.Replace("_", "&");
                        ButtonItem submenu = new ButtonItem(item.Id, label);
                        submenu.BeginGroup   = wantsSeparatorBefore;
                        wantsSeparatorBefore = false;
                        menu.SubItems.Add(submenu);
                        submenu.Tag          = item;
                        item.ReferenceWidget = submenu;
                        submenu.Visible      = display.Visible;
                        if (display.Visible)
                        {
                            // Can be visible and either enabled or disabled.
                            submenu.Enabled = display.Enabled;
                            if (display.Enabled)
                            {
                                //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 REVIEW: would it be better to just disable?
                                //submenu.Visible = submenu.SubItems.Count > 0;
                            }
                            else                                //if we don't have *any* items, it won't look like a submenu
                            {
                                submenu.SubItems.Add(new DevComponents.DotNetBar.ButtonItem("dummy", "dummy"));
                            }
                        }
                        else
                        {
                            submenu.Enabled = false;                             // Not visible, so no need for it to be enabled.
                        }
                        //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.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!");
                            menu.SubItems.Add(CreateButtonItem((ChoiceBase)inlineItem, false));
                        }
                    }
                    else
                    {
                        throw new ApplicationException("Unknown kind of ChoiceGroup.");
                    }
                }
                else
                {
                    throw new ApplicationException("Unknown kind of ChoiceRelatedClass.");
                }
            }

            m_control.ResumeLayout();            //doesn't help
        }
Example #28
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;
        }
Example #29
0
		protected void UpdateDisplay(UIItemDisplayProperties display, CommandBarButton button)
		{
			//can't change text after button is created
			button.IsEnabled = display.Enabled;
/*
 * I started on this so that property-related toolbar buttons could somehow looked depressed when
 * the property that they set equalled the value they set, i.e. in the "checked" state.
 * I gave up because
 * 1) there's no way to tell the CommandBar manager to draw it differently others and changing the icon
 * 2) it would be a pain to define or create different icons, though it would be possible
 * 3) when you change the icon, the CommandBar manager does not bother to repaint it
 * 4) so the way I found to repay was to actually tell the CommandBar manager to refresh
 *		the entire view, which caused a visible flicker.
 * 5) so I am giving up for now.
 *
 * 	if(display.Checked)
			{
				button.Image =m_smallImages.GetImage("Pie");
				//m_commandBarManager. Style=this.Style;//goose it
			}
			else
				button.Image  =m_smallImages.GetImage(display.ImageLabel);

			m_commandBarManager.Refresh();
*/		}
Example #30
0
        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
                        };
                        if (display.ImageLabel != "default")
                        {
                            submenu.Image = m_smallImages.GetImage(display.ImageLabel);
                        }
                        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
        }
Example #31
0
        public bool OnDisplayExport(object commandObject,
			ref UIItemDisplayProperties display)
        {
            display.Enabled = display.Visible = true;
            return true;
        }
Example #32
0
        /// <summary>
        /// populate a combo box on the toolbar
        /// </summary>
        /// <param name="group">The group that is the basis for this combo box.</param>
        private void FillCombo(ChoiceGroup group)
        {
            UIItemDisplayProperties groupDisplay = group.GetDisplayProperties();

#if USE_DOTNETBAR
            ComboBoxItem combo = group.ReferenceWidget as ComboBoxItem;
            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;
            ComboItem selectedItem = null;
            foreach (ChoiceRelatedClass item in group)
            {
                if (item is SeparatorChoice)
                {
                    //TODO
                }
                else if (item is ChoiceBase)
                {
                    UIItemDisplayProperties display = ((ChoiceBase)item).GetDisplayProperties();
                    ComboItem ci = CreateComboItem((ChoiceBase)item, display);
                    if (ci != null)                    //will be null if item is supposed to be invisible now
                    {
                        newItems.Add(ci);
                        if (display.Checked)
                        {
                            selectedItem = ci;                             //nb: if there should be more than one, only the last one will be selected
                        }
                        if (combo.Items.Count < newItems.Count || ((combo.Items[newItems.Count - 1]) as ComboItem).Tag != item)
                        {
                            fDifferent = true;
                        }
                    }
                }
            }

            combo.AccessibleName = group.Label;
            if (fDifferent || selectedItem.Tag != (combo.SelectedItem as ComboItem).Tag)
            {
                combo.SuspendLayout = true;
                combo.Click        -= new EventHandler(OnComboClick);           //don't generate clicks (which end up being onpropertychanged() calls)
                combo.Items.Clear();
                combo.Items.AddRange(newItems.ToArray());
                combo.SelectedItem  = selectedItem;
                combo.Click        += new EventHandler(OnComboClick);
                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();
#endif
        }
Example #33
0
 /// <summary>
 /// Invoked by reflection when displaying the appropriate menu item. Which one is indicated by the paramters node.
 /// This method is responsible to decide whether to display the command, whether to enable it, and what the text of the menu
 /// item should be.
 /// </summary>
 /// <param name="commandObject"></param>
 /// <param name="display"></param>
 /// <returns>true (always) to indicate that we handled this command</returns>
 public bool OnDisplayMacro(object commandObject, ref UIItemDisplayProperties display)
 {
     return DoDisplayMacro(commandObject, display, GetSelection());
 }
Example #34
0
		public bool OnDisplayViewIncorrectWords(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Enabled = display.Visible = InFriendlyArea;
			return true; //we've handled this
		}
Example #35
0
		/// <summary>
		/// Called (by xcore) to control display params of the writing system menu, e.g. whether it should be enabled
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayWritingSystemHvo(object commandObject, ref UIItemDisplayProperties display)
		{
			CheckDisposed();

			display.Enabled = false;

			return false;//we get called before the rootsite, so let them have a say.
		}
Example #36
0
		/// <summary>
		///
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayJumpToTool(object commandObject, ref UIItemDisplayProperties display)
		{
			var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
			var cmd = (Command)commandObject;
			var className = XmlUtils.GetManditoryAttributeValue(cmd.Parameters[0], "className");
			var specifiedClsid = 0;
			if ((cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged).ClassExists(className))
				specifiedClsid = cache.MetaDataCacheAccessor.GetClassId(className);
			var anal = Analysis;
			if (anal != null)
			{
				if (anal.ClassID == specifiedClsid)
				{
					display.Enabled = display.Visible = true;
					return true;
				}

				if (specifiedClsid == WfiGlossTags.kClassId)
				{
					if (m_dataEntryForm != null && m_dataEntryForm.CurrentSlice != null &&
						CurrentSliceObject != null && CurrentSliceObject.ClassID == specifiedClsid)
					{
						display.Enabled = display.Visible = true;
						return true;
					}
				}
			}
			return false;
		}
Example #37
0
		/// <summary>
		///
		/// </summary>
		/// <param name="commandObject"></param>
		/// <param name="display"></param>
		/// <returns></returns>
		public virtual bool OnDisplayMergeWordform(object commandObject,
			ref UIItemDisplayProperties display)
		{
			CheckDisposed();

			display.Enabled = display.Visible = InFriendlyArea;
			return true; //we've handled this
		}
Example #38
0
		public virtual bool OnDisplaySpellingStatusDisapprove(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Enabled = display.Visible = InFriendlyArea;
			return true; //we've handled this
		}
Example #39
0
		public virtual bool OnDisplayGotoWfiWordform(object commandObject,
			ref UIItemDisplayProperties display)
		{
			CheckDisposed();

			if (InFriendlyArea && m_mediator != null)
			{
				var clrk = m_mediator.PropertyTable.GetValue("ActiveClerk") as RecordClerk;
				if (clrk != null && !clrk.IsDisposed && clrk.Id == "concordanceWords")
				{
					display.Visible = true;

					// we only want to enable if we have more than one, because there's no point in finding
					// the one we've already selected.
					display.Enabled = m_wordformRepos.Count > 1;
					return true;
				}
			}
			// Unless everything lines up to make the command workable disable it.
			display.Enabled = display.Visible = false;
			return true; //we've handled this
		}
Example #40
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 (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 (displayProperties.Text.Replace("_", "&") != toolStripItem.Text)
                {
                    return(true);
                }

                counter++;
            }

            // nothing has been detected that needs changing.
            return(false);
        }
Example #41
0
		public virtual bool OnDisplayShowHumanApprovedAnalysisConc(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Enabled = display.Visible = InFriendlyArea;
			return true; //we've handled this
		}
Example #42
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;
        }
Example #43
0
		public virtual bool OnDisplayAnalysisDisapprove(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Enabled = display.Visible = InFriendlyArea;
			display.Checked = Analysis.ApprovalStatusIcon == 2;
			return true; //we've handled this
		}
Example #44
0
        public override UIItemDisplayProperties GetDisplayProperties()
        {
            UIItemDisplayProperties display =new UIItemDisplayProperties(m_parent, this.Label, this.Enabled, ImageName, this.m_defaultVisible);
            display.Checked = this.Checked;

            //
            //			//TODO: do some polling (not clear what we want to do...
            //			// may be structure the name based on the name of the property value,
            //			//but then get the specific list item into the parameters somehow?
            //
            //			//unlike the command parameters, we can go ahead and allow these
            //			//to be enabled and they will work just fine.  So, until we ran into a situation
            //			//where we need to disable some of these, let's just let them always be enabled.
            //
            //			//when we run into a case where we need to control them, then it should be clear
            //			//how to deal with this.
            //			display.Checked = Checked;
            //
            return display;
        }
Example #45
0
		public virtual bool OnDisplayWordformChangeCase(object commandObject,
			ref UIItemDisplayProperties display)
		{
			display.Enabled = display.Visible = InFriendlyArea;
			return true; //we've handled this
		}
Example #46
0
        /// <summary>
        /// allow a colleague to enable or disabled this item
        /// </summary>
        /// <returns></returns>
        public override UIItemDisplayProperties GetDisplayProperties()
        {
            UIItemDisplayProperties display =new UIItemDisplayProperties(m_parent, this.Label, true, ImageName, this.m_defaultVisible);
            display.Checked = this.Checked;
            m_mediator.SendMessage("Display"+this.PropertyName, null, ref display);

            return display;
        }
		/// <summary>
		/// Enable the 'insert word glosses' command
		/// </summary>
		/// <param name="commandObject">The command object.</param>
		/// <param name="display">The display properties.</param>
		/// <returns>true if this command is enabled</returns>
		public bool OnDisplayAddWordGlossesToFreeTrans(object commandObject, ref UIItemDisplayProperties display)
		{
			ISegment dummy1;
			int dummy2;
			display.Visible = display.Enabled = CanAddWordGlosses(out dummy1, out dummy2);
			return true;
		}
Example #48
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));
 * //						}
 * //					}
 *
 *                      }
 */         }
        }