Exemplo n.º 1
0
        public WatchedItems()
        {
            try
            {
                XmlSchemaSet schema = new XmlSchemaSet();
                schema.Add(@"http://outerbanks.software/config.xsd", @"config.xsd");

                XDocument watchedItemsXML = XDocument.Load(@"config.xml");

                watchedItemsXML.Validate(schema, (o, e) =>
                {
                    Log.AppendLine(e.Message);
                });

                foreach (XElement el in watchedItemsXML.Descendants("WatchedItem"))
                {
                    WatchedItem wi = new WatchedItem();

                    wi.Type        = el.Attribute("type").Value;
                    wi.Identifier  = el.Attribute("identifier").Value;
                    wi.DisplayName = el.Attribute("displayname").Value;

                    Items.Add(wi);
                }
            }
            catch (System.Xml.XmlException e)
            {
                //TODO: handle exceptions
            }
        }
Exemplo n.º 2
0
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            foreach (IconAndLabel il in ItemList.Children)
            {
                WatchedItem wi = items.Items.ElementAt(ItemList.Children.IndexOf(il));

                Boolean result = false;

                switch (wi.Type)
                {
                case "process":
                    result = CheckForProcess(wi.Identifier);
                    break;

                case "device":
                    result = CheckForDevice(wi.Identifier);
                    break;

                case "network":
                    result = CheckForNetwork(wi.Identifier);
                    break;

                case "url":
                    result = CheckForUrl(wi.Identifier);
                    break;
                }

                il.icon.Source = (result) ? ok : error;
            }
        }