일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- c# maui
- c# restapi 호출
- 업비트
- 업비트 API
- c# 업비트
- 즐겨찾기
- 북마크
- c# 라이브 차트
- c# restapi
- Upbit API
- 차트
- 나만의 사이트모음집
- 업비트 차트
- C#
- Prism
- maui
- 업비트 c#
- c# 차트
- WPF
- c# api호출
- c# 업비트 api키 목록
- XAML
- Chart
- c# websocket
- 라이브 차트
- upbit
Archives
- Today
- Total
하아찡
[C#/WPF] Upbit 프로젝트 Chart - 7(Converter) 본문
MultipleHeightConverter.cs
using System;
using System.Globalization;
using System.Windows.Data;
namespace Upbit.Converter
{
public class MultipleHeightConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// 여기서 values 배열에 여러 개의 값이 포함됩니다.
// 원하는 계산을 수행하고 계산 결과를 반환하세요.
double result = 1; // 여기에 원하는 계산을 수행하세요
try
{
double val1 = (double)values[0];
double val2 = (double)values[1];
result = val1 * val2;
if (result < 1)
result = 1;
}
catch (Exception ex)
{
}
return result;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Xaml에서 캔들 높이값을 곱해줘서 구해줌.
MultipleYConverter.cs
using System;
using System.Globalization;
using System.Windows.Data;
namespace Upbit.Converter
{
public class MultipleYConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// 여기서 values 배열에 여러 개의 값이 포함됩니다.
// 원하는 계산을 수행하고 계산 결과를 반환하세요.
double result = 0; // 여기에 원하는 계산을 수행하세요
try
{
double max = (double)values[0];
double hp = (double)values[1];
double rate = (double)values[2];
result = (max - hp) * rate;
}
catch(Exception ex)
{
}
return Math.Abs(result);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
캔들 시작하는 Y축 높이를 정할때 사용함
CandleMarginConverter.cs
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace Upbit.Converter
{
public class CandleMarginConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// 여기서 values 배열에 여러 개의 값이 포함됩니다.
// 원하는 계산을 수행하고 계산 결과를 반환하세요.
Thickness result = new Thickness(); // 여기에 원하는 계산을 수행하세요
try
{
double height = (double)values[0];
double rate = (double)values[1];
double top = height * rate;
result = new Thickness { Top = top };
}
catch (Exception ex) { }
return result;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Y축구하는것과 같이 꼬리와 캔들이 같이 그려지는데 꼬리를 기준으로 Y축을 구해줘서 해당 Y축에서 더 띄우기위해 캔들용 마진을 따로구함
CandleGridXWidthConverter.cs
using System;
using System.Globalization;
using System.Windows.Data;
namespace Upbit.Converter
{
class CandleGridXWidthConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// 여기서 values 배열에 여러 개의 값이 포함됩니다.
// 원하는 계산을 수행하고 계산 결과를 반환하세요.
double result = 0; // 여기에 원하는 계산을 수행하세요
double val1 = 0;
double val2 = 0;
try
{
val1 = (double)values[0];
val2 = (double)values[1];
result = val1 * val2;
}
catch (Exception ex) { }
return result + (val2 * 1.5);
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
각 캔들 X축 거리를 띄워주는 역
ChartYAxisConverter.cs
using System;
using System.Globalization;
using System.Windows.Data;
namespace Upbit.Converter
{
class ChartYAxisConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double val = (double)value;
return val - 22;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new InvalidOperationException("IsNullConverter can only be used OneWay.");
}
}
}
현재 그리드 Row를 여러개 합쳐서 사용중이라 딱 맞춰서 사용할라면 22만큼빼줘야해서 추가해줬음.
반응형
'C# > 코인프로그램 - 코드' 카테고리의 다른 글
[C#/WPF/수정] Upbit프로젝트 Balance (2) | 2023.12.05 |
---|---|
[C#/WPF] Upbit 프로젝트 JWT (2) | 2023.12.03 |
[C#/WPF] Upbit 프로젝트 Chart - 6(틱 타입변경) (2) | 2023.12.03 |
[C#/WPF] Upbit 프로젝트 Chart - 5(라이브 캔들) (0) | 2023.12.02 |
[C#/WPF] Upbit프로젝트 PublicFunctions(Upbit관련함수) (2) | 2023.12.02 |