Пример #1
0
        private void dataGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGrid.Rows.Count != 0
             && e.RowIndex >= 0
             && dataGrid.Columns[e.ColumnIndex].Name == "colValue"
                )
            {
                string str;
                if (dataGrid.Rows[e.RowIndex].Cells["colType"].Value.ToString() == HmiAttributeType.PicId.ToString())
                {
                    FormParams formParams = new FormParams
                    {
                        Strings = new string[2]
                    };
                    string[] strArray = ((dataGrid.Rows[e.RowIndex].Cells["colValue"].Value == null)
                                        ? ""
                                        : dataGrid.Rows[e.RowIndex].Cells["colValue"].Value.ToString()
                                        ).Split(Utility.CHAR_MINUS);
                    if (strArray.Length == 2)
                        formParams.Strings[1] = strArray[1];

                    Form form = new PicSelect(m_app, formParams);
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        str = formParams.Strings[0];
                        dataGrid.Rows[e.RowIndex].Cells["colValue"].Value = str;
                        m_obj.SetAttrValue(dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString(), str);
                        if (m_obj.Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_SLIDER
                         && dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString() == "pic2"
                            )
                        {
                            if (!m_obj.SetAttrValue("wid", m_app.Pictures[Utility.GetInt(str)].W.ToString()))
                                m_obj.SetAttrValue("wid", ((m_obj.ObjInfo.Panel.EndX - m_obj.ObjInfo.Panel.X) + 1).ToString());

                            if (!m_obj.SetAttrValue("hig", m_app.Pictures[Utility.GetInt(str)].H.ToString()))
                                m_obj.SetAttrValue("hig", ((m_obj.ObjInfo.Panel.EndY - m_obj.ObjInfo.Panel.Y) + 1).ToString());

                            RefreshObject(m_app, m_page, m_obj);
                        }
                        if (dataGrid.Rows[e.RowIndex].Cells["colIsBinding"].Value != null
                         && dataGrid.Rows[e.RowIndex].Cells["colIsBinding"].Value.ToString() == "1"
                         && str != ""
                         && Utility.GetInt(str) != 0xffff
                         && Utility.GetInt(str) >= 0
                            )
                        {
                            m_obj.BindingPicXY(Utility.GetInt(str));
                            ObjectPosXY(null, null);
                        }
                        ObjectAttach(null, null);
                    }
                }
                else if (dataGrid.Rows[e.RowIndex].Cells["colType"].Value.ToString() == HmiAttributeType.Color.ToString())
                {
                    ColorDialog dialog = new ColorDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        str = Utility.Get16Color(dialog.Color).ToString();
                        dataGrid.Rows[e.RowIndex].Cells["colValue"].Value = str;
                        m_obj.SetAttrValue(dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString(), str);
                        ObjectAttach(null, null);
                    }
                }
            }
        }
Пример #2
0
        private void dataGrid_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGrid.Rows.Count != 0 &&
                e.RowIndex >= 0 &&
                dataGrid.Columns[e.ColumnIndex].Name == "colValue"
                )
            {
                string str;
                if (dataGrid.Rows[e.RowIndex].Cells["colType"].Value.ToString() == HmiAttributeType.PicId.ToString())
                {
                    FormParams formParams = new FormParams
                    {
                        Strings = new string[2]
                    };
                    string[] strArray = ((dataGrid.Rows[e.RowIndex].Cells["colValue"].Value == null)
                                                                                ? ""
                                                                                : dataGrid.Rows[e.RowIndex].Cells["colValue"].Value.ToString()
                                         ).Split(Utility.CHAR_MINUS);
                    if (strArray.Length == 2)
                    {
                        formParams.Strings[1] = strArray[1];
                    }

                    Form form = new PicSelect(m_app, formParams);
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        str = formParams.Strings[0];
                        dataGrid.Rows[e.RowIndex].Cells["colValue"].Value = str;
                        m_obj.SetAttrValue(dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString(), str);
                        if (m_obj.Attributes[0].Data[0] == HmiObjType.OBJECT_TYPE_SLIDER &&
                            dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString() == "pic2"
                            )
                        {
                            if (!m_obj.SetAttrValue("wid", m_app.Pictures[Utility.GetInt(str)].W.ToString()))
                            {
                                m_obj.SetAttrValue("wid", ((m_obj.ObjInfo.Panel.EndX - m_obj.ObjInfo.Panel.X) + 1).ToString());
                            }

                            if (!m_obj.SetAttrValue("hig", m_app.Pictures[Utility.GetInt(str)].H.ToString()))
                            {
                                m_obj.SetAttrValue("hig", ((m_obj.ObjInfo.Panel.EndY - m_obj.ObjInfo.Panel.Y) + 1).ToString());
                            }

                            RefreshObject(m_app, m_page, m_obj);
                        }
                        if (dataGrid.Rows[e.RowIndex].Cells["colIsBinding"].Value != null &&
                            dataGrid.Rows[e.RowIndex].Cells["colIsBinding"].Value.ToString() == "1" &&
                            str != "" &&
                            Utility.GetInt(str) != 0xffff &&
                            Utility.GetInt(str) >= 0
                            )
                        {
                            m_obj.BindingPicXY(Utility.GetInt(str));
                            ObjectPosXY(null, null);
                        }
                        ObjectAttach(null, null);
                    }
                }
                else if (dataGrid.Rows[e.RowIndex].Cells["colType"].Value.ToString() == HmiAttributeType.Color.ToString())
                {
                    ColorDialog dialog = new ColorDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        str = Utility.Get16Color(dialog.Color).ToString();
                        dataGrid.Rows[e.RowIndex].Cells["colValue"].Value = str;
                        m_obj.SetAttrValue(dataGrid.Rows[e.RowIndex].Cells["colName"].Value.ToString(), str);
                        ObjectAttach(null, null);
                    }
                }
            }
        }