private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            // Create our data in another thread to stop the UI from being stalled.
            // It's not appending to SciChart Dataseries that is the problem, its Calling Rand.Next() two million times which is pretty slow :)
            TimedMethod.Invoke(() =>
            {
                var dataSeries = new XyDataSeries <double, double>()
                {
                    AcceptsUnsortedData = true
                };
                var rand = new FasterRandom();

                // Allow 1M points in WPF/DirectX. In Silverlight or software rendering, 100k points is enough to stress the renderer
                int count = FeaturesHelper.Instance.SupportsHardwareAcceleration ? (int)1E6 : (int)1E5;

                // Append some data
                for (int i = 0; i < count; i++)
                {
                    dataSeries.Append(rand.NextDouble(), rand.NextDouble());
                }

                // Bind to scichart
                Action bindData = () => { BindData(dataSeries); };
                Dispatcher.BeginInvoke(bindData);
            }).After(200).OnThread(TimedMethodThread.Background).Go();
        }
        private void OnExampleLoaded(object sender, RoutedEventArgs e)
        {
            // Manages the state of example on enter
            Reset();

            _startDelegate = TimedMethod.Invoke(this.Start).After(500).Go();
        }
Ejemplo n.º 3
0
        public override void FilterAll()
        {
            _filteredDataSeries.Clear();

            int    index = 0;
            double animationStepMillisconds = 1;

            Action appendPoint = null;

            Action onAppendCallback = () =>
            {
                // 2.) Append the point
                _filteredDataSeries.Append(_originalDataSeries.XValues[index], _originalDataSeries.YValues[index]);
                _filteredDataSeries.InvalidateParentSurface(RangeMode.ZoomToFit);

                // 3.) Schedule another until complete
                if (++index < _originalDataSeries.Count)
                {
                    // Achieve some rudimentary easing
                    animationStepMillisconds *= 1.05;
                    animationStepMillisconds  = Math.Min(animationStepMillisconds, 10);

                    // Next point
                    appendPoint();
                }
            };

            appendPoint = () =>
            {
                TimedMethod.Invoke(onAppendCallback).After((int)animationStepMillisconds).Go();
            };

            // 1.) Schedule one point to be appended
            appendPoint();
        }
Ejemplo n.º 4
0
 private static void DoLoaded(object sender, EventArgs e)
 {
     TimedMethod.Invoke(() =>
     {
         var command = GetLoadedEventCommand((DependencyObject)sender);
         if (command != null)
         {
             command.Execute(null);
         }
     }).After(200).Go();
 }
Ejemplo n.º 5
0
        public MainWindowViewModel(IModule module, IUsageCalculator usageCalculator)
        {
            SearchText              = "";
            SearchResults           = new ObservableCollection <ISelectable>();
            _autoCompleteDataSource = module.Examples.Select(ex => ex.Value.Title).ToList();

            WithTrait <AutoCompleteSearchBehaviour>();
            WithTrait <InitializationBehaviour>();

            _hideSearchCommand = new ActionCommand(() =>
            {
                SearchText = null;
            });

            _showSettingsCommand = new ActionCommand(() =>
            {
                IsSettingsShow     = true;
                BlurOnSearchParams = _blurredParams;
            });

            _hideSettingsCommand = new ActionCommand(() =>
            {
                IsSettingsShow     = false;
                BlurOnSearchParams = _defaultParams;
            });

            _exportCommand = new ActionCommand(() =>
            {
                _hideSettingsCommand.Execute(null);
                DeveloperModManager.Manage.IsDeveloperMode = false;
                TimedMethod.Invoke(() => HtmlExportHelper.ExportExampleToHtml(SelectedExample)).After(1000).Go();
            }, () => SelectedExample != null);

            _exportAllHtmlCommand = new ActionCommand(() =>
            {
                _hideSettingsCommand.Execute(null);
                DeveloperModManager.Manage.IsDeveloperMode = false;
                TimedMethod.Invoke(() => HtmlExportHelper.ExportExamplesToHtml(module)).After(1000).Go();
            }, () => SelectedExample != null);

            _exportAllSolutionsCommand = new ActionCommand(() =>
            {
                _hideSettingsCommand.Execute(null);
                ExportExampleHelper.ExportExamplesToSolutions(module);
            }, () => SelectedExample != null);

            _gcCollectCommand = new ActionCommand(() =>
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForFullGCApproach();
            });
        }
        public static void ExportExamplesToHtml(IModule module)
        {
            var enumerator = module.Examples.Select(x => x.Value).GetEnumerator();

            if (!GetPathForExport())
            {
                return;
            }

            Action <UserControl, AppPage> action = null;

            action = (control, page) =>
            {
                RoutedEventHandler controlOnLoaded = null;
                controlOnLoaded = (sender, args) =>
                {
                    TimedMethod.Invoke(() =>
                    {
                        ExportExampleToHtml(enumerator.Current, false);

                        if (enumerator.MoveNext())
                        {
                            Navigator.Instance.Navigate(enumerator.Current);
                            ServiceLocator.Container.Resolve <IModule>().CurrentExample = enumerator.Current;
                        }
                        else
                        {
                            Navigator.Instance.AfterNavigation -= action;
                        }

                        control.Loaded -= controlOnLoaded;
                    }).After(1000).Go();
                };
                control.Loaded += controlOnLoaded;
            };

            Navigator.Instance.AfterNavigation += action;

            if (enumerator.MoveNext())
            {
                Navigator.Instance.Navigate(enumerator.Current);
            }

            ExportIndexToHtml(module);
        }
Ejemplo n.º 7
0
 private void OnExampleLoaded(object sender, RoutedEventArgs e)
 {
     ResetButton_Click(this, null);
     _startDelegate = TimedMethod.Invoke(() => StartButton_Click(this, null)).After(500).Go();
 }
Ejemplo n.º 8
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup   = GetTemplateChild("PART_Popup") as Canvas;
            _border  = GetTemplateChild("PART_Border") as Border;
            _root    = GetTemplateChild("RootElement") as Grid;
            _callout = GetTemplateChild("Callout") as Callout;

            if (_root == null)
            {
                return;
            }
            _fadeStoryboard = ((Storyboard)_root.TryFindResource("FadeBorderAnimation"));

            if (_border == null || _callout == null || _popup == null)
            {
                return;
            }

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                _popup.Visibility = Visibility.Visible;
            }

            MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                }).After(200).Go();
            };
            MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
                if (_popup.Visibility == Visibility.Collapsed)
                {
                    _popup.Visibility = Visibility.Visible;
                }
            };

            _callout.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
            };

            _callout.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                }).After(200).Go();
            };

            //#if !SILVERLIGHT
            //            _popup.VerticalOffset = -32;
            //            _popup.AllowsTransparency = true;
            //            _popup.PopupAnimation = PopupAnimation.Fade;
            //#endif
        }
Ejemplo n.º 9
0
        public static void ExportExamplesToSolutions(IModule module)
        {
            var enumerator = module.Examples.Select(x => x.Value).GetEnumerator();
            var basePath   = DirectoryHelper.GetPathForExport(DefaultExportPath);

            if (string.IsNullOrEmpty(basePath))
            {
                return;
            }

            ExportPath = basePath + "\\" + FolderName + "\\";

            try
            {
                if (File.Exists(ScriptPath))
                {
                    File.Delete(ScriptPath);
                }

                if (Directory.Exists(ExportPath))
                {
                    Directory.Delete(ExportPath, true);
                }

                if (!Directory.Exists(ExportPath))
                {
                    Directory.CreateDirectory(ExportPath);
                }
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("A permissions error occurred when deleting or creating example export paths. Please check you are not trying to export in a restricted directory such as C: or Program Files", ex);
            }

            string lastGroup = null;
            Action <UserControl, AppPage> action = null;

            action = (control, page) =>
            {
                RoutedEventHandler controlOnLoaded = null;
                controlOnLoaded = (sender, args) =>
                {
                    TimedMethod.Invoke(() =>
                    {
                        ExportExampleToSolution(ref lastGroup, enumerator.Current);

                        if (enumerator.MoveNext())
                        {
                            Navigator.Instance.Navigate(enumerator.Current);
                        }
                        else
                        {
                            Navigator.Instance.AfterNavigation -= action;
                        }

                        control.Loaded -= controlOnLoaded;
                    }).After(1000).Go();
                };
                control.Loaded += controlOnLoaded;
            };

            Navigator.Instance.AfterNavigation += action;

            if (enumerator.MoveNext())
            {
                Navigator.Instance.Navigate(enumerator.Current);
            }
        }
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _popup   = GetTemplateChild("PART_Popup") as Canvas;
            _border  = GetTemplateChild("PART_Border") as Border;
            _root    = GetTemplateChild("RootElement") as Grid;
            _callout = GetTemplateChild("Callout") as Callout;

            if (_root == null)
            {
                return;
            }
            _fadeStoryboard = ((Storyboard)_root.TryFindResource("FadeBorderAnimation"));

            if (_border == null || _callout == null || _popup == null)
            {
                return;
            }

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                _popup.Visibility = Visibility.Visible;
            }

            _border.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
                if (_popup.Visibility == Visibility.Collapsed)
                {
                    _popup.Visibility = Visibility.Visible;
                    _fadeStoryboard.Begin();
                }
            };

            _border.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };

            _callout.MouseEnter += (s, e) =>
            {
                if (_popupCloseToken != null)
                {
                    _popupCloseToken.Dispose();
                    _popupCloseToken = null;
                }
            };

            _callout.MouseLeave += (s, e) =>
            {
                _popupCloseToken = TimedMethod.Invoke(() =>
                {
                    _popup.Visibility = Visibility.Collapsed;
                    _fadeStoryboard.Stop();
                }).After(200).Go();
            };
        }