本文整理汇总了C#中InsertPosition类的典型用法代码示例。如果您正苦于以下问题:C# InsertPosition类的具体用法?C# InsertPosition怎么用?C# InsertPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InsertPosition类属于命名空间,在下文中一共展示了InsertPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAnchorablePane
private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation,
string paneName, InsertPosition position)
{
var layoutPanels = layout.Descendents().OfType<LayoutPanel>().ToArray();
var parent = layoutPanels.FirstOrDefault(d => d != null && d.Orientation == orientation);
if (parent == null)
{
parent = layoutPanels.FirstOrDefault();
position = InsertPosition.Start;
}
var toolsPane = new LayoutAnchorablePane { Name = paneName };
if (parent != null)
{
if (position == InsertPosition.Start)
parent.InsertChildAt(0, toolsPane);
else
parent.Children.Add(toolsPane);
}
else
{
var layoutAnchorableFloatingWindow = new LayoutAnchorableFloatingWindow();
toolsPane.Parent = layoutAnchorableFloatingWindow;
}
return toolsPane;
}
示例2: InsertWithCursor
public override Task InsertWithCursor (string operation, InsertPosition defaultPosition, IEnumerable<AstNode> nodes)
{
var tcs = new TaskCompletionSource<object> ();
var editor = document.Editor;
DocumentLocation loc = document.Editor.Caret.Location;
var declaringType = document.ParsedDocument.GetInnermostTypeDefinition (loc);
var mode = new InsertionCursorEditMode (
editor.Parent,
CodeGenerationService.GetInsertionPoints (document, declaringType));
if (mode.InsertionPoints.Count == 0) {
MessageService.ShowError (
GettextCatalog.GetString ("No valid insertion point can be found in type '{0}'.", declaringType.Name)
);
return tcs.Task;
}
var helpWindow = new Mono.TextEditor.PopupWindow.InsertionCursorLayoutModeHelpWindow ();
helpWindow.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
helpWindow.TitleText = operation;
mode.HelpWindow = helpWindow;
switch (defaultPosition) {
case InsertPosition.Start:
mode.CurIndex = 0;
break;
case InsertPosition.End:
mode.CurIndex = mode.InsertionPoints.Count - 1;
break;
case InsertPosition.Before:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location < loc)
mode.CurIndex = i;
}
break;
case InsertPosition.After:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location > loc) {
mode.CurIndex = i;
break;
}
}
break;
}
operationsRunning++;
mode.StartMode ();
mode.Exited += delegate(object s, InsertionCursorEventArgs iCArgs) {
if (iCArgs.Success) {
foreach (var node in nodes.Reverse ()) {
var output = OutputNode (CodeGenerationService.CalculateBodyIndentLevel (declaringType), node);
var offset = document.Editor.LocationToOffset (iCArgs.InsertionPoint.Location);
var delta = iCArgs.InsertionPoint.Insert (editor, output.Text);
output.RegisterTrackedSegments (this, delta + offset);
}
tcs.SetResult (null);
} else {
Rollback ();
}
DisposeOnClose ();
};
return tcs.Task;
}
示例3: InsertWithCursor
public override Task InsertWithCursor(string operation, InsertPosition defaultPosition, IEnumerable<AstNode> nodes)
{
var entity = _context.GetNode<EntityDeclaration>();
foreach (var node in nodes)
{
InsertBefore(entity, node);
}
var tcs = new TaskCompletionSource<object>();
tcs.SetResult(null);
return tcs.Task;
}
示例4: InsertWithCursor
public override Task<Script> InsertWithCursor(string operation, InsertPosition defaultPosition, IList<AstNode> nodes)
{
EntityDeclaration entity = _context.GetNode<EntityDeclaration>();
if (entity is Accessor) {
entity = (EntityDeclaration) entity.Parent;
}
foreach (var node in nodes) {
InsertBefore(entity, node);
}
var tcs = new TaskCompletionSource<Script> ();
tcs.SetResult (this);
return tcs.Task;
}
示例5: InsertWithCursor
public override Task<Script> InsertWithCursor(string operation, InsertPosition defaultPosition, IList<AstNode> nodes)
{
// TODO : Use undo group
var tcs = new TaskCompletionSource<Script>();
var loc = editor.Caret.Location;
var currentPart = context.UnresolvedFile.GetInnermostTypeDefinition(loc);
var insertionPoints = InsertionPoint.GetInsertionPoints(editor.Document, currentPart);
if (insertionPoints.Count == 0) {
SD.MessageService.ShowErrorFormatted("No valid insertion point can be found in type '{0}'.", currentPart.Name);
return tcs.Task;
}
TextArea area = editor.GetService<TextArea>();
if (area == null) return tcs.Task;
var layer = new InsertionCursorLayer(area, operation, insertionPoints);
switch (defaultPosition) {
case InsertPosition.Start:
layer.CurrentInsertionPoint = 0;
break;
case InsertPosition.End:
layer.CurrentInsertionPoint = insertionPoints.Count - 1;
break;
case InsertPosition.Before:
for (int i = 0; i < insertionPoints.Count; i++) {
if (insertionPoints[i].Location < loc)
layer.CurrentInsertionPoint = i;
}
break;
case InsertPosition.After:
for (int i = 0; i < insertionPoints.Count; i++) {
if (insertionPoints[i].Location > loc) {
layer.CurrentInsertionPoint = i;
break;
}
}
break;
}
operationsRunning++;
InsertWithCursorOnLayer(this, layer, tcs, nodes, editor.Document);
return tcs.Task;
}
示例6: InsertWithCursor
public override void InsertWithCursor (string operation, AstNode node, InsertPosition defaultPosition)
{
var editor = document.Editor;
DocumentLocation loc = document.Editor.Caret.Location;
var mode = new InsertionCursorEditMode (editor.Parent, CodeGenerationService.GetInsertionPoints (document, document.ParsedDocument.GetInnermostTypeDefinition (loc)));
var helpWindow = new Mono.TextEditor.PopupWindow.InsertionCursorLayoutModeHelpWindow ();
helpWindow.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
helpWindow.TitleText = operation;
mode.HelpWindow = helpWindow;
switch (defaultPosition) {
case InsertPosition.Start:
mode.CurIndex = 0;
break;
case InsertPosition.End:
mode.CurIndex = mode.InsertionPoints.Count - 1;
break;
case InsertPosition.Before:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location < loc)
mode.CurIndex = i;
}
break;
case InsertPosition.After:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location > loc) {
mode.CurIndex = i;
break;
}
}
break;
}
mode.StartMode ();
mode.Exited += delegate(object s, InsertionCursorEventArgs iCArgs) {
if (iCArgs.Success) {
var output = OutputNode (CodeGenerationService.CalculateBodyIndentLevel (document.ParsedDocument.GetInnermostTypeDefinition (loc)), node);
output.RegisterTrackedSegments (this, document.Editor.LocationToOffset (iCArgs.InsertionPoint.Location));
iCArgs.InsertionPoint.Insert (editor, output.Text);
}
};
}
示例7: Initialize
// Returns false if the given insertion is illegal
public bool Initialize(XmlTreeNode n, InsertPosition position, XmlNodeType type)
{
this.position = position;
this.type = type;
XmlNode xn = null;
this.newNode.NodeType = type;
if (n != null) {
this.parent = new TreeParent(view, doc, n);
xn = n.Node;
} else {
position = InsertPosition.Child; ;
xn = view.Model.Document;
this.parent = new TreeParent(view.TreeView, view.Model.Document);
}
bool result = CanInsertNode(position, type, xn);
if (result) {
if (position == InsertPosition.Child) {
if (xn != null) parent.SetParent(n);
pos = parent.AttributeCount;
if (type != XmlNodeType.Attribute)
pos += parent.ChildCount;
} else {
if (type == XmlNodeType.Attribute ^ xn is XmlAttribute) {
pos = this.parent.AttributeCount;
this.position = InsertPosition.Before;
} else if (n != null) {
pos = n.Index;
}
}
}
return result;
}
示例8: InsertNode
/// <summary>
/// Insert an existing XmlNode into the tree and create a corresponding XmlTreeNode for it.
/// </summary>
/// <param name="target">Anchor point for insertion</param>
/// <param name="position">Where to insert the new node relative to target node</param>
/// <param name="xnode">Provided XmlNode that the new XmlTreeNode will wrap</param>
/// <param name="selectNewNode">Whether to select the node in the tree after it's inserted.</param>
public InsertNode(XmlTreeNode target, InsertPosition position, XmlNode xnode, bool selectNewNode, bool expandNewNode)
{
this.view = target.XmlTreeView;
this.doc = this.view.Model.Document;
this.position = position;
this.type = xnode.NodeType;
this.newNode = new XmlTreeNode(this.view, xnode);
Initialize(newNode, target, position);
this.selectNewNode = selectNewNode;
this.expandNewNode = expandNewNode;
}
示例9: AddVideoWithAudio
public IAudioVideoClipPair AddVideoWithAudio(string fileName, InsertPosition position, double offset,
double clipStart, double clipEnd, bool shadowCopyAudio)
{
return AddVideoWithAudio(null, fileName, position, offset, clipStart, clipEnd, shadowCopyAudio);
}
示例10: Insert
public void Insert(int i, InsertPosition position, XmlNode n)
{
if (n == null) return;
if (n.NodeType == XmlNodeType.Attribute) {
Debug.Assert(this.xparent is XmlElement);
XmlElement pe = (XmlElement)this.xparent;
if (pe.Attributes != null){
XmlNode already = pe.Attributes.GetNamedItem(n.LocalName, n.NamespaceURI);
if (already != null){
throw new ApplicationException(SR.DuplicateAttribute);
}
}
if (pe.Attributes != null && i < pe.Attributes.Count) {
XmlAttribute refNode = this.xparent.Attributes[i];
if (position == InsertPosition.After){
pe.Attributes.InsertAfter((XmlAttribute)n, refNode);
} else {
pe.Attributes.InsertBefore((XmlAttribute)n, refNode);
}
} else {
pe.Attributes.Append((XmlAttribute)n);
}
} else {
i -= this.AttributeCount;
if (this.xparent.HasChildNodes && i < this.xparent.ChildNodes.Count) {
XmlNode refNode = this.xparent.ChildNodes[i];
if (position == InsertPosition.After) {
this.xparent.InsertAfter(n, refNode);
} else {
this.xparent.InsertBefore(n, refNode);
}
} else {
this.xparent.AppendChild(n);
}
}
}
示例11: AddClip
public IClip AddClip(string fileName, GroupMediaType mediaType, InsertPosition position, double offset,
double clipStart, double clipEnd)
{
return AddClip(null, fileName, mediaType, position, offset, clipStart, clipEnd);
}
示例12: InsertWithCursor
public virtual Task InsertWithCursor(string operation, InsertPosition defaultPosition, IEnumerable<AstNode> node)
{
throw new NotImplementedException();
}
示例13: InsertWithCursor
public virtual Task<Script> InsertWithCursor(string operation, InsertPosition defaultPosition, IList<AstNode> nodes)
{
throw new NotImplementedException();
}
示例14: InsertWithCursor
public override void InsertWithCursor (string operation, AstNode node, InsertPosition defaultPosition)
{
var editor = ctx.Document.Editor;
var mode = new InsertionCursorEditMode (editor.Parent, MonoDevelop.Ide.CodeGenerationService.GetInsertionPoints (ctx.Document, ctx.Document.CompilationUnit.GetTypeAt (ctx.Location.Line, ctx.Location.Column)));
var helpWindow = new Mono.TextEditor.PopupWindow.ModeHelpWindow ();
helpWindow.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
helpWindow.TitleText = string.Format (GettextCatalog.GetString ("<b>{0} -- Targeting</b>"), operation);
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Accept</b> target point.")));
helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this operation.")));
mode.HelpWindow = helpWindow;
switch (defaultPosition) {
case InsertPosition.Start:
mode.CurIndex = 0;
break;
case InsertPosition.End:
mode.CurIndex = mode.InsertionPoints.Count - 1;
break;
case InsertPosition.Before:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location < new DocumentLocation (ctx.Location.Line, ctx.Location.Column))
mode.CurIndex = i;
}
break;
case InsertPosition.After:
for (int i = 0; i < mode.InsertionPoints.Count; i++) {
if (mode.InsertionPoints [i].Location > new DocumentLocation (ctx.Location.Line, ctx.Location.Column)) {
mode.CurIndex = i;
break;
}
}
break;
}
mode.StartMode ();
mode.Exited += delegate(object s, InsertionCursorEventArgs iCArgs) {
if (iCArgs.Success) {
var output = OutputNode (GetIndentLevelAt (editor.LocationToOffset (iCArgs.InsertionPoint.Location)), node);
iCArgs.InsertionPoint.Insert (editor, output.Text);
}
};
}
示例15: cvSeqPushMulti
public static extern void cvSeqPushMulti(IntPtr seq, IntPtr elements, int count, InsertPosition in_front);