Пример #1
0
    public static void fadingForm(AlphaForm _obj, Bitmap _bmp, double _transparency, int _speed)
    {
        Bitmap FadingBmp = UiControlsMethod.ControlMethods.getFormControlToBmp(_obj, _bmp);

        _obj.BlendedBackground = FadingBmp;
        Thread fading = new Thread(() =>
        {
            _obj.CrossThreadCalls(() =>
            {
                for (double i = 0; i < _transparency; i += 0.01 * _speed)
                {
                    _obj.SetOpacity(i);
                    Thread.Sleep(10);
                }
                _obj.SetOpacity(_transparency);
            });
        });

        fading.Start();
    }
Пример #2
0
 private void _dropClick(object sender, EventArgs e)
 {
     if (DropClickArea)
     {
         if (!_showState)
         {
             Point flist = Obj.PointToScreen(new Point(location.X, location.Y));
             listForm.Location = new Point(flist.X, flist.Y + bmp_drop.Height + m_set[3]);
             listForm.SetOpacity(transparency * 255);
             _showState = true;
         }
         else
         {
             DropListHidden();
         }
     }
     else
     {
         DropListHidden();
     }
 }
Пример #3
0
    private void getAnimationPutState()
    {
        bool _state = true;

        while (true)
        {
            if (putForm.AnimationBegin)
            {
                if (_state)
                {
                    firstForm.CrossThreadCalls(() => {
                        Thread.Sleep(10); // the same as [ AnimationPutForm.Timer.Interval * 2, becsuse flip delayed]
                        firstForm.Visible = false;
                        firstForm.SetOpacity(0);
                    });
                    _state = false;
                }
            }

            if (!putForm.AnimationStart)
            {
                secondForm.CrossThreadCalls(() => {
                    try
                    {
                        secondForm.Location = firstForm.Location;
                        secondForm.Visible  = true;
                        secondForm.SetOpacity((transparency / 255));
                    }
                    catch { }
                });
                Thread.Sleep(5); // the same as [ AnimationPutForm.Timer.Interval ]
                putForm.AnimationStart = true;
                putForm.PutForm_Close();

                break;
            }
        }
    }
Пример #4
0
    public void InitializeCalendar(Control _obj, int _timeType, string _setTime, int _dispType, Point _location, double _transparency)
    {
        _dayList.Clear();
        obj          = _obj;
        timeType     = _timeType;
        setTime      = _setTime;
        dispType     = _dispType;
        location     = _location;
        transparency = _transparency;

        int              str_X = 0, str_Y = 0, skip_X = 0, skip_Y = 0;
        int              head_X = 0, head_Y = 0;
        Size             ImgSize;
        int              cut_X = 0, cut_Y = 0;
        UiDrawTextMethod ud = new UiDrawTextMethod();
        Font             fnt;

        if (_timeType == 1)
        {
            try
            {
                string[] splitString = _setTime.Split(new string[] { "-" }, StringSplitOptions.None);
                dy = int.Parse(splitString[0]);
                dm = int.Parse(splitString[1]);
            }
            catch { }
        }
        else
        {
            dy = DateTime.Today.Year;
            dm = DateTime.Today.Month;
            dd = DateTime.Today.Day;
        }

        //year before last
        int qdy = dy;
        int qdm;

        if (dm == 1)
        {
            qdm = 12;
            qdy = dy - 1;
        }
        else
        {
            qdm = dm - 1;
        }
        int q_mday = DateTime.DaysInMonth(qdy, qdm);

        //Next year
        int ndy = dy + 1;
        int ndm;

        if ((dm + 1) == 13)
        {
            ndm = 1;
        }
        else
        {
            ndm = dm + 1;
        }

        // now
        int      t_mday = DateTime.DaysInMonth(dy, dm);
        DateTime tmDate = new DateTime(dy, dm, 1);
        int      t_week = (int)tmDate.DayOfWeek;

        if (t_week == 0)
        {
            t_week = 7;
        }

        string str_YMD;

        for (int i = 0; i < t_week - 1; i++)
        {
            if (dm == 1)
            {
                str_YMD = (dy - 1) + "-12-" + (q_mday - t_week + i + 2);
            }
            else
            {
                str_YMD = dy + "-" + (dm - 1) + "-" + (q_mday - t_week + i + 2);
            }
            addDay(q_mday - t_week + i + 2, Color.Gainsboro, false, str_YMD, new Rectangle(0, 0, 0, 0));
        }

        for (int i = 0; i < t_mday; i++)
        {
            str_YMD = dy + "-" + dm + "-" + (i + 1);
            if (DateTime.Today.ToString("yyyy-M-d") == str_YMD)
            {
                addDay(i + 1, Color.Crimson, false, str_YMD, new Rectangle(0, 0, 0, 0));
            }
            else
            {
                addDay(i + 1, Color.Black, false, str_YMD, new Rectangle(0, 0, 0, 0));
            }
        }

        for (int i = 0; i < (42 - t_week - t_mday) + 1; i++)
        {
            if (dm == 12)
            {
                str_YMD = (dy + 1) + "-1-" + (i + 1);
            }
            else
            {
                str_YMD = dy + "-" + (dm + 1) + "-" + (i + 1);
            }
            addDay(i + 1, Color.Gainsboro, false, str_YMD, new Rectangle(0, 0, 0, 0));
        }

        bkImg = new Bitmap(235, 185);
        switch (_dispType)
        {
        case 0:
            _bmp    = SQK_Ui.Calendar.calendarResource.cal_1;
            bkImg   = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            str_X   = 15;
            str_Y   = 62;
            skip_X  = 33;
            skip_Y  = 21;
            head_X  = 80;
            head_Y  = 7;
            ImgSize = new Size(245, 200);
            cut_X   = 5;
            cut_Y   = 5;
            fnt     = new Font("微软雅黑", 10, FontStyle.Bold);
            m_set   = new int[4, 4] {
                { 5, 21, 11, 21 }, { 28, 38, 11, 21 }, { 194, 204, 11, 21 }, { 213, 228, 11, 21 }
            };
            break;

        case 1:
            _bmp    = SQK_Ui.Calendar.calendarResource.cal_2;
            bkImg   = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            str_X   = 15;
            str_Y   = 62;
            skip_X  = 33;
            skip_Y  = 21;
            head_X  = 80;
            head_Y  = 7;
            ImgSize = new Size(245, 200);
            cut_X   = 5;
            cut_Y   = 5;
            fnt     = new Font("微软雅黑", 10, FontStyle.Bold);
            m_set   = new int[4, 4] {
                { 5, 21, 11, 21 }, { 28, 38, 11, 21 }, { 194, 204, 11, 21 }, { 213, 228, 11, 21 }
            };
            break;

        case 2:
            _bmp    = SQK_Ui.Calendar.calendarResource.cal_3;
            bkImg   = _bmp.Clone(new Rectangle(8, 8, 272, 284), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            str_X   = 9;
            str_Y   = 58;
            skip_X  = 40;
            skip_Y  = 40;
            head_X  = 95;
            head_Y  = 5;
            ImgSize = new Size(288, 300);
            cut_X   = 8;
            cut_Y   = 8;
            fnt     = new Font("微软雅黑", 14, FontStyle.Bold);
            m_set   = new int[4, 4] {
                { 8, 24, 5, 21 }, { 48, 58, 5, 21 }, { 211, 221, 5, 21 }, { 246, 261, 5, 21 }
            };
            break;

        default:
            _bmp    = SQK_Ui.Calendar.calendarResource.cal_1;
            bkImg   = _bmp.Clone(new Rectangle(5, 5, 235, 185), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
            str_X   = 15;
            str_Y   = 62;
            skip_X  = 33;
            skip_Y  = 21;
            head_X  = 80;
            head_Y  = 7;
            ImgSize = new Size(245, 200);
            cut_X   = 5;
            cut_Y   = 5;
            fnt     = new Font("微软雅黑", 10, FontStyle.Bold);
            break;
        }
        ud.DrawString(bkImg, dy + "年" + dm + "月", fnt, Color.White, new Rectangle(head_X, head_Y, 120, 20));
        for (int i = 0; i < 6; i++)
        {
            for (int u = 0; u < 7; u++)
            {
                if (_dayList[i * 7 + u].day < 10)
                {
                    ud.DrawString(bkImg, _dayList[i * 7 + u].day.ToString(), fnt, _dayList[i * 7 + u].dcolor, new Rectangle(str_X + u * skip_X, str_Y + i * skip_Y, 25, 20));
                    _dayList[i * 7 + u].mouseRect = new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 22, 18);
                }
                else
                {
                    ud.DrawString(bkImg, _dayList[i * 7 + u].day.ToString(), fnt, _dayList[i * 7 + u].dcolor, new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 25, 20));
                    _dayList[i * 7 + u].mouseRect = new Rectangle(str_X - 5 + u * skip_X, str_Y + i * skip_Y, 22, 18);
                }
            }
        }
        if (!_show)
        {
            calenForm = new AlphaForm();
            calenForm.ShowInTaskbar   = false;
            calenForm.ShowIcon        = false;
            calenForm.FormBorderStyle = FormBorderStyle.None;
            calenForm.StartPosition   = FormStartPosition.Manual;
            calenForm.Animation       = AlphaForm.Animations.None;
            calenForm.Opacity         = _transparency;
            calenForm.TopMost         = true;
            calenForm.Size            = new Size(_bmp.Width, _bmp.Height);
            calenForm.Location        = _location;
            calenForm.窗体图像            = _bmp;

            pb.Size        = ImgSize;
            pb.Location    = new Point(cut_X, cut_Y);
            pb.Image       = bkImg;
            pb.MouseMove  += new MouseEventHandler(_MouseMove);
            pb.MouseClick += new MouseEventHandler(_MouseClick);
            pb.MouseDown  += new MouseEventHandler(_MouseDown);
            calenForm.Controls.Add(pb);

            calenForm.Show();
            _show = true;
        }
        else
        {
            pb.Image = bkImg;
            calenForm.SetOpacity(_transparency * 255);
        }
    }
Пример #5
0
    public void InitializeDropList(Control _obj, int _type, int _width, Point _location, int _transparency, bool _readonly, Color _inputColor)
    {
        Obj          = _obj;
        location     = _location;
        transparency = _transparency;

        /*
         * m_set[0] = drop left-width;      m_set[1] = drop right-width
         * m_set[2] = list width-Adjust;    m_set[3] = list locationY-Adjust;
         * m_set[4] = list add panel size offset
         * m_set[5] = inputbox offset
         * m_set[6] = listitem offsetY
         * m_set[7] = form type
         */
        switch (_type)
        {
        case 0:
            bmp_drop = SQK_Ui.dropList.DropListResource.drop1;
            m_set    = new int[8] {
                10, 41, 3, -8, 12, 10, 0, 60
            };
            dropClick = new Rectangle(m_set[0] + _width + 3, 5, m_set[1] - 9, bmp_drop.Height - 12);
            break;

        case 1:
            bmp_drop = SQK_Ui.dropList.DropListResource.drop2;
            m_set    = new int[8] {
                20, 37, 3, 0, 12, 5, 0, 61
            };
            dropClick = new Rectangle(m_set[0] + _width + 3, 5, m_set[1] - 9, bmp_drop.Height - 12);
            break;

        case 2:
            bmp_drop = SQK_Ui.dropList.DropListResource.drop3;
            m_set    = new int[8] {
                20, 72, 0, -13, 20, 12, 0, 62
            };
            dropClick = new Rectangle(m_set[0] + _width + 3, 5, m_set[1] - 9, bmp_drop.Height - 12);
            break;

        case 3:
            bmp_drop = SQK_Ui.dropList.DropListResource.drop4;
            m_set    = new int[8] {
                6, 46, 3, 3, 15, 8, 3, 63
            };
            dropClick = new Rectangle(m_set[0] + _width + 3, 5, m_set[1] - 9, bmp_drop.Height - 12);
            break;

        default:
            bmp_drop = SQK_Ui.dropList.DropListResource.drop1;
            m_set    = new int[8] {
                10, 41, 3, -8, 12, 10, 0, 61
            };
            dropClick = new Rectangle(m_set[0] + _width + 3, 5, m_set[1] - 9, bmp_drop.Height - 12);
            break;
        }

        Bitmap drop_left   = bmp_drop.Clone(new Rectangle(0, 0, m_set[0], bmp_drop.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
        Bitmap drop_middle = bmp_drop.Clone(new Rectangle(m_set[0], 0, 1, bmp_drop.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
        Bitmap drop_right  = bmp_drop.Clone(new Rectangle(bmp_drop.Width - m_set[1], 0, m_set[1], bmp_drop.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);


        UiControlsMethod.PanelEx pL = new UiControlsMethod.PanelEx();
        int list_height             = 0;

        for (int i = 0; i < _dropItemList.Count; i++)
        {
            _dropItemList[i].dropItemPanel.Location = new Point(0, list_height);
            _dropItemList[i].dropItemPanel.Tag      = i;

            pL.Controls.Add(_dropItemList[i].dropItemPanel);
            list_height += _dropItemList[i].dropItemPanel.Height;
        }
        pL.Size     = new Size(m_set[0] + _width + m_set[1] + m_set[2] - m_set[4] * 2, list_height);
        pL.Location = new Point(m_set[4], m_set[4] + m_set[6]);

        bmp_list                 = new CutPixelAlphaImage().CutAlphaFormImage(m_set[7], m_set[0] + _width + m_set[1] + m_set[2], list_height + m_set[4] * 2); //form type , in CutPixelAlphaImage.cs
        listForm                 = new AlphaForm();
        listForm.窗体图像            = bmp_list;
        listForm.ShowInTaskbar   = false;
        listForm.ShowIcon        = false;
        listForm.FormBorderStyle = FormBorderStyle.None;
        listForm.StartPosition   = FormStartPosition.Manual;
        listForm.Animation       = AlphaForm.Animations.None;
        listForm.TopMost         = true;
        listForm.Size            = new Size(bmp_list.Width + m_set[1], bmp_list.Height);
        Point flist = Obj.PointToScreen(new Point(location.X, location.Y));

        listForm.Location = new Point(flist.X, flist.Y + bmp_drop.Height + m_set[3]);
        listForm.SetOpacity(0);
        listForm.Controls.Add(pL);
        listForm.Show();

        Control mainObj = Obj;

        while (true)
        {
            if (mainObj is Form)
            {
                break;
            }
            else
            {
                mainObj = mainObj.Parent;
            }
        }

        Bitmap   dropImage = new Bitmap(m_set[0] + _width + m_set[1], bmp_drop.Height);
        Graphics gdrop     = Graphics.FromImage(dropImage);

        gdrop.DrawImage(drop_left, 0, 0, drop_left.Width, drop_left.Height);
        for (int i = 0; i < _width; i++)
        {
            gdrop.DrawImage(drop_middle, m_set[0] + i, 0, drop_middle.Width, drop_middle.Height);
        }
        gdrop.DrawImage(drop_right, m_set[0] + _width, 0, drop_right.Width, drop_right.Height);

        _drop.BackColor  = Color.Transparent;
        _drop.Size       = new Size(dropImage.Width + m_set[2], dropImage.Height);
        _drop.Location   = _location;
        _drop.Image      = dropImage;
        _drop.MouseMove += new MouseEventHandler(_dropMouseMove);
        _drop.Click     += new EventHandler(_dropClick);

        _uInput.inputBox(_drop, new Size(_width, bmp_drop.Height - m_set[5] * 2), new Point(m_set[0], m_set[5]), _fnt, _inputColor, null, 0, true, 120, Color.White, 1, 1, _readonly, _InputClick);

        mainObj.LocationChanged += new EventHandler(Obj_LocationChanged);
        _obj.Controls.Add(_drop);
    }