示例#1
0
    public void _putForm(int _first, int _second, int _putSpeed, int rotorType)
    {
        firstForm  = _formList[_first].listForm;
        secondForm = _formList[_second].listForm;

        firstBmp  = _formList[_first].listImg;
        secondBmp = _formList[_second].listImg;

        Bitmap clone_firstBmp  = firstBmp.Clone(new Rectangle(0, 0, firstBmp.Width, firstBmp.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
        Bitmap clone_secondBmp = secondBmp.Clone(new Rectangle(0, 0, secondBmp.Width, secondBmp.Height), System.Drawing.Imaging.PixelFormat.Format32bppPArgb);

        if (rotorType == 0)
        {
            clone_secondBmp.RotateFlip(RotateFlipType.RotateNoneFlipX);
        }
        if (rotorType == 1)
        {
            clone_secondBmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
        }

        putForm = new AnimationPutForm();
        putForm.AnimationStart = true;
        putForm.AnimationBegin = false;
        putForm.PutForm_Initialize(firstForm.Location, clone_firstBmp, clone_secondBmp, transparency, _putSpeed, rotorType);

        Thread animationStat = new Thread(getAnimationPutState);

        animationStat.Start();
    }
 private void addFormInfo(AlphaForm form, Bitmap img)
 {
     _formList.Add(new formList
     {
         listForm = form,
         listImg  = img
     });
 }
示例#3
0
    public static void rotationForm(AlphaForm _firstObj, AlphaForm _secondObj, int _first, int _second, int _x, int _y, int _width, int _height, double _transparency, int _speed, int _rotorType)
    {
        putAlphaForm _rotationForm = new putAlphaForm();

        _rotationForm._putFormBegin(_x, _y, _width, _height, _transparency);
        _rotationForm._getPutFormInfo(_firstObj);
        _rotationForm._getPutFormInfo(_secondObj);
        _rotationForm._putForm(_first, _second, _speed, _rotorType);
    }
示例#4
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();
    }
    public void Initialize3dPut(AlphaForm _firstObj, AlphaForm _secondObj, Point origin, int _first, int _second, int _type)
    {
        _getPutFormInfo(_firstObj);
        _getPutFormInfo(_secondObj);
        Bitmap firstBmp  = _formList[_first].listImg;
        Bitmap secondBmp = _formList[_second].listImg;

        _w   = _formList[_first].listImg.Width;
        _h   = _formList[_first].listImg.Height;
        type = _type;
        cube = new Cube(firstBmp.Width, firstBmp.Height, 1);
        for (int i = 0; i < 90; i++)
        {
            if (_type == 0)
            {
                cube.RotateY = i * 2;
            }
            if (_type == 1)
            {
                cube.RotateX = i * 2;
            }
            cube.calcCube(origin);
            corners[i, 0] = cube.d;
            corners[i, 1] = cube.a;
            corners[i, 2] = cube.c;
            corners[i, 3] = cube.b;
            int t = 0;
            if (_type == 0)
            {
                if ((corners[i, 0].X - corners[i, 1].X) <= 1)
                {
                    if (corners[i, 0].Y < corners[i, 1].Y)
                    {
                        t = corners[i, 0].Y;
                    }
                    else
                    {
                        t = corners[i, 1].Y;
                    }
                    set[i] = new PointF(corners[i, 0].X + _w / 2, t + _h / 2);
                }
                else
                {
                    if (corners[i, 1].Y < corners[i, 0].Y)
                    {
                        t = corners[i, 1].Y;
                    }
                    else
                    {
                        t = corners[i, 0].Y;
                    }
                    set[i] = new PointF(corners[i, 1].X + _w / 2, t + _h / 2);
                }
            }
            if (_type == 1)
            {
                if ((corners[i, 0].Y - corners[i, 2].Y) <= 1)
                {
                    if (corners[i, 0].Y < corners[i, 2].Y)
                    {
                        t = corners[i, 0].Y;
                    }
                    else
                    {
                        t = corners[i, 2].Y;
                    }
                    set[i] = new PointF(corners[i, 0].X + _w / 2, t + _h / 2);
                }
                else
                {
                    if (corners[i, 2].Y < corners[i, 0].Y)
                    {
                        t = corners[i, 2].Y;
                    }
                    else
                    {
                        t = corners[i, 0].Y;
                    }
                    set[i] = new PointF(corners[i, 0].X + _w / 2, t + _h / 2);
                }
            }
            filters[i] = new FreeTransform();
            if (i < 45)
            {
                filters[i].Bitmap = firstBmp;
            }
            else
            {
                filters[i].Bitmap = secondBmp;
            }
        }
        Parallel.For(0, 90, (i) => { updateImage(i); });
    }
 public void _getPutFormInfo(AlphaForm _form)
 {
     addFormInfo(_form, UiControlsMethod.ControlMethods.getFormControlToBmp(_form, _form.BlendedBackground));
 }
示例#7
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);
        }
    }
示例#8
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);
    }
示例#9
0
        //Constructs and initializes all child controls of this dialog box.
        private void InitializeAdditionalComponents()
        {
            //JsonSettings Step 4: Load
            parentFormSettings = JsonSettings.Load <FormSettings>();            //relative path to executing file.


            // horizontal flip yes/no (yes is default)
            flipHCheckBox.Checked = (parentFormSettings.flipH == 1) ? true : false;

            // crop horizontal yes/no (no is default)
            cropAutoCheckBox.Checked = (parentFormSettings.cropAuto == 1) ? true : false;



            // use transparency yes/no (yes is default)
            useTransparencyCheckBox.Checked = (parentFormSettings.useTransparency == 1) ? true : false;

            // resolution default
            resolutionLabel.Text = "          n/a        ";


            //
            // videoSourcePlayer1
            //
            videoSourcePlayer1             = new VideoSourcePlayer();
            videoSourcePlayer1.BorderColor = System.Drawing.Color.Transparent;
            videoSourcePlayer1.Location    = new System.Drawing.Point(10, 31);
            videoSourcePlayer1.Name        = "videoSourcePlayer1";
            videoSourcePlayer1.Size        = new System.Drawing.Size(177, 100);
            videoSourcePlayer1.TabIndex    = 6;
            videoSourcePlayer1.VideoSource = null;
            videoSourcePlayer1.NewFrame   += new AForge.Controls.VideoSourcePlayer.NewFrameHandler(videoSourcePlayer1_NewFrame);
            Controls.Add(videoSourcePlayer1);


            // alphaForm will contain the per-pixel-alpha dib
            alphaForm = new AlphaForm();
            // place alphaForm to the last position, if it is not out of screen dimension
            var myScreen = Screen.FromControl(this);

            if (((parentFormSettings.framePositionX + parentFormSettings.frameSizeWidth) > myScreen.Bounds.Width) ||
                ((parentFormSettings.framePositionY + parentFormSettings.frameSizeHeight) > myScreen.Bounds.Height))
            {
                //reset location if it is out of screen
                parentFormSettings.framePositionX = 100;
                parentFormSettings.framePositionY = 100;
            }
            alphaForm.SetDesktopLocation(parentFormSettings.framePositionX, parentFormSettings.framePositionY);
            alphaForm.SetTargetFrameSizeAndCrop(frameSize);
            alphaForm.setParentForm(this);
            alphaForm.Show();


            frameSize   = new Size(parentFormSettings.frameSizeWidth, parentFormSettings.frameSizeHeight);
            aspectRatio = (float)frameSize.Width / (float)frameSize.Height;

            noTransparencyCounter = 0;

            //InitializeComponent();

            quitProgramDelegate = new QuitProgramDelegate(QuitProgramMethod);


            // show device list
            try
            {
                // enumerate video devices
                videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                int preferredCam = 0;
                if (videoDevices.Count == 0)
                {
                    throw new Exception();
                }
                for (int i = 0, n = videoDevices.Count; i < n; i++)
                {
                    //string cameraName = i + " : " + videoDevices[i - 1].Name;

                    camera1Combo.Items.Add(videoDevices[i].Name);
                    //get last cam by name
                    if (videoDevices[i].Name.Equals(parentFormSettings.lastCam))
                    {
                        preferredCam = i;
                    }
                }
                camera1Combo.SelectedIndex = preferredCam;
            }
            catch
            {
                startButton.Enabled = false;
                camera1Combo.Items.Add("No cameras found");
                camera1Combo.SelectedIndex = 0;
                camera1Combo.Enabled       = false;
            }

            this.Text = this.Text + " Build: " + Application.ProductVersion;
        }        //initializeComponents2