예제 #1
0
        public void Function(ScalarValue digits)
        {
            var n = digits.GetIntegerOrThrowException("digits", Name);

            Context.Precision = n;
            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Information, "Output precision changed to " + Context.Precision + " digits."));
        }
예제 #2
0
        public void Function(PlotValue plot, MatrixValue series, StringValue property, Value newValue)
        {
            var s = new List <string>();

            if (series is RangeValue)
            {
                var r    = series as RangeValue;
                var step = (int)r.Step;
                var end  = r.All ? plot.Count : (int)r.End;

                for (var j = (int)r.Start; j <= end; j += step)
                {
                    s.Add(j.ToString());
                    AlterSeriesProperty(plot, j - 1, property.Value, newValue);
                }
            }
            else
            {
                var end = series.Length;

                for (var i = 1; i <= end; i++)
                {
                    var n = series[i].GetIntegerOrThrowException("series", Name);
                    s.Add(n.ToString());
                    AlterSeriesProperty(plot, n - 1, property.Value, newValue);
                }
            }

            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Failure, "Series " + string.Join(", ", s.ToArray()) + " changed."));
            plot.UpdateProperties();
        }
예제 #3
0
        public void Function(StringValue type)
        {
            var stec  = new StringToEnumConverter(typeof(DisplayStyle));
            var value = stec.Convert(type);

            Context.DefaultDisplayStyle = (DisplayStyle)value;
            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Information, "Display format changed to " + value + "."));
        }
예제 #4
0
        public void Function(PlotValue plot, StringValue property, Value newValue)
        {
            var propertyName = property.Value;

            AlterProperty(plot, propertyName, newValue);
            plot.RaisePlotChanged(propertyName);
            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Success, "Property changed"));
        }
예제 #5
0
 public void Function(MatrixValue series, StringValue property, Value newValue)
 {
     if (Context.LastPlot == null)
     {
         Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Failure, "No plot available... Nothing changed."));
     }
     else
     {
         Function(Context.LastPlot, series, property, newValue);
     }
 }
예제 #6
0
        public void Function(ScalarValue timeout)
        {
            var n     = timeout.GetIntegerOrThrowException("timeout", Name);
            var start = Environment.TickCount;

            using (var blocking = new ManualResetEvent(false))
            {
                blocking.WaitOne(n);
            }

            var time = Environment.TickCount - start;

            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Information, "Slept " + time + "ms."));
        }
예제 #7
0
        public void Function(PlotValue plot, ScalarValue series, StringValue property, Value newValue)
        {
            if (plot.Count == 0)
            {
                throw new YAMPNoSeriesAvailableException("The given plot contains no series.");
            }

            var n = series.GetIntegerOrThrowException("series", Name);

            if (n < 1 || n > plot.Count)
            {
                throw new YAMPArgumentRangeException("series", 1, plot.Count);
            }

            AlterSeriesProperty(plot, n - 1, property.Value, newValue);
            plot.UpdateProperties();
            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Success, "Series " + n + " changed."));
        }
예제 #8
0
        public void Function(StringValue path)
        {
            var p = path.Value;

            if (!Path.IsPathRooted(path.Value))
            {
                p = Path.Combine(Environment.CurrentDirectory, path.Value);
            }

            if (!Directory.Exists(path.Value))
            {
                Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Failure, "The directory " + p + " could not be found."));
            }
            else
            {
                Environment.CurrentDirectory = path.Value;
            }
        }
예제 #9
0
 void Notify(int count)
 {
     Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Information, count + " objects cleared."));
 }
예제 #10
0
        public void Function(StringValue text, ArgumentsValue args)
        {
            var content = string.Format(text.Value, args.ToArray());

            Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Message, content));
        }
예제 #11
0
 void Notify(int count)
 {
     Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Success, count + " objects loaded."));
 }
예제 #12
0
 public void Function(StringValue source, StringValue target)
 {
     File.Copy(source.Value, target.Value);
     Parser.RaiseNotification(Context, new NotificationEventArgs(NotificationType.Success, string.Format("Copied {0} to {1}.", source.Value, target.Value)));
 }