/// <summary> /// Creates and attaches behaviors specified on the element declaratively. /// </summary> /// <param name="element">The element whose behaviors should be created and attached.</param> private void AttachBehaviors(Element element) { string[] behaviorNames = ((string)element.GetAttribute(Application.BehaviorsAttribute)).Split(","); int behaviorCount = behaviorNames.Length; for (int i = 0; i < behaviorCount; i++) { string name = behaviorNames[i].Trim(); BehaviorRegistration registration = _registeredBehaviors[name]; Debug.Assert(registration != null, "Unknown behavior '" + name + "'"); if (registration != null) { Dictionary<string, object> options = OptionsParser.GetOptions(element, name); // Use the Application's IoC capabilities to create behaviors. // This allows satisfying dependencies behaviors have to other services, // and also allows behaviors to provide or register services into the container. Behavior behavior = (Behavior)GetObject(registration.BehaviorType); behavior.Initialize(element, options); if (registration.ServiceType != null) { // Special-case the common case where a behavior represents a single // service type, and auto-register it. // In the case where a behavior is registering multiple service types // (not so common), it can do so manually in its Initialize method. RegisterObject(registration.ServiceType, behavior); } } } }
public PlayerGrid(Element element) : base(element, "PlayerGrid") { // Wire up the select user even for confirming a user jQueryUIObject selectUser = (jQueryUIObject)this.Obj.Find(".selectUser"); selectUser.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e"))); selectUser.Click(UserChallenges.SelectUser); // Wire up the challenge event for a specific user jQueryUIObject requestMatch = (jQueryUIObject)this.Obj.Find(".requestMatch"); requestMatch.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e"))); requestMatch.Click(Players.RequestMatch); jQueryUIObject selects = (jQueryUIObject)this.Obj.Find("th select"); selects.Each((ElementIterationCallback)delegate(int index, Element el) { ((jQueryUIObject)jQuery.FromElement(el)).MultiSelect(new JsonObject( "header", false, "minWidth", "80", "height", "auto", "noneSelectedText", el.Title, "selectedText", el.Title, "close", (Callback)delegate() { DoFilter(this.Obj, true); })); }); this.DoFilter(this.Obj, false); }
public FooBehavior(Element e, int i) : base(e, null) { _intVal = i; _intVal2 = i * 2; _intVal3 = i * 4; }
public PlayerDetails(Element element) : base(element) { jQueryUIObject sendMessage = (jQueryUIObject)this.Obj.Find("#playerMessage .sendMessage"); sendMessage.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e"))); sendMessage.Click(SendMessage); }
public static CanvasInformation Create(Element canvas, int w, int h) { if (w == 0) w = 1; if (h == 0) h = 1; return new CanvasInformation(Raphael.CreatePaper(canvas, w, h), jQuery.FromElement(canvas)); }
public Size Measure(string text, double fontSize, Typeface typeface, double maxWidth) { if (htmlElement == null) { htmlElement = Document.CreateElement("div"); style = new HtmlStyleDictionary(htmlElement); Document.Body.AppendChild(htmlElement); } style.SetValue("position", "absolute"); style.SetValue("visibility", "hidden"); style.SetFontSize(fontSize, converter); style.SetFontFamily(typeface.FontFamily, converter); style.SetFontStretch(typeface.Stretch, converter); style.SetFontStyle(typeface.Style, converter); style.SetFontWeight(typeface.Weight, converter); if (maxWidth.IsNaN() || !Double.IsFinite(maxWidth)) { style.SetTextWrapping(TextWrapping.NoWrap, converter); style.ClearValue("max-width"); } else { style.SetTextWrapping(TextWrapping.Wrap, converter); style.SetValue("max-width", converter.ToPixelString(maxWidth)); } style.Apply(); htmlElement.InnerHTML = converter.ToHtmlContentString(text.DefaultIfNullOrEmpty("A")); return new Size(text.IsNullOrEmpty() ? 0 : htmlElement.OffsetWidth + 2, htmlElement.OffsetHeight); }
public override void Arrange(AxisArrangement x, AxisArrangement y, Element hostElement) { base.Arrange(x, y, hostElement); if (_dom == null) { _dom = jQuery.FromHtml("<div class='ui-vertical-scrollbar' style='position: absolute;'></div>").AppendTo(hostElement); _near = jQuery.FromHtml("<div class='ui-scroll-up-button'></div>").AppendTo(_dom).MouseDown(LineNear); _track = jQuery.FromHtml("<div class='ui-scroll-vertical-track'></div>").AppendTo(_dom).MouseDown(Page); _thumb = jQuery.FromHtml("<div class='ui-scroll-vertical-thumb' style='position: relative'></div>").AppendTo(_track).MouseDown(Scrub); _far = jQuery.FromHtml("<div class='ui-scroll-down-button'></div>").AppendTo(_dom).MouseDown(LineFar); } int buttonLength = (y.Length > 2*x.Length) ? x.Length : (int)Math.Floor(y.Length/2); int trackHeight = y.Length - 2*buttonLength; _minThumbLength = Math.Min(buttonLength, trackHeight); _dom.CSS("width", x.Length + "px").CSS("height", y.Length + "px").CSS("top", y.Position + "px").CSS("left", x.Position + "px"); _near.CSS("width", x.Length + "px").CSS("height", buttonLength + "px"); _far.CSS("width", x.Length + "px").CSS("height", buttonLength + "px"); _track.CSS("width", x.Length + "px").CSS("height", trackHeight + "px"); _thumb.CSS("width", x.Length + "px"); ScrollableAxisChanged(); }
public MyClass() { HtmlElement body = Document.Body; HtmlElement head = Document.GetElementsByTagName("head")[0]; head.AppendChild(body); }
public UserOffers(Element element) : base(element, "UserOffers") { jQueryUIObject cancelMatch = (jQueryUIObject)this.Obj.Find(".cancelMatch"); cancelMatch.Button(new JsonObject("text", false, "icons", new JsonObject("primary", "ui-icon-closethick"))); cancelMatch.Click(CancelOffer); }
public static void OnAfterRender(Element[] rendered) { // Layout grid everytime an image is loaded jQuery.FromElements(rendered).Find("img").Load(delegate(jQueryEvent e) { wall.fitWidth(); }); }
private void SwitchContainer(Element container, Element oldContainer) { foreach (ControlBase control in Controls) { control.RemoveControlFrom(oldContainer); control.AddControlTo(container); } }
public override void Dispose() { base.Dispose(); jQuery.FromElement(_overlay).Empty(); _titleImage = null; _overlay = null; }
private static Binder BindValue(Element element, string property, Expression expression) { Debug.Assert((element.TagName.ToLowerCase() == "input") || (element.TagName.ToLowerCase() == "textarea") || (element.TagName.ToLowerCase() == "select"), "Value can only be bound on user input elements."); return new ValueBinder((InputElement)element, expression); }
public static IControl Inject(ControlDocumentFragment f, string newId, IContainer container, Element parent) { PrepareForInject(f); jQuery.FromElement(parent).Html(f.html); IControl control = (IControl)container.CreateObjectByTypeNameWithConstructorArg(f.controlType, f.configObject); control.Id = newId; return control; }
public override void AddControlTo(Element container) { EnsureChildControlsCreated(); if (container != _lastContainer) { SwitchContainer(container, _lastContainer); _lastContainer = container; } }
public override void RemoveControlFrom(Element container) { EnsureChildControlsCreated(); if (_tempElement != _lastContainer) { SwitchContainer(_tempElement, _lastContainer); _lastContainer = _tempElement; } }
public QuickMatch(Element element) : base(element) { this.Obj.Find(".findMatch").Click(CreateMatch); ((jQueryUIObject)this.Obj.Find(".datepicker")).DatePicker(new JsonObject("minDate", 0)); ((jQueryUIObject)this.Obj.Find(".findMatch")).Button(); ((jQueryUIObject)this.Obj.Find("select")).SelectMenu(); Utility.WireLocationAutoComplete((jQueryUIObject)this.Obj.Find(".placesAutoFill"), (jQueryUIObject)this.Obj.Find(".placesAutoValue")); }
public ConfirmedMatches(Element element) : base(element, "ConfirmedMatches") { jQueryObject cancelObject = jQuery.Select(".confirmedMatch .cancelConfirmedMatch"); jQueryObject reportScoreObject = jQuery.Select(".confirmedMatch .inputScore"); if (cancelObject != null) cancelObject.Click(CancelMatch); if (reportScoreObject != null) reportScoreObject.Click(ReportScore); }
public override void Arrange(AxisArrangement x, AxisArrangement y, Element hostElement) { base.Arrange(x, y, hostElement); /* TODO if (_stackPanel != null) { _stackPanel.Arrange(horizontal, vertical, hostElement); } */ }
protected override void Init() { AddSystem(new MenuBackgroundSystem()); CanPause = false; _overlay = jQuery.Select(".GameOverlay").GetElement(0); _titleImage = base.LoadImage("images/title/title.png", false); jQuery.FromElement(_overlay).Show(); BuildMainMenu(); }
public MultiSelectorBehaviour(Element container, HtmlAutoCompleteBehaviour htmlAutoComplete, InputElement hiddenOutput) { this.container = container; this.hiddenOutput = hiddenOutput; this.HtmlAutoComplete = htmlAutoComplete; this.HtmlAutoComplete.ItemChosen = htmlAutoComplete_ItemChosen; selections = new PairListField(hiddenOutput); InitialiseInitialSelections(); jQuery.FromElement(this.container).Click(this.OnClick); }
public UserChallenges(Element element) : base(element) { jQueryUIObject cancelMatch = (jQueryUIObject)this.Obj.Find(".cancelMatch"); cancelMatch.Button(new JsonObject("text", false, "icons", new JsonObject("primary", "ui-icon-closethick"))); cancelMatch.Click(CancelOffer); jQueryUIObject confirmOffers = (jQueryUIObject)this.Obj.Find(".confirmOffers"); confirmOffers.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e"))); confirmOffers.Click(SelectUserDialog); }
static void Imp( Element element, string message, bool before, int delay, Func<string,string> tmplFn) { var jq = jQuery.Select (tmplFn(message)); if (before) jq.InsertBefore (element); else jq.InsertAfter (element); if (delay > 0) ((Action)(()=> jq.Remove())).RunAfter (delay); }
public Players(Element element) : base(element, "Players") { jQueryUIObject moreButton = (jQueryUIObject)this.Obj.Find(".more"); jQueryUIObject requestMatch = (jQueryUIObject)this.Obj.Find(".requestMatch"); requestMatch.Button(new JsonObject("text", true, "icons", new JsonObject("secondary", "ui-icon-carat-1-e"))); requestMatch.Click(RequestMatch); // playerGridCard moreButton.Click(MoreClick); }
public UserDetails(Element element) : base(element) { EditButton = (jQueryUIObject)this.Obj.Find("a.edit"); EditButton.Click(EditDetails); SaveButton = (jQueryUIObject)this.Obj.Find("a.save"); SaveButton.Click(SaveDetails); ((jQueryUIObject)this.Obj.Find("select")).SelectMenu(); Utility.WireLocationAutoComplete((jQueryUIObject)this.Obj.Find(".placesAutoFill"), (jQueryUIObject)this.Obj.Find(".placesAutoValue")); }
public static void AttachKeyPressHandler(Element el, jQueryEventHandler handler) { // return, escape, F1-F12 // http://www.quirksmode.org/js/keys.html. var jq = jQuery.FromElement(el); jq.Keydown(handler); if (jQuery.Browser.MSIE && (jQuery.Browser.Version == "6.0" || jQuery.Browser.Version == "7.0")) { jq.Keypress(delegate(jQueryEvent e) { if (e.Which == 13 || e.Which == 27 || (e.Which >= 112 && e.Which <= 123)) handler(e); }); } }
public static void Execute(Element parent) { var store = Factory<Empresa>.GetStore (); new EmpresasGrid (parent, store); store.Read (); //store.Read (opt=>{ // opt.OrderByParam="ORDER"; // opt.OrderBy="NAME"; // opt.DynamicQueryParams.Dynamic="dinamico"; // opt.Query<Rq>(new Rq{t1= new DateTime(), t3= new DateTime(2013,3,31), st1="hola mundo"}); //}); }
/// <summary> /// This method will hide then immediately restore all SELECT elements that are children of a specific element, if the browser is IE7. The reason is to fix a strange IE7 bug which causes SELECTs to sometimes be non-interactable. /// </summary> /// <param name="parent"></param> public static void FixStrangeIE7SelectIssue(Element parent) { if (jQuery.Browser.MSIE && Utils.ParseInt(jQuery.Browser.Version) == 7) { // Fix for the strange IE7 bug that causes SELECTs to sometimes be non-interactable Window.SetTimeout(delegate { jQuery.FromElement(parent).Find("select").Each((_, el) => { string oldDisplay = el.Style.Display; el.Style.Display = (el.Style.Display != "none" ? "none" : ""); el.Style.Display = oldDisplay; return true; }); }, 0); } }
protected override void Init() { Element div = Document.CreateElement("DIV"); div.ClassName = "CutScene"; Overlay.AppendChild(div); div.AppendChild(LoadImage(_imagePath, false)); _textElement = Document.CreateElement("DIV"); div.AppendChild(_textElement); _paragraphIndex = 0; _charIndex = 0; _finished = false; }
public void CData() { //arrange const string TestHtml = "<div runat='server'>\nTest\n<span style='color:red;'>\nRed Test\n<![CDATA[\n alert('hello'); \n<html im script />]]>\n</span>\n</div>"; var e = new Html.Element(); e.Text = TestHtml; var text = e.Text; var cdata = e.Find<Html.Literal>(n => n.LiteralToken.Class == TokenClass.CData); Assert.AreEqual("\n alert('hello'); \n<html im script />", cdata.Value); Assert.AreEqual(true, e.IsServerControl); Assert.AreEqual(TestHtml, text); }
/// <summary> /// Gets the loaded module corresponding to the HTML element if it has been loaded /// </summary> /// <param name="element"></param> /// <returns></returns> public static Module GetModule(Element element) { for (int i = 0; i < Instances.Count; ++i) { ModuleInstance instance = (ModuleInstance)Instances[i]; if (instance.Element == element) { return instance.Instance; } } return null; }
public override void Init(System.Html.Element element, Func <object> valueAccessor, Func <System.Collections.Dictionary> allBindingsAccessor, object viewModel, object context) { Func <object> hander = valueAccessor; jQuery.Select(null, element).Click(delegate(jQueryEvent e) { if (clickTimeoutId != 0) { Window.ClearTimeout(0); clickTimeoutId = 0; } else { clickTimeoutId = Window.SetTimeout(delegate() { clickTimeoutId = 0; hander(); }, delay); } }); }
public void Setup(System.Html.Element element) { //this is called before the animation jQuery.FromElement(element).CSS("opacity", 0); }
public void Cancel(System.Html.Element element, Action done) { }
public void Start(System.Html.Element element, Action done, object memo) { var ob = new JsDictionary("opacity", 1); jQuery.FromElement(element).Animate(ob, new TypeOption <int, EffectDuration>(), EffectEasing.Linear, () => { done(); }); }