public virtual Component Map()
        {
            Type t = typeof(T);

            T component;

            if (!AllowMultipleComponents)
            {
                component = ComponentHandler.GetComponent(t) as T;
                if (component == null)
                {
                    component = Activator.CreateInstance(t) as T;
                    ComponentHandler.SetComponent(component);
                }
            }
            else
            {
                component = ComponentHandler.GetComponent(t, ComponentId) as T;
                if (component == null)
                {
                    component = Activator.CreateInstance(t) as T;
                    component = ComponentHandler.AddComponent(component) as T;
                }
            }

            Map(component);
            return(component);
        }
Ejemplo n.º 2
0
        private async Task UniqueInitOnClientReady()
        {
            Database.Init();
            await ComponentHandler.Init(_client);

            _client.Ready -= UniqueInitOnClientReady;
        }
Ejemplo n.º 3
0
        private void CreateButton(ComponentHandler onClick, string name, Point point, Size2 size, string text)
        {
            var entity = new Entity {
                Name = name
            };

            var transform = SystemManager.Get <Transform2D>().Create(entity);

            transform.Position = new Vector2(point.X, point.Y);

            var sprite = SystemManager.Get <Components.Sprite>().Create(entity);

            sprite.Size    = new Vector2(size.Width, size.Height);
            sprite.Texture = ResourceManager.Get <Texture>("button");

            var textComponent = SystemManager.Get <Text>().Create(entity);

            textComponent.Label = text;
            textComponent.Color = Color.Black;

            var button = SystemManager.Get <Button>().Create(entity);

            button.Click += onClick;

            Scene.Add(entity);
        }
Ejemplo n.º 4
0
        public IActionResult GetUpdateComponent(Component model)
        {
            BackEnd.Models.Component component = new BackEnd.Models.Component();
            component.ComponentId = model.ComponentId;
            ComponentHandler handler = new ComponentHandler(new bachelordbContext());
            var newcomp = handler.getComponent(component);

            if (newcomp.Status != null)
            {
                newcomp.AdminComment             = model.AdminComment;
                newcomp.ComponentNumber          = model.ComponentNumber;
                newcomp.SerialNo                 = model.SerialNo;
                newcomp.UserComment              = model.UserComment;
                newcomp.Status                   = model.Status.ToString();
                newcomp.CurrentLoanInformationId = Convert.ToInt64(User.Claims.ElementAt(3).Value);
                handler.EditComponent(newcomp);

                return(RedirectToAction("Index", "HomePage"));
            }
            else
            {
                this.ModelState.AddModelError("AdminComment", "There is no component with that ID");
                return(View("ViewUpdateComponent"));
            }
        }
Ejemplo n.º 5
0
        private async Task CameraComponentGetAllFormats(MessageContainer data)
        {
            uint   width;
            uint   height;
            uint   bitrate;
            string type    = data.ResolveParameter("Type", 0);
            string subtype = data.ResolveParameter("SubType", 1);

            if (!uint.TryParse(data.ResolveParameter("Width", 2), out width))
            {
                width = 0;
            }
            if (!uint.TryParse(data.ResolveParameter("Height", 3), out height))
            {
                height = 0;
            }
            if (!uint.TryParse(data.ResolveParameter("BitRate", 4), out bitrate))
            {
                bitrate = 0;
            }

            foreach (var item in await GetSupportedMediaFormats(type, subtype, width, height, bitrate).ConfigureAwait(false))
            {
                data.AddMultiPartValue("MediaFormat", MediaPropertiesToJson(item));
            }
            await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
        }
Ejemplo n.º 6
0
        public void Ini()
        {
            cHandler = new ComponentHandler();
            string imageFolderPath = Environment.CurrentDirectory + @"\Images\";

            cHandler.LoadImages(imageFolderPath);
        }
Ejemplo n.º 7
0
        public IActionResult DeleteComponent(Component model)
        {
            BackEnd.Models.Component component = new BackEnd.Models.Component();
            component.ComponentId = model.ComponentId;
            ComponentHandler handler = new ComponentHandler(new bachelordbContext());

            handler.DeleteComponent(component);
            return(RedirectToAction("Index", "HomePage"));
        }
Ejemplo n.º 8
0
 private async void Server_OnMessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (e is StringMessageArgs)
     {
         await ComponentHandler.HandleInput(new MessageContainer(e.SessionId, this, (e as StringMessageArgs).Parameters));
     }
     else if (e is JsonMessageArgs)
     {
         await ComponentHandler.HandleInput(new MessageContainer(e.SessionId, this, (e as JsonMessageArgs).Json));
     }
 }
        public static void ExtractComponents(Entity entity, List <object> headers, List <object> values)
        {
            var handler = new ComponentHandler(entity);

            var componentIds = entity.GetComponentIds();

            foreach (var componentId in componentIds)
            {
                Dynamic.ForComponent(componentId, handler);
                FormatRows(handler.componentData, headers, values);
            }
        }
Ejemplo n.º 10
0
        public IActionResult Participant()
        {
            ComponentHandler     comphanlder     = new ComponentHandler(new bachelordbContext());
            ComponentTypeHandler comptypehanlder = new ComponentTypeHandler(new bachelordbContext());
            CategoryHandler      category        = new CategoryHandler(new bachelordbContext());
            HomePageModel        model           = new HomePageModel();

            model.listcategory       = category.getAllCategory();
            model.listcomponenttypes = comptypehanlder.GetAlleComponentTypes();
            model.listcomponent      = comphanlder.getallComponent();
            model.CategoryComponent  = category.GetallCategoryComponentTypes();
            return(View(model));
        }
Ejemplo n.º 11
0
        public IActionResult CreateComponent(Component model)
        {
            BackEnd.Models.Component component = new BackEnd.Models.Component();
            component.AdminComment             = model.AdminComment;
            component.ComponentNumber          = model.ComponentNumber;
            component.SerialNo                 = model.SerialNo;
            component.UserComment              = model.UserComment;
            component.Status                   = model.Status.ToString();
            component.CurrentLoanInformationId = Convert.ToInt64(User.Claims.ElementAt(3).Value);
            ComponentHandler handler = new ComponentHandler(new bachelordbContext());

            handler.saveComponent(component, Int32.Parse(model.selectedCompentype));
            return(RedirectToAction("Index", "HomePage"));
        }
Ejemplo n.º 12
0
    void Start()
    {
        CH = GetComponent <ComponentHandler>();

        this.transform.SetParent(LobbyManager.singleton.GetComponent <LobbyManager>().playerUIiPanel.transform);


        if (isLocalPlayer == false)
        {
            //this belongs to another player
            GetComponent <CanvasGroup>().interactable = false;
            return;
        }

        CmdSelectTeam(1);
        CmdChangeName("Player");
    }
Ejemplo n.º 13
0
        private async Task CameraComponentCapture(MessageContainer data)
        {
            string imageBase64 = string.Empty;

            using (IRandomAccessStream stream = await CaptureMediaStream(ImageEncodingProperties.CreateJpeg()).ConfigureAwait(false))
            {
                byte[] bytes = new byte[stream.Size];
                using (DataReader reader = new DataReader(stream))
                {
                    await reader.LoadAsync((uint)stream.Size);

                    reader.ReadBytes(bytes);
                }
                imageBase64 = Convert.ToBase64String(bytes);
            }
            data.AddValue("ImageBase64", imageBase64);
            await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
        }
Ejemplo n.º 14
0
 public void button()
 {
     if (hotspotLinkedTo != null)
     {
         ComponentHandler componentHandler = hotspotLinkedTo.AddMissingComponent <ComponentHandler>();
         Rigidbody        modelRigidbody   = hotspotLinkedTo.AddMissingComponent <Rigidbody>();
         modelRigidbody.useGravity  = false;
         modelRigidbody.isKinematic = false;
         modelRigidbody.mass        = 200;
         modelRigidbody.drag        = 1;
         modelRigidbody.angularDrag = 0.7f;
         ModelComponentViewerManager.vrControlls.Halt();
         componentHandler.IsolateModelComponent(hotspotLinkedTo.transform.position);
     }
     else
     {
         throw new System.ArgumentException("Hotspot must be linked to something!");
     }
 }
Ejemplo n.º 15
0
        void RaiseChanged <T>(ComponentHandler <T> handler, Entity entity,
                              Option <T> previousOption, Option <T> currentOption) where T : IComponent
        {
            T current; var hasValue = currentOption.TryGet(out current);
            T previous; var hasPrevious = previousOption.TryGet(out previous);

            if (hasValue)
            {
                if (!hasPrevious)
                {
                    handler.RaiseAdded(entity, current);
                    Added?.Invoke(entity, current);
                }
            }
            else if (hasPrevious)
            {
                handler.RaiseRemoved(entity, previous);
                Removed?.Invoke(entity, previous);
            }

            handler.RaiseChanged(entity, previousOption, currentOption);
            Changed?.Invoke(entity, previousOption.Cast <IComponent>(), currentOption.Cast <IComponent>());
        }
Ejemplo n.º 16
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            deferral = taskInstance.GetDeferral();
            taskInstance.Canceled += TaskInstance_Canceled;

            List <Task> setupTasks = new List <Task>();

            setupTasks.Add(ComponentHandler.RegisterComponent(new SocketListener(8027)));
            setupTasks.Add(ComponentHandler.RegisterComponent(new SocketListener(8031, DataFormat.Json)));

            shield = await FEZUtilityShield.CreateAsync().ConfigureAwait(false);

            gripper = new GripperComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P3)));
            setupTasks.Add(ComponentHandler.RegisterComponent(gripper));
            turntable = new TurnTableComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P0)));
            setupTasks.Add(ComponentHandler.RegisterComponent(turntable));
            lowerLever = new LeverComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P1)), "LowerLever");
            setupTasks.Add(ComponentHandler.RegisterComponent(lowerLever));
            upperLever = new LeverComponent(new Servo(new PCA9685PWMChannel(shield.PCA9685PWM, (int)FEZUtilityShield.PwmPin.P2)), "UpperLever");
            setupTasks.Add(ComponentHandler.RegisterComponent(upperLever));

            var videoDevices = await CameraComponent.GetAllVideoDevices().ConfigureAwait(false);

            if (videoDevices.Count > 0)
            {
                frontCamera = new CameraComponent("FrontCamera",
                                                  new MediaCaptureInitializationSettings
                {
                    StreamingCaptureMode = StreamingCaptureMode.Video,
                    PhotoCaptureSource   = PhotoCaptureSource.Auto,
                    AudioDeviceId        = string.Empty,
                    VideoDeviceId        = videoDevices[0].Id
                });
                setupTasks.Add(ComponentHandler.RegisterComponent(frontCamera));
            }
            await Task.WhenAll(setupTasks).ConfigureAwait(false);
        }
Ejemplo n.º 17
0
 public bool RegisterComponent(string component, ComponentHandler CH)
 {
     return(Handler.Add4nRep(component, CH));
 }
Ejemplo n.º 18
0
 public virtual Component Remove()
 {
     return(ComponentHandler.RemoveComponent <T>());
 }
Ejemplo n.º 19
0
        public virtual LocalizableComponentPropertiesValues Map(ILanguageEntity languageEntity, LocalizableComponentPropertiesValues localizableComponentPropertiesValues)
        {
            Type t = typeof(T);

            var component = Activator.CreateInstance(t) as T;

            MapLocalizeValues(component);

            if (localizableComponentPropertiesValues == null)
            {
                var entityComponentsLocalizableProperties =
                    LocalizablePropertyListManager.GetEntityComponentProperties(ComponentHandler.GetEntityType(),
                                                                                Context);

                if (entityComponentsLocalizableProperties == null || !entityComponentsLocalizableProperties.Any())
                {
                    return(null);
                }

                var path = GetLocalizableComponentPath(component);

                var componentProperties =
                    entityComponentsLocalizableProperties.FirstOrDefault(x =>
                                                                         x.Path.Equals(path, StringComparison.OrdinalIgnoreCase));

                if (componentProperties == null || !componentProperties.PropertyValues.Any())
                {
                    return(null);
                }

                localizableComponentPropertiesValues = componentProperties.Clone();
            }


            var properties = TypePropertyListManager.GetProperties(t);

            foreach (var localizablePropertyValues in localizableComponentPropertiesValues.PropertyValues)
            {
                if (!string.IsNullOrEmpty(localizablePropertyValues.PropertyName))
                {
                    var propertyInfo = properties.FirstOrDefault(x =>
                                                                 x.Name.Equals(localizablePropertyValues.PropertyName, StringComparison.OrdinalIgnoreCase));
                    if (propertyInfo != null)
                    {
                        var propertyValue = propertyInfo.GetValue(component);
                        var parameter     = localizablePropertyValues.Parameters.FirstOrDefault(x =>
                                                                                                x.Key.Equals(languageEntity.Language, StringComparison.OrdinalIgnoreCase));

                        if (parameter == null)
                        {
                            parameter = new Parameter {
                                Key = languageEntity.Language, Value = null
                            };
                            localizablePropertyValues.Parameters.Add(parameter);
                        }

                        parameter.Value = propertyValue;
                    }
                }
            }

            return(localizableComponentPropertiesValues);
        }
Ejemplo n.º 20
0
 private async Task ListenerGetDataFormat(MessageContainer data)
 {
     data.AddValue("DataFormat", this.dataFormat.ToString());
     await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
 }
Ejemplo n.º 21
0
 private async Task ListenerGetPort(MessageContainer data)
 {
     data.AddValue("Port", this.port);
     await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
 }
Ejemplo n.º 22
0
 public Entity()
 {
     Components = new ComponentHandler();
 }
Ejemplo n.º 23
0
 public ClassConvention(DomainMapper masterMap)
 {
     this.masterMap        = masterMap;
     this.componentHandler = new ComponentHandler();
 }
Ejemplo n.º 24
0
 private async Task TurnTableComponentGet(MessageContainer data)
 {
     data.AddValue("Position", servo.Position);
     await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
 }
Ejemplo n.º 25
0
 private async Task CameraComponentGetCurrentFormat(MessageContainer data)
 {
     data.AddValue("MediaFormat", MediaPropertiesToJson(await GetCurrentFormat()));
     await ComponentHandler.HandleOutput(data).ConfigureAwait(false);
 }