Ejemplo n.º 1
0
        internal PythonToolsService(IServiceContainer container)
        {
            _container = container;
            _analyzers = new ConcurrentDictionary <string, VsProjectAnalyzer>();

            _langPrefs = new Lazy <LanguagePreferences>(() => new LanguagePreferences(this, typeof(PythonLanguageInfo).GUID));
            _interpreterOptionsService  = new Lazy <IInterpreterOptionsService>(Site.GetComponentModel().GetService <IInterpreterOptionsService>);
            _interpreterRegistryService = new Lazy <IInterpreterRegistryService>(Site.GetComponentModel().GetService <IInterpreterRegistryService>);

            _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService));

            _idleManager             = new IdleManager(container);
            _advancedOptions         = new Lazy <AdvancedEditorOptions>(CreateAdvancedEditorOptions);
            _debuggerOptions         = new Lazy <DebuggerOptions>(CreateDebuggerOptions);
            _experimentalOptions     = new Lazy <Options.ExperimentalOptions>(CreateExperimentalOptions);
            _diagnosticsOptions      = new Lazy <DiagnosticsOptions>(CreateDiagnosticsOptions);
            _generalOptions          = new Lazy <GeneralOptions>(CreateGeneralOptions);
            _suppressDialogOptions   = new Lazy <SuppressDialogOptions>(() => new SuppressDialogOptions(this));
            _interactiveOptions      = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Interactive"));
            _debugInteractiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Debug Interactive Window"));
            _logger = (IPythonToolsLogger)container.GetService(typeof(IPythonToolsLogger));
            _diagnosticsProvider = new DiagnosticsProvider(container);

            _idleManager.OnIdle += OnIdleInitialization;

            EditorServices = ComponentModel.GetService <PythonEditorServices>();
            EditorServices.SetPythonToolsService(this);
        }
Ejemplo n.º 2
0
        internal PythonToolsService(IServiceContainer container)
        {
            _container = container;

            _langPrefs = new Lazy <LanguagePreferences>(() => new LanguagePreferences(this, typeof(PythonLanguageInfo).GUID));
            _interpreterOptionsService = new Lazy <IInterpreterOptionsService>(CreateInterpreterOptionsService);

            _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService));

            _idleManager             = new IdleManager(container);
            _advancedOptions         = new Lazy <AdvancedEditorOptions>(CreateAdvancedEditorOptions);
            _debuggerOptions         = new Lazy <DebuggerOptions>(CreateDebuggerOptions);
            _experimentalOptions     = new Lazy <Options.ExperimentalOptions>(CreateExperimentalOptions);
            _diagnosticsOptions      = new Lazy <DiagnosticsOptions>(CreateDiagnosticsOptions);
            _generalOptions          = new Lazy <GeneralOptions>(CreateGeneralOptions);
            _suppressDialogOptions   = new Lazy <SuppressDialogOptions>(() => new SuppressDialogOptions(this));
            _interactiveOptions      = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Interactive"));
            _debugInteractiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Debug Interactive Window"));
            _logger              = new PythonToolsLogger(ComponentModel.GetExtensions <IPythonToolsLogger>().ToArray());
            _entryService        = (AnalysisEntryService)ComponentModel.GetService <IAnalysisEntryService>();
            _diagnosticsProvider = new DiagnosticsProvider(container);

            _idleManager.OnIdle += OnIdleInitialization;

            EditorServices.SetPythonToolsService(this);
        }
Ejemplo n.º 3
0
        internal CompletionAnalysis GetCompletions(ICompletionSession session, ITextView view, ITextSnapshot snapshot, ITrackingPoint point)
        {
            if (IsSpaceCompletion(snapshot, point) && session.IsCompleteWordMode())
            {
                // Cannot complete a word immediately after a space
                session.ClearCompleteWordMode();
            }

            var bi    = EditorServices.GetBufferInfo(snapshot.TextBuffer);
            var entry = bi?.AnalysisEntry;

            if (entry == null)
            {
                return(CompletionAnalysis.EmptyCompletionContext);
            }

            var options = session.GetOptions(Site);

            if (ReverseExpressionParser.IsInGrouping(snapshot, bi.GetTokensInReverseFromPoint(point.GetPoint(snapshot))))
            {
                options = options.Clone();
                options.IncludeStatementKeywords = false;
            }

            return(new CompletionAnalysis(
                       EditorServices,
                       session,
                       view,
                       snapshot,
                       point,
                       options
                       ));
        }
Ejemplo n.º 4
0
 public Control CreateEditor(ReportControlInfo controlInfo, EditorServices services, System.Collections.Generic.IDictionary <string, object> customProperties)
 {
     return(new PictureBoxSizingEditor()
     {
         ViewModel = new PictureBoxSizingEditorViewModel(services, controlInfo, customProperties)
     });
 }
Ejemplo n.º 5
0
        public GameSystems(Contexts contexts, CoreServices coreServices, GameServices gameServices,
                           EditorServices editorServices, GameFactories gameFactories)
        {
            //Initialize
            Add(new RegisterServicesSystem(contexts, coreServices, gameServices, editorServices));
            Add(new RegisterFactoriesSystem(contexts, gameFactories));

            //Remove
            Add(new RemoveActionSystem(contexts));

            //Action Requests
            Add(new ActionRequestAddEntityToGridSystem(contexts));

            //Actions
            Add(new ActionAddEntityToGridSystem(contexts));
            Add(new ActionCreateMapSystem(contexts));

            //Update
            Add(new UpdateActionDelaySystem(contexts));
            Add(new UpdateSelectionColorSystem(contexts));
            Add(new UpdateTickSystem(contexts));

            //Events
            Add(new ActionEventSystems(contexts));
            Add(new GameEventSystems(contexts));
            Add(new MapEditorEventSystems(contexts));
            Add(new InputEventSystems(contexts));

            //Cleanup
            Add(new CoreServiceCleanupSystems(contexts));
            Add(new DestroyEntitiesSystem(contexts));
        }
        public FileEditor Post(FileEditor file)
        {
            UserProfile _user = AuthManager.CurrentUser;

            if (_user == null)
            {
                throw ExceptionResponse.Forbidden(Request, Messages.InvalidCredentials);
            }

            try
            {
                const string fileName = "Unititled";
                return(EditorServices.Create(file?.Name ?? fileName, _user.Id));
            }
            catch (NotFound ex)
            {
                throw ExceptionResponse.NotFound(Request, ex.Message);
            }
            catch (RequestForbidden ex)
            {
                throw ExceptionResponse.Forbidden(Request, ex.Message);
            }
            catch (Exception)
            {
                throw ExceptionResponse.ServerErrorResponse(Request);
            }
        }
        public IEnumerable <FileEditor> Get()
        {
            UserProfile _user = AuthManager.CurrentUser;

            if (_user == null)
            {
                throw ExceptionResponse.Forbidden(Request, Messages.InvalidCredentials);
            }

            try
            {
                IEnumerable <FileEditor> editors = EditorServices.GetAll(_user.Id);
                return(editors);
            }
            catch (NotFound ex)
            {
                throw ExceptionResponse.NotFound(Request, ex.Message);
            }
            catch (RequestForbidden ex)
            {
                throw ExceptionResponse.Forbidden(Request, ex.Message);
            }
            catch (Exception ex)
            {
                throw ExceptionResponse.ServerErrorResponse(Request);
            }
        }
        public PictureBoxSizingEditorViewModel(EditorServices editorServices, ReportControlInfo controlInfo, IDictionary <string, object> customProperties)
        {
            this.editorServices = editorServices;
            applyCommand        = new DelegateCommand <object>(Apply);
            controlName         = controlInfo.DesignName;
            const string customProperyName = "Sizing";

            ImageSizeMode = customProperties.ContainsKey(customProperyName) && customProperties[customProperyName] is ImageSizeMode ?
                            (ImageSizeMode)customProperties[customProperyName] : DevExpress.XtraPrinting.ImageSizeMode.Normal;
        }
Ejemplo n.º 9
0
        void Awake()
        {
            Application.targetFrameRate = 60;
            _contexts = Contexts.sharedInstance;
            _contexts.SubscribeId();

            _coreServices = new CoreServices(new UnityViewService(), new InputService(_contexts),
                                             new UnityInputController(new UnityInputMapper()), new CollisionService(_contexts),
                                             new SelectionService(_contexts), new UnityTimeService(), new TickService(_contexts));

            _gameServices = new GameServices(new GridService(_contexts));

            _editorServices = new EditorServices(new GridEditorService(_contexts, new UnityMapEditorAssetLoader(),
                                                                       new GridEditorToolsService(), new GridEditorNavigationService(), new GridEditorObjectService()));

            _gameFactories = new GameFactories(new TileFactory(_contexts));


            _systems = CreateSystems();
            _systems.Initialize();

            var grid = _contexts.grid.CreateGrid(10, 10, 1, 1, ObjectType.OBJECT_CATEGORY_TILE);


            var e = _contexts.game.CreateEntity();

            _coreServices.View.LoadAsset(_contexts, e, GlobalVariables.ResourcesAssetsPath + "prefabs/miner");
            e.AddPosition(-3, 3);
            e.AddVisible(true);
            e.AddSelectionColor(newSelectionDown: new Color(0.0f, 1.0f, 0.0f, 1.0f), newSelectionHeld: new Color(),
                                newSelectionHoverIn: new Color(), newSelectionHoverOut: new Color(),
                                newSelectionHoverSelect: new Color(), newSelectionUp: new Color());


            var action = _contexts.action.CreateEntity();

            action.AddActionCreateMap(new Vector2Int(10, 10), TileType.Stone, TileType.Stone);
//            var command = new CommandCreateMapEditor(_contexts, grid.id.value);
//            command.DoCommand();

            var tick    = _contexts.game.CreateEntity();
            var newTick = new Tick()
            {
                delayValue = 0.05f, delay = 1, multiplier = 1f
            };

            tick.AddTick(new Dictionary <TickEnum, Tick>()
            {
                {
                    TickEnum.MapEditor_AssetLoading, newTick
                }
            });
        }
Ejemplo n.º 10
0
        public RegisterServicesSystem(Contexts contexts, CoreServices coreServices, GameServices gameServices,
                                      EditorServices editorServices)
        {
            //Core Services
            Add(new RegisterTimeServiceSystem(contexts, coreServices.Time));
            Add(new RegisterCollisionServiceSystem(contexts, coreServices.Collision));
            Add(new RegisterViewServiceSystem(contexts, coreServices.View));
            Add(new RegisterInputServiceSystem(contexts, coreServices.Input));
            Add(new RegisterSelectionServiceSystem(contexts, coreServices.Selection));
            Add(new RegisterInputControllerSystem(contexts, coreServices.InputController));
            Add(new RegisterTickServiceSystem(contexts, coreServices.Tick));

            //Game Services
            Add(new RegisterGridServiceSystem(contexts, gameServices.Grid));

            //Editor Services
            Add(new RegisterGridEditorServiceSystem(contexts, editorServices.GridEditor));
        }
Ejemplo n.º 11
0
        /// <inheritdoc />
        public override Vector3 GetPositionInScene(Vector2 mousePosition)
        {
            const float limitAngle     = 7.5f * MathUtil.Pi / 180f;
            const float randomDistance = 20f;

            Vector3 scenePosition;
            var     cameraService = EditorServices.Get <IEditorGameCameraService>();

            var ray   = EditorGameHelper.CalculateRayFromMousePosition(cameraService.Component, mousePosition, Matrix.Invert(cameraService.ViewMatrix));
            var plane = new Plane(Vector3.Zero, upAxis);

            // Ensures a ray angle with projection plane of at least 'limitAngle' to avoid the object to go to infinity.
            var dotProductValue = Vector3.Dot(ray.Direction, plane.Normal);
            var comparisonSign  = Math.Sign(Vector3.Dot(ray.Position, plane.Normal) + plane.D);

            if (comparisonSign * (Math.Acos(dotProductValue) - MathUtil.PiOverTwo) < limitAngle || !plane.Intersects(ref ray, out scenePosition))
            {
                scenePosition = ray.Position + randomDistance * ray.Direction;
            }

            return(scenePosition);
        }
Ejemplo n.º 12
0
        /// <inheritdoc />
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            // mount the common database in this micro-thread to have access to the built effects, etc.
            MicrothreadLocalDatabases.MountCommonDatabase();

            // Create fallback effect to use when material is still loading
            fallbackColorMaterial = Material.New(GraphicsDevice, new MaterialDescriptor
            {
                Attributes =
                {
                    Diffuse      = new MaterialDiffuseMapFeature(new ComputeTextureColor()),
                    DiffuseModel = new MaterialDiffuseLambertModelFeature()
                }
            });

            fallbackTextureMaterial = Material.New(GraphicsDevice, new MaterialDescriptor
            {
                Attributes =
                {
                    Diffuse           = new MaterialDiffuseMapFeature(new ComputeTextureColor {
                        FallbackValue = null
                    }),                                                                                        // Do not use fallback value, we want a DiffuseMap
                    DiffuseModel      = new MaterialDiffuseLambertModelFeature()
                }
            });

            // Listen to all Renderer Initialized to plug dynamic effect compilation
            RenderContext.GetShared(Services).RendererInitialized += SceneGameRendererInitialized;
            // Update the marker render target setter viewport
            //OnClientSizeChanged(this, EventArgs.Empty);

            // Initialize the services
            var initialized = new List <IEditorGameService>();

            foreach (var service in EditorServices.OrderByDependency())
            {
                // Check that the current service dependencies have been initialized
                foreach (var dependency in service.Dependencies)
                {
                    if (!initialized.Any(x => dependency.IsInstanceOfType(x)))
                    {
                        throw new InvalidOperationException($"The service [{service.GetType().Name}] requires a service of type [{dependency.Name}] to be initialized first.");
                    }
                }
                if (await service.InitializeService(this))
                {
                    initialized.Add(service);
                }

                var mouseService = service as EditorGameMouseServiceBase;
                mouseService?.RegisterMouseServices(EditorServices);
            }

            // TODO: Maybe define this scene default graphics compositor as an asset?
            var defaultGraphicsCompositor = GraphicsCompositorHelper.CreateDefault(true, EditorGraphicsCompositorHelper.EditorForwardShadingEffect);

            // Add UI (engine doesn't depend on it)
            defaultGraphicsCompositor.RenderFeatures.Add(new UIRenderFeature
            {
                RenderStageSelectors =
                {
                    new SimpleGroupToRenderStageSelector
                    {
                        RenderStage = defaultGraphicsCompositor.RenderStages.First(x => x.Name == "Transparent"),
                        EffectName  = "Test",
                        RenderGroup = GizmoBase.DefaultGroupMask
                    }
                }
            });

            // Make the game switch to this graphics compositor
            UpdateGraphicsCompositor(defaultGraphicsCompositor);

            gameContentLoadedTaskSource.SetResult(true);
        }