当前位置: 首页>>代码示例>>C#>>正文


C# Altaxo.Suspend方法代码示例

本文整理汇总了C#中Altaxo.Suspend方法的典型用法代码示例。如果您正苦于以下问题:C# Altaxo.Suspend方法的具体用法?C# Altaxo.Suspend怎么用?C# Altaxo.Suspend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Altaxo的用法示例。


在下文中一共展示了Altaxo.Suspend方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportImage

    public static void ImportImage(Altaxo.Data.DataTable table)
    {
      ColorAmplitudeFunction colorfunc;
      System.IO.Stream myStream;
      OpenFileDialog openFileDialog1 = new OpenFileDialog();

      openFileDialog1.InitialDirectory = "c:\\" ;
      openFileDialog1.Filter = "Image files (*.bmp;*.jpg;*.png,*.tif)|*.bmp;*.jpg;*.png,*.tif|All files (*.*)|*.*";
      openFileDialog1.FilterIndex = 1 ;
      openFileDialog1.RestoreDirectory = true ;

      if(openFileDialog1.ShowDialog() == DialogResult.OK)
      {
        if((myStream = openFileDialog1.OpenFile())!= null)
        {
          System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myStream);

          int sizex = bmp.Width;
          int sizey = bmp.Height;
          //if(Format16bppGrayScale==bmp.PixelFormat)
          
          colorfunc = new ColorAmplitudeFunction(ColorToBrightness);
          // add here other function or the result of a dialog box
  
          // now add new columns to the worksheet, 
          // the name of the columns should preferabbly simply
          // the index in x direction

          table.Suspend();
          for(int i=0;i<sizex;i++)
          {
            Altaxo.Data.DoubleColumn dblcol = new Altaxo.Data.DoubleColumn();
            for(int j=sizey-1;j>=0;j--)
              dblcol[j] = colorfunc(bmp.GetPixel(i,j));

            table.DataColumns.Add(dblcol,table.DataColumns.FindUniqueColumnName(i.ToString())); // Spalte hinzufügen
          } // end for all x coordinaates

          table.Resume();

          myStream.Close();
          myStream=null;
        } // end if myStream was != null
      } 
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:45,代码来源:FileCommands.cs

示例2: ShowAddColumnsDialog

    /// <summary>
    /// Shows a dialog to add columns to a table.
    /// </summary>
    /// <param name="table">The table where to add the columns.</param>
    /// <param name="bAddToPropertyColumns">If true, the columns are added to the property columns instead of the data columns collection.</param>
    public static void ShowAddColumnsDialog(Altaxo.Data.DataTable table, bool bAddToPropertyColumns)
    {
      Altaxo.Collections.SelectableListNodeList lbitems = new Altaxo.Collections.SelectableListNodeList();
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Numeric", typeof(Altaxo.Data.DoubleColumn), true));
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Date/Time", typeof(Altaxo.Data.DateTimeColumn), false));
      lbitems.Add(new Altaxo.Collections.SelectableListNode("Text", typeof(Altaxo.Data.TextColumn), false));

      IntegerAndComboBoxController ct = new IntegerAndComboBoxController(
        "Number of colums to add:", 1, int.MaxValue, 1,
        "Type of columns to add:", lbitems, 0);

      SpinAndComboBoxControl panel = new SpinAndComboBoxControl();
      ct.View = panel;

      if (true == Current.Gui.ShowDialog(ct,"Add new column(s)",false))
      {
        System.Type columntype = (System.Type)ct.SelectedItem.Item;

        table.Suspend();

        if (bAddToPropertyColumns)
        {
          for (int i = 0; i < ct.IntegerValue; i++)
          {
            table.PropCols.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
          }
        }
        else
        {
          for (int i = 0; i < ct.IntegerValue; i++)
          {
            table.DataColumns.Add((Altaxo.Data.DataColumn)System.Activator.CreateInstance(columntype));
          }
        }

        table.Resume();
      }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:43,代码来源:WorksheetCommands.cs

示例3: ExecuteWithSuspendedNotifications

    /// <summary>
    /// Executes the script. If no instance of the script object exists, a error message will be stored and the return value is false.
    /// If the script object exists, the data change notifications will be switched of (for all tables).
    /// Then the Execute function of this script object is called. Afterwards, the data changed notifications are switched on again.
    /// </summary>
    /// <param name="myTable">The data table this script is working on.</param>
    /// <returns>True if executed without exceptions, otherwise false.</returns>
    /// <remarks>If exceptions were thrown during execution, the exception messages are stored
    /// inside the column script and can be recalled by the Errors property.</remarks>
    public bool ExecuteWithSuspendedNotifications(Altaxo.Data.DataTable myTable)
    {
      bool bSucceeded=true;
      Altaxo.Data.DataTableCollection   myDataSet=null;

      // first, test some preconditions
      if(null==m_ScriptObject)
      {
        m_Errors = new string[1]{"Script Object is null"};
        return false;
      }

      myDataSet = Altaxo.Data.DataTableCollection.GetParentDataTableCollectionOf(myTable);

      if(null!=myDataSet) 
        myDataSet.Suspend();
      else if(null!=myTable)
        myTable.Suspend();

      try
      {
        ((Altaxo.Calc.TableScriptExeBase)m_ScriptObject).Execute(myTable);
      }
      catch(Exception ex)
      {
        bSucceeded = false;
        m_Errors = new string[1];
        m_Errors[0] = ex.ToString();
      }
      finally
      {
        if(null!=myDataSet) 
          myDataSet.Resume();
        else if(null!=myTable)
          myTable.Resume();
      }

      return bSucceeded; 
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:48,代码来源:TableScript.cs

示例4: ImportAscii


//.........这里部分代码省略.........
      
      for(int i=0;true;i++)
      {
        sLine = sr.ReadLine();
        if(null==sLine) break;

        string[] substr = sLine.Split(splitchar);
        int cnt = Math.Min(substr.Length,newcols.ColumnCount);
        for(int k=0;k<cnt;k++)
        {
          if(substr[k].Length==0)
            continue;

          if(newcols[k] is Altaxo.Data.DoubleColumn)
          {
            try { ((Altaxo.Data.DoubleColumn)newcols[k])[i] = System.Convert.ToDouble(substr[k],numberFormatInfo); }
            catch {}
          }
          else if( newcols[k] is Altaxo.Data.DateTimeColumn)
          {
            try { ((Altaxo.Data.DateTimeColumn)newcols[k])[i] = System.Convert.ToDateTime(substr[k]); }
            catch {}
          }
          else if( newcols[k] is Altaxo.Data.TextColumn)
          {
            ((Altaxo.Data.TextColumn)newcols[k])[i] = substr[k];
          }
          else if(null==newcols[k] || newcols[k] is Altaxo.Data.DBNullColumn)
          {
            bool bConverted = false;
            double val=Double.NaN;
            DateTime valDateTime=DateTime.MinValue;

            try
            { 
              val = System.Convert.ToDouble(substr[k]);
              bConverted=true;
            }
            catch
            {
            }
            if(bConverted)
            {
              Altaxo.Data.DoubleColumn newc = new Altaxo.Data.DoubleColumn();
              newc[i]=val;
              newcols.Replace(k,newc);
            }
            else
            {
              try
              { 
                valDateTime = System.Convert.ToDateTime(substr[k]);
                bConverted=true;
              }
              catch
              {
              }
              if(bConverted)
              {
                Altaxo.Data.DateTimeColumn newc = new Altaxo.Data.DateTimeColumn();
                newc[i]=valDateTime;
                
                newcols.Replace(k, newc);
              }
              else
              {
                Altaxo.Data.TextColumn newc = new Altaxo.Data.TextColumn();
                newc[i]=substr[k];
                newcols.Replace(k,newc);
              }
            } // end outer if null==newcol
          }
        } // end of for all cols


      } // end of for all lines
      
      // insert the new columns or replace the old ones
      table.Suspend();
      bool tableWasEmptyBefore = table.DataColumns.ColumnCount==0;
      for(int i=0;i<newcols.ColumnCount;i++)
      {
        if(newcols[i] is Altaxo.Data.DBNullColumn) // if the type is undefined, use a new DoubleColumn
          table.DataColumns.CopyOrReplaceOrAdd(i,new Altaxo.Data.DoubleColumn(), newcols.GetColumnName(i));
        else
          table.DataColumns.CopyOrReplaceOrAdd(i,newcols[i], newcols.GetColumnName(i));

        // set the first column as x-column if the table was empty before, and there are more than one column
        if(i==0 && tableWasEmptyBefore && newcols.ColumnCount>1)
          table.DataColumns.SetColumnKind(0,Altaxo.Data.ColumnKind.X);

      } // end for loop

      // add the property columns
      for(int i=0;i<newpropcols.ColumnCount;i++)
      {
        table.PropCols.CopyOrReplaceOrAdd(i,newpropcols[i], newpropcols.GetColumnName(i));
      }
      table.Resume();
    } // end of function ImportAscii
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:101,代码来源:AsciiImporter.cs


注:本文中的Altaxo.Suspend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。