本文整理汇总了C#中Shape.AddRow方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.AddRow方法的具体用法?C# Shape.AddRow怎么用?C# Shape.AddRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.AddRow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRightMouseAction
/// <summary>This method adds a right mouse action to a shape. The
/// right mouse action is added to the Actions section of the given
/// shape.</summary>
/// <param name="targetShape">Shape to add the action item to.</param>
/// <param name="menuCaption">Caption for the newly created menu item.
/// </param>
/// <param name="menuAction">Action to be taken when the menu item is
/// selected. This is a formula in universal syntax.</param>
/// <param name="menuEnabled">Initial enabled state of the menu item.
/// </param>
/// <param name="menuChecked">Initial checked state of the menu item.
/// </param>
/// <param name="beginGroup">display a divider bar above the command
/// in the menu.</param>
/// <param name="addToBottom">display the command at the bottom of the
/// menu.</param>
private static void AddRightMouseAction(Shape targetShape, string menuCaption, string menuAction,
bool menuEnabled, bool menuChecked, bool beginGroup, bool addToBottom)
{
const string DividerBarPrefix = "_";
const string AddToBottomPrefix = "%";
const string AcceleratorPrefix = "&";
if (menuCaption == null || targetShape == null)
return;
short actionRow;
short actionRows;
string taggedMenuCaption;
string rowCaption;
string cleanMenuCaption;
Cell actionCell;
try {
// the menuCaption string may need to be modified to include a
// tag that indicates the menu should be at the bottom, or
// should be preceeded by a separator line.
taggedMenuCaption = menuCaption;
if (taggedMenuCaption == null)
throw new ArgumentNullException("Menu caption is null");
// strip modifier tokens from the caption
cleanMenuCaption = menuCaption.Replace(AcceleratorPrefix, "");
// Check if the right menu action item already exists.
actionRows = targetShape.get_RowCount((short)VisSectionIndices.visSectionAction);
bool actionExists = false;
for (actionRow = 0; (actionExists == false) && (actionRow < actionRows); actionRow++) {
actionCell = targetShape.get_CellsSRC((short)VisSectionIndices.visSectionAction,
(short)(VisRowIndices.visRowAction + actionRow),
(short)VisCellIndices.visActionMenu);
rowCaption = Common.FormulaStringToString(actionCell.FormulaU);
// strip modifier tokens from the caption before compare
rowCaption = rowCaption.Replace(DividerBarPrefix, "");
rowCaption = rowCaption.Replace(AddToBottomPrefix, "");
rowCaption = rowCaption.Replace(AcceleratorPrefix, "");
if (rowCaption == cleanMenuCaption)
actionExists = true;
}
if (actionExists == false) {
// prefix underscore (_) to the caption to add a separator
// line above it.
if (beginGroup == true && taggedMenuCaption != null)
taggedMenuCaption = taggedMenuCaption.Insert(0, DividerBarPrefix);
// prefix percent (%) to the caption to add it to the
// bottom of the menu.
if (addToBottom == true)
taggedMenuCaption = taggedMenuCaption.Insert(0, AddToBottomPrefix);
// Add a new action row to the shape.
actionRow = targetShape.AddRow((short)VisSectionIndices.visSectionAction,
(short)VisRowIndices.visRowLast,
(short)VisRowIndices.visRowAction);
// Set the menu caption.
actionCell = targetShape.get_CellsSRC((short)VisSectionIndices.visSectionAction,
actionRow,
(short)VisCellIndices.visActionMenu);
actionCell.FormulaU = Common.StringToFormulaForString(taggedMenuCaption);
// Set the action for the menu item.
actionCell = targetShape.get_CellsSRC((short)VisSectionIndices.visSectionAction,
actionRow,
(short)VisCellIndices.visActionAction);
actionCell.FormulaU = menuAction;
// Set the menu item's enabled/disabled state.
actionCell = targetShape.get_CellsSRC((short)VisSectionIndices.visSectionAction,
actionRow,
(short)VisCellIndices.visActionDisabled);
actionCell.set_ResultFromInt(VisUnitCodes.visNumber,
Convert.ToInt32(!menuEnabled, System.Globalization.CultureInfo.InvariantCulture));
//.........这里部分代码省略.........