本文整理汇总了C#中IHTMLElement.appendChild方法的典型用法代码示例。如果您正苦于以下问题:C# IHTMLElement.appendChild方法的具体用法?C# IHTMLElement.appendChild怎么用?C# IHTMLElement.appendChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHTMLElement
的用法示例。
在下文中一共展示了IHTMLElement.appendChild方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: __GroupBox
public __GroupBox()
{
fieldset = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset);
fieldset.style.padding = "0";
fieldset.style.margin = "0";
legend = new IHTMLElement(IHTMLElement.HTMLElementEnum.legend);
legend.style.marginLeft = "0.5em";
fieldset.appendChild(legend);
this.InternalContainer = new IHTMLDiv();
fieldset.appendChild(this.InternalContainer);
this.InternalSetDefaultFont();
}
示例2: GuessingGame
public GuessingGame(IHTMLElement e)
{
//
e.innerHTML = @"<h1>
Try to guess a 5-figure integer
</h1>
";
e.appendChild(HintControl, StatusControl, NumberBar);
StatusControl.style.color = Color.Blue;
Control = e;
ResetButton.onclick +=
delegate
{
new GuessingGame(Control);
};
MyGame.Changed +=
delegate
{
HintControl.innerHTML = "<h2>You have guessed " + MyGame.GuessedValues.length + " times";
StatusControl.innerHTML = MyGame.MaskedValue;
if (MyGame.Done)
{
NumberBar.FadeOut();
StatusControl.innerHTML += "<hr /> game over";
Control.appendChild(ResetButton);
}
};
MyGame.RaiseChanged();
for (int i = 0; i < 10; i++)
{
IHTMLButton btn = new IHTMLButton(i + "");
int ux = i;
btn.onclick +=
delegate
{
MyGame.Guessed(ux);
btn.FadeOut();
};
NumberBar.appendChild(btn);
}
Style.textAlign = IStyle.TextAlignEnum.center;
Style.backgroundColor = Color.System.ButtonFace;
Style.borderColor = Color.Gray;
Style.borderWidth = "1px";
Style.borderStyle = "dotted";
Style.padding = "8px";
}
示例3: Spawn
//async Task __buttryfly()
//{
// //Task.Factory.
//}
//async
void Spawn(IHTMLElement e)
{
Native.Document.body.style.margin = "0px";
Native.Document.body.style.padding = "0px";
Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;
e.style.position = IStyle.PositionEnum.absolute;
e.style.left = "0px";
e.style.top = "0px";
e.style.right = "0px";
e.style.bottom = "0px";
e.style.backgroundColor = Color.FromRGB(209, 245, 245);
IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");
loading.style.SetLocation(64, 64, 200, 64);
e.appendChild(loading);
//await __buttryfly();
new global::ButterFly.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
img =>
{
loading.FadeOut();
try
{
//IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFly.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
}
catch (Exception exc)
{
new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
}
e.style.backgroundImage = "url(" + img.src + ")";
e.style.backgroundRepeat = "no-repeat";
e.DisableContextMenu();
var x = 0;
var y = 0;
Action update =
delegate
{
e.style.backgroundPosition = x + "px " + y + "px";
};
e.onmousemove +=
delegate(IEvent i)
{
#region where is the cursor?
if (Native.Document.pointerLockElement == e)
{
x += i.movementX;
y += i.movementY;
}
else
{
x = i.CursorX;
y = i.CursorY;
}
if (x < -img.width / 2)
x += Native.window.Width;
if (y < -img.height / 2)
y += Native.window.Height;
x = x % Native.window.Width;
y = y % Native.window.Height;
#endregion
update();
};
e.onclick +=
delegate
{
e.requestPointerLock();
};
//.........这里部分代码省略.........
示例4: GoogleGearsSimple
//public const string Alias = "Class1";
//public const string DefaultData = "Class1Data";
/// <summary>
/// Creates a new control
/// </summary>
/// <param name="DataElement">The hidden data element</param>
public GoogleGearsSimple()
{
// this ctor creates a new div which has a text and a button element
// on mouseover over the color text is changed
// on pressing the button the next message in text element is displayed
IHTMLDiv Control = new IHTMLDiv();
Control.AttachToDocument();
Func<string, string, IHTMLElement> link = (href, text) => new IHTMLDiv(new IHTMLAnchor(href, text));
Control.appendChild(link("http://gears.google.com/", "Google Gears"));
Control.appendChild(link("http://code.google.com/apis/gears/samples/hello_world_database.html", "Google Example # 1"));
Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.h3, "This page uses Google Gears to record your entries on the local disk. If you navigate away and revisit this page, all your data will still be here. Try it!"));
// http://code.google.com/apis/gears/samples/hello_world_database.html
GoogleGearsFactory.Database db = null;
try
{
db = new GoogleGearsFactory.Database();
}
catch (Exception exc)
{
var err = new IHTMLCode(exc.Message);
err.style.color = Color.Red;
Control.appendChild(err);
}
IStyleSheet.Default.AddRule(".odd").style.backgroundColor = Color.FromGray(0xa0);
IStyleSheet.Default.AddRule(".even").style.backgroundColor = Color.FromGray(0xef);
if (db != null)
{
db.open("demo1");
db.execute(@"
create table if not exists Demo
(Phrase varchar(255), Timestamp int)
");
var textfield = new IHTMLInput(HTMLInputTypeEnum.text, "text1", "");
var btnadd = new IHTMLButton("Add new entry");
var btnrefresh = new IHTMLButton("Refresh");
var btnclear = new IHTMLButton("Clear");
Control.appendChild(textfield, btnadd, btnclear, btnrefresh,
new IHTMLCode(GoogleGearsFactory.Default.getBuildInfo())
);
var list = new IHTMLElement(IHTMLElement.HTMLElementEnum.ol);
Control.appendChild(list);
var read = default(Action);
read = delegate
{
//from i in Demo
//select new { Phrase, Timestamp }
//order by Timestamp desc
list.removeChildren();
Func<string, IHTMLElement> AddItem =
text => new IHTMLElement(IHTMLElement.HTMLElementEnum.li, text).Aggregate(v => list.appendChild(v));
// this could be rewritten as an expression once they are supported by jsc
int counter = 0;
var query = from Data in db.AsEnumerable<DemoDataEntity>(
"select * from Demo order by Timestamp desc",
typeof(DemoDataEntity)
)
// let ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase)
select new __Type2 { ListItem = AddItem(Data.Timestamp + " - " + Data.Phrase), Data = Data};
foreach (var v in query)
{
counter++;
//.........这里部分代码省略.........
示例5: SimpleFilmstrip
/// <summary>
/// Creates a new control
/// </summary>
/// <param name="DataElement">The hidden data element</param>
public SimpleFilmstrip()
{
IHTMLDiv Control = new IHTMLDiv();
Control.style.position = IStyle.PositionEnum.absolute;
new filmstrip().ToBackground(Control, false);
//Control.style.background = "url(assets/SimpleFilmstrip/filmstrip.png) no-repeat";
Control.style.height = "600px";
Control.style.width = "326px";
var index = 0;
var t_icount = default(int);
var t_interval = default(int);
var t_iwidth = default(int);
var t_iheight = default(int);
var t_feed = default(string);
var Restart = default(Action);
var feed = new IHTMLInput(HTMLInputTypeEnum.text,
new veh_cy().src
);
var iwidth = new IHTMLInput(HTMLInputTypeEnum.text, "48");
var iheight = new IHTMLInput(HTMLInputTypeEnum.text, "48");
var icount = new IHTMLInput(HTMLInputTypeEnum.text, "32");
var interval = new IHTMLInput(HTMLInputTypeEnum.text, "50");
var fps = new IHTMLInput(HTMLInputTypeEnum.text, "24");
feed.onchange += delegate { Restart(); };
iwidth.onchange += delegate { Restart(); };
iheight.onchange += delegate { Restart(); };
interval.onchange += delegate
{
int v = int.Parse(interval.value);
if (v == 0)
return;
fps.value = "" + (1000 / v);
Restart();
};
icount.onchange += delegate { Restart(); };
fps.onchange += delegate
{
int v = int.Parse(fps.value);
if (v == 0)
return;
interval.value = "" + (1000 / v);
Restart();
};
var fieldset = new IHTMLElement(IHTMLElement.HTMLElementEnum.fieldset);
fieldset.style.width = "30em";
fieldset.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.legend, "Properties"));
Func<string, IHTMLElement, IHTMLDiv> AsLabel =
(string text, IHTMLElement control) =>
{
var label = new IHTMLLabel(text, control);
control.style.position = IStyle.PositionEnum.absolute;
control.style.left = "8em";
return new IHTMLDiv(label, control);
};
fieldset.appendChild(AsLabel("feed:", feed));
fieldset.appendChild(AsLabel("width:", iwidth));
fieldset.appendChild(AsLabel("height:", iheight));
fieldset.appendChild(AsLabel("count:", icount));
fieldset.appendChild(AsLabel("interval:", interval));
fieldset.appendChild(AsLabel("fps:", fps));
fieldset.style.position = IStyle.PositionEnum.absolute;
fieldset.style.top = "320px";
var image = new IHTMLDiv();
//.........这里部分代码省略.........
示例6: Spawn
//async Task __buttryfly()
//{
// //Task.Factory.
//}
//async
void Spawn(IHTMLElement e)
{
Native.Document.body.style.margin = "0px";
Native.Document.body.style.padding = "0px";
Native.Document.body.style.overflow = IStyle.OverflowEnum.hidden;
e.style.position = IStyle.PositionEnum.absolute;
e.style.left = "0px";
e.style.top = "0px";
e.style.right = "0px";
e.style.bottom = "0px";
e.style.backgroundColor = Color.FromRGB(209, 245, 245);
IHTMLElement loading = new IHTMLElement(IHTMLElement.HTMLElementEnum.code, "loading...");
loading.style.SetLocation(64, 64, 200, 64);
e.appendChild(loading);
//await __buttryfly();
new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.buttryfly().InvokeOnComplete(
img =>
{
loading.FadeOut();
try
{
//IStyleSheet.Default.AddRule("*", "cursor: none, url('" + new global::ButterFlyWithInteractiveInt32Offset.HTML.Images.FromAssets.nocursor().src + "'), auto;", 0);
//IStyleSheet.Default.AddRule("*", "cursor: none;", 0);
}
catch (Exception exc)
{
new IHTMLElement(IHTMLElement.HTMLElementEnum.pre, exc.Message).AttachToDocument();
}
e.style.backgroundImage = "url(" + img.src + ")";
e.style.backgroundRepeat = "no-repeat";
e.DisableContextMenu();
var x = 0;
var y = 0;
var overlay = new IHTMLDiv();
overlay.style.border = "1px solid red";
overlay.style.SetSize(64, 64);
overlay.AttachToDocument();
Native.window.onframe +=
delegate
{
e.style.backgroundPosition = x + "px " + y + "px";
overlay.style.SetLocation(
// how does this work with the background compiler?
// once browser clicks save, visual studio asks if
// to accept, and bacground compiler
// starts a new compilation
// so, the running app could first be able
// to inspect, whats new?
// and if only the same constant was changed,
// it can be discarded. same with comments.
x + 67.ToInteractiveInt32Form(),
y + 2.ToInteractiveInt32Form()
);
};
e.onmousemove +=
delegate(IEvent i)
{
#region where is the cursor?
if (Native.Document.pointerLockElement == e)
{
x += i.movementX;
y += i.movementY;
}
else
{
x = i.CursorX;
y = i.CursorY;
}
//.........这里部分代码省略.........
示例7: GenerateView
//.........这里部分代码省略.........
var delay_delayed = false;
Status = "creating actions";
var Delay = default(System.Action<System.Action, int>);
Delay = (h, due) => new Timer(
delegate
{
if (delay_delayed)
Delay(h, due);
else
h();
}, due, 0);
System.Func<string> CurrentLineString = () => (1 + index) + ". " + lines[index].Trim();
var DeleteChar = default(System.Action);
var PrintChar = default(System.Action);
var ChooseLine = default(System.Action);
DeleteChar =
() =>
{
index_char--;
span.innerText = CurrentLineString().Substring(0, index_char);
if (index_char == 0)
{
ChooseLine();
}
else
{
Delay(DeleteChar, 30);
}
};
PrintChar =
() =>
{
index_char++;
if (index_char < CurrentLineString().Length)
{
var x = 100;
var y = CurrentLineString()[index_char];
if (",. \t\n".Contains("" + y))
x = 200;
if (index_char > 1)
span.style.color = Color.None;
span.innerText = CurrentLineString().Substring(0, index_char);
Delay(PrintChar, x);
}
else
{
Delay(DeleteChar, 3000);
}
};
ChooseLine =
() =>
{
index = new System.Random().Next() % lines.Length;
index_char = 0;
span.innerText = "";
span.style.color = Color.White;
PrintChar();
};
Status = "adding to document";
c.onmouseover +=
delegate
{
c.style.color = Color.Yellow;
delay_delayed = true;
};
c.onmouseout +=
delegate
{
c.style.color = Color.None;
delay_delayed = false;
};
c.appendChild(span, cursor);
c.AttachToDocument();
ChooseLine();
}
示例8: Dump
private static IHTMLElement Dump(object xs, IHTMLElement to, object diff)
{
var c = new IHTMLDiv();
c.style.backgroundColor = Color.White;
c.style.border = "1px solid gray";
c.style.padding = "1em";
c.style.fontFamily = IStyle.FontFamilyEnum.Consolas;
var ttx = new IHTMLDiv(xs.ToString());
c.appendChild(ttx);
var dx = Expando.Of(diff);
foreach (var v in Expando.Of(xs).GetMembers())
{
var tt = default(IHTMLDiv);
var ok = true;
if (dx != null)
{
if (dx.Contains(v.Name))
{
if (dx[v.Name] == v.Self)
ok = false;
}
}
if (ok)
{
if (v.Self.IsFunction)
{
tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name);
tt.style.color = Color.Red;
}
else if (v.Self.IsObject)
{
tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());
tt.style.color = Color.Blue;
}
else
tt = new IHTMLDiv(v.Self.TypeString + " " + v.Name + " = " + v.Self.ToString());
c.appendChild(tt);
}
}
to.appendChild(c);
return to;
}
示例9: Application
//.........这里部分代码省略.........
// null,
// null,
// //"/thirdpage.htm"
// "/third-page"
//);
Console.WriteLine("replaceState");
Native.window.history.pushState(
//"/third-page",
new { },
"/third-page",
async scope =>
{
// did the server prerender our page?
Console.WriteLine("at replaceState");
var xtitle = Native.document.title;
// { nodeName = #text }
var hidden = (IHTMLElement)Native.document.body.querySelectorAll("hidden-body").FirstOrDefault();
Console.WriteLine("replaceState " + new { hidden });
var layout = default(IThirdPage);
if (hidden == null)
{
hidden = new IHTMLElement("hidden-body");
hidden.style.display = IStyle.DisplayEnum.none;
layout = new ThirdPage();
Native.document.title = layout.title.innerText;
var page_body = Native.document.body;
layout.body.appendChild(hidden);
page_body.parentNode.replaceChild(layout.body, page_body);
// we can also keep it memory
hidden.appendChild(page_body);
}
else
{
//{ nodeName = YDOB }
var page_ydob = (IElement)hidden.querySelectorAll("ydob").FirstOrDefault();
if (page_ydob != null)
{
// chrome will skip body. have to repair on the client
var page_body = new IHTMLBody();
page_ydob.attributes.ToArray().WithEach(a => { page_ydob.removeAttribute(a.name); page_body.setAttribute(a.name, a.value); });
page_ydob.childNodes.ToArray().WithEach(a => { page_ydob.removeChild(a); page_body.appendChild(a); });
hidden.replaceChild(page_body, page_ydob);
}
layout = new ThirdPage.FromDocument();
}
// ready!
// one wait works half time only
//await Native.window.requestAnimationFrameAsync;
//await Native.window.requestAnimationFrameAsync;
//await Task.Delay(11);
示例10: ImageZoomer
/// <summary>
/// Creates a new control
/// </summary>
/// <param name="DataElement">The hidden data element</param>
public ImageZoomer()
{
var Control = new IHTMLElement(IHTMLElement.HTMLElementEnum.center);
Control.AttachToDocument();
Control.appendChild( new IHTMLDiv("A simple image zoomer example") );
Control.appendChild(new IHTMLAnchor("http://valid.tjp.hu/tjpzoom/", "based on tjpZoom"));
Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Use your mouse wheel to zoom!"));
Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.hr));
System.Action<string, string> Spawn =
(src, zoom_src) =>
{
var i = new IHTMLImage(src);
i.style.margin = "2px";
Control.appendChild(i);
// note: image should be loeaded before attaching events on it!
i.InvokeOnComplete(
(img) => MyMagnifier.CreateClickableMagnifier(i, zoom_src)
);
};
System.Action<string, string> SpawnFreezable =
(src, zoom_src) =>
{
var i = new IHTMLImage(src);
i.style.margin = "2px";
Control.appendChild(i);
i.InvokeOnComplete(
(img) => MyMagnifier.CreateFreezableMagnifier(i, zoom_src)
);
};
Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Click to disable or re-enable the magnifier!"));
new[] {
"assets/ImageZoomer/boat.jpg",
"assets/ImageZoomer/boat2.jpg",
"assets/ImageZoomer/tea.jpg",
"assets/ImageZoomer/town.jpg",
}.ForEach( src => Spawn(src, src) );
Control.appendChild(new IHTMLElement(IHTMLElement.HTMLElementEnum.p, "Click to freeze the magnifier!"));
SpawnFreezable("assets/ImageZoomer/belchite_bw.jpg", "assets/ImageZoomer/belchite.jpg");
SpawnFreezable("assets/ImageZoomer/belchite.jpg", "assets/ImageZoomer/belchite_bw_neg.jpg");
}