Ejemplo n.º 1
0
 public DragEventArgs(IColossalControl source, DragDropState state, object data, Vector2 position, IColossalControl target)
 {
     this.State    = state;
     this.Data     = data;
     this.Position = position;
     this.Source   = source;
     this.Target   = target;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Attaches an already existing UI <paramref name="component"/> as a sub control. Moves the existing control as a child below this control.
        /// </summary>
        /// <remarks>
        /// This wraps the given UI <paramref name="component"/> with the SkylineToolkit control wrapper.
        /// </remarks>
        /// <param name="component"></param>
        /// <returns>The attached child control.</returns>
        public new IColossalControl AttachControl(UIComponent component)
        {
            component = this.UIComponent.AttachUIComponent(component.gameObject);

            Type constructedType = typeof(ColossalControl <>).MakeGenericType(component.GetType());

            IColossalControl colossalControl = (IColossalControl)Activator.CreateInstance(constructedType, new object[] { component });

            return(colossalControl);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Finds a child control matching the given filter and control type.
        /// </summary>
        /// <remarks>
        /// The found <see cref="UIComponent"/>, if there's one, gets automatically wrapped up into a SkylineToolkit control wrapper.
        /// </remarks>
        /// <typeparam name="TControl">The type of the expected child control.</typeparam>
        /// <param name="filter">A filter used to search a sub control.</param>
        /// <returns>The found child control or null when found nothin.</returns>
        public IColossalControl FindColossalChild <TControl>(string filter)
            where TControl : UIComponent
        {
            UIComponent component = this.UIComponent.Find <TControl>(filter);

            Type constructedType = typeof(ColossalControl <>).MakeGenericType(component.GetType());

            IColossalControl colossalControl = (IColossalControl)Activator.CreateInstance(constructedType, new object[] { component });

            return(colossalControl);
        }
Ejemplo n.º 4
0
        public new static TControl FromUIComponent <TControl>(UIComponent component)
            where TControl : IColossalControl
        {
            IColossalControl control = (TControl)ColossalControl <ColossalFramework.UI.UIComponent> .FromUIComponent(component);

            if (!typeof(TControl).IsAssignableFrom(control.GetType()))
            {
                throw new InvalidCastException();
            }

            return((TControl)control);
        }
Ejemplo n.º 5
0
        public ColossalControl(IColossalControl control)
        {
            if (control.UIComponent.GetType() != typeof(T))
            {
                throw new InvalidCastException(String.Format("Can't wrap the given ColossalControl<{0}> with ColossalControl<{1}>.", control.GetType().Name, typeof(T).Name));
            }

            this.GameObject = control.GameObject;

            this.UIComponent = (T)control.UIComponent;

            this.SubscribeEvents();
        }
Ejemplo n.º 6
0
        public override void AttachTo(IColossalControl control)
        {
            control.AttachControl(Panel);

            if (HorizontalScrollbar != null)
            {
                HorizontalScrollbar.AttachTo(control);
            }

            if (VerticalScrollbar != null)
            {
                VerticalScrollbar.AttachTo(control);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Finds a child control matching the given filter.
        /// </summary>
        /// <remarks>
        /// The found <see cref="UIComponent"/>, if there's one, gets automatically wrapped up into a SkylineToolkit control wrapper.
        /// </remarks>
        /// <param name="filter">A filter used to search a sub control.</param>
        /// <returns>The found child control or null when found nothin.</returns>
        public new IColossalControl FindChild(string filter)
        {
            UIComponent component = this.UIComponent.Find(filter);

            if (component == null)
            {
                return(null);
            }

            Type constructedType = typeof(ColossalControl <>).MakeGenericType(component.GetType());

            IColossalControl colossalControl = (IColossalControl)Activator.CreateInstance(constructedType, new object[] { component });

            return(colossalControl);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Finds a child control matching the given filter and control type.
        /// </summary>
        /// <remarks>
        /// This uses the SkylineToolkit control wrappers.
        /// The found <see cref="UIComponent"/>, if there's one, gets automatically wrapped up into a SkylineToolkit control wrapper.
        /// </remarks>
        /// <typeparam name="TControl">The type of the expected child control.</typeparam>
        /// <param name="filter">A filter used to search a sub control.</param>
        /// <returns>The found child control or null when found nothin.</returns>
        public TControl FindChild <TControl>(string filter)
            where TControl : IColossalControl
        {
            Type componentType = GetUIComponentType(typeof(TControl));

            UIComponent component = this.UIComponent.Find(filter, componentType);

            if (component == null)
            {
                return(default(TControl));
            }

            Type constructedType = typeof(ColossalControl <>).MakeGenericType(component.GetType());

            IColossalControl colossalControl = (IColossalControl)Activator.CreateInstance(constructedType, new object[] { component });

            return((TControl)colossalControl);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new control of given <paramref name="type"/> and attaches it as a child control.
        /// </summary>
        /// <remarks>
        /// This method accepts both SkylineToolkit and Colossal UI control/component classes.
        /// Original Colossal <see cref="UIComponent"/> types gets wrapped automatically with the control classes from SkylineToolkit.
        /// The returned control requires casting to the desired type.
        /// </remarks>
        /// <param name="type">The type of the new control.</param>
        /// <returns>The newly created control.</returns>
        public new IColossalControl AddControl(Type type)
        {
            if (typeof(ColossalControl <>).IsAssignableFrom(type))
            {
                IColossalControl control = (IColossalControl)Activator.CreateInstance(type);

                this.UIComponent.AddUIComponent(control.UIComponent.GetType());

                return(control);
            }

            if (typeof(UIComponent).IsAssignableFrom(type))
            {
                UIComponent component = this.UIComponent.AddUIComponent(type);

                Type constructedType = typeof(ColossalControl <>).MakeGenericType(component.GetType());

                IColossalControl colossalControl = (IColossalControl)Activator.CreateInstance(constructedType, new object[] { component });

                return(colossalControl);
            }

            throw new InvalidCastException();
        }
Ejemplo n.º 10
0
 public ColossalUserControl(IColossalControl control)
     : base(control)
 {
 }
Ejemplo n.º 11
0
 public TooltipEventArgs(IColossalControl tooltipControl)
 {
     this.TooltipControl = tooltipControl;
 }
Ejemplo n.º 12
0
 public ScrollablePanel(IColossalControl control, bool subschribeEvents = false)
     : base(control, subschribeEvents)
 {
 }
Ejemplo n.º 13
0
 public abstract void AttachTo(IColossalControl control);
Ejemplo n.º 14
0
 /// <summary>
 /// Returns the type of the wrapped <see cref="UIComponent"/> from a ColossalControl wrapper.
 /// </summary>
 /// <param name="control">The SkylineToolkit UI Wrapper from which to receive the wrapped type.</param>
 /// <returns>The type of the wrapped <see cref="UIComponent"/>.</returns>
 protected static Type GetUIComponentType(IColossalControl control)
 {
     return(GetUIComponentType(control.GetType()));
 }
Ejemplo n.º 15
0
 public ColossalUserControl(IColossalControl control, bool subscribeEvents = false)
     : base(control, subscribeEvents)
 {
 }
Ejemplo n.º 16
0
 public TextField(IColossalControl control, bool subschribeEvents = false)
     : base(control, subschribeEvents)
 {
 }
Ejemplo n.º 17
0
 public Sprite(IColossalControl control, bool subschribeEvents = false)
     : base(control, subschribeEvents)
 {
 }
Ejemplo n.º 18
0
 public override void AttachTo(IColossalControl control)
 {
     control.AttachControl(Strip);
     control.AttachControl(Container);
 }
Ejemplo n.º 19
0
 public DragHandle(IColossalControl control, bool subschribeEvents = false)
     : base(control, subschribeEvents)
 {
 }
Ejemplo n.º 20
0
 public TabStrip(IColossalControl control, bool subschribeEvents = false)
     : base(control, subschribeEvents)
 {
 }
Ejemplo n.º 21
0
 public ColossalTextControl(IColossalControl control)
     : base(control)
 {
 }
Ejemplo n.º 22
0
 public void ScrollToControl(IColossalControl control)
 {
     this.ScrollToControl(control.UIComponent);
 }
Ejemplo n.º 23
0
 public Button(IColossalControl control, bool subscribeEvents = false)
     : base(control, subscribeEvents)
 {
 }
Ejemplo n.º 24
0
 public FocusEventArgs(IColossalControl focusedControl, IColossalControl lostFocusControl)
 {
     this.FocusedControl   = focusedControl;
     this.LostFocusControl = lostFocusControl;
 }
Ejemplo n.º 25
0
 public override void AttachTo(IColossalControl control)
 {
     control.AttachControl(Control);
 }