コード例 #1
0
ファイル: HtmlHelper.cs プロジェクト: zhitian/3P
 /// <summary>
 /// Returns a formatted html message with a title, subtitle and icon
 /// </summary>
 public static string FormatTitle(MessageImg image, string title, string subtitle, bool forMessageBox = false)
 {
     return
         ("<div style=\"background-repeat: no-repeat; background-position: left center; background-image: url('" + image + "'); padding-left: 70px; padding-top: 6px; padding-bottom: 6px;\">" + @"
             <div class='NotificationTitle'><img src='" + GetLogo + @"' style='padding-right: 10px;'>" + title + @"</div>
             <div class='NotificationSubTitle'>" + subtitle + @"</div>
         </div>");
 }
コード例 #2
0
        private void server_GetImage(object sender, MessageImg e)
        {
#if USE_EMGUCV
            Emgu.CV.Image <Emgu.CV.Structure.Bgr, byte> image = this.capture.QueryFrame();
            string dateAndTime = DateTime.Now.ToString("yyyy.MM.dd/HH:mm:ss.fff", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            image.Draw(dateAndTime, ref f, new Point(10, 30), new Emgu.CV.Structure.Bgr(0, 255, 0));
            e.Image = image.Bitmap;
#elif NOT_USE_EMGUCV
            e.Image = GetImage();
#endif
        }
コード例 #3
0
 /// <summary>
 /// Returns a formmatted html message with a title, subtitle and icon
 /// </summary>
 public static string FormatTitle(MessageImg image, string title, string subtitle, bool forMessageBox = false)
 {
     return(@"
     <table style='width: 100%'>
         <tr>
             <td rowspan='2' style='width: 70px'><img src='" + image + @"' width='64' height='64' /></td>
             <td class='NotificationTitle'><img src='" + GetLogo + @"' style='padding-right: 10px;'>" + title + @"</td>
         </tr>
         <tr>
             <td class='NotificationSubTitle'>" + subtitle + @"</td>
         </tr>
     </table>");
 }
コード例 #4
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
        /// <summary>
        /// Displays a notification on the bottom right of the screen
        /// </summary>
        /// <param name="id"></param>
        /// <param name="htmlContent"></param>
        /// <param name="clickHandler"></param>
        /// <param name="subTitle"></param>
        /// <param name="duration"></param>
        /// <param name="width"></param>
        /// <param name="imageType"></param>
        /// <param name="title"></param>
        public static void NotifyUnique(string id, string htmlContent, MessageImg imageType, string title, string subTitle, Action <HtmlLinkClickedEventArgs> clickHandler, int duration = 0, int width = 450)
        {
            if (!UiThread.BeginInvoke(() => {
                try {
                    var nppScreen = Npp.NppScreen;
                    var toastNotification = new YamuiNotification(
                        HtmlHelper.FormatTitle(imageType, title, subTitle),
                        HtmlHelper.FormatContent(htmlContent),
                        duration,
                        nppScreen,
                        Math.Min(width, nppScreen.WorkingArea.Width / 3),
                        nppScreen.WorkingArea.Width / 3,
                        nppScreen.WorkingArea.Height / 3,
                        (sender, args) => {
                        if (clickHandler != null)
                        {
                            clickHandler(args);
                        }
                        if (!args.Handled)
                        {
                            Utils.OpenPathClickHandler(sender, args);
                        }
                    });

                    if (id != null)
                    {
                        // close existing notification with the same id
                        CloseUniqueNotif(id);
                        // Remember this notification
                        _registeredNotif.Add(id, toastNotification);
                    }

                    toastNotification.Show();
                } catch (Exception e) {
                    ErrorHandler.LogError(e, "Error in NotifyUnique");

                    // if we are here, display the error message the old way
                    MessageBox.Show("An error has occurred and we couldn't display a notification.\n\nCheck the log at the following location to learn more about this error : " + Config.FileErrorLog.Quoter() + "\n\nTry to restart Notepad++, consider opening an issue on : " + Config.UrlIssues + " if the problem persists.", AssemblyInfo.AssemblyProduct + " error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }))
            {
                ErrorHandler.LogError(new Exception("No UIThread!"), "Error in NotifyUnique");

                // show the old way
                MessageBox.Show("An error has occurred and we couldn't display a notification.\n\nCheck the log at the following location to learn more about this error : " + Config.FileErrorLog.Quoter() + "\n\nTry to restart Notepad++, consider opening an issue on : " + Config.UrlIssues + " if the problem persists.\n\nThe initial message was :\n" + htmlContent.Replace("<br>", "\n"), AssemblyInfo.AssemblyProduct + " error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: UserCommunication.cs プロジェクト: devjerome/3P
        /// <summary>
        /// Displays a notification on the bottom right of the screen
        /// </summary>
        /// <param name="id"></param>
        /// <param name="htmlContent"></param>
        /// <param name="clickHandler"></param>
        /// <param name="subTitle"></param>
        /// <param name="duration"></param>
        /// <param name="width"></param>
        /// <param name="imageType"></param>
        /// <param name="title"></param>
        public static void NotifyUnique(string id, string htmlContent, MessageImg imageType, string title, string subTitle, Action <HtmlLinkClickedEventArgs> clickHandler, int duration = 0, int width = 450)
        {
            Task.Factory.StartNew(() => {
                try {
                    if (Ready)
                    {
                        _anchorForm.BeginInvoke((Action) delegate {
                            var nppScreen         = Npp.NppScreen;
                            var toastNotification = new YamuiNotification(
                                ThemeManager.FormatTitle(imageType, title, subTitle),
                                ThemeManager.FormatContent(htmlContent),
                                duration,
                                nppScreen,
                                Math.Min(width, nppScreen.WorkingArea.Width / 3),
                                nppScreen.WorkingArea.Width / 3,
                                nppScreen.WorkingArea.Height / 3,
                                (sender, args) => {
                                if (clickHandler != null)
                                {
                                    clickHandler(args);
                                }
                                else
                                {
                                    Utils.OpenPathClickHandler(sender, args);
                                }
                            });

                            if (id != null)
                            {
                                // close existing notification with the same id
                                CloseUniqueNotif(id);
                                // Remember this notification
                                _registeredNotif.Add(id, toastNotification);
                            }

                            toastNotification.Show();
                        });
                    }
                } catch (Exception e) {
                    ErrorHandler.LogError(e);

                    // if we are here, display the error message the old way
                    MessageBox.Show("An error has occurred and we couldn't display a notification.\n\nCheck the log at the following location to learn more about this error : " + Config.FileErrorLog.ProQuoter() + "\n\nTry to restart Notepad++, consider opening an issue on : " + Config.IssueUrl + " if the problem persists.", AssemblyInfo.AssemblyProduct + " error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            });
        }
コード例 #6
0
ファイル: ThemeManager.cs プロジェクト: jcaillon/3P
 /// <summary>
 /// Returns a formmatted html message with a title, subtitle and icon
 /// </summary>
 public static string FormatTitle(MessageImg image, string title, string subtitle, bool forMessageBox = false)
 {
     return @"
     <table style='width: 100%'>
         <tr>
             <td rowspan='2' style='width: 70px'><img src='" + image + @"' width='64' height='64' /></td>
             <td class='NotificationTitle'><img src='" + GetLogo + @"' style='padding-right: 10px;'>" + title + @"</td>
         </tr>
         <tr>
             <td class='NotificationSubTitle'>" + subtitle + @"</td>
         </tr>
     </table>";
 }
コード例 #7
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
        private static int Message(ref object data, string htmlContent, MessageImg imageType, string title, string subTitle, List <string> buttonsList = null, bool waitResponse = true, Action <HtmlLinkClickedEventArgs> clickHandler = null, int minWidth = 450)
        {
            var clickedButton = -1;

            if (buttonsList == null)
            {
                buttonsList = new List <string> {
                    "Ok", "Cancel"
                }
            }
            ;

            if (waitResponse && data != null)
            {
                clickedButton = YamuiInput.ShowDialog(
                    Npp.Handle,
                    "3P: " + title,
                    HtmlHelper.FormatTitle(imageType, title, subTitle),
                    HtmlHelper.FormatContent(htmlContent),
                    buttonsList,
                    ref data,
                    Npp.NppScreen.WorkingArea.Width * 3 / 5,
                    Npp.NppScreen.WorkingArea.Height * 9 / 10,
                    minWidth,
                    (sender, args) => {
                    if (clickHandler != null)
                    {
                        clickHandler(args);
                    }
                    else
                    {
                        Utils.OpenPathClickHandler(sender, args);
                    }
                });
            }
            else if (waitResponse)
            {
                UiThread.Invoke(() => {
                    object nullObject = null;
                    clickedButton     = YamuiInput.ShowDialog(
                        Npp.Handle,
                        "3P: " + title,
                        HtmlHelper.FormatTitle(imageType, title, subTitle),
                        HtmlHelper.FormatContent(htmlContent),
                        buttonsList,
                        ref nullObject,
                        Npp.NppScreen.WorkingArea.Width * 3 / 5,
                        Npp.NppScreen.WorkingArea.Height * 9 / 10,
                        minWidth,
                        (sender, args) => {
                        if (clickHandler != null)
                        {
                            clickHandler(args);
                        }
                        else
                        {
                            Utils.OpenPathClickHandler(sender, args);
                        }
                    });
                });
            }
            else
            {
                UiThread.BeginInvoke(() => {
                    YamuiInput form;
                    object nullObject = null;
                    clickedButton     = YamuiInput.Show(
                        Npp.Handle,
                        "3P: " + title,
                        HtmlHelper.FormatTitle(imageType, title, subTitle),
                        HtmlHelper.FormatContent(htmlContent),
                        buttonsList,
                        ref nullObject,
                        out form,
                        Npp.NppScreen.WorkingArea.Width * 3 / 5,
                        Npp.NppScreen.WorkingArea.Height * 9 / 10,
                        minWidth,
                        (sender, args) => {
                        if (clickHandler != null)
                        {
                            clickHandler(args);
                        }
                        else
                        {
                            Utils.OpenPathClickHandler(sender, args);
                        }
                    });
                    _openedMessage.Add(form);
                });
            }
            return(clickedButton);
        }

        #endregion
    }
コード例 #8
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
        /// <summary>
        /// Displays a messagebox like window, can be safely called by a thread
        /// </summary>
        public static int Message(string htmlContent, MessageImg imageType, string title, string subTitle, List <string> buttonsList = null, bool waitResponse = true, Action <HtmlLinkClickedEventArgs> clickHandler = null)
        {
            object nullObject = null;

            return(Message(ref nullObject, htmlContent, imageType, title, subTitle, buttonsList, waitResponse, clickHandler));
        }
コード例 #9
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
 /// <summary>
 /// Allows to ask information to the user,
 /// returns an integer (-1 if closed, or from 0 to x = buttons.count - 1),
 /// buttonsList default to { "Ok", "Cancel" }
 /// Only the first button (i.e. OK) will update the referenced object, it will be untouched for the other buttons
 /// </summary>
 /// <remarks>
 /// This should always be called on the UI THREAD!!!!
 /// </remarks>
 public static int Input(ref object data, string htmlContent, MessageImg imageType, string title, string subTitle, List <string> buttonsList = null, Action <HtmlLinkClickedEventArgs> clickHandler = null)
 {
     return(Message(ref data, htmlContent, imageType, title, subTitle, buttonsList, true, clickHandler));
 }
コード例 #10
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
 public static void Notify(string html, MessageImg imageType, string title, string subTitle, int duration = 0, int width = 450)
 {
     NotifyUnique(null, html, imageType, title, subTitle, null, duration, width);
 }
コード例 #11
0
ファイル: UserCommunication.cs プロジェクト: zhitian/3P
 public static void Notify(string html, MessageImg imageType, string title, string subTitle, Action <HtmlLinkClickedEventArgs> clickHandler, int duration = 0, int width = 450)
 {
     NotifyUnique(null, html, imageType, title, subTitle, clickHandler, duration, width);
 }
コード例 #12
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
        /// <summary>
        /// Displays a notification on the bottom right of the screen
        /// </summary>
        /// <param name="id"></param>
        /// <param name="htmlContent"></param>
        /// <param name="clickHandler"></param>
        /// <param name="subTitle"></param>
        /// <param name="duration"></param>
        /// <param name="width"></param>
        /// <param name="imageType"></param>
        /// <param name="title"></param>
        public static void NotifyUnique(string id, string htmlContent, MessageImg imageType, string title, string subTitle, Action<HtmlLinkClickedEventArgs> clickHandler, int duration = 0, int width = 450)
        {
            Task.Factory.StartNew(() => {

                try {
                    if (Ready) {
                        _anchorForm.BeginInvoke((Action)delegate {
                            var nppScreen = Npp.NppScreen;
                            var toastNotification = new YamuiNotification(
                                ThemeManager.FormatTitle(imageType, title, subTitle),
                                ThemeManager.FormatContent(htmlContent),
                                duration,
                                nppScreen,
                                Math.Min(width, nppScreen.WorkingArea.Width / 3),
                                nppScreen.WorkingArea.Width / 3,
                                nppScreen.WorkingArea.Height / 3,
                                (sender, args) => {
                                    if (clickHandler != null) clickHandler(args);
                                    else Utils.OpenPathClickHandler(sender, args);
                                });

                            if (id != null) {
                                // close existing notification with the same id
                                CloseUniqueNotif(id);
                                // Remember this notification
                                _registeredNotif.Add(id, toastNotification);
                            }

                            toastNotification.Show();
                        });
                    }

                } catch (Exception e) {
                    ErrorHandler.LogError(e);

                    // if we are here, display the error message the old way
                    MessageBox.Show("An error has occurred and we couldn't display a notification.\n\nCheck the log at the following location to learn more about this error : " + Config.FileErrorLog.ProQuoter() + "\n\nTry to restart Notepad++, consider opening an issue on : " + Config.IssueUrl + " if the problem persists.", AssemblyInfo.AssemblyProduct + " error message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            });
        }
コード例 #13
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
 public static void Notify(string html, MessageImg imageType, string title, string subTitle, int duration = 0, int width = 450)
 {
     NotifyUnique(null, html, imageType, title, subTitle, null, duration, width);
 }
コード例 #14
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
 public static void Notify(string html, MessageImg imageType, string title, string subTitle, Action<HtmlLinkClickedEventArgs> clickHandler, int duration = 0, int width = 450)
 {
     NotifyUnique(null, html, imageType, title, subTitle, clickHandler, duration, width);
 }
コード例 #15
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
        public static int Message(ref object data, string htmlContent, MessageImg imageType, string title, string subTitle, List<string> buttonsList = null, bool waitResponse = true, Action<HtmlLinkClickedEventArgs> clickHandler = null, int minWidth = 450)
        {
            var clickedButton = -1;

            if (buttonsList == null)
                buttonsList = new List<string> { "Ok", "Cancel" };

            if (waitResponse) {
                clickedButton = YamuiInput.ShowDialog(
                    Npp.HandleNpp,
                    "3P: " + title,
                    ThemeManager.FormatTitle(imageType, title, subTitle),
                    ThemeManager.FormatContent(htmlContent),
                    buttonsList,
                    ref data,
                    Npp.NppScreen.WorkingArea.Width * 3 / 5,
                    Npp.NppScreen.WorkingArea.Height * 9 / 10,
                    minWidth,
                    (sender, args) => {
                        if (clickHandler != null) clickHandler(args);
                        else Utils.OpenPathClickHandler(sender, args);
                    });
            } else {
                if (_anchorForm != null && _anchorForm.IsHandleCreated) {
                    _anchorForm.BeginInvoke((Action)delegate {
                        YamuiInput form;
                        object nullObject = null;
                        clickedButton = YamuiInput.Show(
                            Npp.HandleNpp,
                            "3P: " + title,
                            ThemeManager.FormatTitle(imageType, title, subTitle),
                            ThemeManager.FormatContent(htmlContent),
                            buttonsList,
                            ref nullObject,
                            out form,
                            Npp.NppScreen.WorkingArea.Width * 3 / 5,
                            Npp.NppScreen.WorkingArea.Height * 9 / 10,
                            minWidth,
                            (sender, args) => {
                                if (clickHandler != null) clickHandler(args);
                                else Utils.OpenPathClickHandler(sender, args);
                            });
                        _openedMessage.Add(form);
                    });
                }
            }
            return clickedButton;
        }
コード例 #16
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
 /// <summary>
 /// Displays a messagebox like window, 
 /// REMARK : DON'T WAIT FOR AN ANSWER IF YOU CALL IT FROM A THREAD!!!!!!!, 
 /// new List string  { "Ok", "Cancel" }, 
 /// returns an integer (-1 if closed, or from 0 to x = buttons.count - 1),
 /// buttonsList default to { "Ok", "Cancel" }
 /// </summary>
 public static int Message(string htmlContent, MessageImg imageType, string title, string subTitle, List<string> buttonsList = null, bool waitResponse = true, Action<HtmlLinkClickedEventArgs> clickHandler = null)
 {
     object nullObject = null;
     return Message(ref nullObject, htmlContent, imageType, title, subTitle, buttonsList, waitResponse, clickHandler);
 }
コード例 #17
0
ファイル: UserCommunication.cs プロジェクト: jcaillon/3P
 /// <summary>
 /// Allows to ask information to the user,
 /// returns an integer (-1 if closed, or from 0 to x = buttons.count - 1), 
 /// buttonsList default to { "Ok", "Cancel" }
 /// </summary>
 public static int Input(ref object data, string htmlContent, MessageImg imageType, string title, string subTitle, List<string> buttonsList = null, Action<HtmlLinkClickedEventArgs> clickHandler = null)
 {
     return Message(ref data, htmlContent, imageType, title, subTitle, buttonsList, true, clickHandler);
 }