Example #1
0
        public static void Compile(string outputFile, string file)
        {
            CSharpCodeProvider provider   = new CSharpCodeProvider();
            CompilerParameters parameters = new CompilerParameters();

            string[] dependencies =
            {
                "Microsoft.VisualBasic.dll",
                "System.Core.dll",          "System.Data.dll",                 "System.dll",     "System.Drawing.dll",  "System.Web.dll",
                "System.Windows.Forms.dll", "System.Xaml.dll",                 "System.Xml.dll", "System.Xml.Linq.dll",
                "WPF\\PresentationCore.dll","WPF\\PresentationFramework.dll",  "WPF\\WindowsBase.dll"
            };

            foreach (string i in dependencies)
            {
                parameters.ReferencedAssemblies.Add(i);
            }

            parameters.OutputAssembly = outputFile;
            CompilerResults results = provider.CompileAssemblyFromFile(parameters, file);

            var errors = results.Errors.Cast <CompilerError>().Select(i => "Line Number " +
                                                                      i.Line + "\r\n" + "Error Number: " + i.ErrorNumber + "\r\n" + i.ErrorText);

            if (errors.Count() > 0)
            {
                ConsoleHelp.WriteError(string.Join("\r\n\r\n", errors), Path.GetFileName(file));
            }
        }
Example #2
0
        public void Error_DataReady(object sender, EventArgs e)
        {
            var output = sender as PipelineReader <Object>;

            while (output.Count > 0)
            {
                ConsoleHelp.WriteError(output.Read(), Module);
            }
        }
Example #3
0
        public static void Init(string customContent, string defaultContent, string activeTheme)
        {
            DefaultThemes = Load(defaultContent);
            CustomThemes  = Load(customContent);

            foreach (Theme theme in CustomThemes)
            {
                if (theme.Name == activeTheme)
                {
                    bool isKeyMissing = false;

                    foreach (string key in DefaultThemes[0].Dictionary.Keys)
                    {
                        if (!theme.Dictionary.ContainsKey(key))
                        {
                            isKeyMissing = true;
                            ConsoleHelp.WriteError($"Theme '{activeTheme}' misses '{key}'");
                            break;
                        }
                    }

                    if (!isKeyMissing)
                    {
                        Current = theme;
                    }

                    break;
                }
            }

            if (Current == null)
            {
                foreach (Theme theme in DefaultThemes)
                {
                    if (theme.Name == activeTheme)
                    {
                        Current = theme;
                    }
                }
            }

            if (Current == null)
            {
                Current = DefaultThemes[0];
            }

            Foreground  = Current.GetBrush("foreground");
            Foreground2 = Current.GetBrush("foreground2");
            Background  = Current.GetBrush("background");
            Heading     = Current.GetBrush("heading");
        }
Example #4
0
            public void Error_DataReady(object sender, EventArgs e)
            {
                if (!WriteError)
                {
                    return;
                }

                var output = sender as PipelineReader <Object>;

                while (output.Count > 0)
                {
                    ConsoleHelp.WriteError("[" + ModuleName + "] " + output.Read().ToString());
                }
            }
Example #5
0
        public Extension()
        {
            try
            {
                AggregateCatalog catalog = new AggregateCatalog();
                string           dir     = Folder.Startup + "Extensions";

                if (Directory.Exists(dir))
                {
                    string[] knownExtensions = { "RatingExtension", "ScriptingExtension" };

                    foreach (string extDir in Directory.GetDirectories(dir))
                    {
                        if (knownExtensions.Contains(Path.GetFileName(extDir)))
                        {
                            catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
                        }
                        else
                        {
                            ConsoleHelp.WriteError("Failed to load extension:\n\n" + extDir +
                                                   "\n\nOnly extensions that ship with mpv.net are allowed in <startup>\\extensions" +
                                                   "\n\nUser extensions have to use <config folder>\\extensions" +
                                                   "\n\nNever copy or install a new mpv.net version over a old mpv.net version.");
                        }
                    }
                }

                dir = core.ConfigFolder + "extensions";

                if (Directory.Exists(dir))
                {
                    foreach (string extDir in Directory.GetDirectories(dir))
                    {
                        catalog.Catalogs.Add(new DirectoryCatalog(extDir, Path.GetFileName(extDir) + ".dll"));
                    }
                }

                if (catalog.Catalogs.Count > 0)
                {
                    CompositionContainer = new CompositionContainer(catalog);
                    CompositionContainer.ComposeParts(this);
                }
            }
            catch (Exception ex)
            {
                App.ShowException(ex);
            }
        }
Example #6
0
        void Error_DataAdded(object sender, DataAddedEventArgs e)
        {
            var error = sender as PSDataCollection <ErrorRecord>;

            ConsoleHelp.WriteError(error[e.Index], Module);
        }
Example #7
0
        void Output_DataAdded(object sender, DataAddedEventArgs e)
        {
            var output = sender as PSDataCollection <PSObject>;

            ConsoleHelp.Write(output[e.Index], Module);
        }
Example #8
0
        static void ProcessGlobalHotkeyLine(string line)
        {
            string key     = line.Substring(0, line.IndexOf(" "));
            string command = line.Substring(line.IndexOf(" ") + 1);

            string[]     parts = key.Split('+');
            KeyModifiers mod   = KeyModifiers.None;
            int          vk;

            for (int i = 0; i < parts.Length - 1; i++)
            {
                string umod = parts[i].ToUpper();

                if (umod == "ALT")
                {
                    mod |= KeyModifiers.Alt;
                }
                if (umod == "CTRL")
                {
                    mod |= KeyModifiers.Ctrl;
                }
                if (umod == "SHIFT")
                {
                    mod |= KeyModifiers.Shift;
                }
                if (umod == "WIN")
                {
                    mod |= KeyModifiers.Win;
                }
            }

            key = parts[parts.Length - 1];

            if (key.Length == 1)
            {
                short result = VkKeyScanEx(key[0], GetKeyboardLayout(0));

                int hi = result >> 8;
                int lo = result & 0xFF;

                if (lo == -1)
                {
                    return;
                }

                vk = lo;

                if ((hi & 1) == 1)
                {
                    mod |= KeyModifiers.Shift;
                }
                if ((hi & 2) == 2)
                {
                    mod |= KeyModifiers.Ctrl;
                }
                if ((hi & 4) == 4)
                {
                    mod |= KeyModifiers.Alt;
                }
            }
            else
            {
                vk = mpv_to_VK(key);
            }

            if (Commands == null)
            {
                Commands = new Dictionary <int, string>();
            }

            if (vk > 0)
            {
                Commands[ID] = command.Trim();
                bool success = RegisterHotKey(HWND, ID++, mod, vk);

                if (!success)
                {
                    ConsoleHelp.WriteError(line + ": " + new Win32Exception().Message + "\n", "global-input.conf");
                }
            }
        }