private Object GetCompareValue_Default(GenericListViewSorter Sorter, String ColumnName, ListViewItem Item)
        {
            //default just returns the String, for now. Later, add special conditions that detect when something is a valid date. Or something...
            int indexuse = Sorter.OurListView.Columns[ColumnName].Index;

            return(Item.SubItems[indexuse].Text);
        }
Example #2
0
        private void JobMonitor_Load(object sender, EventArgs e)
        {
            NotificationIcon = new NotifyIcon();

            //same icon as this form.
            NotificationIcon.Icon = this.Icon;

            //set the ContextMenuStrip....
            NotificationMenu = new ContextMenuStrip();

            HideItem = new ToolStripMenuItem("&Hide");

            RestoreItem = new ToolStripMenuItem("&Restore");
            //make it bold to indicate it is the "default" action.
            RestoreItem.Font = new Font(RestoreItem.Font, FontStyle.Bold);
            QuitItem         = new ToolStripMenuItem("&Quit");

            //set handlers...
            NotificationMenu.Opening += new CancelEventHandler(NotificationMenu_Opening);
            MonitorSorter             = new GenericListViewSorter(lvwUserListing, null);

            HideItem.Click    += new EventHandler(HideItem_Click);
            QuitItem.Click    += new EventHandler(QuitItem_Click);
            RestoreItem.Click += new EventHandler(RestoreItem_Click);
            NotificationMenu.Items.AddRange(new ToolStripItem[] { RestoreItem, HideItem, QuitItem });

            NotificationIcon.DoubleClick     += new EventHandler(RestoreItem_Click);
            NotificationIcon.ContextMenuStrip = NotificationMenu;


            //That's the Notification Icon setup.

            //ready the db...

tryagain:
            try
            {
                //Database.GetConnection();
                Database.DbConnection_Progress();
            }
            catch (Exception exx)
            {
                //oh no!
                //log the error.
                DataLayer.LogAdmin("Exception:" + exx.Message + " Stack Trace:" + exx.StackTrace);
                //show a message.



                if (MessageBox.Show(this, "Error Connecting to the Database:" + exx.Message, "Database Error", MessageBoxButtons.RetryCancel) == DialogResult.Retry)
                {
                    goto tryagain;
                }
                Close();
            }
            DbConnection gotcon = Database.GetConnection();


            //draw our "LED" bitmaps.

            LEDs        = new Bitmap[LEDColorsMiddle.Length];
            LEDGraphics = new Graphics[LEDColorsMiddle.Length];


            for (int i = 0; i < LEDColorsMiddle.Length; i++)
            {
                LEDs[i] = new Bitmap(16, 16);
                Graphics g = LEDGraphics[i] = Graphics.FromImage(LEDs[i]);
                g.Clear(Color.Transparent);
                //draw an ellipse...
                GraphicsPath gpp = new GraphicsPath();
                gpp.AddEllipse(2, 2, 14, 14);


                PathGradientBrush pathbrush = new PathGradientBrush(gpp);
                pathbrush.CenterColor = LEDColorsMiddle[i];
                Color[] surround = pathbrush.SurroundColors;

                for (int j = 0; j < surround.Length; j++)
                {
                    surround[j] = LEDColorsOuter[i];
                }

                pathbrush.SurroundColors = surround;

                pathbrush.CenterPoint = new PointF(8, 8);


                g.FillPath(pathbrush, gpp);

                gpp.Dispose();
                pathbrush.Dispose();
            }

            //create the ImageList.
            imlListView            = new ImageList();
            imlListView.ImageSize  = new Size(16, 16);
            imlListView.ColorDepth = ColorDepth.Depth32Bit;
            imlListView.Images.AddRange(LEDs);


            //add the columns to the listview.
            //right now- a "unlabelled" one, 17 pixels wide, to show the LED;
            //and their Name. simple enough, really.

            lvwUserListing.SmallImageList = imlListView;

            lvwUserListing.Columns.Add("NAME", "Name", 100);
            lvwUserListing.Columns.Add("BUSY", "Time", 100);
            lvwUserListing.SizeColumnsEqual();

            //add  two groups: one for clocked-in and one for clocked-out.

            Clockedingroup  = lvwUserListing.Groups.Add("CLOCKEDIN", "Clocked In");
            Clockedoutgroup = lvwUserListing.Groups.Add("CLOCKEDOUT", "Clocked Out");

            MonitorSelChange             = new BeforeSelItemChange(lvwUserListing);
            MonitorSelChange.fireChange += new BeforeSelItemChange.BeforeItemChangeFunction(MonitorSelChange_fireChange);

            userwatch             = new CUserDataWatcher(Database);
            userwatch.WatchEvent += new CUserDataWatcher.WatchEventFunc(userwatch_WatchEvent);

            //set up the timer as well, which will periodically fire...
            MonitorUpdateTimer          = new Timer();
            MonitorUpdateTimer.Interval = 500;
            MonitorUpdateTimer.Tick    += new EventHandler(MonitorUpdateTimer_Tick);
            //MonitorUpdateTimer.Start();
        }
 private Object GetCompareValue_Default(GenericListViewSorter Sorter, String ColumnName, ListViewItem Item)
 {
     //default just returns the String, for now. Later, add special conditions that detect when something is a valid date. Or something...
     int indexuse = Sorter.OurListView.Columns[ColumnName].Index;
     return Item.SubItems[indexuse].Text;
 }