public WebViewer(FileInfo file) { InitializeComponent(); File = file; Text = Path.GetFileNameWithoutExtension(File.FullName); _childBrowser = new WebControl(); _childBrowser.WebView = new WebView(); _childBrowser.WebView.FileDialog += OnProcessFileDialog; _childBrowser.WebView.BeforeDownload += OnWebViewBeforeDownload; _childBrowser.WebView.DownloadUpdated += OnWebViewDownloadUpdated; _childBrowser.WebView.DownloadCompleted += OnWebViewDownloadCompleted; _childBrowser.WebView.DownloadCanceled += OnWebViewDownloadCanceled; _childBrowser.WebView.CustomUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Essential Objects Chrome/41.0.2272.16 Safari/537.36"; Controls.Add(_childBrowser); _browser = new WebControl(); _browser.WebView = new WebView(); _browser.Dock = DockStyle.Fill; _browser.WebView.LoadCompleted += OnMainWebViewLoadComplete; _browser.WebView.NewWindow += OnMainWebViewNewWindow; _browser.WebView.BeforeDownload += OnWebViewBeforeDownload; _browser.WebView.CustomUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Essential Objects Chrome/41.0.2272.16 Safari/537.36"; Controls.Add(_browser); _browser.BringToFront(); }
void ControlLoaded(object sender, RoutedEventArgs e) { control.Loaded -= ControlLoaded; var session = WebCore.CreateWebSession(baseDirectory, new WebPreferences(true) { WebGL = true, EnableGPUAcceleration = true, SmoothScrolling = true, CustomCSS = @"body { font-family: Segoe UI, sans-serif; font-size:0.8em;} ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background-color: white; } ::-webkit-scrollbar-thumb { background-color: #B9B9B9; } ::-webkit-scrollbar-thumb:hover { background-color: #000000; }" }); markpadDataSource = new MarkpadDataSource(); session.AddDataSource("markpad", markpadDataSource); wb = new WebControl { WebSession = session, UseLayoutRounding = true, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Source = new Uri("asset://markpad/MarkpadPreviewRender.html"), }; wb.Loaded += WbLoaded; AwesomiumResourceHandler.Host = this; WebCore.ResourceInterceptor = AwesomiumResourceHandler.ResourceInterceptor; wb.ShowCreatedWebView += AwesomiumResourceHandler.ShowCreatedWebView; LoadHtml(Html); control.Content = wb; }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { var item = Sitecore.Context.Database.GetItem(Path); if (item == null) return; NameValueCollection parameters = new NameValueCollection(); foreach (Field field in item.Fields) { parameters.Add(field.Name, field.Value); } IRenderingType renderType = null; if (item.TemplateID == SitecoreIds.GlassBehindRazorId) renderType = new BehindRazorRenderingType(); else if (item.TemplateID == SitecoreIds.GlassDynamicRazorId) renderType = new DynamicRazorRenderingType(); else if (item.TemplateID == SitecoreIds.GlassTypedRazorId) renderType = new TypedRazorRenderingType(); _control = renderType.GetControl(parameters, false) as WebControl; _control.DataSource = this.DataSource; this.Controls.Add(_control); base.OnLoad(e); }
public WebViewer() : base(WindowType.Toplevel) { xml = new XML (null, "MainWindow.glade", "mainBox", null); xml.Autoconnect (this); Gdk.Pixbuf pix = new Gdk.Pixbuf (null, "webnotes-16.png"); //Window settings Title = "WebNotes"; WindowPosition = WindowPosition.Center; Icon = pix; Resize (650,600); //Trayicon stuff trayIcon = new TrayIcon ("WebNotes"); EventBox ebox = new EventBox (); ebox.ButtonPressEvent += ButtonPressed; Image image = new Image (pix); ebox.Add (image); trayIcon.Add (ebox); trayIcon.ShowAll (); //Gecko webcontrol wc = new WebControl (); wc.LoadUrl ("http://localhost:8000"); geckoBox.Add (wc); optionMenu.Changed += OptionChanged; BuildMenu (); int firstPage = list.IndexOf ("WikiHome"); if (firstPage != -1) optionMenu.SetHistory ((uint)firstPage); Add (mainBox); }
public static void copyAuctionCategories(WebControl wc) { string jsLib = getMyJavascript(); try { //Создание таблицы categories, если таковой еще нет MySqlConnection con = new MySqlConnection(connectionString); string dbCommand = "CREATE TABLE IF NOT EXISTS categories (browserValue VARCHAR(15) PRIMARY KEY, categoryName VARCHAR(50));"; MySqlCommand comm = new MySqlCommand(dbCommand, con); con.Open(); comm.ExecuteNonQuery(); con.Close(); //Функции javascript JSValue categoryData = wc.ExecuteJavascriptWithResult(jsLib); JSValue[] records; records = (JSValue[])categoryData; JSValue[] catName = (JSValue[])records[0]; JSValue[] browVal = (JSValue[])records[1]; addCategoryData(catName, browVal); } catch(Exception exception) { MessageBox.Show(exception.Message); } }
void ControlLoaded(object sender, RoutedEventArgs e) { control.Loaded -= ControlLoaded; var session = WebCore.CreateWebSession(baseDirectory, new WebPreferences(true) { CustomCSS = @"body { font-family: Segoe UI, sans-serif; font-size:0.8em;} ::-webkit-scrollbar { width: 12px; height: 12px; } ::-webkit-scrollbar-track { background-color: white; } ::-webkit-scrollbar-thumb { background-color: #B9B9B9; } ::-webkit-scrollbar-thumb:hover { background-color: #000000; }" }); wb = new WebControl { WebSession = session, UseLayoutRounding = true, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, }; wb.Loaded += WbLoaded; AwesomiumResourceHandler.Host = this; WebCore.ResourceInterceptor = AwesomiumResourceHandler.ResourceInterceptor; wb.ShowCreatedWebView += AwesomiumResourceHandler.ShowCreatedWebView; wb.LoadHTML(Html); control.Content = wb; }
public static void login (WebControl webControl1) { try { dynamic document = (JSObject)webControl1.ExecuteJavascriptWithResult("document"); if (document == null) throw new Exception("document has null value"); dynamic element = document.getElementById("userEmail"); if (element == null) throw new Exception("email has null value"); element.value = "*****@*****.**"; element = document.getElementById("userPassword"); element.value = "ee34nf3o"; element = document.getElementsByTagName("input"); for (int i = 0; i < element.length; i++) { if (element[i].getAttribute("src") == "images/go_btn.png") ; { element[i].click(); break; } } Thread.Sleep(2000); webControl1.Source = new Uri("http://w1.dwar.ru/area_auction.php"); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
public WebViewSimpleLifeCycleManager(WebControl First, WebControl Second) { _First=First; _Second = Second; _First.Visibility = Visibility.Hidden; _Second.Visibility = Visibility.Hidden; }
private void addNewTab() { //Lets generate a random ID for the tab. It should be good for about 10000 tabs a session. Random random = new Random(); int randomNumber = random.Next(0, 10000); CloseableTabItem item = new CloseableTabItem(); item.Header = "New Tab"; item.SetBrowserTabId(randomNumber); WebControl ctrl = new WebControl(); item.Content = ctrl; ctrl.Width = item.Width; ctrl.Height = item.Height; ctrl.LoadURL("http://google.com"); tabs[randomNumber] = item; browserTabs.Items.Add(item); ctrl.PageContentsReceived += new Awesomium.Core.PageContentsReceivedEventHandler(Browser_PageContentsReceived); ctrl.BeginLoading += new Awesomium.Core.BeginLoadingEventHandler(Browser_BeginLoading); item.CloseTab += new RoutedEventHandler(CloseTab_Click); browserTabs.SelectedItem = item; }
public static void resize(WebControl webControl, float x, float y) { webControl.Location = new Point((int)(webControl.Location.X * x), (int)(webControl.Location.Y * y)); webControl.Size = new Size((int)(webControl.Size.Width * x), (int)(webControl.Size.Height * y)); ResizeJavascript(webControl, x, y); }
///<summary> /// Provides a NameValueCollection of Parameters listed in the /// Webcontrol and Sublayout Data Template. /// Takes the Parameter string Field and Separates it out as such. /// /// Title=Some Title /// Subtitle=Some SubTitle /// Something=Else /// /// Takes this, splits it out for each line, then adds to the collection. /// The above creates: /// {'Title'=>'Some Title','Subtitle'=>'Some SubTitle','Something'=>'Else'} /// /// This overload assumes that the Parameters are separated by line and /// the key/value pairs are delimited by an equal sign (=). ///</summary> ///<param name = "control">The WebControl object, usually 'this' will work.</param> ///<returns>NameValueCollection of Parameters. Returns Empty Collection if nothing.</returns> public static NameValueCollection GetParameters(WebControl control) { List<char> delimiters = new List<char>(); delimiters.Add('\r'); delimiters.Add('\n'); return GetParameters(control, delimiters.ToArray(), '='); }
private void AutoComplit(ref JObject joContextKey, string methodUrl, WebControl control) { JObject jo = new JObject(); jo["contextKey"] = joContextKey; jo["methodUrl"] = VirtualPathUtility.ToAbsolute(methodUrl); jo["minLength"] = 1; control.Attributes.Add("AC_Options", JsonConvert.SerializeObject(jo, Formatting.None)); }
/// <summary> /// Sets the specified control CSS class. /// </summary> private void SetControlCss(WebControl ctrl, string cssClass) { if (!string.IsNullOrEmpty(cssClass)) { ctrl.ControlStyle.Reset(); ctrl.CssClass = cssClass; } }
public CommandManager (WebControl control) { if (control == null) throw new ArgumentNullException ("The Command Manager must be bound to a WebControl instance.", "control"); webControl = control; webControl.TitleChange += new EventHandler (webControl_ECMAStatus); }
private void Load_Click(object sender, RoutedEventArgs e) { var control = new WebControl() { WebView = new WebView() }; BrowserHost.Children.Add(control); }
public void CreateControlByPropertySet() { var homePage = this.Context.NavigateTo<HomePage>(this.TestAppUrl); var race = new WebControl(homePage.Context); race.Parent = homePage; race.SearchProperties.Add(WebControl.SearchNames.JQuerySelector, ".race .item:eq(0)"); Assert.AreEqual("Race1 Item1", race.Text); }
public AwesomiumHTMLWindow(WebControl iWebControl) { _WebControl = iWebControl; _WebControl.SynchronousMessageTimeout = 0; _WebControl.ExecuteWhenReady(FireLoaded); _WebControl.ConsoleMessage += _WebControl_ConsoleMessage; _WebControl.Crashed += _WebControl_Crashed; MainFrame = new AwesomiumWebView(_WebControl); }
public GitHistoryController(WebControl webBrowserControl, SearchBox searchBoxControl, CommitBoxControl commitBoxControl) { this.webBrowserControl = webBrowserControl; this.searchBoxControl = searchBoxControl; this.commitBoxControl = commitBoxControl; Init(); if (gitManager.IsEmpty) { OpenSettings(null, null); } }
private void InitBrowser() { wb = new WebControl(); wb.Visible = true; wb.Dock = DockStyle.Fill; wb.ProcessCreated += wb_ProcessCreated; this.Controls.Add(wb); }
public void AddGeckoPanel() { // First we create a WebControl, using its default constructor web = new WebControl(); // Then we ask it to show itself. // This is required because of a Gecko bug, and doesn't actually show the control yet. web.Show(); // Next, we'll add the web control to our existing frame: frmResultsContent.Add(web); }
public PreviewDialog(string data) { WindowsIdentity id = WindowsIdentity.GetCurrent(); this.Build(); tmp_path = System.IO.Path.GetTempPath (); tmp_path = System.IO.Path.Combine (tmp_path, "pdf2scielo.gui-" + id.Name ); preview = new WebControl (tmp_path, "EditorGecko"); preview.NetStop += OnComplete; Render (data); this.VBox.Add (preview); preview.Show (); }
protected void preencheLinks() { WebControl lista = new WebControl(HtmlTextWriterTag.Div); ContainerLinks.Controls.Add(lista); foreach (Link link in controladorPaginas.obterLinks()) { WebControl itemLista = new WebControl(HtmlTextWriterTag.Div); itemLista.CssClass = "link " + (link.PossuiImagem ? "comImagem" : "semImagem"); itemLista.Controls.Add(new LiteralControl(link.Html)); lista.Controls.Add(itemLista); } }
public WebKitPage() { InitializeComponent(); _webKit = new WebControl(); _webKit.Dock = DockStyle.Fill; Controls.Add(_webKit); _webKit.WebView = new WebView(); _webKit.WebView.CustomUserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Essential Objects Chrome/41.0.2272.16 Safari/537.36"; Text = _webKit.WebView.Title; pbProgressLogo.Image = AppSettingsManager.Instance.SplashLogo; }
static void Main(string [] args) { for (int i = 0; i < args.Length; i++){ switch (args [i]){ case "-width": try { i++; width = Int32.Parse (args [i]); } catch { Console.WriteLine ("-width requires an int argument"); } break; case "-height": try { i++; height = Int32.Parse (args [i]); } catch { Console.WriteLine ("-height requires an int argument"); } break; case "-help": case "-h": Help (); break; default: if (url == null) url = args [i]; else if (output == null) output = args [i]; else Help (); break; } } if (url == null) Help (); if (output == null) output = "shot.png"; Application.Init(); Window w = new Window ("test"); wc = new WebControl (); wc.LoadUrl (args [0]); wc.Show (); wc.LocChange += WaitABit; wc.SetSizeRequest (1024, 768); w.Add (wc); w.ShowAll (); //GLib.Timeout.Add(700, new TimeoutHandler(MakeShot)); Application.Run(); }
public KeyboardWebInput(AbstractKeyboard k, WebControl w) { this.k = k; this.w = w; k.CaretMovedBackward += this.keyboard1_CaretMovedBackward; k.CaretMovedForward += this.keyboard1_CaretMovedForward; k.CharacterDeleted += this.keyboard1_CharacterDeleted; k.SelectionMovedBackward += this.keyboard1_SelectionMovedBackward; k.SelectionMovedForward += this.keyboard1_SelectionMovedForward; k.EnterPressed += this.keyboard1_Enter; k.KeyPressed += this.keyboard1_KeyEvent; }
public MarkdownEditor(FrmMain thisform, TabPage page, WebControl preview) { _markdownPage = page; _thisForm = thisform; _previewBrowser = preview; createRTB(ref _markdownRtb); _markdownRtb.TextChanged += _markdownRtb_TextChanged; var elementHost = new ElementHost(); elementHost.Child = _markdownRtb; elementHost.Dock = DockStyle.Fill; page.Controls.Add(elementHost); }
private static dynamic getCategories(WebControl webControl1) { try { dynamic document = (JSObject)webControl1.ExecuteJavascriptWithResult("document"); dynamic filter = document.getElementsByName("_filter[kind]"); dynamic categories = filter[0].getElementsByTagName("*"); return categories; } catch (Exception exception) { return null; } }
protected void onPreRender(object sender, EventArgs e) { if (Mostrar) { WebControl ImportaGalerific = new WebControl(HtmlTextWriterTag.Script); ImportaGalerific.Attributes["type"] = "text/javascript"; ImportaGalerific.Attributes["src"] = FuncoesRequisicao.ObterUrlEnviaArquivo(Constantes.CaminhoScripts + "jquery.galleriffic.min.js"); Container.Controls.AddAt(0, ImportaGalerific); } else { Container.Controls.Remove(Galeria); } }
public static void ExportWebControlToExcel(string FileName, WebControl control) { HttpContext.Current.Response.Clear(); //HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=text/html;charset=utf-8>"); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpContext.Current.Server.UrlEncode(FileName) + ".xls"); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); control.RenderControl(hw); HttpContext.Current.Response.Write(sw.ToString()); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); }
public AwesomiumWPFWebWindow(WebSession iSession) { _Session = iSession; _WebControl = new WebControl() { WebSession = _Session, Visibility = Visibility.Hidden, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, ContextMenu = new ContextMenu() { Visibility = Visibility.Collapsed } }; _AwesomiumHTMLWindow = new AwesomiumHTMLWindow(_Session, _WebControl); }
void RenderButton(HtmlTextWriter writer) { IList <AttributeInfo> attributeInfoByCategoryId = new List <AttributeInfo>(); attributeInfoByCategoryId = ProductBrowser.GetAttributeInfoByCategoryId(this.CategoryId); if (attributeInfoByCategoryId.Count > 0) { foreach (AttributeInfo info in attributeInfoByCategoryId) { WebControl control = new WebControl(HtmlTextWriterTag.Label); control.Controls.Add(new LiteralControl("<li>")); control.RenderControl(writer); WebControl control2 = new WebControl(HtmlTextWriterTag.Label); control2.Controls.Add(new LiteralControl("<span>" + info.AttributeName + ":</span>")); control2.Attributes.Add("class", this.NameCss); control2.RenderControl(writer); WebControl control3 = new WebControl(HtmlTextWriterTag.A); control3.Controls.Add(new LiteralControl("全部")); string str = ""; if (!string.IsNullOrEmpty(this.ValueStr)) { string[] strArray = this.ValueStr.Split(new char[] { '-' }); if (strArray.Length >= 1) { for (int i = 0; i < strArray.Length; i++) { string[] strArray2 = strArray[i].Split(new char[] { '_' }); if ((strArray2.Length > 0) && (strArray2[0].IndexOf(info.AttributeId.ToString()) != -1)) { strArray2[1] = "0"; strArray[i] = strArray2[0] + "_" + strArray2[1]; } if (string.IsNullOrEmpty(str)) { str = str + strArray[i]; } else { str = str + "-" + strArray[i]; } } if (str.IndexOf(info.AttributeId.ToString()) == -1) { object obj2 = str; str = string.Concat(new object[] { obj2, "-", info.AttributeId, "_0" }); } } } else { str = info.AttributeId + "_0"; } if (string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"])) { control3.Attributes.Add("class", this.AllCss); } else { string str2 = this.Page.Request.QueryString["valueStr"]; if (str2 == str) { control3.Attributes.Add("class", this.AllCss); } } control3.Attributes.Add("href", this.CreateUrl(str)); control3.RenderControl(writer); foreach (AttributeValueInfo info2 in info.AttributeValues) { WebControl control4 = new WebControl(HtmlTextWriterTag.A); control4.Controls.Add(new LiteralControl(info2.ValueStr)); string str3 = ""; if (!string.IsNullOrEmpty(this.ValueStr)) { string[] strArray3 = this.ValueStr.Split(new char[] { '-' }); if (strArray3.Length >= 1) { for (int j = 0; j < strArray3.Length; j++) { string[] strArray4 = strArray3[j].Split(new char[] { '_' }); if ((strArray4.Length > 0) && (strArray4[0].IndexOf(info.AttributeId.ToString()) != -1)) { strArray4[1] = info2.ValueId.ToString(); strArray3[j] = strArray4[0] + "_" + strArray4[1]; } if (string.IsNullOrEmpty(str3)) { str3 = str3 + strArray3[j]; } else { str3 = str3 + "-" + strArray3[j]; } } if (str3.IndexOf(info.AttributeId.ToString() + "_") == -1) { object obj3 = str3; str3 = string.Concat(new object[] { obj3, "-", info2.AttributeId, "_", info2.ValueId }); } } } else { str3 = info2.AttributeId + "_" + info2.ValueId; } bool flag = false; if (!string.IsNullOrEmpty(this.Page.Request.QueryString["valueStr"])) { IList <AttributeValueInfo> list2 = new List <AttributeValueInfo>(); string str4 = Globals.UrlDecode(this.Page.Request.QueryString["valueStr"]); string[] strArray5 = str4.Split(new char[] { '-' }); if (!string.IsNullOrEmpty(str4)) { for (int k = 0; k < strArray5.Length; k++) { string[] strArray6 = strArray5[k].Split(new char[] { '_' }); if (((strArray6.Length > 0) && !string.IsNullOrEmpty(strArray6[1])) && (strArray6[1] != "0")) { AttributeValueInfo item = new AttributeValueInfo(); item.AttributeId = Convert.ToInt32(strArray6[0]); item.ValueId = Convert.ToInt32(strArray6[1]); if (info2.ValueId == Convert.ToInt32(strArray6[1])) { control4.Attributes.Add("class", this.SelectCss); flag = true; } list2.Add(item); } } } } if (!flag) { control4.Attributes.Add("href", this.CreateUrl(str3)); } control4.RenderControl(writer); } WebControl control5 = new WebControl(HtmlTextWriterTag.Label); control5.Controls.Add(new LiteralControl("</li>")); control5.RenderControl(writer); } } }
/// <summary> /// 控件点击 消息确认提示框 /// </summary> /// <param name="control">Web控件</param> /// <param name="message">提示信息</param> public static void ShowConfirm(WebControl control, string message) { //Control.Attributes.Add("onClick","if (!window.confirm('"+msg+"')){return false;}"); control.Attributes.Add("onclick", "return confirm('" + EncodeJS(message) + "');"); }
/// <summary> /// Helper function to bind the API functions to a web control. /// </summary> /// <param name="pControl">The web control to bind the functions too.</param> private void BindAPIFunctions(WebControl pControl) { // Create and acquire a global Javascript object - this will persist for the lifetime of the web-view. using (JSObject pAuthority = pControl.CreateGlobalJavascriptObject(Authority.APIObject_Authority)) { // Handle requests for Authority.request. pAuthority.Bind(Authority.APIObject_AuthorityRequest, false, (s, e) => { // Process the arguments. var sHandler = (e.Arguments.Length > 0 && e.Arguments[0].IsString) ? ((String)e.Arguments[0]) : null; var dObject = (e.Arguments.Length > 1 && e.Arguments[1].IsObject) ? e.Arguments[1] : new JSValue(); // Return the result. var bResult = Authority.ProcessRequest(this, this.ActiveSurface, sHandler, dObject); //e.Result = new JSValue(bResult); }); // Handle requests for Authority.request. pAuthority.Bind(Authority.APIObject_AuthorityCall, false, (s, e) => { // Process the arguments. var sTargetSurface = (e.Arguments.Length > 0 && e.Arguments[0].IsString) ? ((String)e.Arguments[0]) : null; var sTargetFunction = (e.Arguments.Length > 1 && e.Arguments[1].IsString) ? ((String)e.Arguments[1]) : null; //var dObject = (e.Arguments.Length > 2 && e.Arguments[2].IsObject) ? e.Arguments[2] : new JSValue(); List <JSValue> lArgs = new List <JSValue>(); for (int iArg = 2; iArg < e.Arguments.Length; ++iArg) { lArgs.Add(e.Arguments[iArg]); } // Return the result. var bResult = Authority.ProcessRMICall(this, this.ActiveSurface, sTargetSurface, sTargetFunction, lArgs.ToArray()); //e.Result = new JSValue(bResult); }); // Handle requests for Authority.request. pAuthority.Bind(Authority.APIObject_AuthorityLog, false, (s, e) => { // Process the arguments. StringBuilder sOut = new StringBuilder(); for (int iArg = 0; iArg < e.Arguments.Length; ++iArg) { sOut.Append(ToJSON(e.Arguments[iArg])); if (iArg < (e.Arguments.Length - 1)) { sOut.Append(" --- "); } } // Return the result. Log.Write("JS Message: " + sOut.ToString(), this.ToString(), Log.Type.DisplayInfo); }); } // Create a surface object. using (JSObject pSurface = pControl.CreateGlobalJavascriptObject(Authority.APIObject_Surface)) { pSurface["Name"] = new JSValue(ActiveSurface.Identifier); pSurface["Width"] = new JSValue(ActiveSurface.Width); pSurface["Height"] = new JSValue(ActiveSurface.Height); pSurface["AspectRatio"] = new JSValue(ActiveSurface.AspectRatio); pSurface["Angle"] = new JSValue(ActiveSurface.Angle); } // Signal that the properties have changed too. //SignalSurfacePropertiesChanged(); }
public void FieldsManagerTest() { fieldList = new List <IField>(); #region Reflection Test /* * Reflection test */ FieldsManager.LoadTypes(); List <Type> lt = FieldsManager.FieldTypes; Assert.IsTrue(lt.Count > 0); List <MethodInfo> lm1 = FieldsManager.GetConstraints(lt[0]); List <MethodInfo> lm2 = FieldsManager.GetConstraints(lt[1]); Assert.IsNotNull(lm1); Assert.IsNotNull(lm2); Console.WriteLine("--Report1 (reflection test)--"); Console.WriteLine("Types found:"); foreach (Type t in lt) { Console.WriteLine(t.Name); } Console.WriteLine("Constraints for Field: " + lt[0].Name); foreach (MethodInfo m in lm1) { Console.WriteLine(m.Name); } Console.WriteLine("Constraints for Field: " + lt[1].Name); foreach (MethodInfo m in lm2) { Console.WriteLine(m.Name); } #endregion #region Instance Creation Test 1 fieldList.Add(FieldsManager.GetInstance(lt[0])); fieldList.Add(FieldsManager.GetInstance(lt[0])); fieldList.Add(FieldsManager.GetInstance(lt[0])); fieldList.Add(FieldsManager.GetInstance(lt[0])); fieldList.Add(FieldsManager.GetInstance(lt[1])); fieldList.Add(FieldsManager.GetInstance(lt[1])); fieldList.Add(FieldsManager.GetInstance(lt[1])); fieldList.Add(FieldsManager.GetInstance(lt[1])); foreach (IField f in fieldList) { Assert.IsNotNull(f); } for (int i = 0; i < fieldList.Count; i++) { fieldList[i].TypeName = "type" + i; } Console.WriteLine("Fields schema"); XmlSchema xsch = new XmlSchema(); XmlWriterSettings xset = new XmlWriterSettings(); xset.ConformanceLevel = ConformanceLevel.Auto; XmlWriter xwr = XmlWriter.Create(Console.Out, xset); foreach (IField f in fieldList) { xsch.Items.Add(f.TypeSchema); } xsch.Write(xwr); #endregion #region Instance Manipulation //Add Constraint to IntBox /* if (f1 is IntBox) * { * Assert.IsTrue(((IntBox)f1).AddGreaterThanConstraint(1)); * } * Console.WriteLine("IntBox with Constraint"); * XmlSchemaComplexType xsd3 = f1.TypeSchema; * xsch = new XmlSchema(); * xsch.Items.Add(xsd3); * //prints new schema to output * xsch.Write(xwr); */ XmlSchemaSet xsdset = new XmlSchemaSet(); XmlSchema xsd4 = XmlSchema.Read(new StringReader(TestResources.BaseTypes), ValidationEventHandler); xsdset.Add(xsd4); int count1 = 0, count2 = 0; foreach (IField f in fieldList) { xsch = new XmlSchema(); if (f is IntBox) { switch (count1) { case 0: { Assert.IsTrue(((IntBox)f).AddGreaterThanConstraint(1)); } break; case 1: { Assert.IsTrue(((IntBox)f).AddIntervalConstraint(3, 100)); } break; case 2: { Assert.IsTrue(((IntBox)f).AddLowerThanConstraint(9000)); } break; case 3: { Assert.IsTrue(((IntBox)f).AddLowerThanConstraint(0)); Assert.IsTrue(((IntBox)f).AddGreaterThanConstraint(-1000)); // Assert.IsFalse(((IntBox)f).AddLowerThanConstraint(0)); // Assert.IsFalse(((IntBox)f).AddLowerThanConstraint(0)); // Assert.IsFalse(((IntBox)f).AddGreaterThanConstraint(-1000)); } break; } count1++; } if (f is StringBox) { switch (count2) { case 0: { Assert.IsTrue(((StringBox)f).AddMinLengthConstraint(2)); Assert.IsTrue(((StringBox)f).AddMaxLengthConstraint(10)); } break; case 1: { Assert.IsTrue(((StringBox)f).AddPatternConstraint("[0-9]")); Assert.IsTrue(((StringBox)f).AddMaxLengthConstraint(1)); } break; case 2: { Assert.IsTrue(((StringBox)f).AddMaxLengthConstraint(2)); // Assert.IsFalse(((StringBox)f).AddMaxLengthConstraint(2)); // Assert.IsFalse(((StringBox)f).AddMinLengthConstraint(-2)); Assert.IsTrue(((StringBox)f).AddMinLengthConstraint(1)); } break; case 3: { } break; } count2++; } XmlSchemaComplexType xsd3 = f.TypeSchema; xsch.Items.Add(xsd3); xsdset.Add(xsch); } XmlSchema compiledSchema = null; xsdset.Compile(); foreach (XmlSchema sch in xsdset.Schemas()) { compiledSchema = sch; compiledSchema.Write(Console.Out); Console.Out.WriteLine(); } #endregion #region Instance Retrieving XmlSchema xsd5 = XmlSchema.Read(new StringReader(TestResources.BaseTypes), ValidationEventHandler); XmlSchema xsd6 = XmlSchema.Read(new StringReader(TestResources.Field1), ValidationEventHandler); XmlSchema xsd7 = XmlSchema.Read(new StringReader(TestResources.Field2), ValidationEventHandler); XmlSchema xsd8 = XmlSchema.Read(new StringReader(TestResources.Elem1), ValidationEventHandler); XmlSchemaSet xset2 = new XmlSchemaSet(); xset2.Add(xsd5); xset2.Add(xsd6); xset2.Add(xsd7); xset2.Add(xsd8); xset2.Compile(); List <IField> lf = new List <IField>(); foreach (XmlSchemaElement elem in ((XmlSchemaSequence)((XmlSchemaComplexType)xsd8.Items[0]).ContentTypeParticle).Items) { Assert.IsNotNull(elem); IField felem = FieldsManager.GetInstance(xset2, elem); Assert.IsNotNull(felem); lf.Add(felem); } Assert.IsTrue(lf.Count > 0); //XmlSchemaElement elem1 =((XmlSchemaElement)((XmlSchemaSequence)compl1.ContentTypeParticle).Items[0]); //XmlSchemaElement elem2 = ((XmlSchemaElement)((XmlSchemaSequence)compl2.ContentTypeParticle).Items[0]); Console.Out.WriteLine("------Fields Retrieved-------"); List <WebControl> wl = new List <WebControl>(); foreach (IField l in lf) { Assert.IsNotNull(l.Name); Console.Out.WriteLine("Field name: " + l.Name); WebControl w = l.GetWebControl(); Assert.IsNotNull(w); List <BaseValidator> vl = l.GetValidators(); Assert.IsNotNull(vl); Assert.IsTrue(vl.Count > 0); XmlSchema xs = new XmlSchema(); xs.Items.Add(l.TypeSchema); xs.Write(Console.Out); foreach (BaseValidator v in vl) { Console.Out.WriteLine("Validator:" + v.GetType().Name); } } //WebControl w=l.GetWebControl(); // Assert.IsNotNull(w); // w. #endregion }
private void RenderResultsFile(List <FileSearchResult> searchResults) { int cx = 0; foreach (FileSearchResult record in searchResults) { int lastrowindex = resultsTable.Rows.Count; HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell = new HtmlTableCell(); cell.Style[HtmlTextWriterStyle.VerticalAlign] = "top"; cell.ID = "fileCell" + cx.ToString(); resultsTable.Rows.Add(row); row.Cells.Add(cell); //Title: /*HyperLink b = new HyperLink(); * b.NavigateUrl = "~/Pages/SM/SM202510.aspx?fileID=" + record.Url; * b.CssClass = "searchresultTitle"; * b.Text = record.Title; * b.ForeColor = Color.DarkBlue; * b.ID = "srchNavBtn_" + cell.ID + "_0"; * cell.Controls.Add(b);*/ var link = new HyperLink() { CssClass = "searchresultTitle", Text = "<u><nobr>" + record.Title + "</nobr></u>", NavigateUrl = Request.GetWebsiteUrl().Trim('/') + Request.Url.PathAndQuery + "&" + "file=" + HttpUtility.UrlEncode(record.Url) }; cell.Controls.Add(link); /* * //Title: * PXButton b = new PXButton(); * b.BorderColor = Color.Transparent; * b.BorderWidth = 0; * b.RenderAsButton = false; * b.CssClass = "searchresultTitle"; * b.Text = "<u><nobr>" + record.Title + "</nobr></u>"; * //b.Text = "<a href='javascript:void'>" + record.Title + "</a>"; * b.Styles.Hover.Cursor = WebCursor.Hand; * b.CommandName = "navigate:" + record.Url; * b.ForeColor = Color.DarkBlue; * b.AutoCallBack.Command = "navigate"; * b.AutoCallBack.Enabled = true; * b.AutoCallBack.Behavior.PostData = PostDataMode.Container; * b.AutoCallBack.Behavior.RepaintControls = RepaintMode.All; * b.AutoCallBack.Behavior.ContainerID = "PXFormView1"; * b.AutoCallBack.Behavior.BlockPage = true; * b.CallBack += new PXCallBackEventHandler(navigate_CallBack_Files); * b.ID = "srchNavBtn_" + cell.ID + "_0"; * cell.Controls.Add(b); */ //Lines: WebControl divLine1 = new WebControl(HtmlTextWriterTag.Div); divLine1.CssClass = "searchresultLine"; divLine1.Controls.Add(new LiteralControl(record.Line1)); cell.Controls.Add(divLine1); cx++; } }
/// <summary> /// 显示客户端确认窗口 /// </summary> /// <param name="control"></param> /// <param name="eventName"></param> /// <param name="message"></param> public static void ShowCilentConfirm(WebControl control, string eventName, string message) { ShowCilentConfirm(control, eventName, "系统提示", 210, 125, message); }
public HanGame(WebControl webControl) : base(webControl) { webControl.LoadingFrameComplete -= onFinishLoading; webControl.LoadingFrameComplete += onFinishLoading; }
private static WebControl GetPanelWithDimensionsAndBorder(BannerAdvertDimensions dimensions, WebControl control) { /* unnecessary border causing errors with displaying * try * { * //Weird exception is sometimes thrown from there * control.BorderColor = System.Drawing.Color.FromArgb(220, 220, 220); //Grey * control.BorderStyle = BorderStyle.Solid; * control.BorderWidth = Unit.Pixel(1); * } * catch (Exception ex) * { } */ return(control); }
public static void RegisterShow(this WebControl registerControl, string message) { RegisterShowControl(registerControl, message, "onclick", null); }
public void ExecuteOnPreRender(WebControl control, EventArgs args) { // Modify the size, border, etc... any property that is // common to the controls in question }
public static void RenderControls(Control container, EntityFieldDef[] fields, FieldBehavior[] behaviors, string validationGroup) { if (fields == null || fields.Length == 0) { return; } if (behaviors == null || behaviors.Length == 0) { behaviors = new FieldBehavior[fields.Length]; for (int i = 0; i < fields.Length; i++) { behaviors[i] = CreateDefaultBehavior(fields[i]); } RenderControls(container, fields, behaviors, validationGroup); return; } HtmlTable tbl = new HtmlTable(); container.Controls.Add(tbl); foreach (FieldBehavior behavior in behaviors) { EntityFieldDef field = null; foreach (EntityFieldDef tempField in fields) { if (string.Compare(tempField.Name, behavior.FieldName, true) == 0) { field = tempField; break; } } if (field == null) { continue; } HtmlTableRow row = new HtmlTableRow(); tbl.Rows.Add(row); HtmlTableCell cell = new HtmlTableCell(); //label cell.Width = string.Format("{0}px", _labelWidth); cell.Align = "right"; row.Controls.Add(cell); Label lblControl = new Label(); lblControl.Text = field.Caption; cell.Controls.Add(lblControl); //seperator: cell = new HtmlTableCell(); cell.InnerText = ":"; row.Controls.Add(cell); //control cell = new HtmlTableCell(); row.Controls.Add(cell); WebControl control = DataModelControlHelper.CreateControl(field, behavior); cell.Controls.Add(control); //add validators cell = new HtmlTableCell(); row.Controls.Add(cell); BaseValidator[] validators = DataModelControlHelper.GetValidators(field, validationGroup); foreach (BaseValidator validator in validators) { validator.ControlToValidate = control.ID.ToString(); cell.Controls.Add(validator); } } }
public void SetInputValueFromControlValue(WebControl ctl) { this.InputValue = GetControlValue(ctl); }
public void CopyBaseAttributes(WebControl controlSrc) { }
public XmlNode GetValue(WebControl ctrl) { return(null); }
/// <summary> /// 为指定控件绑定前台脚本:显示模态窗口 /// </summary> /// <param name="control"></param> /// <param name="eventName"></param> /// <param name="wid"></param> /// <param name="title"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="url"></param> /// <param name="isScriptEnd"></param> public static void ShowCilentModalWindow(string wid, WebControl control, string eventName, string title, int width, int height, string url, bool isScriptEnd) { string script = isScriptEnd ? "return false;" : ""; control.Attributes[eventName] = string.Format("showModalWindow('{0}','{1}',{2},{3},'{4}');" + script, wid, title, width, height, url); }
public static void NumberOnlyTextBox(WebControl textBoxControl) { textBoxControl.Attributes.Add("onkeypress", "javascript:return NumbersOnly(event);"); }
/// <summary> /// 显示客户端确认窗口 /// </summary> /// <param name="control"></param> /// <param name="eventName"></param> /// <param name="title"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="message"></param> public static void ShowCilentConfirm(WebControl control, string eventName, string title, int width, int height, string message) { control.Attributes[eventName] = string.Format("return showConfirm('{0}',{1},{2},'{3}','{4}');", title, width, height, message, control.ClientID); }
/// <summary> /// Create a new visual to render. /// </summary> /// <returns></returns> private WebControl CreateRenderable() { // Get the web control. var pControl = new WebControl(); // Create a web-session with our settings. if (pWebSession == null) { pWebSession = WebCore.CreateWebSession(new WebPreferences() { EnableGPUAcceleration = Properties.Settings.Default.EnableGPUAcceleration, Databases = Properties.Settings.Default.EnableWebDatabases, WebGL = Properties.Settings.Default.EnableWebGL, WebSecurity = Properties.Settings.Default.EnableWebSecurity, FileAccessFromFileURL = Properties.Settings.Default.EnableWebFileAccessFromFileURL, Plugins = true, }); } pControl.WebSession = pWebSession; // Set the render dimensions. pControl.Width = this.RenderResolution.X; pControl.Height = this.RenderResolution.Y; // Hide the surface while we load. if (ActiveSurface != null) { ActiveSurface.ContentOpacity = 0.01; } // When the process has been createad, bind the global JS objects. // http://awesomium.com/docs/1_7_rc3/sharp_api/html/M_Awesomium_Core_IWebView_CreateGlobalJavascriptObject.htm pControl.ProcessCreated += (object sender, EventArgs e) => { // CALLING window.Surface = {} in JS here has no effect. // Bind all the Authority.request and Authority.call methods. Log.Write("Display Process Created (1)", this.ToString(), Log.Type.AppError); BindAPIFunctions(pControl); }; UrlEventHandler p = null; p = new UrlEventHandler((object senderOuter, UrlEventArgs eOuter) => { // Unbind this handler. pControl.DocumentReady -= p; // Force a re-load so the $(document).ready will have access to our Authority.request etc. pControl.Reload(false); // CALLING window.Surface = {} in JS here has no effect. //SignalSurfacePropertiesChanged(); Log.Write("Display DocReady (1)", this.ToString(), Log.Type.AppError); // Bind the other events. #region Events // Handle navigating away from the URL in the load instruction. pControl.AddressChanged += (object sender, UrlEventArgs e) => { // Rebind the API methods? Log.Write("Display has changed web address. " + e.Url, this.ToString(), Log.Type.DisplayInfo); }; // Handle console messages. pControl.TitleChanged += (object sender, TitleChangedEventArgs e) => { this.Title = e.Title; }; // Document ready.. do we beat JQuery? pControl.DocumentReady += (object sender, UrlEventArgs e) => { // Show the surface now we are loaded. if (ActiveSurface != null) { ActiveSurface.ContentOpacity = 1.0; } // CALLING window.Surface = {} in JS here does not work quick enough. Log.Write("Display DocReady (2)", this.ToString(), Log.Type.AppError); SignalSurfacePropertiesChanged(); // EXPERIMENTAL - this sort of works.. depends on how the page detects touch events.. // SEE: Nice example: http://paulirish.com/demo/multi // SEE: Nicer example: Bing maps! // Try to inject multi-touch into the page. if (ActiveSurface.AttemptMultiTouchInject) { pControl.ExecuteJavascript(Properties.Resources.MultiTouchInject); } }; // Handle changes in responsiveness. pControl.ResponsiveChanged += (object sender, ResponsiveChangedEventArgs e) => { // If it is not responsive, log the problem. if (!e.IsResponsive) { Log.Write("Display is not responsive. Try reloading.", this.ToString(), Log.Type.DisplayError); //this.Reload(false, true); } else { Log.Write("Ready", this.ToString(), Log.Type.DisplayError); } }; // Handle crashes by reloading. pControl.Crashed += (object sender, CrashedEventArgs e) => { // Log the crash. Log.Write("Display crashed - forcing reload. Termination Status = " + e.Status.ToString(), this.LoadInstruction, Log.Type.DisplayError); // Force a hard-reload. This will remove then re-create the entire web control. this.Reload(true); }; /* * // Handle javascript updates. * pControl.JSConsoleMessageAdded += (object sender, Awesomium.Core.JSConsoleMessageEventArgs e) => * { * Log.Write("JS line " + e.LineNumber + ": " + e.Message, pActiveDisplay.ToString(), Log.Type.DisplayInfo); * }; * * // Handle pop-up messages (like alert). * pControl.ShowPopupMenu += (object sender, PopupMenuEventArgs e) => * { * * }; */ #endregion }); pControl.DocumentReady += p; // Set the load instruction. // n.b. we have to then re-load it later to get access to our value pControl.Source = new Uri(this.LoadInstruction); // Return the created control. return(pControl); }
public static WebControl CreateControl(EntityFieldDef field, FieldBehavior behavior) { WebControl control = null; switch (behavior.ControlType) { case ControlTypes.List: { control = new DropDownList(); if (!string.IsNullOrEmpty(behavior.ExtraItem)) { if (field.Nullable) { (control as DropDownList).Items.Add(new ListItem(string.Empty, string.Empty)); } string[] items = behavior.ExtraItem.Split('|'); foreach (string item in items) { string[] textValue = item.Split(','); if (textValue.Length == 1) { (control as DropDownList).Items.Add(new ListItem(item, item)); } else { (control as DropDownList).Items.Add(new ListItem(textValue[0], textValue[1])); } } } else if (field.DataType == DataTypes.Boolean) { if (field.Nullable) { (control as DropDownList).Items.Add(new ListItem(string.Empty, string.Empty)); } (control as DropDownList).Items.Add(new ListItem("Yes", true.ToString())); (control as DropDownList).Items.Add(new ListItem("No", false.ToString())); } } break; case ControlTypes.Label: { control = new Label(); } break; case ControlTypes.Text: case ControlTypes.MultiText: default: { TextBox textBox = new TextBox(); control = textBox; if (behavior.ControlType == ControlTypes.MultiText) { textBox.TextMode = TextBoxMode.MultiLine; textBox.Height = new Unit(60); } if (field.DataType == DataTypes.String) { int maxLength = field.Length; if (maxLength <= 0 || maxLength > 256) { textBox.MaxLength = 256; } else { textBox.MaxLength = maxLength; } } else if (field.DataType == DataTypes.Int) { textBox.MaxLength = 10; } else if (field.DataType == DataTypes.Decimal) { textBox.MaxLength = 18; } } break; } control.ID = _prefix + field.Name; control.Width = new Unit(behavior.Width == 0 ? _defaultWidth : behavior.Width); control.Enabled = !behavior.Readonly; return(control); }
public static void RegisterShow(this WebControl registerControl, string message, EventHandler wrongLogical) { RegisterShowControl(registerControl, message, "onclick", wrongLogical); }
protected override void CreateChildControls() { this.Controls.Clear(); if (!this.dataLoaded) { if (!string.IsNullOrEmpty(this.Context.Request.Form["regionSelectorValue"])) { this.currentRegionId = new int?(int.Parse(this.Context.Request.Form["regionSelectorValue"])); } this.dataLoaded = true; } if (this.currentRegionId.HasValue) { XmlNode region = RegionHelper.GetRegion(this.currentRegionId.Value); if (region != null) { if (region.Name == "county") { this.countyId = new int?(this.currentRegionId.Value); this.cityId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value)); this.provinceId = new int?(int.Parse(region.ParentNode.ParentNode.Attributes["id"].Value)); } else { if (region.Name == "city") { this.cityId = new int?(this.currentRegionId.Value); this.provinceId = new int?(int.Parse(region.ParentNode.Attributes["id"].Value)); } else { if (region.Name == "province") { this.provinceId = new int?(this.currentRegionId.Value); } } } } } this.Controls.Add(RegionSelector.CreateTitleControl(this.ProvinceTitle)); this.ddlProvinces = this.CreateDropDownList("ddlRegions1"); RegionSelector.FillDropDownList(this.ddlProvinces, RegionHelper.GetAllProvinces(), this.provinceId); this.Controls.Add(RegionSelector.CreateTag("<span>")); this.Controls.Add(this.ddlProvinces); this.Controls.Add(RegionSelector.CreateTag("</span>")); this.Controls.Add(RegionSelector.CreateTitleControl(this.CityTitle)); this.ddlCitys = this.CreateDropDownList("ddlRegions2"); if (this.provinceId.HasValue) { RegionSelector.FillDropDownList(this.ddlCitys, RegionHelper.GetCitys(this.provinceId.Value), this.cityId); } this.Controls.Add(RegionSelector.CreateTag("<span>")); this.Controls.Add(this.ddlCitys); this.Controls.Add(RegionSelector.CreateTag("</span>")); Dictionary <int, string> dtCountys = new Dictionary <int, string>(); if (this.cityId.HasValue) { dtCountys = RegionHelper.GetCountys(this.cityId.Value); } Label countyTitle = RegionSelector.CreateTitleControl(this.CountyTitle); if (dtCountys.Count <= 0) { countyTitle.Style.Add("display", "none"); } else { countyTitle.Style.Add("display", "block"); } this.Controls.Add(countyTitle); this.ddlCountys = this.CreateDropDownList("ddlRegions3"); if (this.cityId.HasValue) { RegionSelector.FillDropDownList(this.ddlCountys, dtCountys, this.countyId); } if (dtCountys.Count <= 0) { this.ddlCountys.Style.Add("display", "none"); } else { this.ddlCountys.Style.Add("display", "block"); } this.Controls.Add(RegionSelector.CreateTag("<span>")); this.Controls.Add(this.ddlCountys); this.Controls.Add(RegionSelector.CreateTag("</span>")); }
public static void FreezeTextBox(WebControl textBoxControl) { textBoxControl.Attributes.Add("onkeypress", "javascript:return NoType(event);"); }
// This static handler, will handle the ShowCreatedWebView event for both the // WebControl of our main application window, as well as for any other windows // hosting WebControls. internal static void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { WebControl webControl = sender as WebControl; if (webControl == null) { return; } if (!webControl.IsLive) { return; } // Create an instance of our application's child window, that will // host the new view instance, either we wrap the created child view, // or we let the WebControl create a new underlying web-view. ChildWindow newWindow = new ChildWindow(); // Treat popups differently. If IsPopup is true, the event is always // the result of 'window.open' (IsWindowOpen is also true, so no need to check it). // Our application does not recognize user defined, non-standard specs. // Therefore child views opened with non-standard specs, will not be presented as // popups but as regular new windows (still wrapping the child view however -- se below). if (e.IsPopup && !e.IsUserSpecsOnly) { // JSWindowOpenSpecs.InitialPosition indicates screen coordinates. Int32Rect screenRect = e.Specs.InitialPosition.GetInt32Rect(); // Set the created native view as the underlying view of the // WebControl. This will maintain the relationship between // the parent view and the child, usually required when the new view // is the result of 'window.open' (JS can access the parent window through // 'window.opener'; the parent window can manipulate the child through the 'window' // object returned from the 'window.open' call). newWindow.NativeView = e.NewViewInstance; // Do not show in the taskbar. newWindow.ShowInTaskbar = false; // Set a border-style to indicate a popup. newWindow.WindowStyle = WindowStyle.ToolWindow; // Set resizing mode depending on the indicated specs. newWindow.ResizeMode = e.Specs.Resizable ? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize; // If the caller has not indicated a valid size for the new popup window, // let it be opened with the default size specified at design time. if ((screenRect.Width > 0) && (screenRect.Height > 0)) { // Assign the indicated size. newWindow.Width = screenRect.Width; newWindow.Height = screenRect.Height; } // Show the window. newWindow.Show(); // If the caller has not indicated a valid position for the new popup window, // let it be opened in the default position specified at design time. if ((screenRect.Y > 0) && (screenRect.X > 0)) { // Move it to the indicated coordinates. newWindow.Top = screenRect.Y; newWindow.Left = screenRect.X; } } else if (e.IsWindowOpen || e.IsPost) { // No specs or only non-standard specs were specified, but the event is still // the result of 'window.open' or of an HTML form with tagret="_blank" and method="post". // We will open a normal window but we will still wrap the new native child view, // maintaining its relationship with the parent window. newWindow.NativeView = e.NewViewInstance; // Show the window. newWindow.Show(); } else { // The event is not the result of 'window.open' or of an HTML form with tagret="_blank" // and method="post"., therefore it's most probably the result of a link with target='_blank'. // We will not be wrapping the created view; we let the WebControl hosted in ChildWindow // create its own underlying view. Setting Cancel to true tells the core to destroy the // created child view. // // Why don't we always wrap the native view passed to ShowCreatedWebView? // // - In order to maintain the relationship with their parent view, // child views execute and render under the same process (awesomium_process) // as their parent view. If for any reason this child process crashes, // all views related to it will be affected. When maintaining a parent-child // relationship is not important, we prefer taking advantage of the isolated process // architecture of Awesomium and let each view be rendered in a separate process. e.Cancel = true; // Note that we only explicitly navigate to the target URL, when a new view is // about to be created, not when we wrap the created child view. This is because // navigation to the target URL (if any), is already queued on created child views. // We must not interrupt this navigation as we would still be breaking the parent-child // relationship. newWindow.Source = e.TargetURL; // Show the window. newWindow.Show(); } }
public Authentication(WebControl webControl) { _webControl = webControl; }
protected override void CreateChildControls() { this.Controls.Clear(); WebControl webControl = new WebControl(HtmlTextWriterTag.Input); webControl.Attributes.Add("id", this.ID.ToString() + "_hdPhotoListOriginal"); webControl.Attributes.Add("name", this.ID.ToString() + "_hdPhotoListOriginal"); webControl.Attributes.Add("type", "hidden"); webControl.Attributes.Add("value", this._Value); WebControl webControl2 = new WebControl(HtmlTextWriterTag.Input); webControl2.Attributes.Add("id", this.ID + "_hdPhotoList"); webControl2.Attributes.Add("name", this.ID + "_hdPhotoList"); webControl2.Attributes.Add("type", "hidden"); webControl2.Attributes.Add("value", this._Value); WebControl webControl3 = new WebControl(HtmlTextWriterTag.Div); webControl3.Attributes.Add("id", this.ID + "_divFileProgressContainer"); webControl3.Attributes.Add("style", "height: 75px;display:none;"); Literal literal = new Literal(); StringBuilder stringBuilder = new StringBuilder(); string[] array = this._Value.Split(new char[] { ',' }); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string img = array2[i]; stringBuilder.Append(this.GetOneImgHtml(img)); } literal.Text = stringBuilder.ToString(); Literal literal2 = new Literal(); literal2.Text = string.Concat(new string[] { "<div id=\"", this.ID, "_divImgList\"><div class=\"picfirst\"></div>", stringBuilder.ToString(), "</div>" }); WebControl webControl4 = new WebControl(HtmlTextWriterTag.Div); webControl4.Attributes.Add("id", this.ID + "_divFlashUploadHolder"); webControl4.Attributes.Add("style", "width: 91px; margin: 0px 10px;float: left;"); this.Controls.Add(webControl); this.Controls.Add(webControl2); this.Controls.Add(webControl3); this.Controls.Add(literal2); this.Controls.Add(webControl4); int num = array.Length; if (string.IsNullOrEmpty(this._Value)) { num = 0; } else if (this._MaxNum <= num) { webControl4.Style.Add("display", "none"); } Literal literal3 = new Literal(); literal3.Text = string.Concat(new object[] { "<script type=\"text/javascript\">var obj", this.ID, "_hdPhotoList = new FlashUploadObject(\"", this.ID, "_hdPhotoList\", \"", this.ID, "_divImgList\", \"", this.ID, "_divFlashUploadHolder\", \"picfirst\", \"", this.ID, "_divFileProgressContainer\", ", this.MaxNum, ",", num, ");obj", this.ID, "_hdPhotoList.upfilebuttonload();obj", this.ID, "_hdPhotoList.GetPhotoValue();</script>" }); this.Controls.Add(literal3); }
public static void SetDisabledBootstrapButton(this WebControl value) { if (value is null || !(value is LinkButton || value is Button)) { throw new Exception(); }
internal static void SetUpTableAndCaption(WebControl table, EwfTableStyle style, ReadOnlyCollection <string> classes, string caption, string subCaption) { table.CssClass = StringTools.ConcatenateWithDelimiter(" ", new[] { getTableStyleClass(style) }.Concat(classes).ToArray()); addCaptionIfNecessary(table, caption, subCaption); }
/// <summary> /// The attach. /// </summary> /// <param name="ctl"> /// The ctl. /// </param> public void Attach([NotNull] WebControl ctl) { ctl.Attributes["onclick"] = this.ControlOnClick; ctl.Attributes["onmouseover"] = this.ControlOnMouseOver; }
//private string FixUrl(string url) //{ // string site = Request.GetWebsiteUrl(); // var uri = new System.Uri(url,); //} private void RenderResultsArticle(List <HelpSearchResult> searchResults) { int cx = 0; foreach (HelpSearchResult record in searchResults) { int lastrowindex = resultsTable.Rows.Count; HtmlTableRow row = new HtmlTableRow(); HtmlTableCell cell = new HtmlTableCell(); cell.Style[HtmlTextWriterStyle.VerticalAlign] = "top"; cell.ID = "articleCell" + cx.ToString(); resultsTable.Rows.Add(row); row.Cells.Add(cell); var uri = new System.Uri(HttpContext.Current.Request.Url, ResolveUrl(HttpUtility.UrlPathEncode("~/Wiki/ShowWiki.aspx?PageID=" + record.PageID.ToString()))); var query = Request.Params["query"]; var link = new HyperLink() { CssClass = "searchresultTitle", Text = "<u><nobr>" + record.Title + "</nobr></u>", NavigateUrl = Request.GetWebsiteUrl().Trim('/') + uri.PathAndQuery + "&navigate:" + record.PageID.ToString() + "&query=" + query }; cell.Controls.Add(link); /* * //Title: * PXButton b = new PXButton(); * b.BorderColor = Color.Transparent; * b.BorderWidth = 0; * b.RenderAsButton = false; * b.CssClass = "searchresultTitle"; * b.Text = "<u><nobr>" + record.Title + "</nobr></u>"; * b.Styles.Hover.Cursor = WebCursor.Hand; * b.CommandName = "navigate:" + record.PageID.ToString(); * b.ForeColor = Color.DarkBlue; * b.AutoCallBack.Command = "navigate"; * b.AutoCallBack.Enabled = true; * b.AutoCallBack.Behavior.PostData = PostDataMode.Container; * b.AutoCallBack.Behavior.RepaintControls = RepaintMode.All; * b.AutoCallBack.Behavior.ContainerID = "PXFormView1"; * b.AutoCallBack.Behavior.BlockPage = true; * b.CallBack += new PXCallBackEventHandler(navigate_CallBack_Wiki); * b.ID = "srchNavBtn_" + cell.ID + "_0"; * var menuItem1 = new PXMenuItem(Messages.Open) { CommandName = "Open", NavigateUrl = url }; * var menuItem = new PXMenuItem(Messages.OpenInNewTab) { CommandName = "Open", NavigateUrl = url, Target = "main", OpenFrameset = true }; * b.MenuItems.Add(menuItem1); * b.MenuItems.Add(menuItem); * b.RightButtonMenu = true; * b.RenderMenuButton = false; * b.RenderDropMenu = true; * cell.Controls.Add(b); */ //Path elements: WebControl divPath = new WebControl(HtmlTextWriterTag.Div); divPath.CssClass = "searchresultPath"; divPath.Controls.Add(new LiteralControl(record.Path)); cell.Controls.Add(divPath); //Lines: WebControl divLine1 = new WebControl(HtmlTextWriterTag.Div); divLine1.CssClass = "searchresultLine"; divLine1.Controls.Add(new LiteralControl(record.Text)); cell.Controls.Add(divLine1); cx++; } }
/// <summary> /// Pop up warning asking user to confirm deleting. /// </summary> /// <param name="btn"></param> /// <param name="deleteMessage"></param> /// <remarks></remarks> public static void ShowDeleteWarning(this WebControl btn, string deleteMessage) { AddDeleteConfirmation(btn, deleteMessage); }