Exemple #1
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Layout.main_activity_actions, menu);

            menu.FindItem(Resource.Id.action_play)
            .DoWith(SetStartSTopIcon)
            .SetOnMenuItemClickListener(
                new MenuItemClickListener(
                    item => {
                StartStop();
                SetStartSTopIcon(item);
            }
                    )
                );

            foreach (var plugin in SignalRenders)
            {
                menu.Add(plugin.Title).OnClick(
                    item => SignalRenders.Enable(plugin)
                    );
            }

            foreach (var plugin in CanvasActions)
            {
                menu.Add(plugin.Title).OnClick(item =>
                                               plugin.IsEnabled = !plugin.IsEnabled
                                               );
            }
            menu.Add("ByFrame").OnClick(item => {
                if (PreProcessorType == PreProcessorType.Endless)
                {
                    PreProcessorType = PreProcessorType.ByFrame;
                    item.SetTitle("EndLess");
                }
                else
                {
                    PreProcessorType = PreProcessorType.Endless;
                    item.SetTitle("ByFrame");
                }
                _signalPreProcessor = PreProcessorFty.Create(_signalPreProcessor, PreProcessorType);
            });

            return(base.OnCreateOptionsMenu(menu));
        }
        public static ISignalPreProcessor Create(ISignalPreProcessor previous, PreProcessorType type = PreProcessorType.Endless)
        {
            if (previous != null)
            {
                Points = previous.Points;
            }

            switch (type)
            {
            case PreProcessorType.ByFrame:

                return(new PreProcessor((context, xpoints, rawSignal) => {
                    var last = context.Steps + 1;

                    var m = rawSignal.X % (last);

                    var next = Points.Count + 1 <= last ? Points.Count + 1 : 0;

                    var index = next == m + 1 ? m : next;

                    if (index == 0)
                    {
                        Points = new List <RPoint> ();
                    }

                    Points.Add(new RPoint(index, rawSignal.Y));

                    //Scale
                    return Points.Select(x => {
                        var step = (float)((x.X) * context.Step);

                        return XPointFty.New(step, x.Y);
                    }
                                         ).ToArray();
                }, Points));

            case PreProcessorType.Endless:
                return(new ContinuousPreProcessor(Points));
            }

            throw new ArgumentException("unkwon Preprocessor Type");
        }