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


C# Altaxo.SuspendGetToken方法代码示例

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


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

示例1: 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="myColumn">The property column this script is working on.</param>
		/// <param name="reporter">Progress reporter that can be used by the script to report the progress of its work.</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.DataColumn myColumn, IProgressReporter reporter)
		{
			bool bSucceeded = true;
			Altaxo.Data.DataTableCollection myDataSet = null;

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

			Altaxo.Data.DataColumnCollection myColumnCollection = Altaxo.Data.DataColumnCollection.GetParentDataColumnCollectionOf(myColumn);

			Altaxo.Data.DataTable myTable = Altaxo.Data.DataTable.GetParentDataTableOf(myColumnCollection);

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

			IDisposable suspendToken = null;

			if (null != myDataSet)
				suspendToken = myDataSet.SuspendGetToken();
			else if (null != myTable)
				suspendToken = myTable.SuspendGetToken();
			else if (null != myColumnCollection)
				suspendToken = myColumnCollection.SuspendGetToken();
			else if (null != myColumn)
				suspendToken = myColumn.SuspendGetToken();

			try
			{
				((Altaxo.Calc.ColScriptExeBase)_scriptObject).Execute(myColumn, reporter);
			}
			catch (Exception ex)
			{
				bSucceeded = false;
				_errors = new string[1];
				_errors[0] = ex.ToString();
			}
			finally
			{
				if (null != suspendToken)
					suspendToken.Dispose();
			}

			return bSucceeded;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:57,代码来源:PropertyColumnScript.cs

示例2: Interpolation

		public static void Interpolation(Altaxo.Data.DataColumn xCol, Altaxo.Data.DataColumn yCol,
			Calc.Interpolation.IInterpolationFunction interpolInstance, IROVector samplePoints,
			Altaxo.Data.DataColumn xRes, Altaxo.Data.DataColumn yRes)
		{
			int rows = Math.Min(xCol.Count, yCol.Count);
			IROVector yVec = DataColumnWrapper.ToROVector((INumericColumn)yCol, rows);
			IROVector xVec = DataColumnWrapper.ToROVector((INumericColumn)xCol, rows);

			interpolInstance.Interpolate(xVec, yVec);

			using (var suspendToken_xRes = xRes.SuspendGetToken())
			{
				using (var suspendToken_yRes = yRes.SuspendGetToken())
				{
					for (int i = 0; i < samplePoints.Length; i++)
					{
						//double r = i / (double)(parameters.NumberOfPoints - 1);
						//double x = parameters.XOrg * (1 - r) + parameters.XEnd * (r);
						double x = samplePoints[i];
						double y = interpolInstance.GetYOfX(x);
						xRes[i] = x;
						yRes[i] = y;
					}
					suspendToken_yRes.Resume();
				}
				suspendToken_xRes.Resume();
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:28,代码来源:CalculusCommands.cs

示例3: SavitzkyGolay

		public static void SavitzkyGolay(SavitzkyGolayParameters parameters, Altaxo.Data.DataColumn yCol, Altaxo.Data.DataColumn xCol)
		{
			double spacing = 1;
			if (xCol is Data.INumericColumn)
			{
				Calc.LinearAlgebra.VectorSpacingEvaluator calcspace = new Calc.LinearAlgebra.VectorSpacingEvaluator(Calc.LinearAlgebra.DataColumnWrapper.ToROVector(xCol));
				if (!calcspace.HasValidSpaces || calcspace.HasInvalidSpaces)
				{
					Current.Gui.ErrorMessageBox(string.Format("The x-column {0} contains invalid spaces (is not equally spaced)", xCol.Name));
					return;
				}
				if (calcspace.RelativeSpaceDeviation > 1E-2)
				{
					if (!Current.Gui.YesNoMessageBox(
						string.Format("The x-column {0} is not equally spaced, the deviation is {1}, the mean spacing is {2}. Continue anyway?", xCol.Name, calcspace.RelativeSpaceDeviation, calcspace.SpaceMeanValue),
						"Continue?", true))
						return;
				}

				spacing = calcspace.SpaceMeanValue;
			}

			Calc.Regression.SavitzkyGolay filter = new SavitzkyGolay(parameters);

			using (var suspendToken = yCol.SuspendGetToken())
			{
				filter.Apply(DataColumnWrapper.ToROVectorCopy(yCol), DataColumnWrapper.ToVector(yCol));

				if (parameters.DerivativeOrder > 0)
				{
					double factor = Math.Pow(1 / spacing, parameters.DerivativeOrder) * Calc.GammaRelated.Fac(parameters.DerivativeOrder);
					yCol.Data = yCol * factor;
				}
				suspendToken.Dispose();
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:36,代码来源:CalculusCommands.cs

示例4: 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)
		{
			var 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);
			Current.Gui.FindAndAttachControlTo(ct);

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

				using (var suspendToken = table.SuspendGetToken())
				{
					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));
						}
					}

					suspendToken.Dispose();
				}
			}
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:42,代码来源:WorksheetCommands.cs


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