Exemple #1
0
        public static PluginCollection Parse(Config cn)
        {
            PluginCollection p = new PluginCollection();
            int i = 1;

            foreach (Section s in cn)
            {
                if (s.Name == "[Plugin #" + i + "]")
                {
                    if (s["Path"] != null && s["Username"] != null && s["Password"] != null)
                    {
                        if (s["UserDescription"] != null)
                        {
                            p.Add(new Plugin(s["Path"], s["Username"], s["Password"], s["UserDescription"]));
                        }
                        else
                        {
                            p.Add(new Plugin(s["Path"], s["Username"], s["Password"]));
                        }
                        i++;
                    }
                }
            }
            return(p);
        }
Exemple #2
0
 public Parameters(PluginCollection pluginList, UIParameters vp, bool firstTimeStarted, bool timerEnabled, double interval)
 {
     this.pluginList       = pluginList;
     this.vp               = vp;
     this.firstTimeStarted = firstTimeStarted;
     this.timerEnabled     = timerEnabled;
     this.interval         = interval;
 }
Exemple #3
0
        /*public static PluginCollection operator -(PluginCollection lhs, PluginCollection rhs)
         * {
         *      PluginCollection pc = new PluginCollection();
         *      if (lhs > rhs)
         *      {
         *
         *              //A=lhs, B=rhs
         *              //A⊂ B
         *              foreach (Plugin ParametersInstance in lhs)
         *              {
         *                      Plugin pl = rhs[ParametersInstance.Name, ParametersInstance.Version];
         *                      if (ParametersInstance == pl)
         *                              continue;
         *                      else
         *                              return false;
         *              }
         *              //B⊂A
         *              foreach (Plugin ParametersInstance in rhs)
         *              {
         *                      Plugin pl = lhs[ParametersInstance.Name, ParametersInstance.Version];
         *                      if (ParametersInstance == pl)
         *                              continue;
         *                      else
         *                              return false;
         *              }
         *              return true;
         *      }
         *      else if (rhs > lhs)
         *      {
         *      }
         *      return pc;
         * }*/
        public static PluginCollection FindPlugins(string folder)
        {
            //TODO: добавить обработку исключений
            //MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory);
            PluginCollection pc = new PluginCollection();

            string[] files = Directory.GetFiles(folder, "*.dll");
            foreach (string s in files)
            {
                Plugin p = new Plugin(s);
                if (p.Valid)
                {
                    pc.Add(p);
                }
            }
            return(pc);
        }
Exemple #4
0
        public int CompareTo(object obj)
        {
            PluginCollection pc = obj as PluginCollection;

            if (pc == null)
            {
                throw new ArgumentException("obj is not a PluginCollection");
            }
            if (this == pc)
            {
                return(0);
            }
            if (this > pc)
            {
                return(1);
            }
            //if (this < pc)
            return(-1);
        }
Exemple #5
0
        public static PluginCollection Synchronize(PluginCollection from, PluginCollection to)
        {
            PluginCollection pc = new PluginCollection();

            foreach (Plugin p in to)
            {
                Plugin pl = from[p.Name];
                if (pl != null)
                {
                    p.Username        = pl.Username;
                    p.Password        = pl.Password;
                    p.UserDescription = pl.UserDescription;
                    p.Checked         = true;
                    p.Update();
                    pc.Add(p);
                }
            }
            return(pc);
        }
Exemple #6
0
        public static Parameters Parse(Config cn)
        {
            UIParameters pr = new UIParameters();
            bool         firstTimeStarted = Default.FirstTimeStarted;
            bool         timerEnabled     = Default.TimerEnabled;
            double       interval         = Default.Interval;

            try { firstTimeStarted = Boolean.Parse(cn["[FirstParameters]", "FirstTimeStarted"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { timerEnabled = Boolean.Parse(cn["[FirstParameters]", "TimerEnabled"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { interval = Convert.ToInt32(cn["[FirstParameters]", "Interval"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { double x = Convert.ToDouble(cn["MainWindow", "Opacity"]); pr.Opacity = (x != 0) ? x : UIParameters.Default.Opacity; }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.Color = Color.FromName(cn["MainWindow", "Color"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.TextColor = Color.FromName(cn["MainText", "Color"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.TextFont = new Font(cn["MainText", "FontName"], (float)Convert.ToDouble(cn["MainText", "FontSize"])); }
            catch (ArgumentException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.DesktopLabelCoordinates = new Point(Convert.ToInt32(cn["DesktopText", "X"]), pr.DesktopLabelCoordinates.Y); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.DesktopLabelCoordinates = new Point(pr.DesktopLabelCoordinates.X, Convert.ToInt32(cn["DesktopText", "Y"])); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.DesktopLabelColor1 = Color.FromName(cn["DesktopText", "Color1"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.DesktopLabelColor2 = Color.FromName(cn["DesktopText", "Color2"]); }
            catch (ArgumentNullException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            try { pr.DesktopLabelFont = new Font(cn["DesktopText", "FontName"], ((float)Convert.ToDouble(cn["DesktopText", "FontSize"]))); }
            catch (ArgumentException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }
            catch (FormatException e) { cn.LoggerInstance.WriteLine(e.Message, MessageType.Warning); }

            switch (cn["DesktopText", "Effect"])
            {
            case "BackwardDiagonal":
                pr.DesktopLabelEffect = LinearGradientMode.BackwardDiagonal;
                break;

            case "ForwardDiagonal":
                pr.DesktopLabelEffect = LinearGradientMode.ForwardDiagonal;
                break;

            case "Horizontal":
                pr.DesktopLabelEffect = LinearGradientMode.Horizontal;
                break;

            case "Vertical":
                pr.DesktopLabelEffect = LinearGradientMode.Vertical;
                break;

            default:
                pr.DesktopLabelEffect = UIParameters.Default.DesktopLabelEffect;
                break;
            }
            if (pr.Color.ToArgb() == 0)
            {
                pr.Color = UIParameters.Default.Color;
            }
            if (pr.TextColor.ToArgb() == 0)
            {
                pr.TextColor = UIParameters.Default.TextColor;
            }
            if (pr.DesktopLabelColor1.ToArgb() == 0)
            {
                pr.DesktopLabelColor1 = UIParameters.Default.DesktopLabelColor1;
            }
            if (pr.DesktopLabelColor2.ToArgb() == 0)
            {
                pr.DesktopLabelColor2 = UIParameters.Default.DesktopLabelColor2;
            }
            interval = (interval == 0) ? Default.Interval : interval;
            return(new Parameters(PluginCollection.Parse(cn), pr, firstTimeStarted, timerEnabled, interval));
        }