/// <summary> /// Constructs HTML to PDF converter instance from <code>GlobalSettings</code>. /// </summary> /// <param name="config">global configuration object</param> public SimplePechkin() { this.onErrorDelegate = new StringCallback(this.OnError); this.onFinishedDelegate = new IntCallback(this.OnFinished); this.onPhaseChangedDelegate = new VoidCallback(this.OnPhaseChanged); this.onProgressChangedDelegate = new IntCallback(this.OnProgressChanged); this.onWarningDelegate = new StringCallback(this.OnWarning); Tracer.Trace(string.Format("T:{0} Created SimplePechkin", Thread.CurrentThread.Name)); }
public DBConnection() { enableControls = new BooleanCallback(EnableControls); //setList = new ListCallback(SetList); setMsg = new StringCallback(SetMsg); setList1 = new ListCallback1(SetList1); // // Required for Windows Form Designer support // InitializeComponent(); }
public LeaderBoard( List <string> data, Dictionary <string, RankData> rankDict, Dictionary <string, FavoriteTag> favoriteTagDict, GestureTapCallback onPressMore = null, StringCallback onPressItem = null, Key key = null ) : base(key: key) { this.data = data; this.rankDict = rankDict; this.favoriteTagDict = favoriteTagDict; this.onPressMore = onPressMore; this.onPressItem = onPressItem; }
private void SetStatusBarText(string text) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.InvokeRequired) { StringCallback callBack = new StringCallback(SetStatusBarText); this.Invoke(callBack, new object[] { text }); } else { this.statusBarLabel.Text = text; this.Update(); } }
/// <summary> /// Constructs HTML to PDF converter instance from <code>GlobalConfig</code>. /// </summary> /// <param name="config">global configuration object</param> public SimplePechkin(GlobalConfig config) { this._onErrorDelegate = new StringCallback(this.OnError); this._onFinishedDelegate = new IntCallback(this.OnFinished); this._onPhaseChangedDelegate = new VoidCallback(this.OnPhaseChanged); this._onProgressChangedDelegate = new IntCallback(this.OnProgressChanged); this._onWarningDelegate = new StringCallback(this.OnWarning); Tracer.Trace("T:" + Thread.CurrentThread.Name + " Creating SimplePechkin"); this._globalConfig = config; Tracer.Trace("T:" + Thread.CurrentThread.Name + " Created global config"); this.IsDisposed = false; }
void IString.GetStringValue(StringCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } if (_provider != null) { _callback = callback; _provider.GetRowData(new RowCallback(GetRowData)); } else { callback(null); } }
/// <summary> /// Marca como fallido al archivo en proceso de transferencia. /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void uploadFileFailed(String fileHandlerId) { if (dataGridView.InvokeRequired) { StringCallback d = new StringCallback(uploadFileFailed); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (DataGridViewRow row in dataGridView.Rows) { if (((String)(row.Cells[5].Value)).Equals(fileHandlerId)) { row.Cells[3].Value = FileControlState.FILEFAIL; break; } } } }
public void Init() { if (Value.GetType() == typeof(string)) { StringCallback?.Invoke(GetString()); } else if (Value.GetType() == typeof(bool)) { BoolCallback?.Invoke((bool)Value); } else if (Value.GetType() == typeof(int)) { IntCallback?.Invoke((int)Value); } else if (Value.GetType() == typeof(float)) { FloatCallback?.Invoke((float)Value); } }
/// <summary> /// Marca como fallido al archivo en proceso de transferencia. /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void uploadFileFailed(String fileHandlerId) { if (treeView.InvokeRequired) { StringCallback d = new StringCallback(uploadFileFailed); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (FileItem fileItem in fileList) { if (fileItem.FileHandlerId.Equals(fileHandlerId)) { fileItem.State = FileControlState.FILEFAIL; refreshList(fileItem); break; } } } }
/// <summary> /// Constructs HTML to PDF converter instance from <code>GlobalConfig</code>. /// </summary> /// <param name="config">global configuration object</param> public SimplePechkin(GlobalConfig config) { if (_log.IsTraceEnabled) _log.Trace("T:" + Thread.CurrentThread.Name + " Creating SimplePechkin"); // create and STORE delegates to protect them from GC _errorCallback = OnError; _finishedCallback = OnFinished; _phaseChangedCallback = OnPhaseChanged; _progressChangedCallback = OnProgressChanged; _warningCallback = OnWarning; PechkinStatic.InitLib(false); _globalConfig = config; if (_log.IsTraceEnabled) _log.Trace("T:" + Thread.CurrentThread.Name + " Created global config"); CreateConverter(); }
public InCallForm(Call c, NoneCallback ncb) { this.updateFriendViewOnClosing = ncb; this.call = c; updateGlobalCallVar(); this.callId = new Id(c.callId); InitializeComponent(); this.Text = "(" + Program.username + ") Aktywne połączenie"; StringCallback callback2 = addUser; StringCallback callback3 = removeUser; LoggedInService.AddUserToCall = callback2; LoggedInService.RemoveUserFromCall = callback3; updateUsersInCall(); ByteCallback callback = incomingTraffic; NoneCallback callback4 = closeCall; CallProcessing.ReceiveMsgCallback = callback; CallProcessing.CloseCallCallback = callback4; CallProcessing.Start(); Program.isInCall = true; packetsCounterTimer.Interval = 1000; packetsCounterTimer.Elapsed += packetsCounterTimer_OnTimerElapsed; packetsCounterTimer.AutoReset = true; packetsCounterTimer.Start(); ByteCallback sendCb = sendSound; sp = new SoundProcessing(sendCb); Program.spGlobal = sp; tokenSource = new System.Threading.CancellationTokenSource(); token = tokenSource.Token; Task.Run(() => sp.startUp(this.call.usernames, token), token); }
public Window(SubEnvironment owner, string tag, int group) { base.Name = tag; base.Text = tag; setTitle = new StringCallback(SetTitle); setTag = new StringCallback(SetTag); this.SubEnvironment = owner; owner.Windows.Add(this); BarButton = new ToolBarWindowButton(tag, group, this); BarButton.ImageIndex = group; BarButton.Click += new EventHandler(BarButton_Click); ToolStripItem item; int index = nIRC.UI.Environment.Window.WindowBar.Items.IndexOf(owner.ToolBarSeperator) - 1; while (index > -1) { item = nIRC.UI.Environment.Window.WindowBar.Items[index]; if (!(item is ToolBarWindowButton)) { break; } if (((ToolBarWindowButton)item).Group <= group) { break; } index--; } nIRC.UI.Environment.Window.WindowBar.Items.Insert(index + 1, BarButton); this.TopLevel = false; this.MdiParent = nIRC.UI.Environment.Window; this.ClientSize = new Size(500, 300); this.Show(); }
public LoggedInForm() { InitializeComponent(); invitationContainer.Clear(); friendsContainer.Clear(); UsernameCallback callback4 = newInactiveFriendFunc; UsernameCallback callback5 = newActiveFriendFunc; IdCallback callback6 = callUserReply; BooleanCallback callback7 = callUserReplyFromUser; CallCallback callback8 = openInCallWindow; FriendCallback callback9 = addToFriendContainer; LoggedInService.AddToFriendList = callback9; LoggedInService.NewInactiveFriend = callback4; LoggedInService.NewActiveFriend = callback5; LoggedInService.InviteToConversationReplyOk = callback6; LoggedInService.InviteToConversationReplyFromUser = callback7; LoggedInService.OpenInCallForm = callback8; StringCallback callback2 = writeToInvitingList; LoggedInService.NewInvitationCallback = callback2; this.signedInLogin_Text.Text = Program.username; StringCallback callback = writeToFriendContainer; LoggedInService.GetFriendsCallback = callback; InvitationCallback callback3 = removeFromInvitingList; LoggedInService.InvitationProcessedCallback = callback3; LoggedInService.getFriends(); }
/// <summary> /// Marca como fallido al archivo en proceso de descarga /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void downloadFileFailed(String fileHandlerId) { if (treeView.InvokeRequired) { StringCallback d = new StringCallback(downloadFileFailed); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (FileItem fileItem in fileList) { if (fileItem.FileHandlerId.Equals(fileHandlerId)) { fileItem.State = FileControlState.FILEFAIL; refreshList(fileItem); break; } } } }
static void ScheduleCallback(StringCallback c, string s) { Scheduler.Dispatch(() => c(null, s)); }
static void Wait(string pattern,StringCallback callback) { WriteLine("pattern="+pattern); while (!terminated) { if (fface.Target.ID == 0) { WriteLine(" target.id=0"); break; } string value = callback(); WriteLine(pattern + "~" + value); if (match(pattern, value)) { WriteLine(" value=" + value); break; } Thread.Sleep(100); } }
public static extern int LFD_SetOnError(IntPtr lfdHandle, StringCallback method);
public static void SetWarningCallback(IntPtr converter, StringCallback callback) { if (Log.IsTraceEnabled) { Log.Trace("T:" + Thread.CurrentThread.Name + " Setting warning callback (wkhtmltopdf_set_warning_callback)"); } PechkinBindings.wkhtmltopdf_set_warning_callback(converter, callback); }
public int SetErrorCallback(IntPtr converter, StringCallback callback) { return(WkHtmlToXBindings.wkhtmltopdf_set_error_callback(converter, callback)); }
public void SetErrorCallback(IntPtr converter, StringCallback callback) { Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting error callback (wkhtmltoimage_set_error_callback)"); WkhtmltoxBindings.wkhtmltoimage_set_error_callback(converter, callback); pinnedCallbacks.Register(converter, callback); }
private static extern bool vlWorker_AddTrackingStateListener(IntPtr worker, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback listener, IntPtr clientData);
/// <summary> /// Adds a global "server-sent" message seen in all channels. /// </summary> /// <param name="message">The message received from the server.</param> private void Instance_ServerMessageParsed(string message) { if (cmbCurrentChannel.InvokeRequired) { // Necessary for thread-safety StringCallback d = new StringCallback(Instance_ServerMessageParsed); this.BeginInvoke(d, message); return; } foreach (List<MessageInfo> msgList in MessageInfos) { msgList.Add(new MessageInfo(Color.White, message)); } AddChannelMessageToListBox(currentChannelId); }
/// <summary> /// Run when a QUIT message is received and parsed. /// </summary> /// <param name="message">The name of the quitting user.</param> private void Instance_OnUserQuit(string message) { if (this.InvokeRequired) { // Necessary for thread-safety StringCallback d = new StringCallback(Instance_OnUserQuit); this.BeginInvoke(d, message); return; } int userIndex = UserLists[currentChannelId].FindIndex(u => u.Name == message); if (userIndex > -1) { UserLists[currentChannelId].RemoveAt(userIndex); UpdatePlayerList(); AddChannelMessageToListBox(currentChannelId); } // Check if we've been in a PM convo with the user int index = CnCNetData.PMInfos.FindIndex(c => c.UserName == message); if (index > -1) { CnCNetData.PMInfos[index].Messages.Add(new MessageInfo(Color.White, "has quit CnCNet.")); CnCNetData.PMInfos[index].IsSelfSent.Add(false); } }
/// <summary> /// Handles an incorrect channel password message from the server. /// </summary> /// <param name="channelName">The name of the channel for which an invalid password was entered.</param> private void Instance_OnIncorrectPassword(string channelName) { if (this.InvokeRequired) { StringCallback d = new StringCallback(Instance_OnIncorrectPassword); this.BeginInvoke(d, channelName); return; } // Look for game in the list of games by searching with its channel name bool channelFound = false; for (int gameId = 0; gameId < CnCNetData.Games.Count; gameId++) { if (CnCNetData.Games[gameId].ChannelName == channelName) { MessageInfos[currentChannelId].Add(new MessageInfo(Color.White, "Unable to join game " + CnCNetData.Games[gameId].RoomName + "; incorrect password")); AddChannelMessageToListBox(currentChannelId); channelFound = true; break; } } // If not found (meaning the game was disbanded / hidden after receiving the message), display a generic message if (!channelFound) { MessageInfos[currentChannelId].Add(new MessageInfo(Color.White, "Unable to join game; incorrect password")); AddChannelMessageToListBox(currentChannelId); } }
/// <summary> /// Handles an ERROR message sent by the IRC server. /// </summary> /// <param name="message">The error the server gave us.</param> private void Instance_OnErrorReceived(string message) { if (this.InvokeRequired) { // Necessary for thread-safety StringCallback d = new StringCallback(Instance_OnErrorReceived); this.BeginInvoke(d, message); return; } Logger.Log("CnCNet error received: " + message); Logger.Log("Setting auto-login to false and saving settings."); ProgramConstants.CNCNET_AUTOLOGIN = false; SaveSettings(); MessageBox.Show(message, "Server disconnected", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); }
public void SetWarningCallback(IntPtr converter, StringCallback callback) { NestedToolset.SetWarningCallback(converter, callback); }
/// <summary> /// Marca como atendido a un archivo previamente encolado para transferencia /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void uploadFileOpened(String fileHandlerId) { if (treeView.InvokeRequired) { StringCallback d = new StringCallback(uploadFileOpened); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (FileItem fileItem in fileList) { if (fileItem.FileHandlerId.Equals(fileHandlerId)) { fileItem.State = FileControlState.LOADINGDATA; fileItem.Percent = 0; refreshList(fileItem); break; } } } }
/// <summary> /// Executed when the initial welcome message is received from the IRC server. /// The UI shouldn't be usable before this is run. /// </summary> /// <param name="message">The received welcome message.</param> private void Instance_WelcomeMessageParsed(string message) { if (this.InvokeRequired) { // Necessary for thread-safety StringCallback d = new StringCallback(Instance_WelcomeMessageParsed); this.BeginInvoke(d, message); return; } Logger.Log("Welcome message received."); CnCNetData.ConnectionBridge.SendMessage("MODE " + ProgramConstants.CNCNET_PLAYERNAME + " +x"); Instance_ServerMessageParsed(message); JoinInitialChannels(); this.Text = string.Format("[{0}] CnCNet Lobby: {1} ({2} / {3})", myGame, ProgramConstants.CNCNET_PLAYERNAME, ProgramConstants.GAME_VERSION, Application.ProductVersion); btnJoinGame.Enabled = true; btnNewGame.Enabled = true; btnSend.Enabled = true; SaveSettings(); this.TopMost = true; this.Focus(); this.BringToFront(); this.TopMost = false; }
private void SetCurrentLocale(string locale) { if (this.InvokeRequired) { StringCallback callBack = new StringCallback(SetCurrentLocale); this.Invoke(callBack, new object[] { locale }); } else { cbSupportedLocales.SelectedValue = locale; } }
private void SetProgressText(string text) { //thread safe call if (InvokeRequired) { StringCallback callback = new StringCallback(SetProgressText); Invoke(callback, new object[] { text }); } else { lblProcess.Text = text; Update(); } }
/// <summary> /// Handles the "connection lost" event fired by the networking part of the client. /// </summary> /// <param name="errorMessage">The error message related to the connection error.</param> private void Instance_OnConnectionLost(string errorMessage) { if (this.InvokeRequired) { // Necessary for thread-safety StringCallback d = new StringCallback(Instance_OnConnectionLost); this.BeginInvoke(d, errorMessage); return; } Logger.Log("CnCNet connection lost: " + errorMessage); Logger.Log("Setting auto-login to false and saving settings."); ProgramConstants.CNCNET_AUTOLOGIN = false; SaveSettings(); MessageBox.Show("Your connection to the CnCNet server has been lost. " + Environment.NewLine + Environment.NewLine + "Error message: " + Environment.NewLine + errorMessage + Environment.NewLine + Environment.NewLine + "The CnCNet Client will now exit.", "CnCNet Server Connection Lost", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); }
public int SetErrorCallback(IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback) => wkhtmltopdf_set_error_callback(converter, callback);
private static extern bool getChuckString(System.UInt32 chuckID, System.String name, StringCallback callback);
/// <summary> /// Agrega un mensaje del sistema a la ventana /// <param name="text">el texto de información</param> /// </summary> public void chatWarninglInformation(String text) { if (textBoxText.InvokeRequired) { StringCallback d = new StringCallback(chatWarninglInformation); this.Invoke(d, new object[] { text }); } else { textBoxText.Text = ("WARNING: " + text) + Environment2.NewLine + textBoxText.Text; } }
public void DoStuff( StringCallback callback ) { LoginCallback = callback; }
public void AddLocalizedStringCallback(StringCallback StringCallback) { this.StringCallback = StringCallback; }
public static extern int SPDF_SetOnError(IntPtr spdfHandle, StringCallback method);
public void getAsString(StringCallback callback) { }
public byte[] Convert(ImageDocument doc, string html) { if (doc == null) { throw new Exception("Fast.HtmlToImage ImageDocument is not null"); } #region setting Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "web.defaultEncoding", "utf-8"); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "web.loadImages", "true"); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "web.enableJavascript", "true"); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "load.jsdelay", "1000"); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "load.loadErrorHandling", "skip"); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "load.debugJavascript", "true"); if (doc.Width != 0) { Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "screenWidth", doc.Width.ToString()); } if (doc.Height != 0) { Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "screenHeight", doc.Height.ToString()); } //if (doc.MarginTop != 0) // Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "crop.top", doc.MarginTop.ToString()); //if (doc.MarginLeft != 0) // Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "crop.left", doc.MarginLeft.ToString()); //Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "in", doc.Url); Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "fmt", doc.Format.ToString()); if (doc.SmartWidth) { Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "smartWidth", "true"); } if ((doc.Format == FormatEnum.png || doc.Format == FormatEnum.svg) && doc.Transparent) { Interop.HtmlToImage.wkhtmltoimage_set_global_setting(GlobalSettings, "transparent", "true"); } #endregion StringCallback errorCallback = (converter, errorText) => { throw new Exception(errorText); }; Converter = Interop.HtmlToImage.wkhtmltoimage_create_converter(GlobalSettings, Encoding.UTF8.GetBytes(html)); Interop.HtmlToImage.wkhtmltoimage_set_error_callback(Converter, errorCallback); if (Interop.HtmlToImage.wkhtmltoimage_convert(Converter) != 0) { IntPtr tmp; var len = Interop.HtmlToImage.wkhtmltoimage_get_output(Converter, out tmp); var result = new byte[len]; Marshal.Copy(tmp, result, 0, result.Length); tmp = IntPtr.Zero; return(result); } else { throw new Exception("FastHtmlToImage error"); } }
public void getAsString(StringCallback callback) {}
public int SetErrorCallback(IntPtr converter, StringCallback callback) { AddCallback(converter, callback); return(this.module.SetErrorCallback(converter, callback)); }
/// <summary> /// Marca como completado al archivo en proceso de transferencia /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void uploadFileComplete(String fileHandlerId) { if (treeView.InvokeRequired) { StringCallback d = new StringCallback(uploadFileComplete); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (FileItem fileItem in fileList) { if (fileItem.FileHandlerId.Equals(fileHandlerId)) { fileItem.State = FileControlState.FILECOMPLETE; fileItem.Percent = 100; refreshList(fileItem); break; } } } }
/// <summary> /// Places the server's URL at the top of the window /// </summary> /// <param name="s">The URL to display</param> public void UpdateUrl(string s) { if (this.InvokeRequired) { StringCallback d = new StringCallback(UpdateUrl); this.Invoke(d, new object[] { s }); } else txtUrl.Text = s; }
public static void SetErrorCallback(IntPtr converter, StringCallback callback) { Tracer.Trace("T:" + Thread.CurrentThread.Name + " Setting error callback (wkhtmltopdf_set_error_callback)"); PechkinBindings.wkhtmltopdf_set_error_callback(converter, callback); }
public int SetErrorCallback(IntPtr converter, StringCallback callback) { return(Pinvoke.wkhtmltopdf_set_error_callback(converter, callback)); }
internal static extern int wkhtmltoimage_set_warning_callback( IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);
public void SetWarningCallback(IntPtr converter, StringCallback callback) { throw new NotImplementedException(); }
private static extern bool vlWorker_RemovePerformanceInfoListener(IntPtr worker, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback listener, IntPtr clientData);
/// <summary> /// Marca como atendido a un archivo previamente encolado para transferencia /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void uploadFileOpened(String fileHandlerId) { if (dataGridView.InvokeRequired) { StringCallback d = new StringCallback(uploadFileOpened); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (DataGridViewRow row in dataGridView.Rows) { if (((String)(row.Cells[5].Value)).Equals(fileHandlerId)) { row.Cells[3].Value = FileControlState.LOADINGDATA; row.Cells[2].Value = 0; break; } } } }
public static extern bool RegisterDropFilesCallback([MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);
public byte[] Convert(PdfDocument doc, string html) { if (doc == null) { throw new Exception("Fast.HtmlToPdf PdfDocument is not null"); } var headerPath = string.Empty; var footerPath = string.Empty; var headerId = Guid.NewGuid().ToString(); var footerId = Guid.NewGuid().ToString(); var path = string.Format("{0}\\wwwroot", Directory.GetCurrentDirectory()); if (doc.DisplayHeader && !string.IsNullOrEmpty(doc.Header.Html) && !string.IsNullOrEmpty(doc.Host)) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } headerPath = string.Format("{0}\\wwwroot\\{1}.html", Directory.GetCurrentDirectory(), headerId); doc.Header.Url = string.Format("{0}/{1}.html", doc.Host, headerId); using (var fs = File.Create(headerPath)) { using (var writer = new StreamWriter(fs, Encoding.UTF8)) { if (doc.Header.Html.Contains("<!DOCTYPE html>")) { writer.Write(doc.Header.Html); } else { writer.Write(string.Format("<!DOCTYPE html>{0}", doc.Header.Html)); } } } } if (doc.DisplayFooter && !string.IsNullOrEmpty(doc.Footer.Html) && !string.IsNullOrEmpty(doc.Host)) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } footerPath = string.Format("{0}\\wwwroot\\{1}.html", Directory.GetCurrentDirectory(), footerId); doc.Footer.Url = string.Format("{0}/{1}.html", doc.Host, footerId); using (var fs = File.Create(footerPath)) { using (var writer = new StreamWriter(fs, Encoding.UTF8)) { if (doc.Footer.Html.Contains("<!DOCTYPE html>")) { writer.Write(doc.Footer.Html); } else { writer.Write(string.Format("<!DOCTYPE html>{0}", doc.Footer.Html)); } } } } #region object set Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "web.defaultEncoding", "utf-8"); Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "web.loadImages", "true"); Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "web.enableJavascript", "true"); Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "load.jsdelay", "1000"); Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "load.loadErrorHandling", "skip"); Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "load.debugJavascript", "true"); if (doc.DisplayHeader) { if (doc.Header.FontSize != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.fontSize", doc.Header.FontSize.ToString()); } if (doc.Header.Spacing != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.spacing", doc.Header.Spacing.ToString()); } if (!string.IsNullOrEmpty(doc.Header.Url)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.htmlUrl", doc.Header.Url); } if (!string.IsNullOrEmpty(doc.Header.Center)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.center", doc.Header.Center); } if (!string.IsNullOrEmpty(doc.Header.Left)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.left", doc.Header.Left); } if (!string.IsNullOrEmpty(doc.Header.Right)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.right", doc.Header.Right); } if (doc.Header.Line) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.line", "true"); } if (!string.IsNullOrEmpty(doc.Header.FontName)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "header.fontName", doc.Header.FontName); } } if (doc.DisplayFooter) { if (doc.Footer.FontSize != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.fontSize", doc.Footer.FontSize.ToString()); } if (doc.Footer.Spacing != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.spacing", doc.Footer.Spacing.ToString()); } if (!string.IsNullOrEmpty(doc.Footer.Url)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.htmlUrl", doc.Footer.Url); } if (!string.IsNullOrEmpty(doc.Footer.Center)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.center", doc.Footer.Center); } if (!string.IsNullOrEmpty(doc.Footer.Left)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.left", doc.Footer.Left); } if (!string.IsNullOrEmpty(doc.Footer.Right)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.right", doc.Footer.Right); } if (doc.Footer.Line) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.line", "true"); } if (!string.IsNullOrEmpty(doc.Footer.FontName)) { Interop.HtmlToPdf.wkhtmltopdf_set_object_setting(ObjectSettings, "footer.fontName", doc.Footer.FontName); } } #endregion #region global set if (!string.IsNullOrEmpty(doc.Size)) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "size.pageSize", doc.Size); } else { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "size.pageSize", "A4"); } if (doc.Width != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "size.width", doc.Width * 0.04 + "cm"); } if (doc.Height != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "size.height", doc.Height * 0.04 + "cm"); } if (doc.MarginTop != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "margin.top", doc.MarginTop * 0.04 + "cm"); } if (doc.MarginBottom != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "margin.bottom", doc.MarginBottom * 0.04 + "cm"); } if (doc.MarginLeft != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "margin.left", doc.MarginLeft * 0.04 + "cm"); } if (doc.MarginRight != 0) { Interop.HtmlToPdf.wkhtmltopdf_set_global_setting(GlobalSettings, "margin.right", doc.MarginRight * 0.04 + "cm"); } #endregion StringCallback errorCallback = (converter, errorText) => { if (errorText.Contains(headerId) || errorText.Contains(footerId)) { throw new Exception("must use in startup.cs app.UseStaticFiles()"); } else { throw new Exception(errorText); } }; Interop.HtmlToPdf.wkhtmltopdf_set_error_callback(Converter, errorCallback); Interop.HtmlToPdf.wkhtmltopdf_add_object(Converter, ObjectSettings, Encoding.UTF8.GetBytes(html)); if (Interop.HtmlToPdf.wkhtmltopdf_convert(Converter) != 0) { IntPtr tmp; var len = Interop.HtmlToPdf.wkhtmltopdf_get_output(Converter, out tmp); var result = new byte[len]; Marshal.Copy(tmp, result, 0, result.Length); tmp = IntPtr.Zero; if (!string.IsNullOrEmpty(headerPath)) { File.Delete(headerPath); } if (!string.IsNullOrEmpty(footerPath)) { File.Delete(footerPath); } return(result); } else { throw new Exception("FastHtmlToPdf error"); } }
/// <summary> /// Marca como fallido al archivo en proceso de descarga /// </summary> /// <param name="fileHandlerId">El id de la transferencia</param> public void downloadFileFailed(String fileHandlerId) { if (dataGridView.InvokeRequired) { StringCallback d = new StringCallback(downloadFileFailed); this.Invoke(d, new object[] { fileHandlerId }); } else { foreach (DataGridViewRow row in dataGridView.Rows) { if (((String)(row.Cells[5].Value)).Equals(fileHandlerId)) { row.Cells[3].Value = FileControlState.FILEFAIL; break; } } } }
/// <summary> /// Creates a new StringData instance for the given value. /// </summary> private static StringData ForCallback(StringCallback callback, string name) { StringData result; result = new StringData(); result._stringDelegate = callback; result._name = name; return result; }
public int SetWarningCallback(IntPtr converter, StringCallback callback) { return(Pinvoke.wkhtmltopdf_set_warning_callback(converter, callback)); }
public int wkhtmltopdf_set_error_callback(IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback) => WkHtmlToXBindings.wkhtmltopdf_set_error_callback(converter, callback);
public static extern int wkhtmltopdf_set_error_callback(IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);