DataGridViewToParameters() публичный статический Метод

public static DataGridViewToParameters ( System.Windows.Forms.DataGridView dg, IEcasObject objOut, IEcasParameterized eTypeInfo ) : void
dg System.Windows.Forms.DataGridView
objOut IEcasObject
eTypeInfo IEcasParameterized
Результат void
Пример #1
0
        public static bool UpdateDialog(EcasObjectType objType, ComboBox cmbTypes,
                                        DataGridView dgvParams, IEcasObject o, bool bGuiToInternal,
                                        EcasTypeDxMode dxType)
        {
            bool bResult = true;

            try
            {
                if (bGuiToInternal)
                {
                    IEcasParameterized eTypeInfo = null;

                    if (dxType == EcasTypeDxMode.Selection)
                    {
                        string strSel = (cmbTypes.SelectedItem as string);
                        if (!string.IsNullOrEmpty(strSel))
                        {
                            if (objType == EcasObjectType.Event)
                            {
                                eTypeInfo = Program.EcasPool.FindEvent(strSel);
                                o.Type    = eTypeInfo.Type;
                            }
                            else if (objType == EcasObjectType.Condition)
                            {
                                eTypeInfo = Program.EcasPool.FindCondition(strSel);
                                o.Type    = eTypeInfo.Type;
                            }
                            else if (objType == EcasObjectType.Action)
                            {
                                eTypeInfo = Program.EcasPool.FindAction(strSel);
                                o.Type    = eTypeInfo.Type;
                            }
                            else
                            {
                                Debug.Assert(false);
                            }
                        }
                    }
                    else if (dxType == EcasTypeDxMode.ParamsTag)
                    {
                        IEcasParameterized p = (dgvParams.Tag as IEcasParameterized);
                        if ((p != null) && (p.Type != null))
                        {
                            eTypeInfo = p;
                            o.Type    = eTypeInfo.Type;
                        }
                        else
                        {
                            Debug.Assert(false);
                        }
                    }

                    EcasUtil.DataGridViewToParameters(dgvParams, o, eTypeInfo);
                }
                else                 // Internal to GUI
                {
                    if (dxType == EcasTypeDxMode.Selection)
                    {
                        if (o.Type.Equals(PwUuid.Zero))
                        {
                            cmbTypes.SelectedIndex = 0;
                        }
                        else
                        {
                            int i = -1;
                            if (objType == EcasObjectType.Event)
                            {
                                i = cmbTypes.FindString(Program.EcasPool.FindEvent(o.Type).Name);
                            }
                            else if (objType == EcasObjectType.Condition)
                            {
                                i = cmbTypes.FindString(Program.EcasPool.FindCondition(o.Type).Name);
                            }
                            else if (objType == EcasObjectType.Action)
                            {
                                i = cmbTypes.FindString(Program.EcasPool.FindAction(o.Type).Name);
                            }
                            else
                            {
                                Debug.Assert(false);
                            }

                            if (i >= 0)
                            {
                                cmbTypes.SelectedIndex = i;
                            }
                            else
                            {
                                Debug.Assert(false);
                            }
                        }
                    }
                    else
                    {
                        Debug.Assert(dxType != EcasTypeDxMode.ParamsTag);
                    }

                    IEcasParameterized t = null;
                    if (objType == EcasObjectType.Event)
                    {
                        t = Program.EcasPool.FindEvent(cmbTypes.SelectedItem as string);
                    }
                    else if (objType == EcasObjectType.Condition)
                    {
                        t = Program.EcasPool.FindCondition(cmbTypes.SelectedItem as string);
                    }
                    else if (objType == EcasObjectType.Action)
                    {
                        t = Program.EcasPool.FindAction(cmbTypes.SelectedItem as string);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }

                    if (t != null)
                    {
                        EcasUtil.ParametersToDataGridView(dgvParams, t, o);
                    }
                }
            }
            catch (Exception e) { MessageService.ShowWarning(e); bResult = false; }

            return(bResult);
        }