internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell) { string image = FileSource(false, cell); if (HyperLinkColumn && Grid.DisplayView == DisplayView.Grid) { string a = Grid.EnableCallBack ? Asynchronous.GetCallbackEventReference(Grid, string.Format("RecordClick!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format("RecordClick!{0}!{1}", ColumnId, cell.Row. PrimaryKeyValues)); string b = (String.IsNullOrEmpty(ConfirmMessage)) ? string.Empty : String.Format("if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); image = string.Format( "<a class=\"wglinkfield\" href=\"#\" onclick=\"{0}{1}\">{2}</a>", b, a, image); } LabelHtml(image, writer, cell); }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <param name = "data">The asynchronous data provider.</param> /// <param name = "flags">Flags specifying how the command should operate.</param> /// <returns>The data retrieved from the GPU.</returns> public DataStream GetData(Asynchronous data, AsynchronousFlags flags) { var result = new DataStream(data.DataSize, true, true); GetDataInternal(data, result.DataPointer, (int)result.Length, flags); return(result); }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <param name = "data">The asynchronous data provider.</param> /// <param name = "flags">Flags specifying how the command should operate.</param> /// <returns>The data retrieved from the GPU.</returns> public T GetData <T>(Asynchronous data, AsynchronousFlags flags) where T : struct { T result; GetData <T>(data, flags, out result); return(result); }
/// <summary> /// Tells the message to the actor. /// </summary> /// <param name="message">the message.</param> /// <typeparam name="T">The type of the message.</typeparam> /// <returns>The response of the the actor.</returns> public IObservable <Unit> Send <T>(T message) { var future = new Asynchronous(message); this.mailBox.Add(future); return(Observable.Return(Unit.Default)); }
private void Example2_Click(object sender, RoutedEventArgs e) { var asynchronous = new Asynchronous(); asynchronous.LongRunningTaskCompleted += Asynchronous_LongRunningTaskCompleted; asynchronous.LongRunningTaskAsync(5); Example2Started.Visibility = Visibility.Visible; }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data">The asynchronous data provider.</param> /// <param name="flags">Flags specifying how the command should operate.</param> /// <param name="result">The data retrieved from the GPU.</param> /// <returns> /// True if result contains valid data, false otherwise. /// </returns> public bool GetData <T>(Asynchronous data, AsynchronousFlags flags, out T result) where T : struct { unsafe { result = default(T); return(GetDataInternal(data, (IntPtr)Interop.Fixed(ref result), Utilities.SizeOf <T>(), flags) == Result.Ok); } }
internal void Validate() { if (string.IsNullOrEmpty(ConnectionString)) { throw new ArgumentNullException(nameof(ConnectionString)); } Asynchronous.Validate(); Synchronous.Validate(); Error.Validate(); }
private static void AsyncTest2() { ILogger logger = FileLoggerFactory.Default.Create(true, "AsyncTest2.txt"); for (int i = 100; i < 200; i++) { int j = i; Asynchronous.Invoke(() => { logger.WriteInfo(j.ToString()); }); } }
private static void AsyncTest3() { ILogger logger = FileLoggerFactory.Default.Create(true, "AsyncTest3.txt"); for (int i = 200; i < 250; i++) { int j = i; Asynchronous.Invoke(() => { logger.WriteInfo(j.ToString()); }) .ContinueWithAsync(() => { logger.WriteInfo((j * 2).ToString()); }); } }
private static void AsyncTest1() { ILogger logger = FileLoggerFactory.Default.Create(true, "AsyncTest1.txt"); List <Operator> operators = new List <Operator>(); for (int i = 0; i < 100; i++) { int j = i; var @operator = Asynchronous.Invoke(() => { logger.WriteInfo(j.ToString()); }); operators.Add(@operator); } while (true) { Thread.Sleep(1000); } //operators.ForEach(o => o.Invoke()); }
public ServerResponse(byte[] buffer, Asynchronous.AsyncWrapper client) { fixed (byte* arg = buffer) { client.Identity = BitConverter.ToUInt32(buffer, 4); if (BitConverter.ToUInt32(buffer, 8) > 1) { if (buffer.Length > 32) { Program.GameAddress = Encoding.ASCII.GetString(buffer, 20, 16); Program.GameAddress.Trim('\0'); for (short i = 1; i > -1; i--) //zerobyting packet, will cause error upon connection *((byte*)arg + 12 + i) = 0; for (short i = 1; i > -1; i--) *((byte*)arg + 12 + i) = BitConverter.GetBytes(Program.WorldPort)[i]; for (ushort i = 0; i < 16; i++) *((byte*)(arg + 20 + i)) = 0; for (ushort i = 0; i < Program.ProxyAddress.Length; i++) *((byte*)(arg + 20 + i)) = (byte)Program.ProxyAddress[i]; Kernel.InQueueConnections.TryAdd(client.Identity, client); } } } }
/// <summary> /// Determines whether asynchronous query data is available. /// </summary> /// <param name="data">The data.</param> /// <param name="flags">Optional flags</param> /// <returns> /// <c>true</c> if asynchronous query data is available; otherwise, <c>false</c>. /// </returns> /// <unmanaged>HRESULT ID3D11DeviceContext::GetData([In] ID3D11Asynchronous* pAsync,[Out, Buffer, Optional] void* pData,[In] unsigned int DataSize,[In] D3D11_ASYNC_GETDATA_FLAG GetDataFlags)</unmanaged> public bool IsDataAvailable(Asynchronous data, AsynchronousFlags flags) { return(GetDataInternal(data, IntPtr.Zero, 0, flags) == Result.Ok); }
/// <summary> /// Determines whether asynchronous query data is available. /// </summary> /// <param name="data">The data.</param> /// <returns> /// <c>true</c> if asynchronous query data is available; otherwise, <c>false</c>. /// </returns> /// <unmanaged>HRESULT ID3D11DeviceContext::GetData([In] ID3D11Asynchronous* pAsync,[Out, Buffer, Optional] void* pData,[In] unsigned int DataSize,[In] D3D11_ASYNC_GETDATA_FLAG GetDataFlags)</unmanaged> public bool IsDataAvailable(Asynchronous data) { return(IsDataAvailable(data, AsynchronousFlags.None)); }
internal static void CreateFilterByColumns(Grid grid, WebGridHtmlWriter writer, int[] sortedColumnID) { grid.m_RowsAdded++; writer.Write( grid.IsUsingJQueryUICSSFramework ? "<tr class=\"ui-widget wgrow\" id=\"{0}r{1}\">" : "<tr class=\"wgrow\" id=\"{0}r{1}\">", grid.ID, grid.m_RowsAdded); for (int ii = 0; ii < sortedColumnID.Length; ii++) { Column column = grid.MasterTable.Columns[sortedColumnID[ii]]; if (column.FilterByColumnCollection.Count == 0) { string columnstyle = string.Empty; string columnId = string.Format(" id=\"{0}{1}r{2}\"", grid.ID, column.ColumnId, grid.m_RowsAdded); if (grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty) { columnstyle = string.Format("style=\"width: {0};\"", grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle); } writer.Write("<th {0} {1}> </th>", columnstyle, columnId); continue; } ColumnHeader addcolumn = new ColumnHeader { m_Class = string.Format("{0} wggridcell", column.CssClassTitle), m_Align = column.GridAlign, m_VAlign = VerticalPosition.bottom, m_ColumnWidth = grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle, m_GridRowCount = grid.m_RowsAdded, m_GridId = grid.ID }; addcolumn.RenderBeginTag(writer, column, null, "<th"); string selectedValue = null; if (Grid.GotHttpContext && HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)] != null) { selectedValue = HttpUtility.HtmlEncode( HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)]); grid.State(string.Format("ddl{0}", column.ClientHeaderId), selectedValue); } else if (grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) != null) { selectedValue = grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) as string; } bool isdate = false; if (grid.MasterTable.Columns[column.ColumnId].ColumnType == ColumnType.DateTime) { isdate = true; } string eventScript = string.Empty; if (grid.Page != null) { string link = grid.EnableCallBack && !column.ForcePostBack ? Asynchronous.GetCallbackEventReference(grid, string.Format("ElementPostBack!ddl{0}", column.ColumnId), false, string.Empty, string.Empty) : grid.Page.ClientScript.GetPostBackEventReference(grid, string.Format("ElementPostBack!ddl{0}", column.ColumnId)); eventScript = string.Format(" onchange=\"{0}\" ", link); } string style = grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty ? "class=\"wgeditfield wgselectbox \"" : " class=\"wgeditfield wgselectbox \" "; if (!isdate) { StringBuilder dropdownbox = new StringBuilder("<select "); dropdownbox.AppendFormat("{0} name=\"ddl{1}\" id=\"ddl{1}\" {2}><option value=\"\" selected=\"selected\">{3}</option>", style, column.ClientHeaderId, eventScript, column.Grid.GetSystemMessage("EmptySearchFilter")); if (grid.Scripts == null || !grid.Scripts.DisableSelectMenu) { Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$('#ddl{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});", column.ClientHeaderId, column.WidthColumnHeaderTitle.Value, 400)); } int i = 0; while (i < column.FilterByColumnCollection.Count) { string _value = HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]); string _title = HttpUtility.HtmlEncode(column.FilterByColumnCollection.GetKey(i)); if (selectedValue != null && selectedValue == _value) { dropdownbox.AppendFormat("<option selected=\"selected\" value=\"{0}\">{1}</option>", HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title); } else { dropdownbox.AppendFormat("<option value=\"{0}\">{1}</option>", HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title); } i++; } writer.Write(dropdownbox); writer.Write("</select> "); } else { if (grid.DatabaseConnectionType != DataBaseConnectionType.SqlConnection) { throw new GridException( string.Format("'FilterByColumn' property for 'DateTime' ({0}) columns are only supported by 'SqlConnection' connection strings.", column.ColumnId)); } writer.Write("<span style=\"white-space: nowrap;vertical-align:middle;\">"); string filter = ((WebGrid.DateTime)grid.MasterTable.Columns[column.ColumnId]).SearchFilter; if (string.IsNullOrEmpty(filter)) { StringBuilder s = new StringBuilder(string.Empty); s.AppendFormat( "<a class=\"wglinkfield\" href=\"?DateFilter={0}\">{1}</a>", grid.MasterTable.Columns[column.ColumnId].ColumnId, column.Grid.GetSystemMessage("DateTimeSearch")); writer.Write(s); } else { StringBuilder s = new StringBuilder(string.Empty); s.AppendFormat( "<a class=\"wglinkfield\" href=\"#\" onclick=\"javascript:WGdisableDateTimeSearch('{0}');\";return false;\">{1}</a>", column.ColumnId, column.Grid.GetSystemMessage("DateTimeSearchReset")); writer.Write(s); } // From date writer.Write("</span>"); } addcolumn.RenderEndTag(writer, "</th>"); } writer.Write("</tr>"); }
// 2005.01.19 - jorn, added this recursive function. private void RenderDetailTree(StringBuilder sb, string parentID, int level, RowCell cell) { if (parentID == null) { parentID = string.Empty; } List <string> selectedItems = new List <string>(); if (cell.Value != null && Grid.Page != null && Grid.Page.IsPostBack) { selectedItems.InsertRange(0, cell.Value.ToString().Split(',')); } for (int i = 0; i < Items.Count; i++) { if ((Items[i].ParentId ?? string.Empty) != parentID) { continue; } if (Grid.Page != null && Grid.Page.IsPostBack && selectedItems.Count > 0) { Items[i].Checked = selectedItems.Contains(Items[i].Value); } StringBuilder indentText = new StringBuilder(string.Empty); if (level > 0) { for (int j = 0; j < level; j++) { indentText.Append(TreeIndentText); } } StringBuilder selected = new StringBuilder(string.Empty); if (Items[i].Checked) { selected.Append(ManyToManyType == ManyToManyType.Multiselect ? " selected=\"selected\" " : " checked=\"checked\" "); } if (AllowEdit == false) { selected.Append(" disabled=\"disabled\" "); } if (ManyToManyType == ManyToManyType.Multiselect) { sb.AppendFormat("<option {0} value=\"{1}\">{2}{3}</option>", selected, Items[i].Value, indentText, Items[i].DisplayText); } else { if (i != 0) { if (m_Rowcounter == 0) { sb.Append("</tr><tr><td>"); m_Rowcounter = RecordsPerRow; } else { sb.Append("<td>"); } } m_Rowcounter--; sb.Append(indentText); StringBuilder javascript = new StringBuilder(string.Empty); StringBuilder onblur = new StringBuilder(" onblur=\""); if (Grid.InputHighLight != Color.Empty) { javascript.AppendFormat( " onfocus=\"this.accessKey = this.style.backgroundColor;this.style.backgroundColor='{0}';\"", Grid.ColorToHtml(Grid.InputHighLight)); onblur.Append("this.style.backgroundColor=this.accessKey;"); } if (Grid.ColumnChangedColour != Color.Empty) { onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour)); } onblur.Append("\""); javascript.Append(onblur); if ((AutoPostback || !string.IsNullOrEmpty(ConfirmMessage)) && Grid.Page != null) { StringBuilder eventScript = new StringBuilder(" onclick=\""); if (!string.IsNullOrEmpty(ConfirmMessage)) { eventScript.AppendFormat(" if(wgconfirm('{0}',this),'{1}') ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); } string link = Grid.EnableCallBack && !ForcePostBack ? Asynchronous.GetCallbackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row. PrimaryKeyValues)); eventScript.AppendFormat("{0}\"{1}", link, eventScript); javascript.Append(eventScript); } if (!string.IsNullOrEmpty(CheckedAlias) && Items[i].Checked) { sb.Append(CheckedAlias); sb.Append(Items[i].DisplayText); } else if (!string.IsNullOrEmpty(UncheckedAlias) && !Items[i].Checked) { sb.Append(UncheckedAlias); sb.Append(Items[i].DisplayText); } else { sb.AppendFormat( "<input {0} type=\"checkbox\" id=\"cb_{1}_{2}\" name=\"{1}\" value=\"{2}\" {3} />", javascript, cell.CellClientId, Items[i].Value, selected); sb.AppendFormat( "<label class=\"wglabel\" id=\"label_{0}_{1}\" for=\"cb_{0}_{1}\">", cell.CellClientId, Items[i].Value); sb.AppendFormat("{0}</label>", Items[i].DisplayText); } sb.Append("</td>"); } RenderDetailTree(sb, Items[i].Value, level + 1, cell); } }
private string CreateDropDownPager(bool all) { string eventScript = null; if (m_PagerGrid.Page != null) { eventScript = m_PagerGrid.EnableCallBack ? Asynchronous.GetCallbackEventReference(m_PagerGrid, "PagerClick!JS", false, string.Empty, string.Empty) : m_PagerGrid.Page.ClientScript.GetPostBackEventReference(m_PagerGrid, "PagerClick![JS]"); eventScript = eventScript.Replace("JS", "' + this.value + '"); } StringBuilder dropDown = new StringBuilder(string.Format("<select onchange=\"{0}\" >", eventScript)); if (all) { dropDown.AppendFormat("<option value=\"ALL\">{0}</option>", m_PagerGrid.GetSystemMessage("All")); } if (CompactDropDown && DisplayFirstLast) { dropDown.AppendFormat("<option value=\"1\">{0}</option>", m_PagerGrid.GetSystemMessage("First")); } if (CompactDropDown && DisplayPreviousNext) { dropDown.AppendFormat("<option value=\"{0}\">{1}</option>", (m_PagerGrid.PageIndex + 1), m_PagerGrid.GetSystemMessage("Prev")); } const int startIndex = 1; /* * if( NavigateStyle == NavigateStyles.Paging ) * startIndex = (PagerSequence-1)* PagerWidth+1; * else * { * startIndex = m_PagerGrid.PageIndex - PagerWidth/2; * if(startIndex + PagerWidth > pages) * startIndex = pages - PagerWidth + 1; * * if(startIndex < 1 ) * startIndex = 1; * } */ for (int i = startIndex; i <= m_Pages; i++) { string selected = (i == m_PagerGrid.PageIndex) ? "selected=\"selected\"" : string.Empty; dropDown.AppendFormat("<option {0} value=\"{1}\">{2}</option>", selected, i, String.Format(PageDropDownTemplate, i, m_Pages)); } if (CompactDropDown && DisplayPreviousNext) { int next = (m_PagerGrid.PageIndex + 1); if (next > m_Pages) { next = m_Pages; } dropDown.AppendFormat("<option value={0}>{1}</option>", next, m_PagerGrid.GetSystemMessage("Next")); } if (CompactDropDown && DisplayFirstLast) { dropDown.AppendFormat("<option value={0}>{1}</option>", m_Pages, m_PagerGrid.GetSystemMessage("Last")); } dropDown.Append("</select>"); return(dropDown.ToString()); }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data">The asynchronous data provider.</param> /// <param name="result">The data retrieved from the GPU.</param> /// <returns> /// True if result contains valid data, false otherwise. /// </returns> public bool GetData <T>(Asynchronous data, out T result) where T : struct { return(GetData(data, AsynchronousFlags.None, out result)); }
public void Begin(Asynchronous ass) { context.Begin(ass); }
internal override void RenderEditView(HtmlTextWriter writer, RowCell cell) { if (Table.m_GotData == false) // Data need to be recovered if CacheDatasourceStructure is active. { Table.GetData(true); } if (Identity || AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false)) { RenderLabelView(writer, cell); return; } if (string.IsNullOrEmpty(ValueColumn)) { throw new GridException( String.Format(Table.m_Grid.GetSystemMessage("SystemMessage_ForeignkeyNoValueColumn"), Title)); } StringBuilder s = new StringBuilder(string.Empty); switch (ForeignkeyType) { case ForeignkeyType.Select: case ForeignkeyType.SelectMenu: { StringBuilder eventScript = new StringBuilder(string.Empty); StringBuilder javascript = new StringBuilder(string.Empty); if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false) { eventScript = new StringBuilder(" onchange=\""); if (string.IsNullOrEmpty(ConfirmMessage) == false) { eventScript.AppendFormat(" if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); } string link = Grid.EnableCallBack && !ForcePostBack ? Asynchronous.GetCallbackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row. PrimaryKeyValues)); eventScript.AppendFormat("{0}\"", link); } StringBuilder onblur = new StringBuilder(" onblur=\""); if (Grid.ColumnChangedColour != Color.Empty) { onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour)); } onblur.Append("\""); javascript.Append(onblur); s.AppendFormat("<select {0} class=\"wgeditfield wgselectbox {4}\" id=\"{1}\" name=\"{1}\" {2} {3}>", javascript, cell.CellClientId, eventScript, Attributes, CssClass); if (m_Foreignkeytype == ForeignkeyType.SelectMenu && (Grid.Scripts == null || !Grid.Scripts.DisableSelectMenu)) { if (SelectMenuWidth > 0) { Grid.AddClientScript(writer, string.Format( "$(document).ready(function() {{$('#{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});", cell.CellClientId, SelectMenuWidth, SelectMenuMaxHeight)); } else { Grid.AddClientScript(writer, string.Format( "$(document).ready(function() {{$('#{0}').selectmenu({{maxHeight: {1},style:'dropdown'}});}});", cell.CellClientId, SelectMenuMaxHeight)); } } if (Table.Rows.Count == 0 && NullText == null) { NullText = "No data available."; } if (NullText != null) { s.AppendFormat("<option value=\"{1}\">{0}</option>", NullText, string.Empty); } //CreateRows(Grid,tree,null,0); s.Append(CreateSelectRows(TreeParentId != null, null, 0, cell)); s.Append("</select>"); } break; case ForeignkeyType.Radiobuttons: m_IsFormElement = false; m_Rowcounter = RecordsPerRow; s.AppendFormat("<table class=\"wgradiobuttons {1}\"><tr><td>{0}</td></tr></table>", CreateRadioButtons((TreeParentId != null), null, 0, cell), CssClass); break; } if (string.IsNullOrEmpty(ToolTipInput) == false) { s = new StringBuilder(Tooltip.Add(s.ToString(), ToolTipInput)); } EditHtml(s.ToString(), writer, cell); }
public void End(Asynchronous ass) { context.End(ass); }
// 2005.01.09 - jorn - String.Compare, string.Length // 2005.01.05 - Jorn - Added check to see if there actually is a checkbox on "previous page". // Need to add a hidden field since checkbox "returns null" both for unchecked and non-existing internal void RenderDetail(bool enabled, WebGridHtmlWriter writer, RowCell cell) { if (AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false)) { enabled = false; } string uniqueId = cell.CellClientId; string strValue = DisplayText(cell); const string checkedValue = TrueValue; const string uncheckedValue = FalseValue; StringBuilder sb; if (String.Compare(strValue, checkedValue, true) == 0 && CheckedAlias != null && enabled == false) { sb = new StringBuilder(CheckedAlias); } else if (String.Compare(strValue, uncheckedValue, true) == 0 && UncheckedAlias != null && enabled == false) { sb = new StringBuilder(UncheckedAlias); } else { string bitchecked = string.Empty; string bitEnabled = string.Empty; if (String.Compare(strValue, checkedValue, true) == 0) { bitchecked = " checked=\"checked\""; } if (enabled == false) { bitEnabled = " disabled=\"disabled\""; } StringBuilder javascript = new StringBuilder(string.Empty); StringBuilder onblur = new StringBuilder(" onblur=\""); if (Grid.InputHighLight != Color.Empty) { javascript.AppendFormat( " onfocus=\"this.accessKey = this.style.backgroundColor;this.style.backgroundColor='{0}';\"", Grid.ColorToHtml(Grid.InputHighLight)); onblur.Append("this.style.backgroundColor=this.accessKey;"); } if (Grid.ColumnChangedColour != Color.Empty) { onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour)); } onblur.Append("\""); if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false) { StringBuilder eventScript = new StringBuilder(" onclick=\""); if (string.IsNullOrEmpty(ConfirmMessage) == false) { eventScript.AppendFormat(" if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); } string link = Grid.EnableCallBack && !ForcePostBack?Asynchronous.GetCallbackEventReference(Grid, string.Format("ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues)); eventScript.AppendFormat("{0}\"", link); javascript.Append(eventScript); } javascript.Append(onblur); sb = new StringBuilder( string.Format( "<input {0} type=\"checkbox\" {1} {2} {4} id=\"cb_{3}\" name=\"{3}\" value=\"1\"/>", javascript, bitchecked, bitEnabled, uniqueId, Attributes)); if (string.IsNullOrEmpty(m_Displaylabel) == false) { sb.AppendFormat( "<label class=\"wglabel\" id=\"label_{0}\" for=\"cb_{0}\">{1}</label>", uniqueId, m_Displaylabel); } if (enabled) { writer.Write("<input type=\"hidden\" id=\"{0}_cb\" name=\"{0}_cb\" value=\"{1}\" />", uniqueId, checkedValue); } } if (string.IsNullOrEmpty(ToolTipInput) == false) { sb = new StringBuilder(Tooltip.Add(sb.ToString(), ToolTipInput)); } EditHtml(sb.ToString(), writer, cell); }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <param name = "data">The asynchronous data provider.</param> /// <returns>The data retrieved from the GPU.</returns> public DataStream GetData(Asynchronous data) { return(GetData(data, AsynchronousFlags.None)); }
public static void HandleAuthentication(Asynchronous.AsyncWrapper client, byte[] buffer) { //Console.WriteLine("handling" + BitConverter.ToUInt16(buffer, 2)); if (BitConverter.ToUInt16(buffer, 2) == 1055) new Packets.ServerResponse(buffer, client); }
/// <summary> /// Gets data from the GPU asynchronously. /// </summary> /// <param name = "data">The asynchronous data provider.</param> /// <returns>The data retrieved from the GPU.</returns> public T GetData <T>(Asynchronous data) where T : struct { return(GetData <T>(data, AsynchronousFlags.None)); }
internal void Begin(Asynchronous asyncRef) { m_deviceContext.Begin(asyncRef); }
internal void End(Asynchronous asyncRef) { m_deviceContext.End(asyncRef); CheckErrors(); }
internal T GetData <T>(Asynchronous data, AsynchronousFlags flags) where T : struct { return(m_deviceContext.GetData <T>(data, flags)); }
internal override void RenderEditView(WebGridHtmlWriter writer, RowCell cell) { if (Identity || AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false)) { RenderLabelView(writer, cell); return; } string uniqueID = cell.CellClientId; GetColumnPostBackData(cell); if (IsHtml) { EditHtml( !Grid.IsDesignTime ? DrawHtml(uniqueID, writer, Grid, cell) : HttpUtility.HtmlEncode("<HTML EDITOR DESIGN TIME>"), writer, cell); return; } string s; string theValueToShow = DisplayText(cell); /*if(TheValueToShow == null) * TheValueToShow = Value;*/ if (IsUrl && string.IsNullOrEmpty(theValueToShow)) { theValueToShow = HTTPCONST; } StringBuilder cssstyle = new StringBuilder("style=\""); theValueToShow = HttpUtility.HtmlEncode(theValueToShow); string size = string.Empty; string type = "text"; StringBuilder javascript = new StringBuilder(string.Empty); if (WidthEditableColumn != Unit.Empty) { cssstyle.AppendFormat("width:{0}; ", WidthEditableColumn); } if (HeightEditableColumn != Unit.Empty) { cssstyle.AppendFormat("height:{0}; ", HeightEditableColumn); } if (MaxSize > 0) { size = string.Format("maxlength=\"{0}\" ", MaxSize); } if (IsPassword) { type = "password"; } StringBuilder onblur = new StringBuilder(" onblur=\""); if (Grid.InputHighLight != Color.Empty) { javascript.AppendFormat( " onfocus=\"this.accessKey = style.backgroundColor;style.backgroundColor='{0}';\"", Grid.ColorToHtml(Grid.InputHighLight)); onblur.Append("style.backgroundColor=this.accessKey;"); } if (Grid.ColumnChangedColour != Color.Empty) { onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour)); } if (AutoPostback) { onblur.Append("if(hasChanged(this))"); onblur.Append(Grid.EnableCallBack && !ForcePostBack ? Asynchronous.GetCallbackEventReference(Grid, string.Format("ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues))); } onblur.Append("\""); javascript.Append(onblur); string mask = null; if (!DisableMaskedInput && GenerateColumnMask != null) { string maskId = string.Format("{0}_{1}", Grid.ID, ColumnId); if (!Grid.MaskedColumns.ContainsKey(maskId)) { Grid.MaskedColumns.Add(maskId, GenerateColumnMask); } mask = string.Format(" alt=\"{0}\"", maskId); } cssstyle.Append("\""); if (HeightEditableColumn == Unit.Empty) { s = string.Format( "<input {0} {1} {6}{7} type=\"{2}\" class=\"wgeditfield\" {3} value=\"{4}\" id=\"{5}\" name=\"{5}\"/>", javascript, cssstyle, type, size, theValueToShow, uniqueID, Attributes, mask); } else { s = string.Format( "<textarea rows=\"1\" cols=\"1\" {0} {1} class=\"wgeditfield\" id=\"{2}\" name=\"{3}\" {4}>", javascript, cssstyle, uniqueID, uniqueID, Attributes); if (theValueToShow != null) { s += theValueToShow; } s += "</textarea>"; } if (string.IsNullOrEmpty(ToolTipInput) == false) { s = Tooltip.Add(s, ToolTipInput); } EditHtml(s, writer, cell); }
internal bool GetData <T>(Asynchronous data, AsynchronousFlags flags, out T result) where T : struct { return(m_deviceContext.GetData <T>(data, flags, out result)); }
// 2005.01.09 - jorn, string optimize private string CreateRadioButtons(bool tree, string parentValue, int level, RowCell cell) { bool m_Foreignkeyselected = false; StringBuilder s = new StringBuilder(string.Empty); for (int i = 0; i < Table.Rows.Count; i++) { string optionValue = Table.Rows[i].PrimaryKeyValues; if (!string.IsNullOrEmpty(IdentityColumn) && Table.Rows[i][IdentityColumn].Value != null) { optionValue = Table.Rows[i][IdentityColumn].Value.ToString(); } if (tree) { string treeValue = null; if (Table.Rows[i][TreeParentId].Value != null) { treeValue = Table.Rows[i][TreeParentId].Value.ToString(); } if (treeValue != parentValue || Grid.EMPTYSTRINGCONSTANT.Equals(optionValue)) { continue; } } if (i != 0) { if (m_Rowcounter == 0) { s.Append("</tr><tr><td>"); m_Rowcounter = RecordsPerRow; } else { s.Append("<td>"); } } m_Rowcounter--; string selected = string.Empty; if (!m_Foreignkeyselected && optionValue != null) { if (cell.PostBackValue != null) { selected = Equals(optionValue, cell.PostBackValue) ? " checked=\"checked\" " : string.Empty; } else if (cell.Value != null) { selected = Equals(optionValue, cell.Value.ToString()) ? "checked=\"checked\" " : string.Empty; } else if (RememberState && string.IsNullOrEmpty(selected) && (string)Grid.GetState(cell.CellClientId) != null) { selected = (String.Compare(optionValue, Grid.GetState(cell.CellClientId) as string, true) == 0) ? "checked=\"checked\" " : string.Empty; } if (string.IsNullOrEmpty(selected) == false) { m_Foreignkeyselected = true; } } StringBuilder optionText = new StringBuilder(string.Empty); if (level > 0) { for (int j = 0; j < level; j++) { optionText.Append(TreeIndentText); } } try { optionText.Append(BuildDisplayText(i, ValueColumn, Table)); } catch (Exception e) { throw new GridException(string.Format("Error creating radio buttons rows for foreign keys ({0})", ColumnId), e); } StringBuilder javascript = new StringBuilder(); if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false) { StringBuilder eventScript = new StringBuilder(" onchange=\""); if (string.IsNullOrEmpty(ConfirmMessage) == false) { eventScript.AppendFormat(" if(confirm('{0}')) ", ConfirmMessage); } string link = Grid.EnableCallBack && !ForcePostBack?Asynchronous.GetCallbackEventReference(Grid, string.Format("ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format( "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues)); eventScript.AppendFormat("{0}\"", link); javascript.Append(eventScript); } s.AppendFormat( "<input type=\"radio\" id=\"rb_{0}_{1}\" {4} name=\"{0}\" value=\"{1}\" {3} /><label class=\"wglabel\" for=\"rb_{0}_{1}\">{2}</label>", cell.CellClientId, optionValue, optionText, selected, javascript); if (tree) { s.Append(CreateRadioButtons(true, optionValue, level + 1, cell)); } } return(s.ToString()); }
internal bool IsDataAvailable(Asynchronous data, AsynchronousFlags flags) { return(m_deviceContext.IsDataAvailable(data, flags)); CheckErrors(); }
private static void Mutator(Asynchronous.Channel Done) { Thread.CurrentThread.IsBackground = true; for (int i = 0; i < numIncrements; i++) { Console.Write("."); counter.Inc(); unsafeCounter.Inc(); Thread.Sleep(10); } Done(); }
internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell) { string image = FileSource(true, cell); if (!string.IsNullOrEmpty(PopupImageColumn)) { if (!cell.Row.Columns.Contains(PopupImageColumn)) { throw new ApplicationException( string.Format(@"""PopupImageColumn"" property value for column '{0}' is not valid.", Title)); } string rel = ""; if (m_PopupImageDisplayType == ImageDisplayType.Navigation || m_PopupImageDisplayType == ImageDisplayType.NavigationSlideShow) { rel = string.Format("rel=\"{0}_{1}\"", Grid.ClientID, ColumnId); } image = string.Format(@"<a href=""{1}"" title=""{3}"" {4} class=""wgimage_{5}""><img class=""wgimage"" src=""{0}"" alt=""{2}""/></a>", image, ((Image)cell.Row.Columns[PopupImageColumn]).GetUrl(cell.Row[PopupImageColumn]), Title, PopupImageCaption, rel, ColumnId); switch (PopupImageDisplayType) { case ImageDisplayType.Navigation: Grid.AddClientScript(writer, string.Format("$(\"a[rel='{0}_{1}']\").colorbox({{slideshow:false}});", Grid.ClientID, ColumnId)); break; case ImageDisplayType.NavigationSlideShow: Grid.AddClientScript(writer, string.Format("$(\"a[rel='{0}_{1}']\").colorbox({{slideshow:true}});", Grid.ClientID, ColumnId)); break; case ImageDisplayType.Single: Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$(\".wgimage_{0}\").colorbox();}});", ColumnId)); break; } } else { image = string.Format(@"<img class=""wgimage"" src=""{0}"" alt=""{1}""/>", image, Title); } if (HyperLinkColumn && Grid.DisplayView == DisplayView.Grid) { string a = Grid.EnableCallBack ? Asynchronous.GetCallbackEventReference(Grid, string.Format("RecordClick!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues), false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid, string.Format("RecordClick!{0}!{1}", ColumnId, cell.Row. PrimaryKeyValues)); string b = (String.IsNullOrEmpty(ConfirmMessage)) ? string.Empty : String.Format("if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'")); image = string.Format( "<a class=\"wglinkfield\" href=\"#\" onclick=\"{0}{1}\">{2}</a>", b, a, image); } LabelHtml(image, writer, cell); }