Exemplo n.º 1
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 public static void Init()
 {
     Options = new EngineOptions();
     RunningProcess = Process.GetCurrentProcess();
     InitCounters();
     //			Config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     //			DebugggingConfiguration = Config.GetSection("JGL.Debugging");
 }
Exemplo n.º 2
0
		public Form1()
		{
			EngineOptions options = new EngineOptions();
			eng = new PythonEngine(options);
			eng.Import("site");
			System.IO.FileStream fs = new System.IO.FileStream("scripting-log.txt", System.IO.FileMode.Create);
			eng.SetStandardOutput(fs);
			eng.SetStandardError(fs);

			mod1 = eng.CreateModule("mr", false);

			InitializeComponent();
		}
Exemplo n.º 3
0
        public DUCoverEngine()
            : base(new Container(new TypeEx[] { Microsoft.ExtendedReflection.Metadata.Metadata<IEngineOptions>.Type }), new IComponent[] { })
        {
            EngineOptions options = new EngineOptions();
            this.AddComponent("options", options);
            this.AddComponents();

            var pmd = new PexMeDynamicDatabase();
            pmd.AssemblyName = System.Environment.GetEnvironmentVariable(DUCoverConstants.DUCoverAssemblyVar);
            this.AddComponent("pmd", pmd);

            var psd = new PexMeStaticDatabase();
            psd.AssemblyName = System.Environment.GetEnvironmentVariable(DUCoverConstants.DUCoverAssemblyVar);
            this.AddComponent("psd", psd);
        }
Exemplo n.º 4
0
 public void InitializePythonEngine()
 {
     try
     {
         Thread.CurrentThread.CurrentCulture = clsGlobal.MyCulture;
         this.PythonEngineOutput = new ListBoxStream(ref this.pythonOutput);
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Initializing Python Engine...");
         EngineOptions engineOptions = new EngineOptions();
         engineOptions.ClrDebuggingEnabled = true;
         this.engine = new PythonEngine(engineOptions);
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\PythonStdLib");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts");
         this.engine.AddToPath(ConfigurationManager.AppSettings["InstalledDirectory"] + @"\scripts\core");
         this.engine.AddToPath(Environment.CurrentDirectory);
         this.engine.AddToPath(Path.GetDirectoryName(Application.ExecutablePath));
         this.engine.Import("Site");
         this.engine.Import("System");
         this.engine.Import("System.Diagnostics");
         this.engine.Import("sys");
         this.engine.Import("nt");
         this.engine.Import("os");
         this.engine.Import("shutil");
         this.engine.Import("ConfigParser");
         this.engine.Import("time");
         this.engine.Import("array");
         this.engine.Import("pdb");
         this.engine.Execute("from System import Array");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReference('System.Messaging')");
         this.engine.Execute("from System.Messaging import MessageQueue");
         this.engine.Execute("MessageQueue.EnableConnectionCache = False");
         this.engine.Import("clr");
         this.engine.Execute("clr.AddReferenceByPartialName('CommonClassLibrary')");
         this.engine.Execute("from CommonClassLibrary import *");
         this.engine.SetStandardOutput(this.PythonEngineOutput);
         this.engine.SetStandardError(this.PythonEngineOutput);
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Running.");
         this.engine.Execute("import clr");
         this.engine.Execute("clr.AddReferenceByPartialName('SiRFLive')");
         this.engine.Execute("from SiRFLive import *");
         this.engine.Execute("print dir()");
         this.engine.Execute("nt.chdir(\"..\\scripts\")");
     }
     catch (Exception exception)
     {
         this.pythonOutput.SelectedIndex = this.pythonOutput.Items.Add("Python Engine Failed to Start Properly: " + exception.Message);
     }
 }
Exemplo n.º 5
0
        private void btnGo_Click(object sender, EventArgs e)
        {
            btnGo.Enabled = false;

            string source      = txtSource.Text;
            string destination = txtDestination.Text;

            if (String.IsNullOrEmpty(source))
            {
                MessageBox.Show("No source folder selected.", Application.ProductName);
                return;
            }
            if (String.IsNullOrEmpty(destination))
            {
                if (MessageBox.Show("No destination has been selected.  The files will be rearranged in the current directory.  Is this OK?", Application.ProductName, MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }

            string[] properties = new string[lbProperties.Items.Count];
            for (int i = 0; i < lbProperties.Items.Count; i++)
            {
                properties[i] = lbProperties.Items[i].ToString();
            }

            Settings.Default.LastSourcePath      = source;
            Settings.Default.LastDestinationPath = destination;
            Settings.Default.Save();

            EngineOptions options = new EngineOptions()
            {
                Source                = source,
                Destination           = destination,
                Properties            = properties,
                RecurseSubdirectories = chkSubdirectories.Checked,
                Copy                   = chkCopy.Checked,
                FileExtensions         = clbFileTypes.CheckedItems.Cast <String>().ToArray(),
                DateFormatString       = Settings.Default.DateFormatString,
                SkipFolder             = Settings.Default.SkipFolder,
                MissingFolderName      = Settings.Default.MissingFolderName,
                OverwriteExistingFiles = Settings.Default.OverwriteExistingFiles
            };

            backgroundWorker.RunWorkerAsync(options);
        }
Exemplo n.º 6
0
        protected ScriptEngine(LanguageProvider provider, EngineOptions engineOptions, LanguageContext languageContext)
        {
            Contract.RequiresNotNull(provider, "provider");
            Contract.RequiresNotNull(engineOptions, "engineOptions");
            Contract.RequiresNotNull(languageContext, "languageContext");

#if !SILVERLIGHT // SecurityPermission
            if (engineOptions.ClrDebuggingEnabled)
            {
                // Currently, AssemblyBuilder.DefineDynamicModule requires high trust for emitting debug information.
                new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode).Demand();
            }
#endif
            _provider        = provider;
            _options         = engineOptions;
            _languageContext = languageContext;
        }
Exemplo n.º 7
0
        public SearchClient(SearchConfig config)
        {
            //

            EngineOptions = config.SearchEngines;

            SearchEngines = GetAllEngines()
                            .Where(e => EngineOptions.HasFlag(e.Engine))
                            .ToArray();


            UploadEngine = config.UseImgur ? new ImgurClient() : new ImgOpsEngine();

            /*
             *
             */


            var imageInfo = ResolveUploadUrl(config.ImageInput);


            ImageInfo = imageInfo ?? throw new SmartImageException("Image invalid or upload failed");

            OriginalImageResult = FullSearchResult.GetOriginalImageResult(ImageInfo);


            /*
             *
             */

            config.EnsureConfig();

            //

            Results = CreateSearchResults();


            //

            SearchTasks = CreateSearchTasks();

            IsComplete = false;

            //
        }
Exemplo n.º 8
0
        public DUCoverEngine()
            : base(new Container(new TypeEx[] { Microsoft.ExtendedReflection.Metadata.Metadata <IEngineOptions> .Type }), new IComponent[] { })
        {
            EngineOptions options = new EngineOptions();

            this.AddComponent("options", options);
            this.AddComponents();

            var pmd = new PexMeDynamicDatabase();

            pmd.AssemblyName = System.Environment.GetEnvironmentVariable(DUCoverConstants.DUCoverAssemblyVar);
            this.AddComponent("pmd", pmd);

            var psd = new PexMeStaticDatabase();

            psd.AssemblyName = System.Environment.GetEnvironmentVariable(DUCoverConstants.DUCoverAssemblyVar);
            this.AddComponent("psd", psd);
        }
Exemplo n.º 9
0
        public Engine(IMemory memory, EngineOptions options)
        {
            if (memory == null)
            {
                throw new ArgumentNullException(nameof(memory));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            Options = options;
            base.Initialize(memory, 0);
            if (memory.Reader is IHasMainModuleVersion)
            {
                EnsureSupportedProcessVersion();
            }
            _lastCreated = this;
        }
Exemplo n.º 10
0
            public async Task CreateEngineAsync(TimeSpan inactiveTimeout = default(TimeSpan))
            {
                Engine = new Engine
                {
                    Id = "engine1",
                    SourceLanguageTag = "es",
                    TargetLanguageTag = "en",
                    IsShared          = false,
                    Projects          = { "project1" }
                };
                await EngineRepository.InsertAsync(Engine);

                var options = new EngineOptions {
                    InactiveEngineTimeout = inactiveTimeout
                };

                EngineRunner = new EngineRunner(new OptionsWrapper <EngineOptions>(options), EngineRepository,
                                                BuildRepository, CreateSmtModelFactory(), CreateRuleEngineFactory(), CreateTextCorpusFactory(),
                                                Substitute.For <ILogger <EngineRunner> >(), Engine.Id);
            }
Exemplo n.º 11
0
        /// <summary>
        /// Конструктор реализации буфера хранилища событий.
        /// Создаёт новый экземпляр класса <see cref="EventsBufferEngine"/>.
        /// </summary>
        public EventsBufferEngine(
            IOptions <EngineOptions> engineOptions,
            IEventsWriter eventsWriter,
            ILogger <EventsBufferEngine> logger)
        {
            if (engineOptions == null)
            {
                throw new ArgumentNullException(nameof(engineOptions), $"{nameof(engineOptions)} is null.");
            }
            if (engineOptions.Value == null)
            {
                throw new ArgumentNullException(nameof(engineOptions.Value), $"{nameof(engineOptions.Value)} is null.");
            }

            _engineOptions = engineOptions.Value;
            _eventsWriter  = eventsWriter;
            _logger        = logger;

            _flushTimer = new Timer(async obj => await FlushTimerDelegate(obj), null,
                                    _engineOptions.EventsFlushPeriodSec * 1000,
                                    _engineOptions.EventsFlushPeriodSec * 1000);
        }
Exemplo n.º 12
0
        private void ResolveDateOptions(EngineOptions options)
        {
            var option = chkDateAccessed.Checked ? FileDateOption.Accessed :
                         chkDateChanged.Checked ? FileDateOption.Changed :
                         chkDateCreated.Checked ? FileDateOption.Created : FileDateOption.None;

            if (option == FileDateOption.None || (!chkDateOlderEnabled.Checked && !chkDateBetweenEnabled.Checked))
            {
                return;
            }
            options.DateOption = option;

            if (chkDateOlderEnabled.Checked)
            {
                options.StartDateTime = GetDateOlder();
            }
            else if (chkDateBetweenEnabled.Checked)
            {
                options.StartDateTime = dateDateBetweenStart.Value.Date;
                options.EndDateTime   = dateDateBetweenEnd.Value.AddDays(1).Date.AddMilliseconds(-1);
            }
        }
Exemplo n.º 13
0
        public Engine(/* final */ EngineOptions pEngineOptions)
        {
            Engine.Instance = this;

            //TextureRegionFactory.setAssetBasePath("");
            TextureRegionFactory.SetAssetBasePath("");
            //SoundFactory.setAssetBasePath("");
            SoundFactory.SetAssetBasePath("");
            //MusicFactory.setAssetBasePath("");
            MusicFactory.SetAssetBasePath("");
            //FontFactory.setAssetBasePath("");
            FontFactory.setAssetBasePath("");

            //BufferObjectManager.setActiveInstance(this.mBufferObjectManager);
            BufferObjectManager.SetActiveInstance(this.mBufferObjectManager);

            this.mEngineOptions = pEngineOptions;
            //this.SetTouchController(new SingleTouchController());
            this.TouchController = new SingleTouchController();
            //this.mCamera = pEngineOptions.getCamera();
            this.mCamera = pEngineOptions.GetCamera();

            if (this.mEngineOptions.NeedsSound())
            {
                this.mSoundManager = new SoundManager();
            }

            if (this.mEngineOptions.NeedsMusic())
            {
                this.mMusicManager = new MusicManager();
            }

            if (this.mEngineOptions.HasLoadingScreen())
            {
                this.InitLoadingScreen();
            }

            this.mUpdateThread.Start();
        }
Exemplo n.º 14
0
        private int RunFiles(OptionsParser optionsParser)
        {
            EngineOptions engine_options = (optionsParser != null) ? optionsParser.EngineOptions : null;

            IScriptEngine engine = _options.LanguageProvider.GetEngine(engine_options);

            engine.SetSourceUnitSearchPaths(_options.SourceUnitSearchPaths);

            int result = 0;

            foreach (string filePath in _options.Files)
            {
                SourceUnit sourceUnit = ScriptDomainManager.CurrentManager.Host.TryGetSourceFileUnit(engine, filePath, Encoding.Default);
                if (sourceUnit == null)
                {
                    throw new FileNotFoundException(string.Format("Source file '{0}' not found.", filePath));
                }
                result = RunFile(engine, sourceUnit);
            }

            return(result);
        }
Exemplo n.º 15
0
 public EngineService(IOptions <EngineOptions> options, ISmtModelFactory smtModelFactory, ITranslationEngineFactory ruleEngineFactory)
 {
     _options           = options.Value;
     _smtModelFactory   = smtModelFactory;
     _ruleEngineFactory = ruleEngineFactory;
     _languagePairs     = new ConcurrentDictionary <Tuple <string, string>, LanguagePair>();
     foreach (string configDir in Directory.EnumerateDirectories(_options.RootDir))
     {
         string configFileName = Path.Combine(configDir, "config.json");
         if (!File.Exists(configFileName))
         {
             continue;
         }
         LanguagePairDto languagePairConfig = JsonConvert.DeserializeObject <LanguagePairDto>(File.ReadAllText(configFileName));
         var             languagePair       = new LanguagePair(languagePairConfig.SourceLanguageTag, languagePairConfig.TargetLanguageTag, configDir);
         foreach (ProjectDto projectConfig in languagePairConfig.Projects)
         {
             CreateProject(languagePair, projectConfig.Id, projectConfig.IsShared);
         }
         _languagePairs[Tuple.Create(languagePair.SourceLanguageTag, languagePair.TargetLanguageTag)] = languagePair;
     }
     _commitTimer = new Timer(EngineCommitCallback, null, _options.EngineCommitFrequency, _options.EngineCommitFrequency);
 }
Exemplo n.º 16
0
        private void ApplyEngineOptions(EngineOptions pEngineOptions)
        {
            if (pEngineOptions.IsFullscreen())
            {
                this.RequestFullscreen();
            }

            if (pEngineOptions.NeedsMusic() || pEngineOptions.NeedsSound())
            {
                /*this.SetVolumeControlStream(AudioManager.STREAM_MUSIC);*/
                this.VolumeControlStream = (int)Stream.Music;
            }

            switch (pEngineOptions.GetScreenOrientation())
            {
            case EngineOptions.ScreenOrientationOptions.LANDSCAPE:
                this.SetRequestedOrientation(ScreenOrientation.Landscape);
                break;

            case EngineOptions.ScreenOrientationOptions.PORTRAIT:
                this.SetRequestedOrientation(ScreenOrientation.Portrait);
                break;
            }
        }
        public static bool TurnOn(EngineOptions options)
        {
            StartTimer = Stopwatch.StartNew();

            DebugHelper.WriteLine("");
            DebugHelper.WriteLine(string.Format("{0} r{1} started", GetProductName(), Adapter.AppRevision));
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            DialogResult startEngine = DialogResult.OK;

            if (IsPortable)
            {
                ConfigApp.PreferSystemFolders = false;
                RootAppFolder = PortableRootFolder;
            }
            else
            {
                if (options.ShowConfigWizard && !File.Exists(AppSettings.AppSettingsFile))
                {
                    if (ConfigWorkflow == null)
                    {
                        ConfigWorkflow = Workflow.Read(Engine.WorkflowConfigPath);
                    }
                    ConfigWizard cw = new ConfigWizard(DocsAppFolder);
                    startEngine = cw.ShowDialog();
                    if (startEngine == DialogResult.OK)
                    {
                        if (!cw.PreferSystemFolders)
                        {
                            Engine.ConfigApp.RootDir = cw.RootFolder;
                        }
                        Engine.ConfigApp.PreferSystemFolders = cw.PreferSystemFolders;
                        Engine.ConfigApp.AppOutputs          = cw.cwOutputs.Cast <int>().ToList();
                        Engine.ConfigApp.ClipboardContent    = cw.cwClipboardContent.Cast <int>().ToList();
                        Engine.ConfigApp.ImageUploaders      = cw.cwImageUploaders;
                        Engine.ConfigApp.FileUploaders       = cw.cwFileUploaders;
                        Engine.ConfigApp.TextUploaders       = cw.cwTextUploaders;
                        Engine.ConfigApp.LinkUploaders       = cw.cwLinkUploaders;

                        ConfigWorkflow.Write(WorkflowConfigPath); // DestSelector in ConfigWizard automatically initializes MyUploadersConfig if null so no errors

                        RunConfig = true;
                    }
                }
            }

            ConfigApp.Write();

            if (!ConfigApp.PreferSystemFolders && Directory.Exists(Engine.ConfigApp.RootDir))
            {
                RootAppFolder = Engine.ConfigApp.RootDir;
            }
            else if (!IsPortable) // issue 613
            {
                RootAppFolder = DocsAppFolder;
            }

            if (startEngine == DialogResult.OK)
            {
                DebugHelper.WriteLine("Core file: " + AppSettings.AppSettingsFile);
                if (!ConfigApp.PreferSystemFolders)
                {
                    DebugHelper.WriteLine(string.Format("Root Folder: {0}", RootAppFolder));
                }
                DebugHelper.WriteLine("Initializing Default folder paths...");
                Engine.InitializeDefaultFolderPaths(); // happens before XMLSettings is readed

                bool bGrantedOwnership;
                try
                {
                    Guid     assemblyGuid    = Guid.Empty;
                    object[] assemblyObjects = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), true);
                    if (assemblyObjects.Length > 0)
                    {
                        assemblyGuid = new Guid(((System.Runtime.InteropServices.GuidAttribute)assemblyObjects[0]).Value);
                    }
                    Engine.mAppMutex = new Mutex(true, assemblyGuid.ToString(), out bGrantedOwnership);
                }
                catch (UnauthorizedAccessException)
                {
                    bGrantedOwnership = false;
                }

                if (!bGrantedOwnership)
                {
                    IsMultiInstance = true;
                }
            }

            return(startEngine == DialogResult.OK);
        }
Exemplo n.º 18
0
        private static void Execute()
        {
            EngineOptions engineOptions = new EngineOptions();

            engineOptions.VersionMatching = VersionMatching.MajorMinorBuild;


            //if (Program.SingleThreaded)
            //    while (Engine.Create(engineOptions) == null) { System.Threading.Thread.Sleep(50); }

            while (Engine.Current == null)
            {
                System.Threading.Thread.Sleep(1);
            }


            while (true)
            {
                try
                {
                    Thread.Sleep(16); //reduce cpu usage

                    var tick = Engine.Current.ApplicationLoopCount;
                    if (tick != _tick)
                    {
                        _tick = tick;

                        //--
                        Stopwatch s_handler = new Stopwatch();
                        s_handler.Start();
                        //

                        ////--SingleThreaded
                        //if (Program.SingleThreaded)
                        //{
                        //    A_Collector.IC_Player.Collect();
                        //    A_Collector.IC_Skills.Collect();
                        //    A_Collector.IC_Actors.Collect();
                        //    A_Collector.IC_Area.Collect();
                        //    A_Collector.IC_Preferences.Collect();
                        //    A_Collector.IC_D3UI.Collect();
                        //    A_Collector.IC_Party.Collect();
                        //}
                        ////

                        A_Collector.H_D3Client.Collect();

                        if (A_Collection.Environment.Scene.GameTick > 1 && A_Collection.Environment.Scene.Counter_CurrentFrame != 0 && A_Collection.Me.HeroStates.isInGame)
                        {
                            //A_Handler.HealthPotion.HealthPotion.handlePotion();
                            A_Handler.SkillHandler.SkillHandler.handleSkills();
                            A_Tools.InputSimulator.IS_Keyboard.ChannelKey_Maintain();
                            A_Handler.EventHandler.EventHandler.handleEvents();
                            A_Collector.H_Keyboard.Collect();
                        }

                        A_Handler.StatHandler.StatHandler.handleStats();
                        A_Collector.H_ExternalFiles.Collect();


                        if (A_Handler.Log.Exception.ExceptionLog.Count > 0)
                        {
                            A_Handler.Log.Exception.log_Exceptions();
                        }

                        if (A_Handler.Log.Exception.HandlerLog.Count > 0 && Properties.Settings.Default.Logger_extendedLog)
                        {
                            A_Handler.Log.Exception.log_Handler();
                        }

                        //--
                        s_handler.Stop();
                        TimeSpan t_handler = s_handler.Elapsed;

                        lock (ProcessingTimes)
                        {
                            ProcessingTimes.Add(t_handler.TotalMilliseconds);
                        }
                        if (ProcessingTimes.Count > 180)
                        {
                            lock (ProcessingTimes)
                            {
                                ProcessingTimes.RemoveAt(0);
                            }
                        }

                        double TimeLeftToNextTick = ((1000 / Properties.Settings.Default.D3Helper_UpdateRate) - t_handler.TotalMilliseconds);
                        if (TimeLeftToNextTick > 0)
                        {
                            System.Threading.Thread.Sleep((int)TimeLeftToNextTick);
                        }
                    }
                }
                catch (Exception e)
                {
                    A_Handler.Log.Exception.addExceptionLogEntry(e, A_Enums.ExceptionThread.Handler);

                    System.Environment.Exit(1);
                }
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// This function gets a specified option parameter and returns its value.
 /// </summary>
 /// <param name="param">option parameter</param>
 /// <returns>current value of the specified option parameter</returns>
 public static float getOption(EngineOptions param)
 {
     return NativeMethodsEngine.getOption(param);
 }
Exemplo n.º 20
0
 /// <summary>
 /// This function sets a specified option parameter to a specified value.
 /// </summary>
 /// <param name="param">option parameter</param>
 /// <param name="value">value of the option parameter</param>
 /// <returns>true if the option could be set to the specified value, otherwise false</returns>
 public static bool setOption(EngineOptions param, float value)
 {
     return NativeMethodsEngine.setOption( (int) param, value);
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            if (args.Contains("-h") || args.Contains("--help"))
            {
                ShowHelp();
                return;
            }

            if (args.Length > 1)
            {
                string[]      properties = new string[] { };
                EngineOptions options    = new EngineOptions();
                options.Source      = args[0];
                options.Destination = args[1];

                string logFilePath = String.Empty;

                for (int i = 2; i < args.Length; i++)
                {
                    if (args[i] == "-p" || args[i] == "--props")
                    {
                        i++;
                        if (i < args.Length)
                        {
                            properties = args[i].Split(',');
                        }
                    }
                    else if (args[i] == "-r" || args[i] == "--recurse")
                    {
                        options.RecurseSubdirectories = true;
                    }
                    else if (args[i] == "-m" || args[i] == "--move")
                    {
                        options.Copy = false;
                    }
                    if (args[i] == "-e" || args[i] == "--exts")
                    {
                        i++;
                        if (i < args.Length)
                        {
                            options.FileExtensions = args[i].Split(',');
                        }
                    }
                    if (args[i] == "-u" || args[i] == "--unsorted")
                    {
                        i++;
                        if (i < args.Length)
                        {
                            options.MissingFolderName = args[i];
                        }
                    }
                    if (args[i] == "-d" || args[i] == "--date")
                    {
                        i++;
                        if (i < args.Length)
                        {
                            options.DateFormatString = args[i];
                        }
                    }
                    if (args[i] == "-l" || args[i] == "--log")
                    {
                        i++;
                        if (i < args.Length)
                        {
                            logFilePath = args[i];
                        }
                    }
                }

                options.Properties = properties;
                Engine engine = new Engine(options);
                engine.OnProgressUpdate += Engine_ProgressUpdate;

                try
                {
                    engine.Process();

                    if (!String.IsNullOrEmpty(logFilePath))
                    {
                        Log.Save(logFilePath);
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    System.Console.WriteLine("An error occurred trying to access files.  " + ex.Message);
                }
                catch (Exception ex)
                {
                    System.Console.WriteLine("An unknown error occurred.  " + ex.Message);
                }

                System.Console.WriteLine("Process completed!");
            }
        }
Exemplo n.º 22
0
 public Engine(Process process, EngineOptions options)
     : this(new ReadOnlyMemory(new ProcessMemoryReader(process)), options)
 {
 }
Exemplo n.º 23
0
 public OpenOcrOptions()
 {
     Language      = EngineLanguage.eng;
     EngineOptions = new EngineOptions();
     Preprocessors = null;
 }
Exemplo n.º 24
0
 IScriptEngine ILanguageProvider.GetEngine(EngineOptions options)
 {
     return(this.GetEngine(options));
 }
Exemplo n.º 25
0
        public EngineOptions GetEngineOptions()
        {
            EngineOptions eo = new EngineOptions();

            eo.Assemblies     = Assemblies;
            eo.OutputFilename = BinaryFilename;
            eo.CPU            = CPU;
            eo.ConsoleDump    = ConsoleDump;

            if (DumpFile == "-")
            {
                eo.DumpFile    = null;
                eo.ConsoleDump = true;
            }
            else
            {
                eo.DumpFile = DumpFile;
            }

            eo.NoMetadata     = NoMetadata;
            eo.AsmFile        = AsmFile;
            eo.TextDump       = TextDump;
            eo.DumpVerbosity  = DumpVerbosity;
            eo.Verbosity      = Verbosity;
            eo.ForceRecompile = ForceRecompile;

            if (Verbosity == 0 && Verbose)
            {
                eo.Verbosity = 1;
            }

            eo.DumpFilter = DumpFilter;

            foreach (string res in Resources)
            {
                byte [] contents;
                byte [] buffer = new byte [1024];
                int     read = 0;
                int     x = 0;
                Stream  fs = null;
                string  key, value;

                if (!res.Contains(":"))
                {
                    throw new Exception("Invalid resource: '" +
                                        res + "': format is 'name:file'");
                }

                key      = res.Substring(0, res.IndexOf(':'));
                value    = res.Substring(key.Length);
                fs       = File.Open(value, FileMode.Open, FileAccess.Read);
                contents = new byte [fs.Length];

                while ((read = fs.Read(buffer, 0, buffer.Length)) != 0)
                {
                    Array.Copy(buffer, 0, contents, x, read);
                    x += read;
                }

                fs.Close();

                eo.Resources.Add(key, contents);
            }

            return(eo);
        }
Exemplo n.º 26
0
 public IronSchemeScriptEngine(LanguageProvider lp, EngineOptions eo, LanguageContext lc)
     : base(lp, eo, lc)
 {
     ((IronSchemeLanguageContext)LanguageContext).se = this;
 }
Exemplo n.º 27
0
 public EngineOptionsMessage(EngineOptions options = null, Action <IDictionary <string, string> > callback = null) : base()
 {
     EngineOptionsVM = new EngineOptionsViewModel(options, callback);
 }
Exemplo n.º 28
0
        private static unsafe void Main(string[] args)
        {
            var options = new EngineOptions(
                "simple 3d game",
                720, 1280,
                true,
                UiResourcesHelper.PressStart2PFontPath,
                UiResourcesHelper.CrossSpritePath,
                UiResourcesHelper.ScrollSpritePath);

            using var engine = EngineBuilder.BuildEngine25D(options);
            var resourceLoader = ResourceCachedLoader.Instance;
            var player         = new MyPlayer(new Vector2(2.0f, 2.0f), new Vector2(0.3f, 0.3f), MathF.PI / 2, 10);
            var wallTexture    = Sprite.Load("./sprites/greystone.png");
            var floorTexture   = Sprite.Load("./sprites/colorstone.png");
            var windowTexture  = Sprite.Load("./sprites/window.png");
            var ceilingTexture = Sprite.Load("./sprites/wood.png");
            var bedTexture     = Sprite.Load("./sprites/bed.png");
            var sword          = Sword.Create(resourceLoader);
            var bow            = Bow.Create(resourceLoader);
            var doorAnimation  = resourceLoader.GetAnimation("./animations/door");

            player.Weapons = new Weapon[] { sword, bow };
            var backGroundMusic = resourceLoader.GetMusic(MusicResourceHelper.EnvironmentDungeonMusic);
            var objects         = new IMapObject[]
            {
                Lich.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                Skeleton.Create(resourceLoader, new Vector2(6f, 6f), 0.0f),
                GreenLight.Create(resourceLoader, new Vector2(8.0f, 8.0f), new Vector2(0, 0), 0),
                HealingPotion.Create(new Vector2(6f, 6f)),
                ArrowPack.Create(new Vector2(7f, 7f)),
                Note.Create(new Vector2(5f, 5f), "о, привет!\nследующая строка\nотвратительно длинная строка с кучей слов капец\nа вот это уже максимум по длине лучше бы его не переступать ага га гус")
            };

            backGroundMusic.Play(-1);
            var storage = new MapTextureStorage(ceilingTexture, wallTexture, floorTexture, windowTexture, bedTexture, doorAnimation);
            var map     = Map.FromStrings(new[]
            {
                "###############################",
                "#.............................#",
                "#.............................#",
                "#.............................#",
                "##...................#........#",
                "#b...................###......#",
                "#b...................#........#",
                "####......##########.#........#",
                "##...................#......###",
                "#........####........#........#",
                "#........#..#........#........#",
                "#........#..#........###......#",
                "#####.####..####.....#........#",
                "#####.####..####.....#........#",
                "#....................#......###",
                "#....................#........#",
                "#####.####..####.....###......#",
                "#####.####..####.....#........#",
                "#....................#........#",
                "###############################"
            }, storage.GetCellByChar);
            var level = new Scene(player, map, objects);

            while (engine.Update(level))
            {
            }
        }
Exemplo n.º 29
0
 public IScriptEngine GetEngine(EngineOptions options)
 {
     return(new RemoteScriptEngine(_provider.GetEngine(options)));
 }
Exemplo n.º 30
0
        public static bool TurnOn(EngineOptions options)
        {
            StartTimer = Stopwatch.StartNew();

            DebugHelper.WriteLine("");
            DebugHelper.WriteLine(string.Format("{0} r{1} started", GetProductName(), Adapter.AppRevision));
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            DialogResult startEngine = DialogResult.OK;

            if (IsPortable)
            {
                ConfigApp.PreferSystemFolders = false;
                RootAppFolder = PortableRootFolder;
            }
            else
            {
                if (options.ShowConfigWizard && !File.Exists(AppSettings.AppSettingsFile))
                {
                    if (ConfigWorkflow == null)
                    {
                        ConfigWorkflow = Workflow.Read(Engine.WorkflowConfigPath);
                    }
                    ConfigWizard cw = new ConfigWizard(DocsAppFolder);
                    startEngine = cw.ShowDialog();
                    if (startEngine == DialogResult.OK)
                    {
                        if (!cw.PreferSystemFolders)
                        {
                            Engine.ConfigApp.RootDir = cw.RootFolder;
                        }
                        Engine.ConfigApp.PreferSystemFolders = cw.PreferSystemFolders;
                        Engine.ConfigApp.AppOutputs = cw.cwOutputs.Cast<int>().ToList();
                        Engine.ConfigApp.ClipboardContent = cw.cwClipboardContent.Cast<int>().ToList();
                        Engine.ConfigApp.ImageUploaders = cw.cwImageUploaders;
                        Engine.ConfigApp.FileUploaders = cw.cwFileUploaders;
                        Engine.ConfigApp.TextUploaders = cw.cwTextUploaders;
                        Engine.ConfigApp.LinkUploaders = cw.cwLinkUploaders;

                        ConfigWorkflow.Write(WorkflowConfigPath); // DestSelector in ConfigWizard automatically initializes MyUploadersConfig if null so no errors

                        RunConfig = true;
                    }
                }
            }

            ConfigApp.Write();

            if (!ConfigApp.PreferSystemFolders && Directory.Exists(Engine.ConfigApp.RootDir))
            {
                RootAppFolder = Engine.ConfigApp.RootDir;
            }
            else if (!IsPortable) // issue 613
            {
                RootAppFolder = DocsAppFolder;
            }

            if (startEngine == DialogResult.OK)
            {
                DebugHelper.WriteLine("Core file: " + AppSettings.AppSettingsFile);
                if (!ConfigApp.PreferSystemFolders)
                {
                    DebugHelper.WriteLine(string.Format("Root Folder: {0}", RootAppFolder));
                }
                DebugHelper.WriteLine("Initializing Default folder paths...");
                Engine.InitializeDefaultFolderPaths(); // happens before XMLSettings is readed

                bool bGrantedOwnership;
                try
                {
                    Guid assemblyGuid = Guid.Empty;
                    object[] assemblyObjects = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), true);
                    if (assemblyObjects.Length > 0)
                    {
                        assemblyGuid = new Guid(((System.Runtime.InteropServices.GuidAttribute)assemblyObjects[0]).Value);
                    }
                    Engine.mAppMutex = new Mutex(true, assemblyGuid.ToString(), out bGrantedOwnership);
                }
                catch (UnauthorizedAccessException)
                {
                    bGrantedOwnership = false;
                }

                if (!bGrantedOwnership)
                {
                    IsMultiInstance = true;
                }
            }

            return startEngine == DialogResult.OK;
        }
Exemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        GameOver      += (sender, e) => Debug.Log("Game over!");
        materialColors = new Material[trainCarColors.Length];
        if (camera == null)
        {
            throw new InvalidOperationException("camera is null!");
        }
        camera.orthographic = true;
        EngineOptions options = new EngineOptions();

#if !DEBUG
        if (seed == 0)
        {
            byte[] foo = BitConverter.GetBytes(UnityEngine.Random.value);
            byte[] bar = new byte[foo.Length * 2];
            foo.CopyTo(bar, 0);
            foo = BitConverter.GetBytes(UnityEngine.Random.value);
            foo.CopyTo(bar, foo.Length);
            seed = BitConverter.ToUInt64(bar, 0);
        }
#endif
        options.seed                       = seed;
        options.gridWidth                  = width;
        options.gridHeight                 = length;
        options.trainCanCrashWithSelf      = trainCanCrashWithSelf;
        options.blockSections              = blockSections;
        options.canSwapOutTrackUnderTrain  = canSwapOutTrackUnderTrain;
        options.couplingLength             = couplingLength;
        options.trainCarLength             = trainCarLength;
        options.speedCount                 = speedCount;
        calculatedObjectLength             = _tileSize * trainCarLength / blockSections;
        SequenceTrainEngine.DebugLogEvent += (sender, e) => Debug.Log(e.thing);
        engine = new SequenceTrainEngine(options);
        addHandlers();
        grid = new GameObject[width, length];
        float cameraWidth  = _tileSize * width;
        float cameraHeight = _tileSize * length;
        float newCameraSize;        // = mainCamera.orthographicSize;
        if (camera.aspect > 1)
        {
            newCameraSize = cameraHeight / 2;
        }
        else
        {
            newCameraSize = ((1 / camera.aspect) * cameraWidth) / 2;
        }
        camera.orthographicSize = newCameraSize;
        //fill the grid
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < length; y++)
            {
                GameObject item = generateTrackPiece(x, y);
                grid[x, y] = item;
            }
        }
        GameObject trainObject = TrainCarHandler.createGameObject(engine.trainList[0],
                                                                  this);
        trainEngineHandler = trainObject.GetComponent <TrainCarHandler>();
        trainEngineHandler.positionSelf();
        trainCars.Add(trainEngineHandler);
        //place the camera
        Vector3 cameraPos = new Vector3(cameraWidth / 2, 10, -cameraHeight / 2 + 5);
        camera.transform.position = cameraPos;
    }
Exemplo n.º 32
0
 public virtual ScriptEngine GetEngine(EngineOptions options)
 {
     throw new NotSupportedException(String.Format(Resources.MissingService_OptionsParser, LanguageDisplayName));
 }
Exemplo n.º 33
0
 public SystemState(EngineOptions options)
 {
     #if DEBUG
     // All fields should be initialized in Initialize(). So ensure that the fields have default values
     FieldInfo[] fields = typeof(SystemState).GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
     foreach (FieldInfo field in fields) {
         object value = field.GetValue(this);
         // If this throws an InvalidCastException, it must mean that a new field was added of a type
         // that is not handled here. The assert will need to be relaxed to handle the new type.
         Debug.Assert(value == null ||
             (value is int && ((int)value) == 0) ||
             (value is bool && ((bool)value) == false));
     }
     #endif
     engineOptions = options;
     Initialize();
 }
        private static void Execute()
        {
            EngineOptions engineOptions = new EngineOptions();

            engineOptions.VersionMatching = VersionMatching.MajorMinorBuild;

            while (Engine.Create(engineOptions) == null)
            {
                System.Threading.Thread.Sleep(50);
            }


            while (Engine.Current == null)
            {
                System.Threading.Thread.Sleep(1);
            }


            while (true)
            {
                try
                {
                    Thread.Sleep(16); //reduce cpu usage

                    var tick = Engine.Current.ApplicationLoopCount;
                    if (tick != _tick)
                    {
                        _tick = tick;


                        //--
                        Stopwatch s_collector = new Stopwatch();
                        s_collector.Start();
                        //
                        A_Collector.IC_Player.Collect();
                        A_Collector.IC_Skills.Collect();
                        A_Collector.IC_Actors.Collect();
                        A_Collector.IC_Area.Collect();
                        A_Collector.IC_Preferences.Collect();
                        A_Collector.IC_D3UI.Collect();
                        A_Collector.IC_Party.Collect();

                        //--
                        s_collector.Stop();
                        TimeSpan t_collector = s_collector.Elapsed;

                        lock (ProcessingTimes)
                        {
                            ProcessingTimes.Add(t_collector.TotalMilliseconds);
                        }
                        if (ProcessingTimes.Count > 180)
                        {
                            lock (ProcessingTimes)
                            {
                                ProcessingTimes.RemoveAt(0);
                            }
                        }

                        double TimeLeftToNextTick = ((1000 / Properties.Settings.Default.D3Helper_UpdateRate) - t_collector.TotalMilliseconds);
                        if (TimeLeftToNextTick > 0)
                        {
                            System.Threading.Thread.Sleep((int)TimeLeftToNextTick);
                        }
                    }
                }
                catch (Exception e)
                {
                    A_Handler.Log.Exception.addExceptionLogEntry(e, A_Enums.ExceptionThread.ICollector);

                    System.Environment.Exit(1);
                }
            }
        }
Exemplo n.º 35
0
        public static Engine Create(EngineOptions options, IController controller, IEventsCycle eventsCycle,
                                    ISceneRenderer sceneRenderer)
        {
            if (SDL_Init(SDL_INIT_VIDEO) < 0)
            {
                throw new InvalidOperationException($"Cant initialize SDL2: {SDL_GetError()}");
            }

            if (SDL_image.IMG_Init(SDL_image.IMG_InitFlags.IMG_INIT_JPG | SDL_image.IMG_InitFlags.IMG_INIT_PNG) < 0)
            {
                throw new InvalidOperationException($"Cant initialize SDL_image: {SDL_GetError()}");
            }

            if (SDL_ttf.TTF_Init() < 0)
            {
                throw new InvalidOperationException($"TTF_Init: {SDL_GetError()}");
            }

            if (SDL_ShowCursor(0) < 0)
            {
                throw new InvalidOperationException($"Cant disable cursor: {SDL_GetError()}");
            }

            if (SDL_mixer.Mix_Init(
                    SDL_mixer.MIX_InitFlags.MIX_INIT_MP3
                    | SDL_mixer.MIX_InitFlags.MIX_INIT_MID
                    | SDL_mixer.MIX_InitFlags.MIX_INIT_MOD
                    | SDL_mixer.MIX_InitFlags.MIX_INIT_OGG
                    | SDL_mixer.MIX_InitFlags.MIX_INIT_FLAC
                    | SDL_mixer.MIX_InitFlags.MIX_INIT_OPUS) < 0)
            {
                throw new InvalidOperationException($"MixInit: {SDL_GetError()}");
            }

            if (SDL_mixer.Mix_OpenAudio(22050, SDL_mixer.MIX_DEFAULT_FORMAT, 2, 4096) < 0)
            {
                throw new InvalidOperationException($"OpenAudio: {SDL_GetError()}");
            }

            if (SDL_mixer.Mix_AllocateChannels(16) < 0)
            {
                throw new InvalidOperationException($"Cant allocate channels: {SDL_GetError()}");
            }

            if (SDL_mixer.Mix_Volume(-1, 64) < 0)
            {
                throw new InvalidOperationException($"Min_Volume: {SDL_GetError()}");
            }


            var screen = Ui.Screen.Create(options.WindowTitle, options.ScreenHeight, options.ScreenWidth,
                                          options.FullScreen);
            var miniMapRenderer       = new MiniMapRenderer();
            var statusBarHeight       = screen.Height / 8;
            var statusBarWidth        = screen.Width;
            var statusBarSprite       = Sprite.Load(UiResourcesHelper.StatusBarSpritePath);
            var bowSprite             = Sprite.Load(UiResourcesHelper.BowMiniSpritePath);
            var frameSprite           = Sprite.Load(UiResourcesHelper.FrameSpritePath);
            var crossSprite           = options.CrossSpritePath == null ? null : Sprite.Load(options.CrossSpritePath);
            var arrowSprite           = Sprite.Load(UiResourcesHelper.ArrowSpritePath);
            var swordSprite           = Sprite.Load(UiResourcesHelper.SwordSpritePath);
            var fireBallSprite        = Sprite.Load(UiResourcesHelper.FireBallSpritePath);
            var shockBallSprite       = Sprite.Load(UiResourcesHelper.ShockBallSpritePath);
            var faceSprite            = Sprite.Load(UiResourcesHelper.FaceSprintPath);
            var faceHurtedSprite      = Sprite.Load(UiResourcesHelper.FaceHurtedSpritePath);
            var faceBadSprite         = Sprite.Load(UiResourcesHelper.FaceBadSpritePath);
            var logTextRenderer       = TextRenderer.Load(options.FontPath, screen.Height / 50);
            var notesTextRenderer     = TextRenderer.Load(options.FontPath, screen.Height / 50);
            var statusTextRenderer    = TextRenderer.Load(options.FontPath, screen.Height / 20);
            var notesRenderer         = new NotesRenderer(Sprite.Load(options.NotesSpritePath), notesTextRenderer, statusBarHeight);
            var monologueTextRenderer = TextRenderer.Load(options.FontPath, screen.Height / 50);
            var monologueRenderer     = new MonologueRenderer(monologueTextRenderer, statusBarHeight);
            var statusBarRenderer     = new StatusRenderer(
                statusBarSprite,
                crossSprite,
                statusBarHeight,
                logTextRenderer,
                notesRenderer,
                monologueRenderer,
                bowSprite,
                swordSprite,
                frameSprite,
                statusTextRenderer,
                arrowSprite,
                fireBallSprite,
                shockBallSprite,
                faceSprite,
                faceHurtedSprite,
                faceBadSprite);
            var textRenderer = options.FontPath == null ? null : TextRenderer.Load(options.FontPath, 24);

            return(new Engine(screen, controller, eventsCycle, sceneRenderer, miniMapRenderer, statusBarRenderer,
                              textRenderer));
        }