Esempio n. 1
0
 //-------------------------------------------------------------------------------------------------------------------------------
 // Show the note: it is the startup of the creation process of the note
 //-------------------------------------------------------------------------------------------------------------------------------
 public static short Show(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier",
                          bool isDialog = false, int timeout = 0, Form inApp = null, EventHandler clickevent = null)
 {
     if (NotifierAlreadyPresent(desc, type, title, isDialog, out var updated_note_id, out var updated_note_occurence))
     {
         Update(updated_note_id, desc, type, "[" + ++updated_note_occurence + "] " + title);
     }
Esempio n. 2
0
        private readonly Form InApplication;                                       // In App UINotifier: the note is bind to the specified container

        #endregion GLOBALS

        #region CONSTRUCTOR & DISPLAY

        //-------------------------------------------------------------------------------------------------------------------------------
        // Default constructor
        //-------------------------------------------------------------------------------------------------------------------------------
        private UINotifier(string dsc, UINotifierType type, string title, bool isDialog = false, int timeout_ms = 0, Form insideMe = null)
        {
            IsDialog        = isDialog;
            Description     = dsc;
            _uiNotifierType = type;
            Title           = title;
            Timeout         = timeout_ms;
            InApplication   = insideMe;

            InitializeComponent();

            foreach (var nt in Notes)                                   // Use the latest available ID from the note list
            {
                if (nt.ID > ID)
                {
                    ID = nt.ID;
                }
            }
            ID++;                                                       // Set the Note ID

            if (insideMe != null && !inAppNoteExists())                 // Register the drag and resize events
            {
                insideMe.LocationChanged += inApp_LocationChanged;
                insideMe.SizeChanged     += inApp_LocationChanged;
            }

            foreach (Control c in Controls)                             // Make all the note area draggable
            {
                if (c is UISymbolLabel || c.Name == "icon")
                {
                    c.MouseDown += OnMouseDown;
                    c.MouseUp   += OnMouseUp;
                    c.MouseMove += OnMouseMove;
                }
            }
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------------------------------------------------------------
        // Create the Note and handle its location
        //-------------------------------------------------------------------------------------------------------------------------------
        private void setNotifier(string description, UINotifierType noteType, string title, bool isUpdate = false)
        {
            Title           = title;
            Description     = description;
            _uiNotifierType = noteType;

            noteTitle.Text   = title;                             // Fill the UINotifier data title
            noteContent.Text = description;                       // Fill the UINotifier data description
            noteDate.Text    = DateTime.Now + "";                 // Fill the UINotifier data Timestamp

            #region ADJUST COLORS

            switch (noteType)
            {
            case UINotifierType.ERROR:
                icon.Symbol      = 61527;
                icon.SymbolColor = UIStyles.Red.ButtonFillColor;
                LeaveColor       = UIStyles.Red.ButtonFillColor;
                HoverColor       = UIStyles.Red.ButtonFillHoverColor;
                break;

            case UINotifierType.INFO:
                icon.Symbol      = 61530;
                icon.SymbolColor = UIStyles.Blue.ButtonFillColor;
                LeaveColor       = UIStyles.Blue.ButtonFillColor;
                HoverColor       = UIStyles.Blue.ButtonFillHoverColor;
                break;

            case UINotifierType.WARNING:
                icon.Symbol      = 61553;
                icon.SymbolColor = UIStyles.Orange.ButtonFillColor;
                LeaveColor       = UIStyles.Orange.ButtonFillColor;
                HoverColor       = UIStyles.Orange.ButtonFillHoverColor;
                break;

            case UINotifierType.OK:
                icon.Symbol      = 61528;
                icon.SymbolColor = UIStyles.Green.ButtonFillColor;
                LeaveColor       = UIStyles.Green.ButtonFillColor;
                HoverColor       = UIStyles.Green.ButtonFillHoverColor;
                break;
            }

            buttonClose.BackColor = LeaveColor;                              // Init colors
            buttonMenu.BackColor  = LeaveColor;
            noteTitle.BackColor   = LeaveColor;

            buttonClose.MouseHover += (s, e) =>                    // Mouse hover
            {
                buttonClose.BackColor = HoverColor;
                buttonMenu.BackColor  = HoverColor;
                noteTitle.BackColor   = HoverColor;
            };
            buttonMenu.MouseHover += (s, e) =>
            {
                buttonMenu.BackColor  = HoverColor;
                buttonClose.BackColor = HoverColor;
                noteTitle.BackColor   = HoverColor;
            }; noteTitle.MouseHover += (s, e) =>
            {
                buttonMenu.BackColor  = HoverColor;
                buttonClose.BackColor = HoverColor;
                noteTitle.BackColor   = HoverColor;
            };

            buttonClose.MouseLeave += (s, e) =>                    // Mouse leave
            {
                buttonClose.BackColor = LeaveColor;
                buttonMenu.BackColor  = LeaveColor;
                noteTitle.BackColor   = LeaveColor;
            };
            buttonMenu.MouseLeave += (s, e) =>
            {
                buttonMenu.BackColor  = LeaveColor;
                buttonClose.BackColor = LeaveColor;
                noteTitle.BackColor   = LeaveColor;
            };
            noteTitle.MouseLeave += (s, e) =>
            {
                buttonMenu.BackColor  = LeaveColor;
                buttonClose.BackColor = LeaveColor;
                noteTitle.BackColor   = LeaveColor;
            };

            #endregion ADJUST COLORS

            #region DIALOG NOTE

            if (IsDialog)
            {
                Button ok_button = new Button();                     // Dialog note comes with a simple Ok button
                ok_button.FlatStyle = FlatStyle.Flat;
                ok_button.BackColor = LeaveColor;
                ok_button.ForeColor = Color.White;
                Size = new Size(Size.Width,              // Resize the note to contain the button
                                Size.Height + 50);
                ok_button.Size     = new Size(120, 40);
                ok_button.Location = new Point(Size.Width / 2 - ok_button.Size.Width / 2,
                                               Size.Height - 50);
                ok_button.Text   = UILocalize.OK;
                ok_button.Click += onOkButtonClick;
                Controls.Add(ok_button);

                noteDate.Location = new Point(noteDate.Location.X,    // Shift down the date location
                                              noteDate.Location.Y + 44);

                noteLocation = new NoteLocation(Left, Top);      // Default Center Location
            }

            #endregion DIALOG NOTE

            #region NOTE LOCATION

            if (!IsDialog && !isUpdate)
            {
                NoteLocation location = adjustLocation(this);          // Set the note location

                Left = location.X;                                     // UINotifier position X
                Top  = location.Y;                                     // UINotifier position Y
            }

            #endregion NOTE LOCATION
        }
Esempio n. 4
0
 private static void ShowNotifier(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier", bool isDialog = false, int timeout = 0, Form inApp = null)
 {
     UINotifier.Show(desc, type, title, isDialog, timeout, inApp);
 }
Esempio n. 5
0
 public static void ShowNotifier(string desc, EventHandler clickEvent, UINotifierType type = UINotifierType.INFO, string title = "Notifier", int timeout = 0)
 {
     UINotifier.Show(desc, type, title, false, timeout, null, clickEvent);
 }