コード例 #1
0
    // merge files
    private void button_Merge_Click(object sender, System.EventArgs e)
    {      
      int selectedIndex=0;
      
      for(int index=0; index<=checkedListBox1.CheckedIndices.Count-1; index++)  
      {
        selectedIndex = (int)checkedListBox1.CheckedIndices[index];

        PersonalMethodList[selectedIndex].Attributes.GetNamedItem("GENERATE").InnerText = "YES"; 
      }

      #region ShowNewXmlFile
      StreamWriter xr =  File.CreateText("DB_TABLE.xml");
      xr.WriteLine(this.newDoc.InnerXml);
      xr.Close();    
      #endregion

      #region MakeCppAndHeader
      // if method are cheched, missing or old
      if( !CData.Instance.getPersonalMethodsToGenerate().Equals(0) || !CData.Instance.getGeneratedMethodsToMerge((int)CData.MethodType.BOTH).Equals(0))
      {
        System.Environment.CurrentDirectory = CData.Instance.getWorkingDirectory();
        CCodeWriter writer = new CCodeWriter();
        writer.writeCode(this.TableName, this.newDoc);
      }
      #endregion

      this.Close();
    }
コード例 #2
0
        private void button_DefGenerate_Click(object sender, System.EventArgs e)
        {
            try
            {
                int firstCount  = 0;
                int secondCount = 0;

                String firstColName  = "";
                String secondColName = "";
                //String Value =

                for (int index = 0; index < GetDataSetFromDataSource().Tables["DefTable"].Rows.Count; index++)
                {
                    // Name
                    if (typeof(bool) == GetTypeFromRow(index, 2))
                    {
                        bool Ischecked = (bool)GetDataSetFromDataSource().Tables["DefTable"].Rows[index].ItemArray.GetValue(2);

                        if (Ischecked)
                        {
                            // to avoid misktakes when compling code, note only strings are allowed for names
                            if (typeof(string) == GetDataSetFromDataSource().Tables["DefTable"].Rows[index].ItemArray.GetValue(0).GetType())
                            {
                                m_detailIndex = index;
                                firstColName  = GetDataSetFromDataSource().Tables["DefTable"].Rows[index].ItemArray.GetValue(0).ToString();
                                firstCount++;
                            }
                        }
                    }

                    // Value
                    if (typeof(bool) == GetTypeFromRow(index, 3))
                    {
                        bool Ischecked = (bool)GetDataSetFromDataSource().Tables["DefTable"].Rows[index].ItemArray.GetValue(3);

                        if (Ischecked)
                        {
                            m_dataIndex   = index;
                            secondColName = GetDataSetFromDataSource().Tables["DefTable"].Rows[index].ItemArray.GetValue(0).ToString();
                            secondCount++;
                        }
                    }
                }

                // exor condition
                if (firstCount == 1 && secondCount == 1)
                {
                    XmlDocument defDoc = new XmlDocument();

                    CCodePreprocessor pre = new CCodePreprocessor();
                    defDoc = pre.createDefClass(Desc_Table, m_detailIndex, m_dataIndex);

                    FileInfo f        = new FileInfo(this.Filename);
                    string   Filename = f.Name.ToString();
                    Filename = Filename.Remove(0, 1);

                    System.Environment.CurrentDirectory = CData.Instance.getWorkingDirectory();

                    CCodeWriter writer = new CCodeWriter();
                    writer.writeDefCode(Filename, defDoc);

                    this.DialogResult = System.Windows.Forms.DialogResult.OK;

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Generate_Click : for each checkbox row only one is allowed to selecet",
                                    "Error on check box", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Abort;

                MessageBox.Show(ex.StackTrace + " : \r\n\r\n"
                                + ex.Message,
                                "Error: " + ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }//private void button_DefGenerate_Click(object sender, System.EventArgs e)