示例#1
0
        [STAThread] // STAThread est nécessaire pour accéder au clipboard (Clipboard.GetText)
        public static void Main(string[] args)
        {
            try
            {
                XmlConfig.CurrentConfig = new XmlConfig();
                cTrace.NewOutputPath(XmlConfig.CurrentConfig.Get("Log"));
                //cTrace.KeepOutputOpen = XmlConfig.CurrentConfig.Get<bool>("LogKeepOutputOpen", false);

                FormatInfo.SetInvariantCulture();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                WindowsApp.Trace = XmlConfig.CurrentConfig.Get <bool>("WinProcTrace", false);

                if (!WindowsApp.ControlApplicationExit(args))
                {
                    return;
                }

                //cTrace.Trace("Download");

                Icon icon = WRunSource.Class.Print.Base.Download_resource.AppIcon;
                WindowsApp.CurrentWindowsApp = new WindowsApp(icon, WAOptions.Type2);
                WindowsApp.CurrentWindowsApp.ApplicationExiting      += new WindowsApp.EventApplicationExiting(ApplicationExit);
                WindowsApp.CurrentWindowsApp.TrayIcon.NotifyIcon.Text = "Download";

                Init();

                Application.Run();
            }
            catch (Exception ex)
            {
                cf.ErrorMessageBox(ex);
            }
        }
        public static string compileAndExecuteFile(string strFileToExecute, string[] strReferenceAssembliesToAdd)
        {
            WindowsApp waWindowsApp = new WindowsApp();

            waWindowsApp.Run(new string[] { strFileToExecute }, strReferenceAssembliesToAdd);
            return(waWindowsApp.StrCompilationErrors);
        }
 public static string compileSourceCode(string strSourceCodeToExecute, string[] strReferenceAssembliesToAdd, string strPathToTempCompiledFile)
 {
     if ("" == strPathToTempCompiledFile)
     {
         strPathToTempCompiledFile = Path.GetTempFileName();
     }
     else
     {
         strPathToTempCompiledFile = Path.Combine(strPathToTempCompiledFile, files.returnUniqueFileName(".tmp.cs"));
     }
     if (strSourceCodeToExecute.Length == 0)
     {
         return("Error: Code to compile cannot be empty");
     }
     else
     {
         utils.files.SaveFileWithStringContents(strPathToTempCompiledFile, strSourceCodeToExecute);
         string strCompilationResult = new WindowsApp().Compile(strPathToTempCompiledFile, strReferenceAssembliesToAdd);
         if ("" == strCompilationResult)
         {
             File.Delete(strPathToTempCompiledFile);
             return("Compilation OK");
         }
         else
         {
             return(strCompilationResult);
         }
     }
 }
示例#4
0
        /// <summary>
        /// Runs the application.
        /// </summary>
        /// <param name="appPaths">The app paths.</param>
        /// <param name="logManager">The log manager.</param>
        /// <param name="runService">if set to <c>true</c> [run service].</param>
        /// <param name="options">The options.</param>
        private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
        {
            var fileSystem = new WindowsFileSystem(new PatternsLogger(logManager.GetLogger("FileSystem")));

            fileSystem.AddShortcutHandler(new MbLinkShortcutHandler(fileSystem));

            var nativeApp = new WindowsApp(fileSystem)
            {
                IsRunningAsService = runService
            };

            _appHost = new ApplicationHost(appPaths,
                                           logManager,
                                           options,
                                           fileSystem,
                                           "emby.windows.zip",
                                           nativeApp);

            var initProgress = new Progress <double>();

            if (!runService)
            {
                if (!options.ContainsOption("-nosplash"))
                {
                    ShowSplashScreen(_appHost.ApplicationVersion, initProgress, logManager.GetLogger("Splash"));
                }

                // Not crazy about this but it's the only way to suppress ffmpeg crash dialog boxes
                SetErrorMode(ErrorModes.SEM_FAILCRITICALERRORS | ErrorModes.SEM_NOALIGNMENTFAULTEXCEPT |
                             ErrorModes.SEM_NOGPFAULTERRORBOX | ErrorModes.SEM_NOOPENFILEERRORBOX);
            }


            var task = _appHost.Init(initProgress);

            task = task.ContinueWith(new Action <Task>(a => _appHost.RunStartupTasks()));

            if (runService)
            {
                StartService(logManager);
            }
            else
            {
                Task.WaitAll(task);

                task = InstallVcredistIfNeeded(_appHost, _logger);
                Task.WaitAll(task);

                SystemEvents.SessionEnding += SystemEvents_SessionEnding;
                SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

                HideSplashScreen();

                ShowTrayIcon();

                task = ApplicationTaskCompletionSource.Task;
                Task.WaitAll(task);
            }
        }
示例#5
0
 private static void ApplicationExit()
 {
     //cTrace.Trace("Exit in progress");
     gAppParameters.Save();
     if (gCon != null)
     {
         gCon.Close();
     }
     WindowsApp.RunControlApplicationExit();
 }
示例#6
0
 public static void SwitchAutorun(string appName, string appPath = null, bool isConsoleApp = false)
 {
     if (runningWindows)
     {
         WindowsApp.SwitchAutorun(appName, appPath, isConsoleApp);
     }
     else
     {
         LinuxApp.SwitchAutorun(appName, appPath, isConsoleApp);
     }
 }
示例#7
0
 public static CompilerResults compileAndReturnCompilerResults(string strSourceCodeToExecute, string[] strReferenceAssembliesToAdd, ref string strCompilationErrors)
 {
     string strTempFileName = Path.GetTempFileName();
     if (strSourceCodeToExecute.Length == 0)
     {
         MessageBox.Show("Code to compile cannot be empty");
         return null;
     }
     else
     {
         utils.files.SaveFileWithStringContents(strTempFileName, strSourceCodeToExecute);
         WindowsApp  waWindowsApp = new WindowsApp();
         CompilerResults crCompilerResults = waWindowsApp.compileAndReturnCompilerResultsObject(strTempFileName, strReferenceAssembliesToAdd);
         strCompilationErrors = waWindowsApp.StrCompilationErrors;
         return crCompilerResults;
     }
 }
        public static CompilerResults compileAndReturnCompilerResults(string strSourceCodeToExecute, string[] strReferenceAssembliesToAdd, ref string strCompilationErrors)
        {
            string strTempFileName = Path.GetTempFileName();

            if (strSourceCodeToExecute.Length == 0)
            {
                MessageBox.Show("Code to compile cannot be empty");
                return(null);
            }
            else
            {
                utils.files.SaveFileWithStringContents(strTempFileName, strSourceCodeToExecute);
                WindowsApp      waWindowsApp      = new WindowsApp();
                CompilerResults crCompilerResults = waWindowsApp.compileAndReturnCompilerResultsObject(strTempFileName, strReferenceAssembliesToAdd);
                strCompilationErrors = waWindowsApp.StrCompilationErrors;
                return(crCompilerResults);
            }
        }
示例#9
0
        private static int run()
        {
            int error = 0;

            //Start calculator and wait for UI to be loaded
            try
            {
                System.Diagnostics.Process pr = System.Diagnostics.Process.Start("calc.exe");
                Thread.Sleep(2000);
                //Get process name
                string processName = GetActualCalculatorProcessName();

                //Find Calculator | Windows 10
                if (IsWindows10())
                {
                    WindowsApp calculator = Host.Local.FindSingle <WindowsApp>("winapp[@processname='" + processName + "']");

                    Button button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='num2Button']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='plusButton']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='num3Button']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='minusButton']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='num3Button']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@automationid='equalButton']");
                    button.Click();

                    Thread.Sleep(2000);
                    //Close calculator
                    calculator.As <Form>().Close();
                }
                //Find Calculator | Windows 8.X or older
                else
                {
                    Form calculator = Host.Local.FindSingle <Form>("form[@processname='" + processName + "']");

                    calculator.EnsureVisible();

                    Button button = calculator.FindSingle <Ranorex.Button>(".//button[@controlid='132']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@controlid='92']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@controlid='133']");
                    button.Click();

                    button = calculator.FindSingle <Ranorex.Button>(".//button[@controlid='121']");
                    button.Click();

                    //Close calculator
                    calculator.Close();
                }
            }
            catch (RanorexException e)
            {
                Console.WriteLine(e.ToString());
                error = -1;
            }

            return(error);
        }
示例#10
0
 public static string compileSourceCode(string strSourceCodeToExecute,string[] strReferenceAssembliesToAdd, string strPathToTempCompiledFile)
 {
     if ("" == strPathToTempCompiledFile)
         strPathToTempCompiledFile = Path.GetTempFileName();
     else
         strPathToTempCompiledFile = Path.Combine(strPathToTempCompiledFile, files.returnUniqueFileName(".tmp.cs"));
     if (strSourceCodeToExecute.Length==0)
         return "Error: Code to compile cannot be empty";
     else
     {
         utils.files.SaveFileWithStringContents(strPathToTempCompiledFile, strSourceCodeToExecute);
         string strCompilationResult = new WindowsApp().Compile(strPathToTempCompiledFile, strReferenceAssembliesToAdd);
         if ("" == strCompilationResult)
         {
             File.Delete(strPathToTempCompiledFile);
             return "Compilation OK";
         }
         else
             return strCompilationResult;
     }
 }
示例#11
0
 public static string compileAndExecuteFile(string strFileToExecute,string[] strReferenceAssembliesToAdd)
 {
     WindowsApp waWindowsApp = new WindowsApp();
     waWindowsApp.Run(new string[] { strFileToExecute }, strReferenceAssembliesToAdd);
     return waWindowsApp.StrCompilationErrors;
 }
示例#12
0
 public static bool VerifyAutorun(string appName, string appPath) => runningWindows?
 WindowsApp.VerifyAutorun(appName, appPath) : LinuxApp.VerifyAutorun(appName, appPath);
示例#13
0
 public static bool IsElevated() => runningWindows?WindowsApp.IsElevated() : LinuxApp.IsElevated();