コード例 #1
0
ファイル: DatabaseService.cs プロジェクト: Joe4422/QSelect
        public static async Task InitialiseAsync(string packagesPath, string sourcePortsPath)
        {
            if (packagesPath is null)
            {
                throw new ArgumentNullException(nameof(packagesPath));
            }
            if (sourcePortsPath is null)
            {
                throw new ArgumentNullException(nameof(sourcePortsPath));
            }

            if (Packages != null || SourcePorts != null)
            {
                throw new Exception("Attempted to re-initialise DatabaseService.");
            }

            Packages = new PackageDatabaseManager(new()
            {
                new InstalledPackageRepository(packagesPath),
                new BuiltInPackageRepository(),
                new QuaddictedPackageRepository()
            });
            await Packages.RefreshDatabaseAsync();

            SourcePorts = new SourcePortDatabaseManager(new()
            {
                new InstalledSourcePortRepository(sourcePortsPath),
                new BuiltInSourcePortRepository()
            });
            await SourcePorts.RefreshDatabaseAsync();

            Initialised?.Invoke();
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of GA with a random initial population sample
        /// </summary>
        /// <param name="adapter">GA Adapter to be used by the algorithm</param>
        public GeneticAlgorithm(IGeneticAlgorithmAdapter <TIndividual, TGene> adapter)
        {
            initialPopulation       = new Population <TIndividual, TGene>(SettingsAccessor.PopulationSize, SettingsAccessor.PopulationSize);
            currentGeneration       = new Population <TIndividual, TGene>(initialPopulation);
            nextGeneration          = new Population <TIndividual, TGene>(desiredSize: SettingsAccessor.PopulationSize);
            this.adapter            = adapter;
            CurrentGenerationNumber = 1;

            Initialised?.Invoke(new GaEventArgs <TIndividual, TGene>(initialPopulation, CurrentGenerationNumber));
        }
コード例 #3
0
        private void Initialise(string userName, string name, DateTime commitedAtUtc)
        {
            // describe it as an event, rather than modifying the underlying model
            var @event = new Initialised(Guid.NewGuid(), commitedAtUtc, Id, userName, name);

            // mark this event as uncommitted, so that they can be picked up and persisted
            _uncommittedEvents.Add(@event);

            // apply this event to aggregate, which then updates the underlying model
            Handle(@event);
        }
コード例 #4
0
ファイル: MarvinSystem.cs プロジェクト: tebben/marvin-netcore
        /// <summary>
        /// Start Marvin.Core, Start will load available modules and triggers
        /// MarvinInitialised when ready
        /// </summary>
        public void Start()
        {
            Console.Out.WriteLine("Marvin system starting");

            Modules = ModuleProvider.LoadModules();
            WireActions(Modules);
            Endpoints = CreateEndpoints();

            Console.Out.WriteLine("Marvin system ready for lift off");
            Initialised?.Invoke(this);
        }
コード例 #5
0
        public static void Initialise()
        {
            if (Game != null)
            {
                throw new Exception("Attempted to re-initialise GameService.");
            }

            Game = new GameLauncher(SettingsService.Settings, DatabaseService.Packages, DatabaseService.SourcePorts);

            Initialised?.Invoke();
        }
コード例 #6
0
ファイル: Sheet.cs プロジェクト: lie112/ApsimX
        /// <summary>Initialise the widget.</summary>
        /// <param name="cr">The drawing context.</param>
        public void Initialise(IDrawContext cr)
        {
            if (cr != null)
            {
                CalculateColumnWidths(cr);
            }

            // The first time through here calculate maximum number of hidden rows.
            if (MaximumNumberHiddenRows == 0)
            {
                MaximumNumberHiddenRows = DataProvider.RowCount - FullyVisibleRowIndexes.LastOrDefault();
            }

            Initialised?.Invoke(this, new EventArgs());
        }
コード例 #7
0
        /// <summary>
        /// Creates an instance of GA whose initial population contains certain individuals
        /// (+ additional random individuals if desired population size is larger than number of defined ones)
        /// </summary>
        /// <param name="adapter">GA Adapter to be used by the algorithm</param>
        /// <param name="include">Set of individuals to be included in the initial population</param>
        public GeneticAlgorithm(IGeneticAlgorithmAdapter <TIndividual, TGene> adapter, ICollection <TIndividual> include)
        {
            int possibleToInclude         = Math.Min(include.Count, SettingsAccessor.PopulationSize);
            int randomIndividualsRequired = SettingsAccessor.PopulationSize - possibleToInclude;

            initialPopulation = new Population <TIndividual, TGene>(randomIndividualsRequired, SettingsAccessor.PopulationSize);
            initialPopulation.AddRange(include.Take(possibleToInclude).ToArray());

            currentGeneration       = new Population <TIndividual, TGene>(initialPopulation);
            nextGeneration          = new Population <TIndividual, TGene>(desiredSize: SettingsAccessor.PopulationSize);
            this.adapter            = adapter;
            CurrentGenerationNumber = 1;

            Initialised?.Invoke(new GaEventArgs <TIndividual, TGene>(initialPopulation, CurrentGenerationNumber));
        }
コード例 #8
0
ファイル: ForgeEngine.cs プロジェクト: sami016/Forge
        public void Initialise(GraphicsDeviceManager graphics, ContentManager content, GameWindow gameWindow)
        {
            _graphics = graphics;
            if (_graphics != null)
            {
                _spriteBatch = new SpriteBatch(_graphics.GraphicsDevice);
                ServiceContainer.AddService <GraphicsDeviceManager>(graphics);
                ServiceContainer.AddService <GraphicsDevice>(graphics.GraphicsDevice);
            }
            if (content != null)
            {
                ServiceContainer.AddService <ContentManager>(content);
            }
            if (gameWindow != null)
            {
                ServiceContainer.AddService <GameWindow>(gameWindow);
            }

            Initialised?.Invoke();
        }
コード例 #9
0
ファイル: SheetWidget.cs プロジェクト: ilhuber/ApsimX
        /// <summary>Initialise the widget.</summary>
        /// <param name="cr">The drawing context.</param>
        private void Initialise(Context cr)
        {
#if NETFRAMEWORK
            Width  = Parent.Allocation.Width;
            Height = Parent.Allocation.Height;
#else
            Width  = this.AllocatedWidth;
            Height = this.AllocatedHeight;
#endif
            if (cr != null)
            {
                CalculateColumnWidths(cr);
            }

            // The first time through here calculate maximum number of hidden rows.
            if (MaximumNumberHiddenRows == 0)
            {
                MaximumNumberHiddenRows = DataProvider.RowCount - FullyVisibleRowIndexes.Last();
            }

            Initialised?.Invoke(this, new EventArgs());
            GrabFocus();
        }
コード例 #10
0
ファイル: Workspace.cs プロジェクト: smwhit/Naru
        void ISupportActivationState.Activate()
        {
            Log.Debug(string.Format("Activate called on {0} - {1}", GetType().FullName, Header));
            Log.Debug(string.Format("Active value - {0}", IsActive));
            if (IsActive)
            {
                return;
            }

            IsActive = true;
            Log.Debug(string.Format("Active value - {0}", IsActive));

            _activationStateChanged.OnNext(IsActive);

            OnActivate();

            if (_onInitialiseHasBeenCalled)
            {
                return;
            }

            Log.Debug(string.Format("Calling OnInitialise on {0} - {1}", GetType().FullName, Header));

            BusyViewModel.ActiveAsync("... Initialising ...")
            .Then(() =>
            {
                OnInitialise();

                Initialised.SafeInvoke(this);
                _onInitialiseHasBeenCalled = true;
            }, Scheduler.TPL.Task)
            .LogException(Log)
            .CatchAndHandle(ex => ViewService
                            .StandardDialogBuilder()
                            .Error("Error", string.Format("Exception in OnInitialise() call. {0}", ex.Message)), Scheduler.TPL.Task)
            .Finally(BusyViewModel.InActive, Scheduler.TPL.Task);
        }
コード例 #11
0
 private void Handle(Initialised initialised)
 {
     Name = initialised.Name;
 }
コード例 #12
0
 protected virtual void OnInitilised(SimInitialisedEventArgs e)
 {
     Initialised?.Invoke(this, e);
 }
コード例 #13
0
        internal static void Initialise(Window mainWindow)
        {
            Instance = new Win32Handler(mainWindow);

            Initialised?.Invoke(null, EventArgs.Empty);
        }
コード例 #14
0
ファイル: OgreImage.cs プロジェクト: Pedlar/PacmanOgre
        protected bool _InitOgre()
        {
            lock (this)
            {
                IntPtr hWnd = IntPtr.Zero;

                foreach (PresentationSource source in PresentationSource.CurrentSources)
                {
                    var hwndSource = (source as HwndSource);
                    if (hwndSource != null)
                    {
                        hWnd = hwndSource.Handle;
                        break;
                    }
                }

                if (hWnd == IntPtr.Zero)
                {
                    return(false);
                }

                CallResourceItemLoaded(new ResourceLoadEventArgs("Engine", 0));

                WindowReadyEvent?.Invoke(this, new WindowEventArgs {
                    WinPtr = hWnd
                });

                GameWPF.Singleton.ExternalWindowHandle = hWnd;

                if (GameWPF.Singleton.getRoot() == null)
                {
                    GameWPF.Singleton.initApp();
                }

                _root = GameWPF.Singleton.getRoot();

                if (_root == null)
                {
                    throw new Exception("Ogre not Initialised properly, need to register WindowReadyEvent and Initialize");
                }

                _renderWindow = GameWPF.Singleton.getRenderWindow();

                this.Dispatcher.Invoke(
                    (MethodInvoker) delegate
                {
                    IsFrontBufferAvailableChanged += _isFrontBufferAvailableChanged;

                    Initialised?.Invoke(this, new RoutedEventArgs());

                    GameWPF.Singleton.Game.IsEditor = true;
                    GameWPF.Singleton.SetupGame();

                    var _sceneManager = GameWPF.Singleton.Game.CurrentScene.GetOgreSceneManager();

                    _camera = _sceneManager.createCamera("EditorCamera");
                    //_camera.setAutoAspectRatio(true);
                    _camera.setNearClipDistance(5);
                    SceneNode camnode = _sceneManager.getRootSceneNode().createChildSceneNode(/* TODO: Name Component? */);
                    camnode.setPosition(0f, 50, 10f);
                    camnode.yaw(new Radian(0f));
                    camnode.pitch(new Radian(-1.2f));
                    camnode.attachObject(_camera);


                    ReInitRenderTarget();
                    AttachRenderTarget(true);

                    OnFrameRateChanged(this.FrameRate);

                    _currentThread = null;
                });

                return(true);
            }
        }
コード例 #15
0
 /// <summary>
 /// Invokes the <see cref="Initialised"/> event
 /// </summary>
 protected virtual void OnInitialised()
 {
     Initialised?.Invoke(new GaEventArgs <TIndividual, TGene>(initialPopulation, 1));
 }