Example #1
0
        private unsafe byte valueToTouchPos(ref InfoObject obj, InfoSliderParam* param, byte ID)
        {
            ushort num;
            byte num2;
            byte num3;
            if (param->Mode > 0)
            {
                num2 = (byte)(param->CursorHeight / 2);
                num3 = (byte)(param->CursorHeight - num2);

                if (param->NowVal >= param->MaxVal)
                    param->TouchPos = (ushort)((obj.Panel.Y + num3) - 1);
                else if (param->NowVal <= param->MinVal)
                    param->TouchPos = (ushort)(obj.Panel.EndY - num2);
                else
                {
                    num = (ushort)(((param->NowVal - param->MinVal) * (((obj.Panel.EndY - obj.Panel.Y) - param->CursorHeight) + 1)) / ((param->MaxVal - param->MinVal) + 1));
                    param->TouchPos = (ushort)((obj.Panel.EndY - num3) - num);
                }
            }
            else
            {
                num2 = (byte)(param->CursorWidth / 2);
                num3 = (byte)(param->CursorWidth - num2);

                if (param->NowVal >= param->MaxVal)
                    param->TouchPos = (ushort)((obj.Panel.EndX - num3) + 1);
                else if (param->NowVal <= param->MinVal)
                    param->TouchPos = (ushort)(obj.Panel.X + num2);
                else
                {
                    num = (ushort)((obj.Panel.X + num2) + ((((long)(param->NowVal - param->MinVal)) * (obj.Panel.EndX - obj.Panel.X - param->CursorWidth + 1)) / ((long)(param->MaxVal - param->MinVal + 1))));
                    param->TouchPos = num;
                }
            }

            if (!m_runScreen.IsEditor)
                m_guiApp.PageObjects[ID].RefreshFlag = 1;

            param->LastVal = param->NowVal;
            return 1;
        }
Example #2
0
 private unsafe byte drawSliderCursor(ref InfoObject obj, InfoSliderParam* param, ushort* x0, ushort* x1, ushort* y0, ushort* y1)
 {
     byte num;
     if (param->Mode > 0)
     {
         num = (byte)(param->CursorHeight / 2);
         x0[0] = (ushort)(((((obj.Panel.EndX - obj.Panel.X) + 1) - param->CursorWidth) / 2) + obj.Panel.X);
         x1[0] = (ushort)((x0[0] + param->CursorWidth) - 1);
         y1[0] = (ushort)(param->TouchPos + num);
         y0[0] = (ushort)((y1[0] - param->CursorHeight) + 1);
     }
     else
     {
         num = (byte)(param->CursorWidth / 2);
         y0[0] = (ushort)(((((obj.Panel.EndY - obj.Panel.Y) + 1) - param->CursorHeight) / 2) + obj.Panel.Y);
         y1[0] = (ushort)((y0[0] + param->CursorHeight) - 1);
         x0[0] = (ushort)(param->TouchPos - num);
         x1[0] = (ushort)((x0[0] + param->CursorWidth) - 1);
     }
     if (param->CursorType > 0)
     {
         if (param->CutsorPicId >= m_guiApp.App.PictureCount)
         {
             return 0;
         }
         m_guiApp.BrushInfo.sta = 2;
         m_guiApp.BrushInfo.pic = m_runScreen.ReadInfoPicture(param->CutsorPicId);
         m_guiApp.BrushInfo.X = x0[0];
         m_guiApp.BrushInfo.Y = y0[0];
     }
     else
     {
         m_guiApp.BrushInfo.sta = 1;
         m_guiApp.BrushInfo.BackColor = param->CutsorPicId;
     }
     m_runScreen.ClearBackground(
         x0[0],
         y0[0],
         param->CursorWidth,
         param->CursorHeight
     );
     return 1;
 }
Example #3
0
        private unsafe byte drawSliderBackGround(ref InfoObject obj, InfoSliderParam* param)
        {
            switch (param->BackType)
            {
                case 0:
                    if (param->BackPicId < m_guiApp.App.PictureCount)
                    {
                        m_guiApp.BrushInfo.pic = m_runScreen.ReadInfoPicture(param->BackPicId);
                        break;
                    }
                    return 0;

                case 1:
                    m_guiApp.BrushInfo.BackColor = param->BackPicId;
                    break;

                case 2:
                    if (param->BackPicId < m_guiApp.App.PictureCount)
                    {
                        m_guiApp.BrushInfo.X = obj.Panel.X;
                        m_guiApp.BrushInfo.Y = obj.Panel.Y;
                        m_guiApp.BrushInfo.pic = m_runScreen.ReadInfoPicture(param->BackPicId);
                        break;
                    }
                    return 0;
            }
            m_guiApp.BrushInfo.sta = param->BackType;
            m_runScreen.ClearBackground(
                obj.Panel.X,
                obj.Panel.Y,
                (ushort)(obj.Panel.EndX - obj.Panel.X + 1),
                (ushort)(obj.Panel.EndY - obj.Panel.Y + 1)
            );
            return 1;
        }
Example #4
0
 private unsafe byte clearSliderCursor(ref InfoObject obj, InfoSliderParam* param, ushort* x0, ushort* x1, ushort* y0, ushort* y1)
 {
     ushort x = 0;
     ushort y = 0;
     ushort num3 = 0;
     ushort lastPos = 0;
     if (param->Mode > 0)
     {
         x = x0[0];
         num3 = x1[0];
         if (y1[0] < param->LastPos)
         {
             lastPos = param->LastPos;
             y = (ushort)((lastPos - param->CursorHeight) + 1);
             if (y1[0] >= y)
                 y = (ushort)(y1[0] + 1);
         }
         else if (y1[0] > param->LastPos)
         {
             lastPos = param->LastPos;
             y = (ushort)((lastPos - param->CursorHeight) + 1);
             if (lastPos >= y0[0])
                 lastPos = (ushort)(y0[0] - 1);
         }
     }
     else
     {
         y = y0[0];
         lastPos = y1[0];
         if (x0[0] < param->LastPos)
         {
             x = param->LastPos;
             num3 = (ushort)((x + param->CursorWidth) - 1);
             if (x1[0] >= x)
                 x = (ushort)(x1[0] + 1);
         }
         else if (x0[0] > param->LastPos)
         {
             x = param->LastPos;
             num3 = (ushort)((x + param->CursorWidth) - 1);
             if (num3 >= x0[0])
                 num3 = (ushort)(x0[0] - 1);
         }
     }
     switch (param->BackType)
     {
         case 0:
             m_guiApp.BrushInfo.pic = m_runScreen.ReadInfoPicture(param->BackPicId);
             break;
         case 1:
             m_guiApp.BrushInfo.BackColor = param->BackPicId;
             break;
         case 2:
             m_guiApp.BrushInfo.pic = m_runScreen.ReadInfoPicture(param->BackPicId);
             m_guiApp.BrushInfo.X = obj.Panel.X;
             m_guiApp.BrushInfo.Y = obj.Panel.Y;
             break;
     }
     m_guiApp.BrushInfo.sta = param->BackType;
     m_runScreen.ClearBackground(x, y, (ushort)((num3 - x) + 1), (ushort)((lastPos - y) + 1));
     return 1;
 }
Example #5
0
 private unsafe byte changeTouchValue(ref InfoObject obj, InfoSliderParam* param, ushort val)
 {
     byte num;
     byte num2;
     ushort nowVal = param->NowVal;
     if (param->Mode > 0)
     {
         num = (byte)(param->CursorHeight / 2);
         num2 = (byte)(param->CursorHeight - num);
         if (val >= (obj.Panel.EndY - num))
         {
             param->TouchPos = (ushort)(obj.Panel.EndY - num);
             param->NowVal = param->MinVal;
         }
         else if (val <= ((obj.Panel.Y + num2) - 1))
         {
             param->TouchPos = (ushort)((obj.Panel.Y + num2) - 1);
             param->NowVal = param->MaxVal;
         }
         else
         {
             param->TouchPos = val;
             param->NowVal = (ushort)(param->MinVal + ((((long)(obj.Panel.EndY - num2 - val)) * (param->MaxVal - param->MinVal + 1)) / ((long)(obj.Panel.EndY - obj.Panel.Y - param->CursorHeight + 1))
                     )
                 );
         }
     }
     else
     {
         num = (byte)(param->CursorWidth / 2);
         num2 = (byte)(param->CursorWidth - num);
         if (val <= (obj.Panel.X + num))
         {
             param->TouchPos = (ushort)(obj.Panel.X + num);
             param->NowVal = param->MinVal;
         }
         else if (val >= ((obj.Panel.EndX - num2) + 1))
         {
             param->TouchPos = (ushort)((obj.Panel.EndX - num2) + 1);
             param->NowVal = param->MaxVal;
         }
         else
         {
             param->TouchPos = val;
             param->NowVal = (ushort)(param->MinVal + ((((long)((val - obj.Panel.X) - num)) * ((param->MaxVal - param->MinVal) + 1)) / ((long)(obj.Panel.EndX - obj.Panel.X - param->CursorWidth + 1))));
         }
     }
     if (param->NowVal > 100)
         param->NowVal = param->NowVal;
     if (nowVal != param->NowVal)
     {
         param->LastVal = param->NowVal;
         return 1;
     }
     return 0;
 }
Example #6
0
        public ushort GetObjRamBytes(ref byte[] bytes, ushort pos0)
        {
            int length = bytes.Length;
            int pos = pos0;

            #region OBJECT_TYPE_SLIDER
            if (Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_SLIDER)
            {
                InfoSliderParam param = new InfoSliderParam();
                try
                {
                    param.RefFlag = 0;
                    param.Mode = GetAttributeValue("mode")[0];
                    param.BackType = GetAttributeValue("sta")[0];
                    param.CursorType = GetAttributeValue("psta")[0];
                    param.CursorWidth = GetAttributeValue("wid")[0];
                    param.CursorHeight = GetAttributeValue("hig")[0];

                    if (param.BackType == 0)
                        param.BackPicId = GetAttributeValue("picc").ToU16();
                    else if (param.BackType == 2)
                        param.BackPicId = GetAttributeValue("pic").ToU16();
                    else if (param.BackType == 1)
                        param.BackPicId = GetAttributeValue("bco").ToU16();

                    if (param.CursorType == 0)
                        param.CutsorPicId = GetAttributeValue("pco").ToU16();
                    else if (param.CursorType == 1)
                        param.CutsorPicId = GetAttributeValue("pic2").ToU16();

                    param.MaxVal = GetAttributeValue("maxval").ToU16();
                    param.MinVal = GetAttributeValue("minval").ToU16();
                    param.NowVal = GetAttributeValue("val").ToU16();
                    param.LastVal = 0xffff;

                    Attributes[5].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 6);
                    Attributes[6].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 6);
                    Attributes[7].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 6);
                    Attributes[8].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 8);
                    Attributes[9].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 8);
                    Attributes[10].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 4);
                    Attributes[11].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 5);
                    Attributes[12].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 10);
                    Attributes[13].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 12);
                    Attributes[14].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 14);

                    bytes = Utility.MergeBytes(bytes, Utility.ToBytes(param));
                    return (ushort)(bytes.Length - length);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                return 0;
            }
            #endregion

            #region OBJECT_TYPE_CURVE
            if (Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_CURVE)
            {
                InfoCurveParam param = new InfoCurveParam();
                InfoCurveChannelParam channel_param = new InfoCurveChannelParam();
                try
                {
                    param.BackType = GetAttributeValue("sta")[0];
                    if (param.BackType == 0)
                        param.PicID = GetAttributeValue("picc").ToU16();
                    else if (param.BackType == 2)
                        param.PicID = GetAttributeValue("pic").ToU16();

                    param.GridX = GetAttributeValue("gdw")[0];
                    param.GridY = GetAttributeValue("gdh")[0];
                    param.RefFlag = 0;
                    param.ChannelCount = (byte)(GetAttributeValue("ch")[0] + 1);
                    param.Width = (ushort)((ObjInfo.Panel.EndX - ObjInfo.Panel.X) + 1);
                    param.Height = (ushort)((ObjInfo.Panel.EndY - ObjInfo.Panel.Y) + 1);
                    param.BackColor = GetAttributeValue("bco").ToU16();
                    param.Griclr = GetAttributeValue("gdc").ToU16();
                    if ((param.Width * 0.3) > 120.0)
                        param.BufLen = (ushort)(param.Width + 120);
                    else
                        param.BufLen = (ushort)(param.Width * 1.3);

                    Attributes[4].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 11);
                    Attributes[5].InfoAttribute.Start = Attributes[4].InfoAttribute.Start;
                    Attributes[6].InfoAttribute.Start = Attributes[4].InfoAttribute.Start;
                    Attributes[7].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 13);
                    Attributes[8].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 2);
                    Attributes[9].InfoAttribute.Start = (ushort)(ObjInfo.AttributeStart + 3);
                    bytes = Utility.MergeBytes(bytes, Utility.ToBytes(param));
                    InfoCurveParam curve_param2 = new InfoCurveParam();
                    InfoCurveChannelParam curve_channel_param2 = new InfoCurveChannelParam();
                    pos = (ushort)((pos + Marshal.SizeOf(curve_param2)) + (Marshal.SizeOf(curve_channel_param2) * param.ChannelCount));
                    for (int j = 0; j < param.ChannelCount; j++)
                    {
                        curve_param2 = new InfoCurveParam();
                        curve_channel_param2 = new InfoCurveChannelParam();
                        Attributes[10 + j].InfoAttribute.Start = (ushort)(((ObjInfo.AttributeStart + Marshal.SizeOf(curve_param2)) + (Marshal.SizeOf(curve_channel_param2) * j)) + 4);
                        channel_param = new InfoCurveChannelParam();
                        channel_param.Begin = (ushort)(pos + (j * param.BufLen));
                        channel_param.End = (ushort)((channel_param.Begin + param.BufLen) - 1);
                        switch (j)
                        {
                            case 0:
                                channel_param.Penclr = GetAttributeValue("pco0").ToU16();
                                break;

                            case 1:
                                channel_param.Penclr = GetAttributeValue("pco1").ToU16();
                                break;

                            case 2:
                                channel_param.Penclr = GetAttributeValue("pco2").ToU16();
                                break;

                            case 3:
                                channel_param.Penclr = GetAttributeValue("pco3").ToU16();
                                break;
                        }
                        channel_param.BufFree = (ushort)(param.BufLen - 1);
                        channel_param.BufNext = (ushort)channel_param.Begin;
                        channel_param.DotLen = 0;
                        bytes = Utility.MergeBytes(bytes, Utility.ToBytes(channel_param));
                    }
                    return (ushort)(bytes.Length + param.BufLen * param.ChannelCount - length);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                return 0;
            }
            #endregion

            #region Attributes
            for (int i = 0; i < Attributes.Count; i++)
            {
                if (Attributes[i].InfoAttribute.AttrType < HmiAttributeType.Type15
                 && Attributes[i].InfoAttribute.CanModify == 1
                 && checkAttribute(Attributes[i]))
                {
                    if (Attributes[i].InfoAttribute.AttrType == HmiAttributeType.String)
                    {
                        if ((Attributes[i].Data.Length == 0) || (Attributes[i].Data[Attributes[i].Data.Length - 1] != 0))
                            Utility.MergeBytes(Attributes[i].Data, Utility.BYTE_ZERO);
                        if (Attributes[i].Data.Length > Attributes[i].InfoAttribute.Length)
                        {
                            MessageBox.Show(string.Concat(
                                "Attribute".Translate(),
                                Utility.GetString(Attributes[i].Name),
                                "The initial value is larger than the allocated space".Translate()
                                ));
                            return 0;
                        }
                        bytes = Utility.MergeBytes(bytes, Attributes[i].Data, Utility.ToBytes("", Attributes[i].InfoAttribute.Length - Attributes[i].Data.Length));
                    }
                    else
                    {
                        if (Attributes[i].Data.Length != Attributes[i].InfoAttribute.Length)
                        {
                            MessageBox.Show(string.Concat(
                                "Attribute".Translate(),
                                Utility.GetString(Attributes[i].Name),
                                "The initial value is larger than the allocated space".Translate()
                                ));
                            return 0;
                        }
                        bytes = Utility.MergeBytes(bytes, Attributes[i].Data);
                    }
                    Attributes[i].InfoAttribute.Start = (ushort)pos;
                    pos += Attributes[i].InfoAttribute.Length;
                }
            }
            #endregion

            return (ushort)(bytes.Length - length);
        }