Exemple #1
0
        public static void setGadgetPositionAt(int index, int posX, int posY)
        {
            GadgetInfo gInfo = _gadgetInfoList[index];

            gInfo.X = posX;
            gInfo.Y = posY;
            _gadgetInfoList[index] = gInfo;
        }
Exemple #2
0
 private void importGadgetLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (gadgetBrowserDialog.ShowDialog() == DialogResult.OK)
     {
         if (GadgetManager.addGadget(gadgetBrowserDialog.SelectedPath))
         {
             GadgetInfo        gInfo        = GadgetManager.getLastGadgetInfo();
             GadgetIconControl gIconControl = new GadgetIconControl(GadgetManager.getGedgetCount(), gInfo.name, gInfo.icon.src);
             gadgetListPanel.Controls.Add(gIconControl);
         }
         else
         {
             MessageBox.Show("Error", "Can't load Gadget");
         }
     }
 }
Exemple #3
0
        public static void setGadgetActivationAt(int index, bool isActive)
        {
            GadgetInfo gInfo = _gadgetInfoList[index];

            gInfo.isActived        = isActive;
            _gadgetInfoList[index] = gInfo;

            if (isActive && !_gadgetFormList.ContainsKey(index))
            {
                // Create
                _gadgetFormList.Add(index, new GadgetForm(index, gInfo.X, gInfo.Y));
                _gadgetFormList[index].Show();
            }
            else if (!isActive && _gadgetFormList.ContainsKey(index))
            {
                // Delete
                _gadgetFormList[index].Close();
                _gadgetFormList.Remove(index);
            }
        }
Exemple #4
0
        public static bool addGadget(string dirPath)
        {
            XmlDocument menifestXml;
            GadgetInfo  gadgetInfo = new GadgetInfo();

            try
            {
                gadgetInfo.rootDir = dirPath;

                menifestXml = new XmlDocument();
                menifestXml.Load(Path.Combine(dirPath, "Gadget.xml"));

                XmlNode gadgetNode = menifestXml.SelectSingleNode("gadget");

                gadgetInfo.name    = gadgetNode.SelectSingleNode("name").InnerText;
                gadgetInfo.version = gadgetNode.SelectSingleNode("version").InnerText;
                string absolutePath = gadgetNode.SelectSingleNode("base").Attributes.GetNamedItem("src").Value;
                if (!Path.IsPathRooted(absolutePath))
                {
                    absolutePath = Path.Combine(dirPath, absolutePath);
                }
                gadgetInfo.htmlPath = absolutePath;

                try
                {
                    XmlNode authorNode = gadgetNode.SelectSingleNode("author");
                    gadgetInfo.autherInfo.name = authorNode.Attributes.GetNamedItem("name").Value;

                    try
                    {
                        gadgetInfo.autherInfo.infoUrl = authorNode.SelectSingleNode("info").Attributes.GetNamedItem("url").Value;
                    }
                    catch { }
                    try
                    {
                        string absoluteSrc = authorNode.SelectSingleNode("logo").Attributes.GetNamedItem("src").Value;
                        if (!Path.IsPathRooted(absoluteSrc))
                        {
                            absoluteSrc = Path.Combine(dirPath, absoluteSrc);
                        }
                        gadgetInfo.autherInfo.logoIcon.src = absoluteSrc;
                    }
                    catch { }
                    try
                    {
                        gadgetInfo.autherInfo.logoIcon.height = float.Parse(authorNode.SelectSingleNode("logo").Attributes.GetNamedItem("height").Value);
                    }
                    catch { }
                    try
                    {
                        gadgetInfo.autherInfo.logoIcon.width = float.Parse(authorNode.SelectSingleNode("logo").Attributes.GetNamedItem("width").Value);
                    }
                    catch { }
                }
                catch { }

                try
                {
                    gadgetInfo.licence = gadgetNode.SelectSingleNode("copyright").InnerText;
                }
                catch { }

                try
                {
                    gadgetInfo.description = gadgetNode.SelectSingleNode("description").InnerText;
                }
                catch { }

                try
                {
                    XmlNode iconNode = gadgetNode.SelectSingleNode("icons").SelectSingleNode("icon");

                    try
                    {
                        string absoluteSrc = iconNode.Attributes.GetNamedItem("src").Value;
                        if (!Path.IsPathRooted(absoluteSrc))
                        {
                            absoluteSrc = Path.Combine(dirPath, absoluteSrc);
                        }
                        gadgetInfo.icon.src = absoluteSrc;
                    }
                    catch { }
                    try
                    {
                        gadgetInfo.icon.height = float.Parse(iconNode.Attributes.GetNamedItem("height").Value);
                    }
                    catch { }
                    try
                    {
                        gadgetInfo.icon.width = float.Parse(iconNode.Attributes.GetNamedItem("width").Value);
                    }
                    catch { }
                }
                catch { }

                try
                {
                    string absoluteSrc = gadgetNode.SelectSingleNode("defaultImage").Attributes.GetNamedItem("src").Value;
                    if (!Path.IsPathRooted(absoluteSrc))
                    {
                        absoluteSrc = Path.Combine(dirPath, absoluteSrc);
                    }
                    gadgetInfo.defaultImg.src = absoluteSrc;
                }
                catch { }
                try
                {
                    gadgetInfo.defaultImg.height = float.Parse(gadgetNode.SelectSingleNode("defaultImage").Attributes.GetNamedItem("height").Value);
                }
                catch { }
                try
                {
                    gadgetInfo.defaultImg.width = float.Parse(gadgetNode.SelectSingleNode("defaultImage").Attributes.GetNamedItem("width").Value);
                }
                catch { }

                gadgetInfo.isActived = false;
                gadgetInfo.X         = 0;
                gadgetInfo.Y         = 0;

                _gadgetInfoList.Add(gadgetInfo);
            }
            catch
            {
                return(false);
            }

            return(true);
        }