Example #1
0
 //-------------------------------------------------------------------------------------------------------------------------------
 // check if the specified location (X, Y) is already used by another note
 //-------------------------------------------------------------------------------------------------------------------------------
 private bool isLocationAlreadyUsed(NoteLocation location, UINotifier note)
 {
     foreach (var p in Notes)
     {
         if (p.Left == location.X &&
             p.Top == location.Y)
         {
             if (note.InApplication != null &&
                 p.ID == note.ID)
             {
                 return(false);
             }
             return(true);
         }
     }
     return(false);
 }
Example #2
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);
 }
Example #3
0
        //-------------------------------------------------------------------------------------------------------------------------------
        // Find a valid position for the note into the note area:
        // 1. Inside the Screen (support multiple screens)
        // 2. Inside the father application (if specified)
        //-------------------------------------------------------------------------------------------------------------------------------
        private NoteLocation adjustLocation(UINotifier note)
        {
            Rectangle notesArea;
            int       nColumn = 0, xShift = 25;                                               // Custom note overlay
            //  x_Shift     = Width + 5;                                         // Full visible note (no overlay)
            bool add = false;

            if (InApplication != null && InApplication.WindowState == FormWindowState.Normal)        // Get the available notes area, based on the type of note location
            {
                notesArea = InApplication.Bounds;
            }
            else
            {
                notesArea = new Rectangle(Screen.GetWorkingArea(note).Left,
                                          Screen.GetWorkingArea(note).Top,
                                          Screen.GetWorkingArea(note).Width,
                                          Screen.GetWorkingArea(note).Height);
            }

            int nMaxRows    = notesArea.Height / Height;                             // Max number of rows in the available space
            int nMaxColumns = notesArea.Width / xShift;                              // Max number of columns in the available space

            noteLocation = new NoteLocation(notesArea.Width +                        // Initial Position X
                                            notesArea.Left -
                                            Width,
                                            notesArea.Height +                        // Initial Position Y
                                            notesArea.Top -
                                            Height);

            while (nMaxRows > 0 && !add)                                              // Check the latest available position (no overlap)
            {
                for (int nRow = 1; nRow <= nMaxRows; nRow++)
                {
                    noteLocation.Y = notesArea.Height +
                                     notesArea.Top -
                                     Height * nRow;

                    if (!isLocationAlreadyUsed(noteLocation, note))
                    {
                        add = true; break;
                    }

                    if (nRow == nMaxRows)                                            // X shift if no more column space
                    {
                        nColumn++;
                        nRow = 0;

                        noteLocation.X = notesArea.Width +
                                         notesArea.Left -
                                         Width - xShift * nColumn;
                    }

                    if (nColumn >= nMaxColumns)                                      // Last exit condition: the screen is full of note
                    {
                        add = true; break;
                    }
                }
            }

            noteLocation.initialLocation = new Point(noteLocation.X,                  // Init the initial Location, for drag & drop
                                                     noteLocation.Y);
            return(noteLocation);
        }