Esempio n. 1
0
        private void MessageTimeout(object sender, EventArgs e)
        {
            Data.Message msg = null;
            // display a message window
            lock (lockMessages)
            {
                msg = messages.DisplayMessage;
            }

            if (msg == null)
            {
                Logger.Write("No DisplayMessage was received.", LoggerErrorLevels.WARNING);
                return;
            }

            //if (taskbarNotifier3 == null)
            //{
            //    taskbarNotifier3 = new TaskbarNotifier();
            //    taskbarNotifier3.SetBackgroundBitmap(Resource.skin3, Color.FromArgb(255, 0, 255));
            //    taskbarNotifier3.SetCloseBitmap(Resource.close, Color.FromArgb(255, 0, 255), new Point(280, 57));
            //    taskbarNotifier3.TitleRectangle = new Rectangle(150, 57, 125, 28);
            //    taskbarNotifier3.ContentRectangle = new Rectangle(75, 92, 215, 55);
            //    taskbarNotifier3.TitleClick += new EventHandler(TitleClick);
            //    taskbarNotifier3.ContentClick += new EventHandler(ContentClick);
            //    taskbarNotifier3.CloseClick += new EventHandler(CloseClick);
            //}

            //taskbarNotifier3.CloseClickable = true;
            //taskbarNotifier3.TitleClickable = false;
            //taskbarNotifier3.ContentClickable = false;
            //taskbarNotifier3.EnableSelectionRectangle = true;
            //taskbarNotifier3.KeepVisibleOnMousOver = true;	// Added Rev 002
            //taskbarNotifier3.ReShowOnMouseOver = true;			// Added Rev 002

            //taskbarNotifier3.Show(msg.Title, msg.Body, 500, Config.Instance.TimeoutDisplayNotificationWindow, 500);

            DisplayNotificationWindow(msg.Title, msg.Body, Config.Instance.TimeoutDisplayNotificationWindow, 3);
        }
Esempio n. 2
0
        public MesajeApplication()
        {
            InitializeComponent();

            notifyIcon = new NotifyIcon();
            contextMenu = new ContextMenu();
            exitMenuItem = new MenuItem();
            newMessageMenuItem = new MenuItem();
            optionsMenuItem = new MenuItem();

            // set up the Message Updater
            backWorker.WorkerReportsProgress = true;
            backWorker.WorkerSupportsCancellation = true;
            backWorker.DoWork += new DoWorkEventHandler(bw_DoWork);
            //backWorker.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            backWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

            // initialize the context menu
            contextMenu.MenuItems.AddRange(new MenuItem[] { exitMenuItem, optionsMenuItem, newMessageMenuItem });

            // initialize the menu items
            exitMenuItem.Index = 2;
            exitMenuItem.Text = "E&xit";
            exitMenuItem.Click += new EventHandler(exitMenuItem_Click);

            optionsMenuItem.Index = 1;
            optionsMenuItem.Text = "&Options";
            optionsMenuItem.Click += new EventHandler(optionsMenuItem_Click);

            newMessageMenuItem.Index = 0;
            newMessageMenuItem.Text = "Arata mesaj &nou";
            newMessageMenuItem.Click += new EventHandler(newMessageMenuItem_Click);

            // create the notification icon
            notifyIcon = new NotifyIcon();
            notifyIcon.Icon = Resource.Application;

            notifyIcon.ContextMenu = contextMenu;
            notifyIcon.Text = "Mesaje diverse";
            notifyIcon.BalloonTipIcon = ToolTipIcon.Info;
            notifyIcon.BalloonTipText = "Apasati pe icoana pentru mesaje diverse.";
            notifyIcon.BalloonTipTitle = "Mesaje diverse";
            notifyIcon.Visible = true;
            notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick);

            // add the resize event
            this.Resize += new EventHandler(MesajeApplication_Resize);
            notifyIcon.Visible = true;
            notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick);

            AppSettingsReader appSettings = new AppSettingsReader();
            // set the timer
            messageDisplayTimer = new Timer();
            messageDisplayTimer.Interval = Config.Instance.PublishInterval;
            messageDisplayTimer.Tick += new EventHandler(MessageTimeout);
            messageDisplayTimer.Enabled = true;
            messageDisplayTimer.Start();

            messageUpdateTimer = new Timer();
            messageUpdateTimer.Interval = Config.Instance.MessageUpdateInterval;
            messageUpdateTimer.Tick += new EventHandler(UpdateMessagesTimeout);
            messageUpdateTimer.Enabled = true;
            messageUpdateTimer.Start();

            // initialize the Notification windows
            taskbarNotifier1 = new TaskbarNotifier();
            taskbarNotifier1.SetBackgroundBitmap(Resource.skin, Color.FromArgb(255, 0, 255));
            taskbarNotifier1.SetCloseBitmap(Resource.close, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier1.TitleRectangle = new Rectangle(150, 57, 125, 28);
            taskbarNotifier1.ContentRectangle = new Rectangle(75, 92, 215, 55);
            taskbarNotifier1.TitleClick += new EventHandler(TitleClick);
            taskbarNotifier1.ContentClick += new EventHandler(ContentClick);
            taskbarNotifier1.CloseClick += new EventHandler(CloseClick);
            taskbarNotifier1.EnableSelectionRectangle = true;
            taskbarNotifier1.KeepVisibleOnMousOver = true;
            taskbarNotifier1.ReShowOnMouseOver = true;

            taskbarNotifier2 = new TaskbarNotifier();
            taskbarNotifier2.SetBackgroundBitmap(Resource.skin2, Color.FromArgb(255, 0, 255));
            taskbarNotifier2.SetCloseBitmap(Resource.close2, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier2.TitleRectangle = new Rectangle(150, 57, 125, 28);
            taskbarNotifier2.ContentRectangle = new Rectangle(75, 92, 215, 55);
            taskbarNotifier2.TitleClick += new EventHandler(TitleClick);
            taskbarNotifier2.ContentClick += new EventHandler(ContentClick);
            taskbarNotifier2.CloseClick += new EventHandler(CloseClick);
            taskbarNotifier2.EnableSelectionRectangle = true;
            taskbarNotifier2.KeepVisibleOnMousOver = true;
            taskbarNotifier2.ReShowOnMouseOver = true;

            taskbarNotifier3 = new TaskbarNotifier();
            taskbarNotifier3.SetBackgroundBitmap(Resource.skin3, Color.FromArgb(255, 0, 255));
            taskbarNotifier3.SetCloseBitmap(Resource.close, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier3.TitleRectangle = new Rectangle(150, 57, 125, 28);
            taskbarNotifier3.ContentRectangle = new Rectangle(75, 92, 215, 55);
            taskbarNotifier3.TitleClick += new EventHandler(TitleClick);
            taskbarNotifier3.ContentClick += new EventHandler(ContentClick);
            taskbarNotifier3.CloseClick += new EventHandler(CloseClick);
            taskbarNotifier3.EnableSelectionRectangle = true;
            taskbarNotifier3.KeepVisibleOnMousOver = true;
            taskbarNotifier3.ReShowOnMouseOver = true;

            //LoadItems();
            //MessageManagement.UpdateXml();
            // start updating the message list
            UpdateMessagesTimeout(null, null);

            // add a dummy item
            Mesaje.Data.Message dummy = new Data.Message();
            dummy.ID = 1;
            dummy.Body = "Dummy body,the red cow is crossing the street.";
            dummy.Title = "Dummy title";
            lock (lockMessages)
            {
                messages.Add(dummy);
            }

            this.WindowState = FormWindowState.Minimized;
        }
Esempio n. 3
0
        /// <summary>
        /// Serialize into XML format the given Message object
        /// </summary>
        /// <param name="msg">The Message to be serialized</param>
        /// <returns>A XML string representation of the specifiedobject</returns>
        public static string ToXml(Message msg)
        {
            string xml = "<mesaj>";

            // add the Id
            xml += "<id>" + msg.ID + "</id>";

            // add the title
            if (msg.Title != null)
            {
                xml += "<titlu>" + msg.Title + "</titlu>";
            }

            // add the content
            if (msg.Body != null)
            {
                xml += "<continut>" + msg.Body + "</continut>";
            }

            // add the author
            if (msg.Author != null)
            {
                xml += "<autor>" + msg.Author + "</autor>";
            }

            // add the authorLink
            if (msg.AuthorLink != null)
            {
                xml += "<autorlink>" + msg.AuthorLink + "</autorlink>";
            }

            // add the timesPublished
            xml += "<numarpublicatii>" + msg.TimesPublished + "</numarpublicatii>";

            // add the addDate
            xml += "<dataadaugarii>" + msg.AddDate + "</dataadaugarii>";

            // add the lastpublished
            xml += "<ultimapublicare>" + msg.LastPublished + "</ultimapublicare>";

            // add the datapublicarii
            xml += "<datapublicarii>" + msg.PublishDate + "</datapublicarii>";

            xml += "</mesaj>";
            return xml;
        }
Esempio n. 4
0
        /// <summary>
        /// Deserialize a Message from an XML node
        /// </summary>
        /// <param name="node">The XML structure containing the Message info.</param>
        /// <returns>A new Message with the information received from the XML</returns>
        public static Message FromXml(XmlNode node)
        {
            Message msg = new Message();

            // try to get all the available information from the node
            XmlNode tmpNode = null;

            // get the title
            tmpNode = node.SelectSingleNode("titlu");
            if (tmpNode != null)
            {
                msg.Title = tmpNode.InnerText;
            }

            // get the body
            tmpNode = node.SelectSingleNode("continut");
            if (tmpNode != null)
            {
                msg.Body = tmpNode.InnerText;
            }

            // get the author
            tmpNode = node.SelectSingleNode("autor");
            if (tmpNode != null)
            {
                msg.Author = tmpNode.InnerText;
            }

            // get the author link
            tmpNode = node.SelectSingleNode("autorlink");
            if (tmpNode != null)
            {
                msg.AuthorLink = tmpNode.InnerText;
            }

            // get the id
            tmpNode = node.SelectSingleNode("id");
            if (tmpNode != null)
            {
                msg.ID = uint.Parse(tmpNode.InnerText);
            }

            // get the author timesPublished
            tmpNode = node.SelectSingleNode("numarpublicatii");
            if (tmpNode != null)
            {
                msg.TimesPublished = uint.Parse(tmpNode.InnerText);
            }

            // get the author addDate
            tmpNode = node.SelectSingleNode("dataadaugarii");
            if (tmpNode != null)
            {
                msg.AddDate = DateTime.Parse(tmpNode.InnerText);
            }

            // get the author lastpublished
            tmpNode = node.SelectSingleNode("ultimapublicare");
            if (tmpNode != null)
            {
                msg.LastPublished = DateTime.Parse(tmpNode.InnerText);
            }

            // get the author datapublicarii
            tmpNode = node.SelectSingleNode("datapublicarii");
            if (tmpNode != null)
            {
                msg.PublishDate = DateTime.Parse(tmpNode.InnerText);
            }

            return msg;
        }
Esempio n. 5
0
        //private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
        //{
        //    lblStatusBarInfo.Visible = true;
        //    progressStatusBar.Visible = true;

        //    this.lblStatusBarInfo.Text = "Updating message list";
        //    this.progressStatusBar.Value = e.ProgressPercentage;
        //}
        #endregion

        public MesajeApplication()
        {
            InitializeComponent();

            notifyIcon         = new NotifyIcon();
            contextMenu        = new ContextMenu();
            exitMenuItem       = new MenuItem();
            newMessageMenuItem = new MenuItem();
            optionsMenuItem    = new MenuItem();

            // set up the Message Updater
            backWorker.WorkerReportsProgress      = true;
            backWorker.WorkerSupportsCancellation = true;
            backWorker.DoWork += new DoWorkEventHandler(bw_DoWork);
            //backWorker.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            backWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

            // initialize the context menu
            contextMenu.MenuItems.AddRange(new MenuItem[] { exitMenuItem, optionsMenuItem, newMessageMenuItem });

            // initialize the menu items
            exitMenuItem.Index  = 2;
            exitMenuItem.Text   = "E&xit";
            exitMenuItem.Click += new EventHandler(exitMenuItem_Click);

            optionsMenuItem.Index  = 1;
            optionsMenuItem.Text   = "&Options";
            optionsMenuItem.Click += new EventHandler(optionsMenuItem_Click);

            newMessageMenuItem.Index  = 0;
            newMessageMenuItem.Text   = "Arata mesaj &nou";
            newMessageMenuItem.Click += new EventHandler(newMessageMenuItem_Click);

            // create the notification icon
            notifyIcon      = new NotifyIcon();
            notifyIcon.Icon = Resource.Application;

            notifyIcon.ContextMenu     = contextMenu;
            notifyIcon.Text            = "Mesaje diverse";
            notifyIcon.BalloonTipIcon  = ToolTipIcon.Info;
            notifyIcon.BalloonTipText  = "Apasati pe icoana pentru mesaje diverse.";
            notifyIcon.BalloonTipTitle = "Mesaje diverse";
            notifyIcon.Visible         = true;
            notifyIcon.DoubleClick    += new EventHandler(notifyIcon_DoubleClick);

            // add the resize event
            this.Resize            += new EventHandler(MesajeApplication_Resize);
            notifyIcon.Visible      = true;
            notifyIcon.DoubleClick += new EventHandler(notifyIcon_DoubleClick);

            AppSettingsReader appSettings = new AppSettingsReader();

            // set the timer
            messageDisplayTimer          = new Timer();
            messageDisplayTimer.Interval = Config.Instance.PublishInterval;
            messageDisplayTimer.Tick    += new EventHandler(MessageTimeout);
            messageDisplayTimer.Enabled  = true;
            messageDisplayTimer.Start();


            messageUpdateTimer          = new Timer();
            messageUpdateTimer.Interval = Config.Instance.MessageUpdateInterval;
            messageUpdateTimer.Tick    += new EventHandler(UpdateMessagesTimeout);
            messageUpdateTimer.Enabled  = true;
            messageUpdateTimer.Start();

            // initialize the Notification windows
            taskbarNotifier1 = new TaskbarNotifier();
            taskbarNotifier1.SetBackgroundBitmap(Resource.skin, Color.FromArgb(255, 0, 255));
            taskbarNotifier1.SetCloseBitmap(Resource.close, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier1.TitleRectangle           = new Rectangle(150, 57, 125, 28);
            taskbarNotifier1.ContentRectangle         = new Rectangle(75, 92, 215, 55);
            taskbarNotifier1.TitleClick              += new EventHandler(TitleClick);
            taskbarNotifier1.ContentClick            += new EventHandler(ContentClick);
            taskbarNotifier1.CloseClick              += new EventHandler(CloseClick);
            taskbarNotifier1.EnableSelectionRectangle = true;
            taskbarNotifier1.KeepVisibleOnMousOver    = true;
            taskbarNotifier1.ReShowOnMouseOver        = true;

            taskbarNotifier2 = new TaskbarNotifier();
            taskbarNotifier2.SetBackgroundBitmap(Resource.skin2, Color.FromArgb(255, 0, 255));
            taskbarNotifier2.SetCloseBitmap(Resource.close2, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier2.TitleRectangle           = new Rectangle(150, 57, 125, 28);
            taskbarNotifier2.ContentRectangle         = new Rectangle(75, 92, 215, 55);
            taskbarNotifier2.TitleClick              += new EventHandler(TitleClick);
            taskbarNotifier2.ContentClick            += new EventHandler(ContentClick);
            taskbarNotifier2.CloseClick              += new EventHandler(CloseClick);
            taskbarNotifier2.EnableSelectionRectangle = true;
            taskbarNotifier2.KeepVisibleOnMousOver    = true;
            taskbarNotifier2.ReShowOnMouseOver        = true;

            taskbarNotifier3 = new TaskbarNotifier();
            taskbarNotifier3.SetBackgroundBitmap(Resource.skin3, Color.FromArgb(255, 0, 255));
            taskbarNotifier3.SetCloseBitmap(Resource.close, Color.FromArgb(255, 0, 255), new Point(280, 57));
            taskbarNotifier3.TitleRectangle           = new Rectangle(150, 57, 125, 28);
            taskbarNotifier3.ContentRectangle         = new Rectangle(75, 92, 215, 55);
            taskbarNotifier3.TitleClick              += new EventHandler(TitleClick);
            taskbarNotifier3.ContentClick            += new EventHandler(ContentClick);
            taskbarNotifier3.CloseClick              += new EventHandler(CloseClick);
            taskbarNotifier3.EnableSelectionRectangle = true;
            taskbarNotifier3.KeepVisibleOnMousOver    = true;
            taskbarNotifier3.ReShowOnMouseOver        = true;

            //LoadItems();
            //MessageManagement.UpdateXml();
            // start updating the message list
            UpdateMessagesTimeout(null, null);

            // add a dummy item
            Mesaje.Data.Message dummy = new Data.Message();
            dummy.ID    = 1;
            dummy.Body  = "Dummy body,the red cow is crossing the street.";
            dummy.Title = "Dummy title";
            lock (lockMessages)
            {
                messages.Add(dummy);
            }

            this.WindowState = FormWindowState.Minimized;
        }