private void OnLeftButtonUp(object sender, System.Windows.Forms.HtmlElementEventArgs arg) { System.Windows.Forms.HtmlDocument doc = (System.Windows.Forms.HtmlDocument)sender; System.Windows.Forms.HtmlElement element = doc.GetElementFromPoint(arg.MousePosition); HtmlScreenElementBase button = FindButtonInHtml(element); if (null == button) { System.Windows.Forms.HtmlElement parentElement = element.Parent; if (null == parentElement) { return; } button = FindButtonInHtml(parentElement); if (null == button) { return; } } button.OnLeftMouseUp(sender, arg); arg.ReturnValue = true; }
public BindingExpress(string argBindedProperty, string argProperty, HtmlScreenElementBase argElement) { Debug.Assert(!string.IsNullOrEmpty(argProperty) && !string.IsNullOrEmpty(argBindedProperty) && null != argElement); m_bindedProperty = argBindedProperty; m_property = argProperty; m_element = argElement; }
public HtmlScreenElementBase FindElement(string argName) { //Debug.Assert(!string.IsNullOrEmpty(argName)); if (string.IsNullOrEmpty(argName)) { return(null); } HtmlScreenElementBase element = null; if (m_dicScreenElements.TryGetValue(argName, out element)) { return(element); } return(null); }
private void OnLeftButtonDown(object sender, System.Windows.Forms.HtmlElementEventArgs arg) { System.Windows.Forms.HtmlDocument doc = (System.Windows.Forms.HtmlDocument)sender; System.Windows.Forms.HtmlElement element = doc.GetElementFromPoint(arg.MousePosition); HtmlScreenElementBase newFcsElement = FindFocusElement(element); if (null != newFcsElement) { if (m_focusElement != newFcsElement) { m_focusElement = newFcsElement; // ShowHandleInput(true); } m_focusElement.SetFocus(); } else { ShowScreenKeyboard(false); m_focusElement = null; // ShowHandleInput(false); } HtmlScreenElementBase button = FindButtonInHtml(element); if (null == button) { System.Windows.Forms.HtmlElement parentElement = element.Parent; if (null == parentElement) { return; } button = FindButtonInHtml(parentElement); if (null == button) { return; } } button.OnLeftMouseDown(sender, arg); arg.ReturnValue = true; }
private HtmlScreenElementBase FindFocusElement(System.Windows.Forms.HtmlElement argElement) { Debug.Assert(null != argElement); if (string.IsNullOrEmpty(argElement.Id)) { return(null); } string id = argElement.Id.ToLowerInvariant(); HtmlScreenElementBase element = null; if (m_dicScreenElements.TryGetValue(id, out element) && element.CanFocus) { return(element); } return(null); }
//private void FindAllButtonsInHtml( System.Windows.Forms.HtmlDocument doc ) //{ // Debug.Assert(null != doc); // System.Windows.Forms.HtmlElement body = doc.Body; // if ( null == body ) // { // return; // } // m_listButtons.Clear(); // System.Windows.Forms.HtmlElementCollection elementCollection = body.All; // Debug.Assert(null != elementCollection); // string valueOfAttri = null; // foreach ( System.Windows.Forms.HtmlElement element in elementCollection ) // { // valueOfAttri = element.GetAttribute(s_typeAttri); // if ( string.IsNullOrEmpty (valueOfAttri) ) // { // continue; // } // if ( 0 == string.Compare( valueOfAttri, s_buttonValue, true ) ) // { // m_listButtons.Add(element); // } // } //} private void ExtractAllScreenElements(System.Windows.Forms.HtmlDocument argDoc) { Debug.Assert(null != argDoc); System.Windows.Forms.HtmlElement body = argDoc.Body; if (null == body) { return; } m_listBindingExpresses.Clear(); ClearScreenElements(); System.Windows.Forms.HtmlElementCollection elementCollection = body.All; Debug.Assert(null != elementCollection); HtmlScreenElementBase screenElement = null; string idsValue = null; string valueOfAttri = null; IResourceService iCurrentUIResource = null; if (null != m_application.ResourceManager) { iCurrentUIResource = m_application.ResourceManager.CurrentUIResource; } string text = null; string replaceAttri = null; int replaceValue = 0; string imagePath = null; string srcPath = null; foreach (System.Windows.Forms.HtmlElement element in elementCollection) { //replace ids idsValue = element.GetAttribute(s_UITextKey); if (null != iCurrentUIResource && !string.IsNullOrEmpty(idsValue)) { if (iCurrentUIResource.LoadString(idsValue, TextCategory.s_UI, out text)) { element.InnerHtml = ConvertText(text); } } //replace image if (null != iCurrentUIResource && s_imgName.Equals(element.TagName, StringComparison.OrdinalIgnoreCase)) { replaceAttri = element.GetAttribute(s_replaceAttri); srcPath = element.GetAttribute("src"); if (!string.IsNullOrEmpty(replaceAttri) && !string.IsNullOrEmpty(srcPath) && int.TryParse(replaceAttri, out replaceValue) && replaceValue == 1) { if (iCurrentUIResource.QueryImagePath(srcPath, out imagePath)) { element.SetAttribute("src", imagePath); } } } if (string.IsNullOrEmpty(element.Id)) { continue; } valueOfAttri = element.GetAttribute(s_typeAttri); if (string.IsNullOrEmpty(valueOfAttri)) { continue; } valueOfAttri = valueOfAttri.ToLowerInvariant(); if (m_dicScreenElementCreator.ContainsKey(valueOfAttri)) { try { screenElement = m_dicScreenElementCreator[valueOfAttri].Invoke(element); if (null != screenElement) { m_dicScreenElements.Add(element.Id.ToLowerInvariant(), screenElement); } } catch (System.Exception ex) { LogProcessorService.Log.UIService.LogWarn(string.Format("Failed to create a screen element[{0}]", element.Id), ex); } } } }
public object ExecuteCustomCommand(string argName, params object[] args) { Debug.Assert(!string.IsNullOrEmpty(argName)); Log.UIService.LogDebugFormat("execute command[{0}] in html screen", argName); switch (argName) { case UIServiceCommands.s_clearDataBind: { Log.UIService.LogDebug("Remove property changed event"); RemovePropertyChangedEvent(); ShowScreenKeyboard(false); } break; case UIServiceCommands.s_updateData: { Log.UIService.LogDebug("Prepare for update data"); foreach (var item in m_dicScreenElements) { if ((item.Value is HtmlScreenInputElement) || (item.Value is HtmlScreenSelectElement)) { item.Value.UpdateBindingData(true); } } } break; case UIServiceCommands.s_buttonDown: { if (null == args[0] || !(args[0] is string)) { return(null); } Log.UIService.LogDebugFormat("The button [{0}] is down", args[0]); string name = (string)args[0]; HtmlScreenElementBase element = null; if (m_dicScreenElements.TryGetValue(name, out element)) { element.OnLeftMouseDown(null, null); } //foreach (var item in m_dicScreenElements) //{ // if ( (item.Value is HtmlScreenButtonElement) && // (name.Equals( item.Value.HostedElement.Id, StringComparison.OrdinalIgnoreCase )) ) // { // item.Value.OnLeftMouseDown( null, null ); // break; // } //} } break; case UIServiceCommands.s_buttonUp: { if (null == args[0]) { return(null); } Log.UIService.LogDebugFormat("The button [{0}] is up", args[0]); string name = (string)args[0]; HtmlScreenElementBase element = null; if (m_dicScreenElements.TryGetValue(name, out element)) { element.OnLeftMouseUp(null, null); } //foreach (var item in m_dicScreenElements) //{ // if ((item.Value is HtmlScreenButtonElement) && // (name.Equals(item.Value.HostedElement.Id, StringComparison.OrdinalIgnoreCase))) // { // item.Value.OnLeftMouseUp(null, null); // break; // } //} } break; default: { Log.UIService.LogDebug("The unsupported custom command"); Debug.Assert(false); } break; } return(null); }