Exemplo n.º 1
0
 private static void SetPropertyValue(Data.SettingParam setting, Data.PropertyParam param, KeyValuePair <System.Reflection.PropertyInfo, object> propertyInfo)
 {
     if (setting.Value is IConvertible)
     {
         object value = Convert.ChangeType(setting.Value, param.Type);
         if (param.Type == typeof(int))
         {
             object min = Convert.ChangeType(setting.Minimum, param.Type);
             if (Convert.ToDouble(value) < Convert.ToDouble(min))
             {
                 return;
             }
         }
         propertyInfo.Key.SetValue(propertyInfo.Value, value, null);
     }
     else
     {
         propertyInfo.Key.SetValue(propertyInfo.Value, setting.Value, null);
     }
 }
Exemplo n.º 2
0
        internal void RangeSelectorChanged()
        {
            if (financialChart != null && Model.LowerValue != null && Model.UpperValue != null)
            {
                financialChart.BeginUpdate();

                IEnumerable <Object.QuoteRange> ranges = GetYRange(Model.LowerValue.Value, Model.UpperValue.Value);
                if (ranges != null && ranges.Any())
                {
                    if (financialChart != null)
                    {
                        mainSeries.AxisY.Min
                              = financialChart.AxisY.Min
                              = ranges.Min(p => { return(p == null ? int.MaxValue : p.Min); });
                        mainSeries.AxisY.Max
                              = financialChart.AxisY.Max
                              = ranges.Max(p => { return(p == null ? int.MinValue : p.Max); });

                        IndicatorsRangeSelectorChanged();

                        if (arcs.Visibility == C1.Chart.SeriesVisibility.Visible)
                        {
                            Data.ArcsRange range = GetArcsRange(Model.LowerValue.Value, Model.UpperValue.Value);

                            arcs.StartX = range.StartX;
                            arcs.EndX   = range.EndX;

                            arcs.StartY = range.StartY;
                            arcs.EndY   = range.EndY;

                            IEnumerable <Data.SettingParam> settings;
                            if (ViewModel.ViewModel.Instance.Settings.TryGetValue("Fibonacci Arcs", out settings))
                            {
                                Data.SettingParam param = (from p in settings where p.Key == "StartX" select p).FirstOrDefault();
                                param.Value = arcs.StartX;
                                param       = (from p in settings where p.Key == "EndX" select p).FirstOrDefault();
                                param.Value = arcs.EndX;

                                param       = (from p in settings where p.Key == "StartY" select p).FirstOrDefault();
                                param.Value = arcs.StartY;
                                param       = (from p in settings where p.Key == "EndY" select p).FirstOrDefault();
                                param.Value = arcs.EndY;
                            }
                        }
                        else if (fans.Visibility == C1.Chart.SeriesVisibility.Visible)
                        {
                            Data.ArcsRange range = GetArcsRange(Model.LowerValue.Value, Model.UpperValue.Value);

                            fans.StartX = range.EndX;
                            fans.EndX   = range.StartX;

                            fans.StartY = range.EndY;
                            fans.EndY   = range.StartY;

                            IEnumerable <Data.SettingParam> settings;
                            if (ViewModel.ViewModel.Instance.Settings.TryGetValue("Fibonacci Fans", out settings))
                            {
                                Data.SettingParam param = (from p in settings where p.Key == "StartX" select p).FirstOrDefault();
                                param.Value = fans.StartX;
                                param       = (from p in settings where p.Key == "EndX" select p).FirstOrDefault();
                                param.Value = fans.EndX;

                                param       = (from p in settings where p.Key == "StartY" select p).FirstOrDefault();
                                param.Value = fans.StartY;
                                param       = (from p in settings where p.Key == "EndY" select p).FirstOrDefault();
                                param.Value = fans.EndY;
                            }
                        }
                    }
                }
                var quote = ranges.First();
            }
            financialChart.EndUpdate();
        }