Ejemplo n.º 1
0
        public object Clone()
        {
            ConstantData ret = new ConstantData();

            ret.NameJ = this.NameJ;
            ret.NameE = this.NameE;
            ret.NameC = this.NameC;

            ret.Value = this.Value;

            return ret;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// constructor
 /// </summary>
 public ConstantSetting()
 {
     typeOfClass = TYPEOFCLASS.ConstantSetting;
     ConstantList = new ConstantData[10];
 }
Ejemplo n.º 3
0
        /// <summary>
        /// form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmTagSettingConstant_Load(object sender, EventArgs e)
        {
            int count = 0;
            try
            {
                if(SystemSetting.ConstantSetting != null)
                {
                    this.setting = SystemSetting.ConstantSetting;
                    dgvConstant.Rows.Clear();
                    if (this.setting != null && this.setting.ConstantList != null)
                    {
                        count = this.setting.ConstantList.Length > ConstantSetting.MaxArraySize ? ConstantSetting.MaxArraySize : this.setting.ConstantList.Length;
                        for (int i = 0; i < count; i++)
                        {
                            if (this.setting.ConstantList[i] != null)
                            {
                                dgvConstant.Rows.Add(new string[] { (i + 1).ToString(), this.setting.ConstantList[i].GetSystemConstantName(), this.setting.ConstantList[i].Value.ToString() });
                                this.list.Add(this.setting.ConstantList[i]);
                            }
                        }
                        this.currentData = this.list[0];
                    }
                    if (Mode == CONSTANTMODE.Update)
                    {
                        btnSelect.Text = "TXT_UPDATE";
                        for (int j = 0; j < count; j++)
                        {
                            dgvConstant.Rows[j].Cells[2].ReadOnly = false;
                        }
                    }
                }

                AppResource.SetControlsText(this);
                this.dirtyFlag = false;
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// check what to do in each constant mode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmTagSettingConstant_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (Mode == CONSTANTMODE.Read)
                {
                    if (dgvConstant.RowCount > 0)
                    {
                        this.currentData = this.setting.ConstantList[dgvConstant.CurrentCell.RowIndex];
                        this.selectedNo = dgvConstant.CurrentCell.RowIndex + 1;
                    }
                    if (this.DialogResult == System.Windows.Forms.DialogResult.OK && this.currentData == null && dgvConstant.RowCount > 0)
                    {
                        e.Cancel = true;
                        MessageBox.Show(AppResource.GetString("MSG_TAG_CONSTANT_NOT_SELECT"));
                    }
                }
                else if (Mode == CONSTANTMODE.Update)
                {
                    if (dgvConstant.IsCurrentCellDirty)
                    {
                        dgvConstant.EndEdit();
                    }

                    if (dgvConstant.RowCount > 0)
                    {

                        if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
                        {
                            if (ValidateValue() == false)
                            {
                                e.Cancel = true;
                                return;
                            }
                            if (this.dirtyFlag)
                            {
                                if (MessageBox.Show(AppResource.GetString("MSG_CONFIRM_SAVE"), this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                                {
                                    this.setting.ConstantList = this.list.ToArray();
                                    this.setting.Serialize();
                                }
                                else
                                {
                                    e.Cancel = true;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            if (this.dirtyFlag)
                            {
                                if (MessageBox.Show(AppResource.GetString("MSG_CONFIRM_DISCARD"), this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
                                     System.Windows.Forms.DialogResult.Cancel)
                                {
                                    e.Cancel = true;
                                }
                                else
                                { this.setting.Revert(); }
                            }

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }