本文整理汇总了C#中TextEditor.AddButton方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.AddButton方法的具体用法?C# TextEditor.AddButton怎么用?C# TextEditor.AddButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor.AddButton方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Application
/// <summary>
/// This is a javascript application.
/// </summary>
/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
public Application(IDefault page)
{
//#region introOnce
//var introOnce = new Cookie("intro");
//if (!introOnce.BooleanValue)
//{
// var canvas = new ApplicationCanvas();
// canvas.TriggerOnClick = false;
// canvas.Background = Brushes.Transparent;
// canvas.AnimationAllWhite +=
// delegate
// {
// Native.Document.body.style.backgroundColor = JSColor.None;
// };
// canvas.AnimationCompleted +=
// delegate
// {
// ScriptCoreLib.JavaScript.Extensions.AvalonExtensions.ToHTMLElement(
// canvas
// ).Orphanize();
// introOnce.BooleanValue = true;
// };
// canvas.AttachToContainer(Native.Document.body);
// canvas.AutoSizeTo(Native.Document.body);
//}
//else
//{
Native.Document.body.style.backgroundColor = JSColor.None;
//}
//#endregion
//canvas.AutoSizeTo(page.ContentSize);
page.HiddenContent.ToggleVisible();
//page.SubHeader.innerText = Native.Window.unescape(Native.Document.location.pathname);
#region AtEdit
Func<Action> AtEdit =
delegate
{
page.Edit.ToggleVisible();
var Control = new IHTMLDiv();
Control.AttachToDocument();
var Content = page.Content.innerHTML;
page.Content.Clear();
var Editor = new TextEditor(Control);
Editor.InnerHTML = Content;
Editor.IsFadeEnabled = false;
TextEditor.ToolbarButton SaveChanges = null;
SaveChanges = Editor.AddButton(
new RTA_save(),
"Save Changes And Refresh",
delegate
{
var xml = Editor.InnerHTML;
// android seems to use this
xml = xml.Replace(" ", " ");
SaveChanges.Button.disabled = true;
service.SaveChanges(
Native.window.unescape(Native.Document.location.pathname),
XElement.Parse("<div>" + xml + "</div>"),
delegate
{
// refresh
// does not work for hash tags
//Native.Document.location = Native.Document.location;
Native.Document.location.replace(
Native.window.unescape(Native.Document.location.pathname)
);
}
);
}
);
//.........这里部分代码省略.........
示例2: Application
/// <summary>
/// This is a javascript application.
/// </summary>
/// <param name="page">HTML document rendered by the web server which can now be enhanced.</param>
public Application(IDefault page)
{
Func<Action> AtEdit =
delegate
{
page.Edit.ToggleVisible();
var Control = new IHTMLDiv();
Control.AttachToDocument();
var Content = page.Content.innerHTML;
page.Content.Clear();
var Editor = new TextEditor(Control);
Editor.InnerHTML = Content;
Editor.IsFadeEnabled = false;
TextEditor.ToolbarButton SaveChanges = null;
SaveChanges = Editor.AddButton(
new RTA_save(),
"Save Changes And Refresh",
delegate
{
Console.WriteLine("Save Changes And Refresh ... ");
SaveChanges.Button.disabled = true;
this.SaveChanges(
Native.Document.location.pathname,
XElement.Parse("<div>" + Editor.InnerHTML + "</div>"),
delegate
{
// refresh
// does not work for hash tags
//Native.Document.location = Native.Document.location;
var href =
Native.Document.location.ToString().TakeUntilIfAny("#")
;
Console.WriteLine("Save Changes And Refresh ... done! " + new { href });
Native.Document.location.replace(href);
}
);
}
);
Editor.BottomToolbarContainer.Add(
SaveChanges.Control
);
return delegate
{
Editor.Control.Orphanize();
page.Content.innerHTML = Content;
page.Edit.ToggleVisible();
};
};
page.Edit.onclick +=
delegate
{
Native.window.history.pushState(
data: "",
title: "edit",
url: "#edit"
);
var revert = AtEdit();
Native.window.window.onpopstate +=
e =>
{
if (revert != null)
{
revert();
}
revert = null;
};
};
if (Native.Document.location.hash == "#edit")
AtEdit();
//page.Fullscreen.onclick +=
// delegate
// {
// Native.Document.body.requestFullscreen();
//.........这里部分代码省略.........
示例3: Application
//.........这里部分代码省略.........
{
DoCreateNew();
};
#endregion
var buttons = new List<IHTMLButton>();
Action EitherCreateNewOrSelectFirst = delegate
{
if (buttons.Count == 0)
{
DoCreateNew();
}
else
{
if (buttons.Any(k => k.innerText == oldtitle))
{
//already selected
}
else
{
oldtitle = buttons.First().innerText;
text.InnerHTML = storage[oldtitle];
}
}
};
#region Remove this document
var remove = text.AddButton(null, "Remove this document",
delegate
{
var button = buttons.FirstOrDefault(k => k.innerText == oldtitle);
if (button == null)
return;
//Native.Window.localStorage.removeItem(button.innerText);
storage.Remove(button.innerText);
button.Orphanize();
buttons.Remove(button);
EitherCreateNewOrSelectFirst();
}
);
#endregion
IHTMLElement remove_element = remove;
remove_element.style.Float = IStyle.FloatEnum.right;
text.BottomToolbar.appendChild(remove_element);
#region new_SidebarButton
Func<IHTMLButton> new_SidebarButton =
delegate
{
var button = new IHTMLButton { className = "SidebarButton" }.AttachTo(
LeftScrollable
);