Example #1
0
        /// <summary>
        /// Builds the <see cref="TextFormatFlags"/> based on this control's values.
        /// </summary>
        /// <param name="ctrl">The control.</param>
        /// <param name="singleLine">if set to <c>true</c> text is in a single line.</param>
        /// <returns>A <see cref="TextFormatFlags"/> value for this control.</returns>
        public static TextFormatFlags BuildTextFormatFlags(this Control ctrl, bool singleLine = true)
        {
            var align = ctrl.GetPropertyValue("TextAlign", ContentAlignment.TopLeft);
            var ellip = ctrl.GetPropertyValue("AutoEllipsis", false);
            var mne   = ctrl.GetPropertyValue("UseMnemonic", false);
            var kb    = ctrl.GetPropertyValue("ShowKeyboardCues", false);

            return(GraphicsExtension.BuildTextFormatFlags(align, singleLine, ellip, mne, ctrl.GetRightToLeftProperty(), kb));
        }
        public static List <string> GetLinesFromTextBox(Control ctrl)
        {
            List <string> ret = null;

            if (ctrl.InvokeRequired)
            {
                TextBox blub = new TextBox();

                MethodInvoker delcall = () => { ret = GetLinesFromTextBox(ctrl); };

                try
                { ctrl.Invoke(delcall); }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else
            {
                string[] temp = (string[])ctrl.GetPropertyValue("Lines");
                ret = temp.ToList();

                //ret = ctrl.Lines.ToList();
            }

            return(ret);
        }
Example #3
0
            /// <summary>
            /// Creates a new animation.
            /// </summary>
            /// <param name="ctrl">The control to target (Button, TextBox, Panel,..).</param>
            /// <param name="propertyname">The name of the property to alter (Width, Height, Left,..)</param>
            /// <param name="changeinvalue">How much it has to change in value, it will move forth and back from the starting value plus this value.</param>
            /// <param name="animspeed">The speed of the animation. Higher is faster.</param>
            public ControlAnimation(Control ctrl, string propertyname, int changeinvalue, double animspeed = 0.4)
            {
                anitype     = AnimationType.SingleValue;
                m_animspeed = animspeed;

                m_propertyname = propertyname;
                m_control      = ctrl;
                m_increase     = changeinvalue;

                m_startvalue = (int)m_control.GetPropertyValue(m_propertyname);

                m_anitimer          = new Timer();
                m_anitimer.Interval = 1;
                m_anitimer.Tick    += AnitimerTick;
            }
Example #4
0
            /// <summary>
            /// Creates a new animation.
            /// </summary>
            /// <param name="ctrl">The control to target (Button, TextBox, Panel,..).</param>
            /// <param name="propertyname">The name of the property to alter (BackColor, ForeColor,..)</param>
            /// <param name="targetColor">The color to change to. The color it's set to before this was called will be seen as the starting color.</param>
            /// <param name="animspeed">The speed of the animation. Higher is faster.</param>
            public ControlAnimation(Control ctrl, string propertyname, Color targetColor, double animspeed = 0.4)
            {
                anitype     = AnimationType.Color;
                m_animspeed = animspeed;

                m_propertyname = propertyname;
                m_control      = ctrl;

                m_colorA = (Color)m_control.GetPropertyValue(m_propertyname);
                m_colorB = targetColor;

                m_anitimer          = new Timer();
                m_anitimer.Interval = 1;
                m_anitimer.Tick    += AnitimerTick;

                //m_anitimer.Enabled = true;
            }
        public static void ControlAddItemRange(Control ctrl, object[] values)
        {
            if (ctrl.InvokeRequired)
            {
                MethodInvoker delcall = () => { ControlAddItemRange(ctrl, values); };

                try
                { ctrl.Invoke(delcall); }

                catch { }
            }

            else
            {
                object items = ctrl.GetPropertyValue("Items");

                if (items != null)
                {
                    items.InvokeMethod("AddRange", ref values);
                }
            }
        }
        public static void ControlClearItems(Control ctrl)
        {
            if (ctrl.InvokeRequired)
            {
                MethodInvoker delcall = () => { ControlClearItems(ctrl); };

                try
                { ctrl.Invoke(delcall); }

                catch { }
            }

            else
            {
                object items = ctrl.GetPropertyValue("Items");

                if (items != null)
                {
                    items.InvokeSafe("Clear");
                }
            }
        }
        public static void ControlAddItem(Control ctrl, object value)
        {
            if (ctrl.InvokeRequired)
            {
                MethodInvoker delcall = () => { ControlAddItem(ctrl, value); };

                try
                { ctrl.Invoke(delcall); }

                catch { }
            }

            else
            {
                object items = ctrl.GetPropertyValue("Items");

                if (items != null)
                {
                    object[] temp = new object[] { value };

                    items.InvokeMethod("Add", ref temp);
                }
            }
        }
 public override object GetControlValue(Control control)
 {
     return(control.GetPropertyValue(ControlPropertyName));
 }
        public static void UpdateTextBox(Control control, List <string> msg, bool append = false, int insertAt = -1)
        {
            if (control.InvokeRequired)
            {
                MethodInvoker delcall = () => { UpdateTextBox(control, msg, append, insertAt); };

                try
                { control.BeginInvoke(delcall); }

                catch (Exception ex)
                { ex.ToDummy(); }
            }

            else
            {
                List <string> temp = new List <string>();

                if (!append)
                {
                    control.InvokeSafe("Clear");

                    temp = msg;

                    object[] args = new object[] { 0, 0 };

                    control.InvokeMethod("Select", ref args);

                    //control.Select(0, 0);

                    control.InvokeSafe("ScrollToCaret");

                    //control.ScrollToCaret();
                }

                else
                {
                    temp = ((string[])control.GetPropertyValue("Lines")).ToList();
                    //temp = control.Lines.ToList();

                    //if ((control.Lines.Count() < 1000) || (msg.Count < 1000))
                    //{ temp = control.Lines.ToList(); }

                    //else
                    //{
                    //    temp.Add(control.Lines[control.Lines.Count() - 2]);
                    //    temp.Add(control.Lines[control.Lines.Count() - 1]);
                    //}

                    if (insertAt == -1)
                    {
                        temp.AddRange(msg);
                    }

                    else
                    {
                        temp.InsertRange(insertAt, msg);
                    }
                }

                control.SetPropertyValue("Lines", temp.ToArray());
                //control.Lines = temp.ToArray();

                if (insertAt == -1)
                {
                    string txt = (string)control.GetPropertyValue("Text");

                    object[] args = new object[] { txt.Length, 0 };

                    control.InvokeMethod("Select", ref args);
                    //control.Select(control.Text.Length, 0);
                }

                else
                {
                    object[] args = new object[] { insertAt, 0 };

                    control.InvokeMethod("Select", ref args);

                    // control.Select(insertAt, 0);
                }

                control.InvokeSafe("ScrollToCaret");
                //control.ScrollToCaret();

                control.Refresh();
            }
        }
            /// <summary>
            /// Creates a new animation.
            /// </summary>
            /// <param name="ctrl">The control to target (Button, TextBox, Panel,..).</param>
            /// <param name="propertyname">The name of the property to alter (BackColor, ForeColor,..)</param>
            /// <param name="targetColor">The color to change to. The color it's set to before this was called will be seen as the starting color.</param>
            /// <param name="animspeed">The speed of the animation. Higher is faster.</param>
            public ControlAnimation(Control ctrl, string propertyname, Color targetColor, double animspeed = 0.4)
            {
                anitype = AnimationType.Color;
                m_animspeed = animspeed;

                m_propertyname = propertyname;
                m_control = ctrl;

                m_colorA = (Color)m_control.GetPropertyValue(m_propertyname);
                m_colorB = targetColor;

                m_anitimer = new Timer();
                m_anitimer.Interval = 1;
                m_anitimer.Tick += AnitimerTick;

                //m_anitimer.Enabled = true;
            }
            /// <summary>
            /// Creates a new animation.
            /// </summary>
            /// <param name="ctrl">The control to target (Button, TextBox, Panel,..).</param>
            /// <param name="propertyname">The name of the property to alter (Width, Height, Left,..)</param>
            /// <param name="changeinvalue">How much it has to change in value, it will move forth and back from the starting value plus this value.</param>
            /// <param name="animspeed">The speed of the animation. Higher is faster.</param>
            public ControlAnimation(Control ctrl, string propertyname, int changeinvalue, double animspeed = 0.4)
            {
                anitype = AnimationType.SingleValue;
                m_animspeed = animspeed;

                m_propertyname = propertyname;
                m_control = ctrl;
                m_increase = changeinvalue;

                m_startvalue = (int) m_control.GetPropertyValue(m_propertyname);

                m_anitimer = new Timer();
                m_anitimer.Interval = 1;
                m_anitimer.Tick += AnitimerTick;
            }