Пример #1
0
        //public void ExternAddNewObject(Designer designer, ItemRectangle drawitem)
        //{
        //    AddNewObject(designer, drawitem);
        //}
        public override void OnMouseDown(Designer designer, MouseEventArgs e)
        {
            AddNewObject(designer, new ItemRectangle(e.X, e.Y, 1, 1));
            x           = e.X;
            y           = e.Y;
            startpointX = e.X;
            startpointY = e.Y;
            Touch t = Touch.GetSingle();

            t.PIC_GBoxShow(Main_Form.SelectType);
        }
Пример #2
0
        public override void OnMouseMove(Designer designer, MouseEventArgs e)
        {
            //designer.Cursor = ToolCursor;
            if (e.Button == MouseButtons.Left)
            {
                /*根据鼠标当前的坐标点与起始坐标点
                 * 确定移动移动的方向获取不同的手柄
                 * 1--2--3
                 *|     |
                 * 4     5
                 *|     |
                 * 6--7--8
                 */

                int x1, y1;
                designer.Cursor = Cursors.Cross;
                x1 = (e.X > designer.Width) ? designer.Width:e.X;
                y1 = (e.Y > designer.Height) ? designer.Height : e.Y;
                if (x1 < 0)
                {
                    x1 = 0;
                }
                if (y1 < 0)
                {
                    y1 = 0;
                }
                Point point  = new Point(x1, y1);
                int   handle = 8;
                if (x > e.X && y > e.Y)
                {
                    handle = 1;
                }
                else if (x > e.X && y < e.Y)
                {
                    handle = 6;
                }
                else if (x < e.X && y < e.Y)
                {
                    handle = 8;
                }
                else if (x < e.X && y > e.Y)
                {
                    handle = 3;
                }
                designer.Items[0].MoveHandleTo(point, handle);
                designer.Refresh();
            }
        }
Пример #3
0
 public override void OnMouseUp(Designer designer, MouseEventArgs e)
 {
     if (selectmode == SelectionMode.NetSelection)
     {
         designer.Items.SelectInRectangle(designer.SelectRectangle);
         selectmode = SelectionMode.None;
         designer.IsDrawSelectRectangle = false;
     }
     //如果是改变大小则结束改变
     if (resizeObject != null)
     {
         resizeObject.Normalize();
         resizeObject = null;
     }
     designer.Capture = false;
     designer.Refresh();
 }
Пример #4
0
        public override void OnMouseDown(Designer designer, MouseEventArgs e)
        {
            selectmode = SelectionMode.None;
            Point point       = new Point(e.X, e.Y);
            int   selectCount = designer.Items.SelectionCount;

            //如果光标在后柄上,则模式为改变对像的大小
            for (int i = 0; i < selectCount; i++)
            {
                //找到要修改的对像
                ItemBase item = designer.Items.GetSelectItem(i);
                if (item == null)
                {
                    continue;
                }
                int handleNumber = item.HitTest(point);
                if (handleNumber > 0)
                {
                    selectmode   = SelectionMode.Size;
                    resizeHandle = handleNumber;
                    resizeObject = item;
                    designer.Items.UnSelectAll();
                    resizeObject.Selected = true;
                    break;
                }
            }

            //如果没有选中对像手柄,则检查是否在对像上
            if (selectmode == SelectionMode.None)
            {
                int      itemCount = designer.Items.Count;
                ItemBase item      = null;
                for (int i = 0; i < itemCount; i++)
                {
                    if (designer.Items[i].visibility == true)
                    {
                        if (designer.Items[i].HitTest(point) == 0)
                        {
                            item       = designer.Items[i];
                            selectmode = SelectionMode.Move;
                            designer.Items.UnSelectAll();
                            item.Selected        = true;
                            Main_Form.SelectType = item.ControlType;
                            switch (Main_Form.SelectType)
                            {
                            case PIC_Obj.data_display:
                            case PIC_Obj.icon_display:
                                Main_Form.VarType = Main_Form.myGraphicsType.other;
                                break;

                            case PIC_Obj.basictouch:
                            case PIC_Obj.datainput:
                            case PIC_Obj.keyreturn:
                            case PIC_Obj.menu_display:
                            case PIC_Obj.increadj:
                            case PIC_Obj.sliadj:
                            case PIC_Obj.GBK:
                            case PIC_Obj.ASCII:
                            case PIC_Obj.TouchState:
                            case PIC_Obj.RTC_Set:
                                Main_Form.VarType = Main_Form.myGraphicsType.touch;
                                break;

                            case PIC_Obj.artfont:
                            case PIC_Obj.slidis:
                            case PIC_Obj.iconrota:
                            case PIC_Obj.clockdisplay:
                            case PIC_Obj.text_dispaly:
                            case PIC_Obj.rtc_display:
                            case PIC_Obj.QR_display:
                            case PIC_Obj.aniicon_display:
                            case PIC_Obj.BasicGra:
                                Main_Form.VarType = Main_Form.myGraphicsType.variable;
                                break;
                            }
                            designer.Cursor = Cursors.SizeAll;
                            break;
                        }
                    }
                }
            }
            // 如果没有选中对像,则是进行区域选择
            if (selectmode == SelectionMode.None)
            {
                selectmode = SelectionMode.NetSelection;
                designer.Items.UnSelectAll();
                designer.IsDrawSelectRectangle = true;
            }
            lastPoint.X              = startPoint.X = e.X;
            lastPoint.Y              = startPoint.Y = e.Y;
            designer.Capture         = true;
            designer.SelectRectangle = GetNormalizedRectangle(startPoint.X, startPoint.Y, lastPoint.X, lastPoint.Y);
            //designer.Refresh();
        }
Пример #5
0
        public override void OnMouseMove(Designer designer, MouseEventArgs e)
        {
            int x1, y1;

            if (e.X > designer.Width)
            {
                x1 = designer.Width;
            }
            else if (e.X < 0)
            {
                x1 = 0;
            }
            else
            {
                x1 = e.X;
            }
            if (e.Y > designer.Height)
            {
                y1 = designer.Height;
            }
            else if (e.Y < 0)
            {
                y1 = 0;
            }

            else
            {
                y1 = e.Y;
            }

            //Point point = new Point(e.X, e.Y);
            Point point = new Point(x1, y1);

            //如果是移动鼠标,改变鼠标的指针
            if (e.Button == MouseButtons.None)
            {
                Cursor cursor = Cursors.Default;

                for (int i = 0; i < designer.Items.Count; i++)
                {
                    int n = designer.Items[i].HitTest(point);
                    if (n > 0)
                    {
                        cursor = designer.Items[i].GetHandleCursor(n);
                        break;
                    }
                }
                designer.Cursor = cursor;
            }
            if (e.Button == MouseButtons.Left)
            {
                int dx = e.X - lastPoint.X;
                int dy = e.Y - lastPoint.Y;
                //Console.WriteLine("dx = {0},dy = {1}",dx,dy);
                lastPoint.X = e.X;
                lastPoint.Y = e.Y;

                //改变对像的尺寸
                if (selectmode == SelectionMode.Size)
                {
                    resizeObject.MoveHandleTo(point, resizeHandle);
                    //designer.ChangeFlage = true;
                    designer.Refresh();
                    //designer.SelectedItem(resizeObject);
                }
                //移动选中的对像
                if (selectmode == SelectionMode.Move)
                {
                    int n = designer.Items.SelectionCount;
                    for (int i = 0; i < n; i++)
                    {
                        designer.Items.GetSelectItem(i).Move(dx, dy, designer);
                    }

                    designer.Cursor = Cursors.SizeAll;
                    //designer.ChangeFlage = true;
                    designer.Refresh();
                }
                // 区域选择
                if (selectmode == SelectionMode.NetSelection)
                {
                    designer.SelectRectangle = GetNormalizedRectangle(startPoint.X, startPoint.Y, lastPoint.X, lastPoint.Y);
                    //Console.WriteLine("s.X = {0},s.Y = {1},l.X = {2},l.Y = {3}", startPoint.X, startPoint.Y, lastPoint.X, lastPoint.Y);
                    designer.Refresh();
                }
            }
        }
Пример #6
0
 public virtual void OnMouseUp(Designer designer, MouseEventArgs e)
 {
 }
Пример #7
0
        protected void AddNewObject(Designer designer, ItemRectangle drawitem)
        {
            switch (Main_Form.VarType)
            {
            case Main_Form.myGraphicsType.touch:
                drawitem.FillColor = Color.FromArgb(60, Color.Yellow);
                break;

            case Main_Form.myGraphicsType.variable:
                drawitem.FillColor = Color.FromArgb(60, Color.SkyBlue);
                break;

            case Main_Form.myGraphicsType.other:
                drawitem.FillColor = Color.FromArgb(60, Color.Red);
                break;

            case Main_Form.myGraphicsType.AreaSetting:
                drawitem.FillColor = Color.FromArgb(60, Color.PaleGreen);
                break;
            }
            drawitem.presentpage_num = Main_Form.presentpage_num;//绑定图元所在页面
            drawitem.ControlType     = Main_Form.SelectType;
            switch (drawitem.ControlType)
            {
                #region case basictouch
            case PIC_Obj.basictouch:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "Base_Touch";
                drawitem.BaseTouchInfo.ButtonEffect_Image = null;
                drawitem.BaseTouchInfo.Pic_On             = -1;
                drawitem.BaseTouchInfo.PageChange_Image   = null;
                drawitem.BaseTouchInfo.Pic_Next           = -1;
                drawitem.BaseTouchInfo.TP_Code            = 0x00;
                break;

                #endregion
                #region case data_display
            case PIC_Obj.data_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Data_Display";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.DataVarInfo.Display_Color  = Color.Black;
                drawitem.DataVarInfo.Lib_ID         = 0x00;
                drawitem.DataVarInfo.Font_Size      = 8;
                drawitem.DataVarInfo.Font_Align     = 0;
                drawitem.DataVarInfo.Var_Type       = 0;
                drawitem.DataVarInfo.Integer_Length = 8;

                drawitem.DataVarInfo.String_Uint   = "";
                drawitem.DataVarInfo.Initial_Value = 0;
                break;

                #endregion
                #region case icon_display
            case PIC_Obj.icon_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Icon";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.IconVarInformation.Iconfileselect        = -1;
                drawitem.IconVarInformation.Icon_FileName         = string.Empty;
                drawitem.IconVarInformation.V_Max                 = 0;
                drawitem.IconVarInformation.Icon_MaxPic           = null;
                drawitem.IconVarInformation.Icon_IsMaxTransparent = false;
                drawitem.IconVarInformation.Icon_Max              = -1;
                drawitem.IconVarInformation.V_Min                 = 0;
                drawitem.IconVarInformation.Icon_MinPic           = null;
                drawitem.IconVarInformation.Icon_IsMinTransparent = false;
                drawitem.IconVarInformation.Icon_Min              = -1;
                drawitem.IconVarInformation.InitialValue          = 0;
                break;

                #endregion
                #region case text_dispaly
            case PIC_Obj.text_dispaly:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Text_Display";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.TextDisplayInformation.Display_Color     = Color.Black;
                drawitem.TextDisplayInformation.Encode_Mode       = 0;
                drawitem.TextDisplayInformation.IsCharacternotadj = false;
                drawitem.TextDisplayInformation.initial_value     = string.Empty;
                drawitem.TextDisplayInformation.Font_X_Dots       = 16;
                drawitem.TextDisplayInformation.Font_Y_Dots       = 16;
                break;

                #endregion
                #region case rtc_display
            case PIC_Obj.rtc_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "RTC_Display";
                drawitem.SP          = 0XFFFF;
                drawitem.RTCDisplayInformatin.Font_X_Dots   = 16;
                drawitem.RTCDisplayInformatin.Display_Color = Color.Black;
                drawitem.RTCDisplayInformatin.String_Code   = "Y-M-D H:Q:S W";
                break;

                #endregion
                #region case datainput
            case PIC_Obj.datainput:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "DataInput";
                drawitem.DataInputInformation.Pic_ID              = (UInt16)Main_Form.presentpage_num;
                drawitem.DataInputInformation.IsDataAutoUpLoad    = false;
                drawitem.DataInputInformation.Pic_On              = -1;
                drawitem.DataInputInformation.ButtonEffectPic     = null;
                drawitem.DataInputInformation.Pic_Next            = -1;
                drawitem.DataInputInformation.ButtonChangePagePic = null;
                drawitem.VP = 0x0000;
                drawitem.DataInputInformation.Display_Color = Color.Black;
                drawitem.DataInputInformation.Lib_ID        = 0;
                drawitem.DataInputInformation.Font_Hor      = 16;
                drawitem.DataInputInformation.N_Int         = 8;
                drawitem.DataInputInformation.PIC_KB        = -1;
                drawitem.DataInputInformation.Return_VP     = 0x0000;
                break;

                #endregion
                #region case keyreturn
            case PIC_Obj.keyreturn:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "Key_Return";
                drawitem.KeyReturnInformation.Pic_ID                 = (UInt16)Main_Form.presentpage_num;
                drawitem.KeyReturnInformation.Pic_On                 = -1;
                drawitem.KeyReturnInformation.Pic_Next               = -1;
                drawitem.KeyReturnInformation.Key_Code               = 0x0000;
                drawitem.KeyReturnInformation.Touch_Key_Code         = 0xFFFF;
                drawitem.KeyReturnInformation.Touch_KeyPressing_Code = 0xFFFF;
                drawitem.VP = 0x0000;
                drawitem.KeyReturnInformation.VP_Mode = 0x0;
                break;

                #endregion
                #region case QR_code
            case PIC_Obj.QR_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "QR_Code";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.QRCodeInformation.Unit_Pixels = 4;
                break;

                #endregion
                #region case popupmenu
            case PIC_Obj.menu_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "PopupMenu";
                drawitem.PopupMenuInformation.Pic_ID           = (UInt16)Main_Form.presentpage_num;
                drawitem.PopupMenuInformation.IsDataAutoUpLoad = false;
                drawitem.PopupMenuInformation.Pic_On           = -1;
                drawitem.PopupMenuInformation.ButtonEffectPic  = null;
                drawitem.VP = 0x0000;
                drawitem.PopupMenuInformation.VP_Mode         = 0x00;
                drawitem.PopupMenuInformation.Pic_Menu        = -1;
                drawitem.PopupMenuInformation.PopupMenuPic    = null;
                drawitem.PopupMenuInformation.AREA_Menu_Xs    = 0;
                drawitem.PopupMenuInformation.AREA_Menu_Ys    = 0;
                drawitem.PopupMenuInformation.AREA_Menu_Xe    = 0;
                drawitem.PopupMenuInformation.AREA_Menu_Ye    = 0;
                drawitem.PopupMenuInformation.Menu_Position_X = 0;
                drawitem.PopupMenuInformation.Menu_Position_Y = 0;
                break;

                #endregion
                #region case ActionIcon
            case PIC_Obj.aniicon_display:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "ActionIcon";
                drawitem.SP          = 0XFFFF;
                drawitem.VP          = 0x0000;
                drawitem.ActionIconInforamtion.Iconfileselect = -1;
                drawitem.ActionIconInforamtion.Icon_FileName  = string.Empty;
                drawitem.ActionIconInforamtion.V_Stop         = 0;
                drawitem.ActionIconInforamtion.V_Start        = 0;
                drawitem.ActionIconInforamtion.Icon_Start     = 0;
                drawitem.ActionIconInforamtion.Icon_Stop      = 0;
                drawitem.ActionIconInforamtion.Icon_End       = 0;
                drawitem.ActionIconInforamtion.Mode           = 0;
                drawitem.ActionIconInforamtion.InitlizValue   = 0;
                break;

                #endregion
                #region case IncreaseAdj
            case PIC_Obj.increadj:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "Incremental Adjustment";
                drawitem.IncreaseAdjInformation.Pic_ID = (UInt16)Main_Form.presentpage_num;
                drawitem.IncreaseAdjInformation.Pic_On = -1;
                break;

                #endregion
                #region case SlideAdj
            case PIC_Obj.sliadj:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "Slider Adjustment";
                drawitem.VP          = 0x0000;
                break;

                #endregion
                #region case ArtFont
            case PIC_Obj.artfont:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Art Word";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.ArtFontInformation.Icon_SelectIndex = -1;
                drawitem.ArtFontInformation.Icon_FileName    = string.Empty;
                drawitem.ArtFontInformation.Integer_Length   = 8;
                break;

                #endregion
                #region case SlideDisplay
            case PIC_Obj.slidis:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Slider Display";
                drawitem.SP          = 0XFFFF;
                drawitem.VP          = 0x0000;
                drawitem.SlideDisplayInformation.Icon_SelectIndex = -1;
                drawitem.SlideDisplayInformation.Icon_FileName    = string.Empty;
                break;

                #endregion
                #region case IconRotation
            case PIC_Obj.iconrota:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Icon Rotation";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.IconRotationInformation.Icon_SelectIndex = -1;
                drawitem.IconRotationInformation.Icon_FileName    = string.Empty;
                break;

                #endregion
                #region case ClockDisplay
            case PIC_Obj.clockdisplay:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "Clock Display";
                drawitem.SP          = 0xFFFF;
                drawitem.ClockDisplayInformation.Icon_SelectIndex = -1;
                drawitem.ClockDisplayInformation.Icon_FileName    = string.Empty;
                break;

            case PIC_Obj.GBK:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "GBK";
                drawitem.GBKInformation.IsDataAutoUpLoad = 0xFE;
                drawitem.GBKInformation.Pic_Next         = -1;
                drawitem.GBKInformation.Pic_On           = -1;
                drawitem.GBKInformation.Color1           = Color.Black;
                drawitem.GBKInformation.Color2           = Color.Black;
                drawitem.GBKInformation.Font_Scale1      = 16;
                drawitem.GBKInformation.Font_Scale2      = 16;
                drawitem.GBKInformation.PIC_KB           = -1;
                drawitem.GBKInformation.Scan_Return_Mode = 0xAA;
                break;

                #endregion
                #region case ASCII
            case PIC_Obj.ASCII:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "ASCII";
                drawitem.ASCIIInformation.IsDataAutoUpLoad = 0xFE;
                drawitem.ASCIIInformation.Pic_Next         = -1;
                drawitem.ASCIIInformation.Pic_On           = -1;
                drawitem.ASCIIInformation.Color            = Color.Black;
                drawitem.ASCIIInformation.Font_Hor         = 8;
                drawitem.ASCIIInformation.Font_Ver         = 16;
                drawitem.ASCIIInformation.PIC_KB           = -1;
                drawitem.ASCIIInformation.Scan_Return_Mode = 0xAA;
                break;

                #endregion
                #region case TouchState
            case PIC_Obj.TouchState:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "按压数据同步返回";
                drawitem.TouchStateInformation.Pic_Next = -1;
                drawitem.TouchStateInformation.Pic_On   = -1;
                drawitem.TouchStateInformation.LEN1     = 2;
                drawitem.TouchStateInformation.LEN2     = 2;
                drawitem.TouchStateInformation.LEN3     = 2;
                break;

                #endregion
                #region case RTCset
            case PIC_Obj.RTC_Set:
                drawitem.touchvar    = ItemBase.TouchOrVar.touch;
                drawitem.Name_define = "RTC 设置";
                drawitem.RTCsetInformation.TP_Code  = 0xFE04;
                drawitem.RTCsetInformation.Pic_On   = -1;
                drawitem.RTCsetInformation.PIC_KB   = -1;
                drawitem.RTCsetInformation.Color    = Color.Black;
                drawitem.RTCsetInformation.Font_Hor = 16;
                break;

                #endregion
                #region case BasicGra
            case PIC_Obj.BasicGra:
                drawitem.touchvar    = ItemBase.TouchOrVar.varable;
                drawitem.Name_define = "基本图像设置";
                drawitem.SP          = 0xFFFF;
                drawitem.VP          = 0x0000;
                drawitem.BasicGraInformation.Dash_Set_1 = 1;
                drawitem.BasicGraInformation.Dash_Set_2 = 1;
                drawitem.BasicGraInformation.Dash_Set_3 = 1;
                drawitem.BasicGraInformation.Dash_Set_4 = 1;
                break;
                #endregion
            }
            //在设计器对像列表中加入新的对像
            designer.Items.Add(drawitem);
            //将原来选中的对像设计为未选中
            designer.Items.UnSelectAll();
            //设置新添加的对像为选中状态
            drawitem.Selected = true;

            designer.Capture = true;
            designer.Refresh();
        }
Пример #8
0
 public override void OnMouseUp(Designer designer, MouseEventArgs e)
 {
 }
Пример #9
0
 /// <summary>
 /// 将对像移动到哪个点上
 /// </summary>
 /// <param name="deltaX">X坐标点</param>
 /// <param name="deltaY">Y坐标点</param>
 public virtual void Move(int deltaX, int deltaY, Designer designer)
 {
 }