Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Label"/> class with the specified text.
 /// </summary>
 /// <param name="text">The specified text for this <see cref="Label"/>.</param>
 public Label(string text)
 {
     IntPtr strPtr = text.ToLibuiString();
     Handle = new SafeControlHandle(LibuiLibrary.uiNewLabel(strPtr));
     Marshal.FreeHGlobal(strPtr);
     this.text = text;
 }
Пример #2
0
 public SpinBox(int min, int max)
 {
     Handle       = new SafeControlHandle(LibuiLibrary.uiNewSpinbox(min, max));
     MinimumValue = min;
     MaximumValue = max;
     InitializeEvents();
 }
Пример #3
0
        public GroupBox(string title)
        {
            IntPtr strPtr = title.ToLibuiString();

            Handle = new SafeControlHandle(LibuiLibrary.uiNewGroup(strPtr));
            Marshal.FreeHGlobal(strPtr);
        }
Пример #4
0
 public DateTimePicker()
 {
     if (!(this is DatePicker || this is TimePicker))
     {
         Handle = new SafeControlHandle(LibuiLibrary.uiNewDateTimePicker());
     }
     InitializeEvents();
 }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Button"/> class with the specified text.
        /// </summary>
        /// <param name="text">The text to be displayed by this button.</param>
        public Button(string text)
        {
            IntPtr strPtr = text.ToLibuiString();

            Handle = new SafeControlHandle(LibuiLibrary.uiNewButton(strPtr));
            Marshal.FreeHGlobal(strPtr);
            this.text = text;
            InitializeEvents();
        }
Пример #6
0
        public MenuStrip(string name)
        {
            IntPtr strPtr = name.ToLibuiString();

            Handle = new SafeControlHandle(LibuiLibrary.uiNewMenu(strPtr));
            Marshal.FreeHGlobal(strPtr);
            Name  = name;
            Items = new List <MenuStripItem>();
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckBox"/> class with the specified text.
        /// </summary>
        /// <param name="text">The text specified by the <see cref="CheckBox"/>.</param>
        public CheckBox(string text)
        {
            IntPtr strPtr = LibuiLibrary.UTF8Helper.ToUTF8Ptr(text);

            Handle = new SafeControlHandle(LibuiLibrary.uiNewCheckbox(strPtr));
            Marshal.FreeHGlobal(strPtr);
            this.text = text;
            InitializeEvents();
        }
Пример #8
0
 protected ComboBoxBase()
 {
     if (this is ComboBox)
     {
         Handle = new SafeControlHandle(LibuiLibrary.uiNewCombobox());
     }
     else if (this is EditableComboBox)
     {
         Handle = new SafeControlHandle(LibuiLibrary.uiNewEditableCombobox());
     }
 }
Пример #9
0
 public MultilineTextBox(bool wordWrap = true)
 {
     if (wordWrap)
     {
         Handle = new SafeControlHandle(LibuiLibrary.uiNewMultilineEntry());
     }
     else
     {
         Handle = new SafeControlHandle(LibuiLibrary.uiNewNonWrappingMultilineEntry());
     }
     WordWrap = wordWrap;
     InitializeEvents();
 }
Пример #10
0
        protected SurfaceBase(ISurfaceHandler events)
        {
            SurfaceHandler surfaceEvents = new SurfaceHandler
            {
                Draw = (IntPtr surfaceHandler, IntPtr surface, ref LibuiLibrary.uiAreaDrawParams args) =>
                {
                    SafeControlHandle surfaceHandle = new SafeControlHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    DrawEventArgs     a             = args.ToDrawEventArgs();
                    events.Draw(realSurface, ref a);
                },
                MouseEvent = (IntPtr surfaceHandler, IntPtr surface, ref LibuiLibrary.uiAreaMouseEvent args) =>
                {
                    SafeControlHandle surfaceHandle = new SafeControlHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    MouseEventArgs    a             = args.ToMouseEventArgs();
                    events.MouseEvent(realSurface, ref a);
                },
                MouseCrossed = (surfaceHandler, surface, left) =>
                {
                    SafeControlHandle     surfaceHandle = new SafeControlHandle(surface);
                    SurfaceBase           realSurface   = Surfaces[surfaceHandle];
                    MouseCrossedEventArgs a             = new MouseCrossedEventArgs(left);
                    events.MouseCrossed(realSurface, a);
                },
                DragBroken = (surfaceHandler, surface) =>
                {
                    SafeControlHandle surfaceHandle = new SafeControlHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    events.DragBroken(realSurface);
                },
                KeyEvent = (IntPtr surfaceHandler, IntPtr surface, ref LibuiLibrary.uiAreaKeyEvent args) =>
                {
                    SafeControlHandle surfaceHandle = new SafeControlHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    KeyEventArgs      a             = args.ToKeyEventArgs();
                    return(events.KeyEvent(realSurface, ref a));
                }
            };

            EventHandler = new LibuiLibrary.uiAreaHandler
            {
                DragBroken   = Marshal.GetFunctionPointerForDelegate(surfaceEvents.DragBroken),
                Draw         = Marshal.GetFunctionPointerForDelegate(surfaceEvents.Draw),
                KeyEvent     = Marshal.GetFunctionPointerForDelegate(surfaceEvents.KeyEvent),
                MouseCrossed = Marshal.GetFunctionPointerForDelegate(surfaceEvents.MouseCrossed),
                MouseEvent   = Marshal.GetFunctionPointerForDelegate(surfaceEvents.MouseEvent)
            };
        }
Пример #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Separator"/> class with the specified orientation.
        /// </summary>
        /// <param name="orientation">The specified orientation.</param>
        public Separator(Orientation orientation)
        {
            switch (orientation)
            {
            case Orientation.Horizontal:
                Handle = new SafeControlHandle(LibuiLibrary.uiNewHorizontalSeparator());
                break;

            case Orientation.Vertical:
                Handle = new SafeControlHandle(LibuiLibrary.uiNewVerticalSeparator());
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(orientation));
            }
            Orientation = orientation;
        }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Window"/> class, with the options of specifying
        /// the window's width, height, title, and whether or not it has a <see cref="MenuStrip"/>.
        /// </summary>
        /// <param name="width">The width of the window.</param>
        /// <param name="height">The height of the window.</param>
        /// <param name="title">The title at the top of the window.</param>
        /// <param name="hasMenuStrip">Whether or not the window will have a menu.</param>
        public Window(int width = 500, int height = 300, string title = null, bool hasMenuStrip = false) : base()
        {
            if (string.IsNullOrEmpty(title))
            {
                title = "LibUISharp";
            }

            IntPtr strPtr = title.ToLibuiString();

            Handle = new SafeControlHandle(LibuiLibrary.uiNewWindow(strPtr, width, height, hasMenuStrip));
            Marshal.FreeHGlobal(strPtr);

            WindowCache.Add(Handle, this);
            this.title = title;
            size       = new Size(width, height);
            InitializeEvents();
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StackPanel"/> class with the specified orientation.
        /// </summary>
        /// <param name="orientation">The orientation controls are placed in the <see cref="StackPanel"/>.</param>
        public StackPanel(Orientation orientation)
        {
            switch (orientation)
            {
            case Orientation.Horizontal:
                Handle = new SafeControlHandle(LibuiLibrary.uiNewHorizontalBox());
                break;

            case Orientation.Vertical:
                Handle = new SafeControlHandle(LibuiLibrary.uiNewVerticalBox());
                break;

            default:
                throw new ArgumentOutOfRangeException("orientation");
            }
            Orientation = orientation;
        }
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DateTimePickerBase"/> class.
        /// </summary>
        protected DateTimePickerBase()
        {
            if (this is DatePicker)
            {
                Handle = new SafeControlHandle(LibuiLibrary.uiNewDatePicker());
            }
            else if (this is TimePicker)
            {
                Handle = new SafeControlHandle(LibuiLibrary.uiNewTimePicker());
            }
            else
            {
                Handle = new SafeControlHandle(LibuiLibrary.uiNewDateTimePicker());
            }
#if LIBUI_4_0
            InitializeEvents();
#endif
        }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextBoxBase"/> class.
 /// </summary>
 protected TextBoxBase()
 {
     if (!(this is TextBlock))
     {
         if (this is PasswordBox)
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewPasswordEntry());
         }
         else if (this is SearchBox)
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewSearchEntry());
         }
         else
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewEntry());
         }
     }
 }
Пример #16
0
 public TextBox()
 {
     if (!(this is MultilineTextBox))
     {
         if (this is PasswordBox)
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewPasswordEntry());
         }
         else if (this is SearchBox)
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewSearchEntry());
         }
         else
         {
             Handle = new SafeControlHandle(LibuiLibrary.uiNewEntry());
         }
         InitializeEvents();
     }
     else
     {
         throw new TypeInitializationException("LibUISharp.Controls.MultilineTextBox", new InvalidOperationException());
     }
 }
Пример #17
0
 internal StackContainerBase(SafeControlHandle handle, bool cacheable = true) : base(handle, cacheable)
 {
 }
Пример #18
0
 internal MenuStripItem(IntPtr handle)
 {
     Handle = new SafeControlHandle(handle);
     InitializeEvents();
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DateTimePickerBase"/> class.
 /// </summary>
 internal DateTimePickerBase(SafeControlHandle handle, bool cacheable = true) : base(handle, cacheable)
 {
 }
Пример #20
0
 internal SingleChildContainer(SafeControlHandle handle, bool cacheable = true) : base(handle, cacheable)
 {
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorPicker"/> class.
 /// </summary>
 public ColorPicker()
 {
     Handle = new SafeControlHandle(LibuiLibrary.uiNewColorButton());
     color  = Color.Empty;
     InitializeEvents();
 }
Пример #22
0
 internal Context(SafeControlHandle Handle)
 {
 }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of a <see cref="PreferencesMenuItem"/> class from the specified handle.
 /// </summary>
 /// <param name="handle">The specified handle.</param>
 internal PreferencesMenuItem(SafeControlHandle handle)
     : base(handle)
 {
 }
Пример #24
0
 internal TextBlockBase(SafeControlHandle handle, bool cacheable = true) : base(handle, cacheable) => InitializeEvents();
Пример #25
0
 /// <summary>
 /// Initializes a new instance of a <see cref="QuitMenuItem"/> class from the specified handle.
 /// </summary>
 /// <param name="handle">The specified handle.</param>
 internal QuitMenuItem(SafeControlHandle handle) : base(handle)
 {
 }
Пример #26
0
 internal SeparatorBase(SafeControlHandle handle, bool cacheable = true) : base(handle, cacheable)
 {
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RadioButtonList"/> class.
 /// </summary>
 public RadioButtonList()
 {
     Handle = new SafeControlHandle(LibuiLibrary.uiNewRadioButtons());
     InitializeEvents();
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of a <see cref="MenuItemBase"/> class from the specified handle.
 /// </summary>
 /// <param name="handle">The specified handle.</param>
 internal MenuItemBase(SafeControlHandle handle) : base(handle) => InitializeEvents();
Пример #29
0
 /// <summary>
 /// Initializes a new instance of a <see cref="MenuItem"/> class from the specified handle with the specified name.
 /// </summary>
 /// <param name="handle">The specified handle.</param>
 /// <param name="name">The menu child's name.</param>
 internal MenuItem(SafeControlHandle handle, string name) : base(handle) => Name = name;
Пример #30
0
 public FontPicker()
 {
     Handle = new SafeControlHandle(LibuiLibrary.uiNewFontButton());
     InitializeEvents();
 }