ComponentBase

We found 10 examples in language CSharp for this search. You will see 40 fragments of code.

        public static ComponentBase New(Type type, ComponentProps props)
        {
            return New(type, GetInstanceId(type.Name), props);
        }


        public static T New<T>() where T : ComponentBase
        {
            return New<T>(new ComponentProps { });
        }

        public static ComponentBase GetById(string id)
        {
            if (componentInstances.ContainsKey(id))
                return componentInstances[id];
            else return null;
        }

        public static void DestroyComponent(ComponentBase c)
        {
            if (c != null)
            {
                GameObject.DestroyObject(c.gameObject);
                componentInstances.Remove(c.name);
                OnComponentDestroy.Invoke(c, new ComponentEventArgs(c));
            }
        }

        public static IEnumerable<T> GetAll<T>() where T : ComponentBase
        {
            return componentInstances.Where(x => x.Value.GetType() == typeof(T)).Select(x => x.Value as T);
        }


        public ComponentBase[] GetInputs()
        {
            return inputs;
        }

        public void RemoveAndShiftInputs(int pos)
        {
            var tmpList = new List<ComponentBase>(inputs);
            tmpList.RemoveAt(pos);
            inputs = tmpList.ToArray();

            for (int i = pos; i < inputs.Length; ++i)
                SetInput(inputs[i], i);
        }


        public void UpdateMessage(ComponentBase source, string message)
        {
            Message = message;
            NotifyStateChanged(source, nameof(Message));
        }

        public void UpdateEnabled(ComponentBase source, bool enabled)
        {
            Enabled = enabled;
            NotifyStateChanged(source, nameof(Enabled));
        }

        public void UpdateCounter(ComponentBase source, int counter)
        {
            Counter = counter;
            NotifyStateChanged(source, nameof(Counter));
        }

        private void NotifyStateChanged(ComponentBase source, string property) =>
            StateChanged?.Invoke(source, property);


        private void Start()
        {
            gridCompositor = ComponentManager.New<FadeMediaCompositor>(new MediaCompositorProps { width = 1920, height = 1080 });
            gridCompositor.inputs = new ComponentBase[2];
        }


        public void UpdateMessage(ComponentBase source, string message)
        {
            Message = message;
            NotifyStateChanged(source, nameof(Message));
        }

        public void UpdateEnabled(ComponentBase source, bool enabled)
        {
            Enabled = enabled;
            NotifyStateChanged(source, nameof(Enabled));
        }

        public void UpdateCounter(ComponentBase source, int counter)
        {
            Counter = counter;
            NotifyStateChanged(source, nameof(Counter));
        }

        private void NotifyStateChanged(ComponentBase source, string property) =>
            StateChanged?.Invoke(source, property);


    private bool CanMove(ComponentBase c)
    {
      return c.HasFlag(Flags.CanMove) && !c.HasRestriction(Restrictions.DontMove);
    }

    private bool CanResize(ComponentBase c)
    {
      return c.HasFlag(Flags.CanResize) && !c.HasRestriction(Restrictions.DontResize);
    }

    internal void Update()
    {
      FList.Clear();
      if (FDesigner.SelectedObjects != null)
      {
        foreach (Base c in FDesigner.SelectedObjects)
        {
          if (c is ComponentBase)
            FList.Add(c as ComponentBase);
        }
      }
    }
    
    /// <summary>
    /// Aligns left edges of the selected objects.
    /// </summary>
    public void AlignLeft()
    {
      foreach (ComponentBase c in MoveList)
      {
        c.Left = First.Left;
      }
      FDesigner.SetModified();
    }

    /// <summary>
    /// Aligns right edges of the selected objects.
    /// </summary>
    public void AlignRight()
    {
      foreach (ComponentBase c in MoveList)
      {
        c.Left = First.Right - c.Width;
      }
      FDesigner.SetModified();
    }

    /// <summary>
    /// Aligns centers of the selected objects.
    /// </summary>
    public void AlignCenter()
    {
      foreach (ComponentBase c in MoveList)
      {
        c.Left = First.Left + (First.Width - c.Width) / 2;
      }
      FDesigner.SetModified();
    }


    private void CheckVirtualVGuide(float x, ComponentBase c)
    {
      x = Converter.DecreasePrecision(x, 2);
      int i = FVirtualVGuides.IndexOfKey(x);
      if (i != -1)
      {
        FVirtualGuides.Add(new RectangleF(x, c.AbsTop, x, FVirtualVGuides.Values[i].AbsTop));
      }
    }

    private void CheckVirtualHGuide(float y, ComponentBase c)
    {
      y = Converter.DecreasePrecision(y, 2);
      int i = FVirtualHGuides.IndexOfKey(y);
      if (i != -1)
      {
        FVirtualGuides.Add(new RectangleF(c.AbsLeft, y, FVirtualHGuides.Values[i].AbsLeft, y));
      }
    }

    private void AddVGuide(float x, ComponentBase c)
    {
      x = Converter.DecreasePrecision(x, 2);
      if (!FVirtualVGuides.ContainsKey(x))
        FVirtualVGuides.Add(x, c);
    }

    private void AddHGuide(float y, ComponentBase c)
    {
      y = Converter.DecreasePrecision(y, 2);
      if (!FVirtualHGuides.ContainsKey(y))
        FVirtualHGuides.Add(y, c);
    }

    public void CreateVirtualGuides()
    {
      FVirtualVGuides.Clear();
      FVirtualHGuides.Clear();
      foreach (Base obj in Designer.Objects)
      {
        if (obj is ComponentBase && !Designer.SelectedObjects.Contains(obj))
        {
          ComponentBase c = obj as ComponentBase;
          AddVGuide(c.AbsLeft, c);
          AddVGuide(c.AbsRight, c);
          AddHGuide(c.AbsTop, c);
          AddHGuide(c.AbsBottom, c);
        }
      }
    }

    public void CheckVirtualGuides()
    {
      FVirtualGuides.Clear();
      foreach (Base obj in Designer.SelectedObjects)
      {
        if (obj is ComponentBase)
        {
          ComponentBase c = obj as ComponentBase;
          CheckVirtualVGuide(c.AbsLeft, c);
          CheckVirtualVGuide(c.AbsRight, c);
          CheckVirtualHGuide(c.AbsTop, c);
          CheckVirtualHGuide(c.AbsBottom, c);
        }
      }
    }

		[DebuggerHidden] // 0x00000001801CDAD0-0x00000001801CDAE0
		IEnumerator<ComponentBase> IEnumerable<ComponentBase>.GetEnumerator(); // 0x0000000180787440-0x00000001807874E0


    #region override methods

    public override void Init()
    {
        base.Init();
        this.CurrentItemList = new List<ComponentBase>();
    }

    public override void Clear()
    {
        StopAllCoroutines();
        foreach (ComponentBase item in this.CurrentItemList)
        {
            item.Hide();
        }
        this.backupSelectionItem = null;
        this.HideSelectionEffect();
        base.Clear();
    }

    #endregion

    #region abstract methods

    protected abstract void ItemClick(ComponentBase comp);
    protected abstract void ItemPress(ComponentBase comp, bool isPress);

    public virtual void DeleteItem(ComponentBase comp)
    {
        this.CurrentItemList.Remove(comp);
        DestroyImmediate(comp.MyGameObject);
        this.ResetPosition();
    }
    #endregion

    #region protected methods

    protected void AddCompEvent(ComponentBase comp)
    {
        if (this.ClickType != PackageItemClickType.CantClick)
        {
            UIEventListener listener = UIEventListener.Get(comp.MyGameObject);
            listener.onClick += this.InPackageItemClick;
            listener.onPress += this.InPackageItemPress;
        }
    }


        public bool HasComponent<TComponent>() where TComponent : ComponentBase
        {
            return _components.Any(x => x is TComponent);
        }

        public TComponent GetComponent<TComponent>() where TComponent : ComponentBase
        {
            return (TComponent)_components.FirstOrDefault(x => x is TComponent);
        }

        public TComponent AddComponent<TComponent>(TComponent component) where TComponent : ComponentBase
        {
            _components.Add(component);
            component.Entity = this;
            SystemMessageBroker.Send(new ComponentAdded<TComponent>(component, this));
            return component;
        }

        public void RemoveComponent<TComponent>(TComponent component) where TComponent : ComponentBase
        {
            _components.Remove(component);
            component.Entity = null;
            SystemMessageBroker.Send(new ComponentRemoved<TComponent>(component, this));
        }

        public IEnumerable<ComponentBase> GetComponents()
        {
            return _components.ToList();
        }

Microsoft.AspNetCore.Components.ComponentBase : IComponent, IHandleEvent, IHandleAfterRender

Constructors :

public ComponentBase()

Methods :

public Task SetParametersAsync(ParameterView parameters = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods

Other methods