Esempio n. 1
0
 public void SetPos(Point?pos = null)
 {
     ControlTools.SetWindowPos(this, pos);
 }
Esempio n. 2
0
        public static Task Create(string msg, IEnumerable <PlotInfo> plotInfos, IEnumerable <double> baseLines)
        {
            if (plotInfos is null)
            {
                return(null);
            }

            if (baseLines is null)
            {
                baseLines = new List <double>()
                {
                    0
                };
            }

            var allList       = new List <double>(baseLines);
            int baseLineCount = allList.Count;

            foreach (var plotInfo in plotInfos)
            {
                if (plotInfo is null)
                {
                    continue;
                }

                if (plotInfo.list.Count < 2)
                {
                    continue;
                }

                allList.AddRange(plotInfo.list);
            }

            if (allList.Count == baseLineCount)
            {
                return(null);
            }

#if false   // あまり意味が無さそう
            var tasks2 = new List <Task <double> >();
            tasks2.Add(Task.Run(() => StatisticsLib.MinInTheList(allList)));
            tasks2.Add(Task.Run(() => StatisticsLib.MaxInTheList(allList)));
            var    aaaa     = Task.WhenAll(tasks2).Result;
            double minPoint = aaaa[0];
            double maxPoint = aaaa[1];
#else
            double minPoint = StatisticsLib.Min(allList);
            double maxPoint = StatisticsLib.Max(allList);
#endif
            allList.Clear();
            allList = null;

            var _baseLines = new List <double>(baseLines);
            if (_baseLines.Count == 0)
            {
                _baseLines.Add(minPoint);
                _baseLines.Add(maxPoint);
                _baseLines.Add(0);
            }
            baseLines = null;

            PlotWindow plotWindow = new PlotWindow();
            plotWindow.Owner = CommandCanvasList.OwnerWindow;

            plotWindow.Dispatcher.BeginInvoke(new Action(() =>
            {
                ControlTools.SetWindowPos(plotWindow, null);
            }), DispatcherPriority.Loaded);

            plotWindow.Title = "Plot";
            if (msg != null && msg.Trim() != "")
            {
                plotWindow.Title += ": " + msg;
            }
            plotWindow.Show();

            DrawGuideLine(plotWindow, _baseLines, minPoint, maxPoint);

            var tasks = new List <Task>();
            foreach (var plotInfo in plotInfos)
            {
                if (plotInfo is null)
                {
                    continue;
                }

                var task = Task.Run(() => PlotOut(plotWindow, plotInfo.list, minPoint, maxPoint, plotInfo.drawType, plotInfo.solidColorBrush));
                tasks.Add(task);
            }
            return(Task.WhenAll(tasks));
        }