| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using MuchInfo.Chart.Data.EnumTypes;
- using MuchInfo.Chart.Data.Interfaces;
- using MuchInfo.Chart.DataAccess;
- using MuchInfo.Chart.WPF.Primitives;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Input;
- namespace MuchInfo.Chart.App.Services
- {
- /// <summary>
- /// Class DataService
- /// </summary>
- public class DataService : IDataService
- {
- #region Methods
- #region Public Methods
- public List<ModifierKeys> GetModifierKeys()
- {
- var list = GetEnumList<ModifierKeys>();
- list.Remove(ModifierKeys.Windows);
- return list;
- }
- public List<CycleType> GetCycleTypes()
- {
- var list = GetEnumList<CycleType>();
- list.Remove(CycleType.None);
- list.Remove(CycleType.Custom);
- return list;
- }
- /// <summary>
- /// Gets the data set.
- /// </summary>
- /// <param name="symbol">The symbol.</param>
- /// <param name="type">The type.</param>
- /// <param name="count">The count.</param>
- /// <returns>ChartDataSet.</returns>
- public ChartDataSet GetDataSet(string symbol, CycleType type, int count)
- {
- try
- {
- if (string.IsNullOrWhiteSpace(symbol)) return null;
- var dataAccess = new FileDataAccess();
- var dataPoints = dataAccess.GetDataPoints(symbol, type, DateTime.MinValue, DateTime.Now, count);
- if (dataPoints == null) return null;
- var result = dataPoints.Cast<ILineDataPoint>().ToList();
- var dataSet = new ChartDataSet(result);
- return dataSet;
- }
- catch
- {
- return null;
- }
- }
- public List<DrawingToolPositionType> GetDrawingToolPositions()
- {
- return GetEnumList<DrawingToolPositionType>();
- }
- public List<DrawingToolType> GetDrawingToolTypes()
- {
- return GetEnumList<DrawingToolType>();
- }
- public List<string> GetIndicatorTypes()
- {
- return new List<string>()
- {
- "MACD",
- "FASTSO",
- "RSI"
- };
- }
- public Dictionary<ChartLanguageType, string> GetLanguages()
- {
- return new Dictionary<ChartLanguageType, string>
- {
- {ChartLanguageType.SimplifiedChinese, "简体中文"},
- {ChartLanguageType.TraditionalChinese, "繁体中文"},
- {ChartLanguageType.English, "英文"}
- };
- }
- public List<LinePlotType> GetLinePlotTypes()
- {
- return GetEnumList<LinePlotType>();
- }
- public List<Visibility> GetVisibilities()
- {
- return new List<Visibility>
- {
- Visibility.Visible,
- Visibility.Collapsed
- };
- }
- #endregion Public Methods
- #region Private Methods
- private List<T> GetEnumList<T>()
- {
- var values = Enum.GetValues(typeof(T));
- return values.Cast<T>().ToList();
- }
- #endregion Private Methods
- #endregion Methods
- }
- }
|