示例#1
0
        /// <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));
        }
示例#2
0
		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;
 }
示例#4
0
 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();
     }
 }
示例#5
0
        /// <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);
        }
    }
示例#7
0
 /// <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;
             }
         }
     }
 }
示例#8
0
 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);
     }
 }
示例#9
0
 /// <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;
             }
         }
     }
 }
示例#10
0
        /// <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();
        }
示例#11
0
        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);
        }
示例#12
0
文件: Window.cs 项目: kaetemi/n-irc
        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();
        }
示例#13
0
        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;
             }
         }
     }
 }
示例#15
0
 static void ScheduleCallback(StringCallback c, string s)
 {
     Scheduler.Dispatch(() => c(null, s));
 }
示例#16
0
 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);
     }
 }
示例#17
0
 public static extern int LFD_SetOnError(IntPtr lfdHandle, StringCallback method);
示例#18
0
        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);
        }
示例#19
0
 public int SetErrorCallback(IntPtr converter, StringCallback callback)
 {
     return(WkHtmlToXBindings.wkhtmltopdf_set_error_callback(converter, callback));
 }
示例#20
0
        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);
        }
示例#21
0
 private static extern bool vlWorker_AddTrackingStateListener(IntPtr worker,
                                                              [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback listener,
                                                              IntPtr clientData);
示例#22
0
        /// <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);
        }
示例#23
0
        /// <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);
            }
        }
示例#24
0
        /// <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);
            }
        }
示例#25
0
        /// <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);
        }
示例#26
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;
             }
         }
     }
 }
示例#28
0
		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();
			}
		}
示例#29
0
        /// <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;
        }
示例#30
0
		private void SetCurrentLocale(string locale)
		{
			if (this.InvokeRequired)
			{
				StringCallback callBack = new StringCallback(SetCurrentLocale);
				this.Invoke(callBack, new object[] { locale });
			}
			else
			{
				cbSupportedLocales.SelectedValue = locale;
			}
		}
示例#31
0
		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();
			}
		}
示例#32
0
        /// <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);
示例#34
0
 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;
     }
 }
示例#36
0
 public void DoStuff( StringCallback callback )
 {
    LoginCallback = callback;
 }
示例#37
0
 public void AddLocalizedStringCallback(StringCallback StringCallback)
 {
     this.StringCallback = StringCallback;
 }
示例#38
0
 public void AddLocalizedStringCallback(StringCallback StringCallback)
 {
     this.StringCallback = StringCallback;
 }
		public static extern int SPDF_SetOnError(IntPtr spdfHandle, StringCallback method);
示例#40
0
 public void getAsString(StringCallback callback)
 {
 }
示例#41
0
        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");
            }
        }
示例#42
0
 public void SetWarningCallback(IntPtr converter, StringCallback callback)
 {
     NestedToolset.SetWarningCallback(converter, callback);
 }
示例#43
0
	public  void getAsString(StringCallback callback) {}
示例#44
0
        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;
             }
         }
     }
 }
示例#46
0
文件: Window.cs 项目: Jack1312/Evolve
 /// <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;
 }
示例#47
0
        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);
        }
示例#48
0
 public int SetErrorCallback(IntPtr converter, StringCallback callback)
 {
     return(Pinvoke.wkhtmltopdf_set_error_callback(converter, callback));
 }
示例#49
0
 internal static extern int wkhtmltoimage_set_warning_callback(
     IntPtr converter,
     [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);
示例#50
0
 public void SetWarningCallback(IntPtr converter, StringCallback callback)
 {
     throw new NotImplementedException();
 }
示例#51
0
 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;
             }
         }
     }
 }
示例#53
0
 public static extern bool RegisterDropFilesCallback([MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);
示例#54
0
        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;
             }
         }
     }
 }
示例#56
0
        /// <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;
        }
示例#57
0
 public int SetWarningCallback(IntPtr converter, StringCallback callback)
 {
     return(Pinvoke.wkhtmltopdf_set_warning_callback(converter, callback));
 }
示例#58
0
 public int wkhtmltopdf_set_error_callback(IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback) => WkHtmlToXBindings.wkhtmltopdf_set_error_callback(converter, callback);
示例#59
0
 public static extern int wkhtmltopdf_set_error_callback(IntPtr converter, [MarshalAs(UnmanagedType.FunctionPtr)] StringCallback callback);
示例#60
0
		public static extern int LFD_SetOnError(IntPtr lfdHandle, StringCallback method);