102 lines
3.9 KiB
C#
102 lines
3.9 KiB
C#
using DevExpress.XtraEditors;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Security.Policy;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using DevExpress.Data.Extensions;
|
|
using DevExpress.Data.Helpers;
|
|
using DevExpress.Utils.DirectXPaint.Svg;
|
|
using DevExpress.Utils.Extensions;
|
|
using DevExpress.Utils.Serializing.Helpers;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using Million;
|
|
using Million.IndicatorConditionSetup;
|
|
|
|
namespace Million.HunterSubForm.IndicatorSetupForm
|
|
{
|
|
public partial class BolingerBandSetupUserForm : XtraUserControl
|
|
{
|
|
private BolingerConditionSetup _bolingerConditionSetup;
|
|
private bool _isCreate = false;
|
|
|
|
public BolingerBandSetupUserForm(object bolingerBandSetup, bool IsCreate)
|
|
{
|
|
InitializeComponent();
|
|
_bolingerConditionSetup = (BolingerConditionSetup) bolingerBandSetup;
|
|
_isCreate = IsCreate;
|
|
InitForm();
|
|
}
|
|
|
|
public void InitForm()
|
|
{
|
|
labelControl_IndicatorName.Text = @"볼린저 밴드";
|
|
|
|
// 기준선 체크박스 설정 (현재는 Overline 만 사용함)
|
|
foreach (var items in Enum.GetNames(enumType: typeof(CommonProperty.Indicator_BolingerOverLine)))
|
|
{
|
|
checkedListBoxControl_Lines.Items.Add(items,
|
|
items == CommonProperty.Indicator_BolingerOverLine.상향선.ToString());
|
|
}
|
|
|
|
// 저장 - 로드된 데이터가 아닌 경우
|
|
if (_isCreate)
|
|
{
|
|
_bolingerConditionSetup = new BolingerConditionSetup();
|
|
|
|
// 지표 기본값 설정
|
|
textEdit_Period.Text = @"40";
|
|
textEdit_Squared.Text = @"1";
|
|
|
|
// 볼린저 기준선 (OverLine으로 설정)
|
|
checkedListBoxControl_Lines.Items.First(item =>
|
|
item.Value.ToString() == CommonProperty.Indicator_BolingerOverLine.상향선.ToString()).CheckState = CheckState.Checked;
|
|
}
|
|
// 저장된 데이터인 경우
|
|
else
|
|
{
|
|
// 지표 기본값 설정
|
|
textEdit_Period.Text = _bolingerConditionSetup.Period.ToString();
|
|
textEdit_Squared.Text = _bolingerConditionSetup.Squared.ToString();
|
|
|
|
// 지표 기준선 설정
|
|
checkedListBoxControl_Lines.Items
|
|
.First(item => item.Value.ToString() == _bolingerConditionSetup.Indicator_BolingerOverLine.ToString())
|
|
.CheckState =
|
|
CheckState.Checked;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// Indicator 정보 저장
|
|
public void SaveIndicatorSetup(object indicatorSetupData)
|
|
{
|
|
// 예외처리 필요
|
|
var bolingerBandSetup = (BolingerConditionSetup)indicatorSetupData;
|
|
// 지표 설정
|
|
bolingerBandSetup.IndicatorType = CommonProperty.IndicatorType.볼린저밴드;
|
|
|
|
// 지표 기본 값
|
|
bolingerBandSetup.Period = int.Parse(textEdit_Period.Text);
|
|
bolingerBandSetup.Squared = int.Parse(textEdit_Squared.Text);
|
|
|
|
// 지표 기준선
|
|
Enum.TryParse(checkedListBoxControl_Lines.Items.First(item => item.CheckState == CheckState.Checked).Value.ToString()
|
|
, out CommonProperty.Indicator_BolingerOverLine indicatorOverLine);
|
|
bolingerBandSetup.Indicator_BolingerOverLine = indicatorOverLine;
|
|
|
|
var description = string.Format("[{0},{1},{2}]", bolingerBandSetup.Period.ToString(),
|
|
bolingerBandSetup.Squared.ToString(), bolingerBandSetup.Indicator_BolingerOverLine.ToString());
|
|
|
|
bolingerBandSetup.Description = description + bolingerBandSetup.Description;
|
|
}
|
|
}
|
|
}
|