2017-06-12 19:09:09 +00:00
|
|
|
using System;
|
2017-06-18 23:50:22 +00:00
|
|
|
using System.ComponentModel;
|
2017-06-12 19:09:09 +00:00
|
|
|
|
2017-06-12 18:45:24 +00:00
|
|
|
namespace Ooui
|
|
|
|
{
|
2017-06-12 20:45:27 +00:00
|
|
|
public abstract class Element : Node
|
2017-06-12 18:45:24 +00:00
|
|
|
{
|
2017-06-12 20:45:27 +00:00
|
|
|
string className = "";
|
|
|
|
public string ClassName {
|
|
|
|
get => className;
|
2017-06-13 07:51:24 +00:00
|
|
|
set => SetProperty (ref className, value, "className");
|
|
|
|
}
|
|
|
|
|
2017-06-18 23:50:22 +00:00
|
|
|
public Style Style { get; private set; } = new Style ();
|
|
|
|
|
2017-06-13 07:51:24 +00:00
|
|
|
string title = "";
|
|
|
|
public string Title {
|
|
|
|
get => title;
|
|
|
|
set => SetProperty (ref title, value, "title");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hidden = false;
|
|
|
|
public bool IsHidden {
|
|
|
|
get => hidden;
|
|
|
|
set => SetProperty (ref hidden, value, "hidden");
|
2017-06-12 19:09:09 +00:00
|
|
|
}
|
2017-06-15 09:39:19 +00:00
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler Clicked {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("click", value);
|
|
|
|
remove => RemoveEventListener ("click", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler DoubleClicked {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("dblclick", value);
|
|
|
|
remove => RemoveEventListener ("dblclick", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler KeyDown {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("keydown", value);
|
|
|
|
remove => RemoveEventListener ("keydown", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler KeyPressed {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("keypress", value);
|
|
|
|
remove => RemoveEventListener ("keypress", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler KeyUp {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("keyup", value);
|
|
|
|
remove => RemoveEventListener ("keyup", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseDown {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mousedown", value);
|
|
|
|
remove => RemoveEventListener ("mousedown", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseEntered {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mouseenter", value);
|
|
|
|
remove => RemoveEventListener ("mouseenter", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseLeft {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mouseleave", value);
|
|
|
|
remove => RemoveEventListener ("mouseleave", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseMoved {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mousemove", value);
|
|
|
|
remove => RemoveEventListener ("mousemove", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseOut {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mouseout", value);
|
|
|
|
remove => RemoveEventListener ("mouseout", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseOver {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mouseover", value);
|
|
|
|
remove => RemoveEventListener ("mouseover", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler MouseUp {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("mouseup", value);
|
|
|
|
remove => RemoveEventListener ("mouseup", value);
|
|
|
|
}
|
|
|
|
|
2017-07-08 05:55:04 +00:00
|
|
|
public event TargetEventHandler Wheeled {
|
2017-06-19 05:28:14 +00:00
|
|
|
add => AddEventListener ("wheel", value);
|
|
|
|
remove => RemoveEventListener ("wheel", value);
|
|
|
|
}
|
|
|
|
|
2017-11-19 20:19:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A signal to Ooui that this element should take up the
|
|
|
|
/// entire browser window.
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool WantsFullScreen => false;
|
|
|
|
|
2017-06-15 09:39:19 +00:00
|
|
|
protected Element (string tagName)
|
|
|
|
: base (tagName)
|
|
|
|
{
|
2017-06-18 23:50:22 +00:00
|
|
|
Style.PropertyChanged += HandleStylePropertyChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandleStylePropertyChanged (object sender, PropertyChangedEventArgs e)
|
|
|
|
{
|
|
|
|
SendSet ("style." + Style.GetJsName (e.PropertyName), Style[e.PropertyName]);
|
2017-06-15 09:39:19 +00:00
|
|
|
}
|
2017-06-12 18:45:24 +00:00
|
|
|
}
|
2017-06-12 19:09:09 +00:00
|
|
|
}
|