public SettingsWindow(PropertyInfo[] properties, GraphService graph)
        {
            InitializeComponent();

            _graph         = graph;
            _properties    = properties;
            _defaultValues = new float[properties.Length];

            for (var i = 0; i < properties.Length; i++)
            {
                var property = properties[i];
                var range    = property.GetCustomAttribute <RangeAttribute>();

                _defaultValues[i] = (float)property.GetValue(graph);

                RootPanel.Children.Add(new TextBlock()
                {
                    Text = range.Name
                });
                var slider = new Slider()
                {
                    Minimum       = range.Min,
                    Maximum       = range.Max,
                    Value         = _defaultValues[i],
                    TickFrequency = (range.Max - range.Min) / 100,
                };
                slider.ValueChanged += (s, e) =>
                {
                    property.SetValue(_graph, (float)e.NewValue);
                };
                RootPanel.Children.Add(slider);
            }
        }
Beispiel #2
0
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            _graphService = new GraphService(Surface);
            _graphService.Run(Surface);

            _graphService.UserSelected  += GraphServiceOnUserSelected;
            _graphService.UserNavigated += GraphServiceOnUserNavigated;

            var properties = typeof(GraphService).GetProperties()
                             .Where(i => i.GetCustomAttribute <RangeAttribute>() != null)
                             .ToArray();

            _settingsWindow = new SettingsWindow(properties, _graphService);

            Auth(false);
        }