/// <summary>
		/// Called if user presses the "Ok" button on the dialog box.
		/// </summary>
		public bool Apply(bool disposeController)
		{
			if (this.m_CreateSpectrumFrom == CreateSpectrumFrom.Row)
			{
				Altaxo.Data.INumericColumn xcol;

				if (this.m_XValuesFrom == XValuesFrom.Column)
				{
					string colname = _view.XValuesColumnName;
					if (null == colname)
					{
						Current.Gui.ErrorMessageBox("No x-column selected");
						return false;
					}

					xcol = this.m_Table.PropCols[colname] as Altaxo.Data.INumericColumn;
				}
				else // xvalues are continuous number
				{
					xcol = new Altaxo.Data.IndexerColumn();
				}

				Altaxo.Data.DataColumn extFileNameCol = null;
				if (this.m_ExtendFileNameWith == ExtendFileNameWith.Column)
					extFileNameCol = m_Table[_view.ExtFileNameColumnName];

				int i, j;
				bool bUseRowSel = (null != m_SelectedRows && this.m_SelectedRows.Count > 0);
				int numOfSpectra = bUseRowSel ? m_SelectedRows.Count : m_Table.DataColumns.RowCount;

				for (j = 0; j < numOfSpectra; j++)
				{
					i = bUseRowSel ? m_SelectedRows[j] : j;

					string filename = _view.BasicFileName;

					if (null != extFileNameCol)
						filename += "_" + extFileNameCol[i].ToString();
					else
						filename += "_" + j.ToString();

					string error = Export.FromRow(filename, this.m_Table, i, xcol, this.m_SelectedColumns);

					if (null != error)
					{
						Current.Gui.ErrorMessageBox(string.Format("There were error(s) during export: {0}", error));
						return false;
					}
				}
				Current.Gui.InfoMessageBox(string.Format("Export of {0} spectra successfull.", numOfSpectra));
			}
			else if (this.m_CreateSpectrumFrom == CreateSpectrumFrom.Column)
			{
				Altaxo.Data.INumericColumn xcol;

				if (this.m_XValuesFrom == XValuesFrom.Column)
				{
					string colname = _view.XValuesColumnName;
					if (null == colname)
					{
						Current.Gui.ErrorMessageBox("No x-column selected");
						return false;
					}

					xcol = this.m_Table.DataColumns[colname] as Altaxo.Data.INumericColumn;
				}
				else // xvalues are continuous number
				{
					xcol = new Altaxo.Data.IndexerColumn();
				}

				Altaxo.Data.DataColumn extFileNameCol = null;
				if (this.m_ExtendFileNameWith == ExtendFileNameWith.Column)
					extFileNameCol = m_Table.PropCols[_view.ExtFileNameColumnName];

				int i, j;
				bool bUseColSel = (null != m_SelectedColumns && this.m_SelectedColumns.Count > 0);
				int numOfSpectra = bUseColSel ? m_SelectedColumns.Count : m_Table.DataColumns.ColumnCount;

				for (j = 0; j < numOfSpectra; j++)
				{
					i = bUseColSel ? m_SelectedColumns[j] : j;

					string filename = _view.BasicFileName;

					if (null != extFileNameCol)
						filename += extFileNameCol[i].ToString();
					else
						filename += j.ToString() + ".spc";

					string error = Export.FromColumn(filename, this.m_Table, i, xcol, this.m_SelectedRows);

					if (null != error)
					{
						Current.Gui.ErrorMessageBox(string.Format("There were error(s) during export: {0}", error));
						return false;
					}
				}

				Current.Gui.InfoMessageBox(string.Format("Export of {0} spectra successfull.", numOfSpectra));
			}
			return true;
		}
        /// <summary>
        /// Called if user presses the "Ok" button on the dialog box.
        /// </summary>
        public void EhOk()
        {
            if (this.m_CreateSpectrumFrom == Options.CreateSpectrumFrom.Row)
            {
                Altaxo.Data.INumericColumn xcol;

                if (this.m_XValuesFrom == Options.XValuesFrom.Column)
                {
                    string colname = m_Form.XValuesColumnName;
                    if (null == colname)
                    {
                        MessageBox.Show(m_Form, "No x-column selected", "Error");
                        return;
                    }

                    xcol = this.m_Table.PropCols[colname] as Altaxo.Data.INumericColumn;
                }
                else // xvalues are continuous number
                {
                    xcol = new Altaxo.Data.IndexerColumn();
                }

                Altaxo.Data.DataColumn extFileNameCol = null;
                if (this.m_ExtendFileNameWith == Options.ExtendFileNameWith.Column)
                {
                    extFileNameCol = m_Table[m_Form.ExtFileNameColumnName];
                }



                int  i, j;
                bool bUseRowSel   = (null != m_SelectedRows && this.m_SelectedRows.Count > 0);
                int  numOfSpectra = bUseRowSel ? m_SelectedRows.Count : m_Table.DataColumns.RowCount;

                for (j = 0; j < numOfSpectra; j++)
                {
                    i = bUseRowSel ? m_SelectedRows[j] : j;

                    string filename = m_Form.BasicFileName;

                    if (null != extFileNameCol)
                    {
                        filename += "_" + extFileNameCol[i].ToString();
                    }
                    else
                    {
                        filename += "_" + j.ToString();
                    }


                    string error = Export.FromRow(filename, this.m_Table, i, xcol, this.m_SelectedColumns);

                    if (null != error)
                    {
                        MessageBox.Show(m_Form, error, "There were error(s) during export!");
                        return;
                    }
                }

                MessageBox.Show(m_Form, string.Format("Export of {0} spectra successfull.", numOfSpectra));
            }
            else if (this.m_CreateSpectrumFrom == Options.CreateSpectrumFrom.Column)
            {
                Altaxo.Data.INumericColumn xcol;

                if (this.m_XValuesFrom == Options.XValuesFrom.Column)
                {
                    string colname = m_Form.XValuesColumnName;
                    if (null == colname)
                    {
                        MessageBox.Show(m_Form, "No x-column selected", "Error");
                        return;
                    }

                    xcol = this.m_Table.DataColumns[colname] as Altaxo.Data.INumericColumn;
                }
                else // xvalues are continuous number
                {
                    xcol = new Altaxo.Data.IndexerColumn();
                }

                Altaxo.Data.DataColumn extFileNameCol = null;
                if (this.m_ExtendFileNameWith == Options.ExtendFileNameWith.Column)
                {
                    extFileNameCol = m_Table.PropCols[m_Form.ExtFileNameColumnName];
                }



                int  i, j;
                bool bUseColSel   = (null != m_SelectedColumns && this.m_SelectedColumns.Count > 0);
                int  numOfSpectra = bUseColSel ? m_SelectedColumns.Count : m_Table.DataColumns.ColumnCount;

                for (j = 0; j < numOfSpectra; j++)
                {
                    i = bUseColSel ? m_SelectedColumns[j] : j;

                    string filename = m_Form.BasicFileName;

                    if (null != extFileNameCol)
                    {
                        filename += extFileNameCol[i].ToString();
                    }
                    else
                    {
                        filename += j.ToString() + ".spc";
                    }


                    string error = Export.FromColumn(filename, this.m_Table, i, xcol, this.m_SelectedRows);

                    if (null != error)
                    {
                        MessageBox.Show(m_Form, error, "There were error(s) during export!");
                        return;
                    }
                }

                MessageBox.Show(m_Form, string.Format("Export of {0} spectra successfull.", numOfSpectra));
            }
            m_Form.DialogResult = DialogResult.OK;
            m_Form.Close();
        }
    /// <summary>
    /// Called if user presses the "Ok" button on the dialog box.
    /// </summary>
    public void EhOk()
    {
      if(this.m_CreateSpectrumFrom == Options.CreateSpectrumFrom.Row)
      {
        Altaxo.Data.INumericColumn xcol;

        if(this.m_XValuesFrom == Options.XValuesFrom.Column)
        {
          string colname = m_Form.XValuesColumnName;
          if(null==colname)
          {
            MessageBox.Show(m_Form, "No x-column selected", "Error");
            return;
          }

          xcol = this.m_Table.PropCols[colname] as Altaxo.Data.INumericColumn;
        }
        else // xvalues are continuous number
        {
          xcol = new Altaxo.Data.IndexerColumn();
        }

        Altaxo.Data.DataColumn extFileNameCol=null;
        if(this.m_ExtendFileNameWith == Options.ExtendFileNameWith.Column)
          extFileNameCol = m_Table[m_Form.ExtFileNameColumnName];



        int i,j;
        bool bUseRowSel = (null!=m_SelectedRows && this.m_SelectedRows.Count>0);
        int numOfSpectra = bUseRowSel ? m_SelectedRows.Count : m_Table.DataColumns.RowCount;

        for(j=0;j<numOfSpectra;j++)
        {
          i = bUseRowSel ? m_SelectedRows[j] : j;

          string filename = m_Form.BasicFileName;

          if(null!=extFileNameCol)
            filename += "_" + extFileNameCol[i].ToString();
          else
            filename += "_" + j.ToString();


          string error = Export.FromRow(filename,this.m_Table,i,xcol,this.m_SelectedColumns);

          if(null!=error)
          {
            MessageBox.Show(m_Form,error,"There were error(s) during export!");
            return;
          }
        }
        
        MessageBox.Show(m_Form, string.Format("Export of {0} spectra successfull.",numOfSpectra)); 
      }
      else if(this.m_CreateSpectrumFrom == Options.CreateSpectrumFrom.Column)
      {
        Altaxo.Data.INumericColumn xcol;

        if(this.m_XValuesFrom == Options.XValuesFrom.Column)
        {
          string colname = m_Form.XValuesColumnName;
          if(null==colname)
          {
            MessageBox.Show(m_Form, "No x-column selected", "Error");
            return;
          }

          xcol = this.m_Table.DataColumns[colname] as Altaxo.Data.INumericColumn;
        }
        else // xvalues are continuous number
        {
          xcol = new Altaxo.Data.IndexerColumn();
        }

        Altaxo.Data.DataColumn extFileNameCol=null;
        if(this.m_ExtendFileNameWith == Options.ExtendFileNameWith.Column)
          extFileNameCol = m_Table.PropCols[m_Form.ExtFileNameColumnName];



        int i,j;
        bool bUseColSel = (null!=m_SelectedColumns && this.m_SelectedColumns.Count>0);
        int numOfSpectra = bUseColSel ? m_SelectedColumns.Count : m_Table.DataColumns.ColumnCount;

        for(j=0;j<numOfSpectra;j++)
        {
          i = bUseColSel ? m_SelectedColumns[j] : j;

          string filename = m_Form.BasicFileName;

          if(null!=extFileNameCol)
            filename += extFileNameCol[i].ToString();
          else
            filename += j.ToString() + ".spc";


          string error = Export.FromColumn(filename,this.m_Table,i,xcol,this.m_SelectedRows);

          if(null!=error)
          {
            MessageBox.Show(m_Form,error,"There were error(s) during export!");
            return;
          }
        }
        
        MessageBox.Show(m_Form, string.Format("Export of {0} spectra successfull.",numOfSpectra)); 
      }
      m_Form.DialogResult = DialogResult.OK;
      m_Form.Close();
    }
Example #4
0
        /// <summary>
        /// Called if user presses the "Ok" button on the dialog box.
        /// </summary>
        public bool Apply(bool disposeController)
        {
            if (m_CreateSpectrumFrom == CreateSpectrumFrom.Row)
            {
                Altaxo.Data.INumericColumn xcol;

                if (m_XValuesFrom == XValuesFrom.Column)
                {
                    string colname = _view.XValuesColumnName;
                    if (null == colname)
                    {
                        Current.Gui.ErrorMessageBox("No x-column selected");
                        return(false);
                    }

                    xcol = m_Table.PropCols[colname] as Altaxo.Data.INumericColumn;
                }
                else // xvalues are continuous number
                {
                    xcol = new Altaxo.Data.IndexerColumn();
                }

                Altaxo.Data.DataColumn extFileNameCol = null;
                if (m_ExtendFileNameWith == ExtendFileNameWith.Column)
                {
                    extFileNameCol = m_Table[_view.ExtFileNameColumnName];
                }

                int  i, j;
                bool bUseRowSel   = (null != m_SelectedRows && m_SelectedRows.Count > 0);
                int  numOfSpectra = bUseRowSel ? m_SelectedRows.Count : m_Table.DataColumns.RowCount;

                for (j = 0; j < numOfSpectra; j++)
                {
                    i = bUseRowSel ? m_SelectedRows[j] : j;

                    string filename = _view.BasicFileName;

                    if (null != extFileNameCol)
                    {
                        filename += "_" + extFileNameCol[i].ToString();
                    }
                    else
                    {
                        filename += "_" + j.ToString();
                    }

                    string error = Export.FromRow(filename, m_Table, i, xcol, m_SelectedColumns);

                    if (null != error)
                    {
                        Current.Gui.ErrorMessageBox(string.Format("There were error(s) during export: {0}", error));
                        return(false);
                    }
                }
                Current.Gui.InfoMessageBox(string.Format("Export of {0} spectra successfull.", numOfSpectra));
            }
            else if (m_CreateSpectrumFrom == CreateSpectrumFrom.Column)
            {
                Altaxo.Data.INumericColumn xcol;

                if (m_XValuesFrom == XValuesFrom.Column)
                {
                    string colname = _view.XValuesColumnName;
                    if (null == colname)
                    {
                        Current.Gui.ErrorMessageBox("No x-column selected");
                        return(false);
                    }

                    xcol = m_Table.DataColumns[colname] as Altaxo.Data.INumericColumn;
                }
                else // xvalues are continuous number
                {
                    xcol = new Altaxo.Data.IndexerColumn();
                }

                Altaxo.Data.DataColumn extFileNameCol = null;
                if (m_ExtendFileNameWith == ExtendFileNameWith.Column)
                {
                    extFileNameCol = m_Table.PropCols[_view.ExtFileNameColumnName];
                }

                int  i, j;
                bool bUseColSel   = (null != m_SelectedColumns && m_SelectedColumns.Count > 0);
                int  numOfSpectra = bUseColSel ? m_SelectedColumns.Count : m_Table.DataColumns.ColumnCount;

                for (j = 0; j < numOfSpectra; j++)
                {
                    i = bUseColSel ? m_SelectedColumns[j] : j;

                    string filename = _view.BasicFileName;

                    if (null != extFileNameCol)
                    {
                        filename += extFileNameCol[i].ToString();
                    }
                    else
                    {
                        filename += j.ToString() + ".spc";
                    }

                    string error = Export.FromColumn(filename, m_Table, i, xcol, m_SelectedRows);

                    if (null != error)
                    {
                        Current.Gui.ErrorMessageBox(string.Format("There were error(s) during export: {0}", error));
                        return(false);
                    }
                }

                Current.Gui.InfoMessageBox(string.Format("Export of {0} spectra successfull.", numOfSpectra));
            }
            return(true);
        }