Skip to content

Commit

Permalink
Update todo
Browse files Browse the repository at this point in the history
  • Loading branch information
dogzz9445 committed Jul 19, 2024
1 parent e283c49 commit 00cb980
Show file tree
Hide file tree
Showing 17 changed files with 1,212 additions and 197 deletions.
29 changes: 21 additions & 8 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## TODO
- [ ] (WidgetSystem) WidgetContext 구현
- [ ] (WidgetSystem) DataSourceService 구현
- [ ] (WidgetSystem) DataSourceContext 구현
- [ ] (WidgetSystem) DataSourceContext 에서 데이터를 읽어오는 기능 구현
- [ ] (WidgetSystem) DataSourceContext 에서 OnMessage 구현하기
- [ ] (WidgetSystem) WidgetContext 에서 OnMessage 구현하기
Expand All @@ -12,6 +11,7 @@
- [ ] (Contracts) ArgumentCastNullException 추가
- [ ] (Organizer) Dashboard View 의 TabControl 의 Placeholder 에서 CornerRadius 가 없는 버튼을 배치하고 안에 Border 및 Corner Radius 를 넣어 버튼을 구현
- [ ] (Organizer) Dashboard View 의 TabControl 에서 Add Button 을 구현하는데 문제가 있음. TabControl 을 재구현하여 사용하거나 다른 방식을 고려하여야함
- [ ] (Organizer) Settings 에서 TypeName 을 Generator 네임으로 변경해야함. 따라서, Generator가 되는 Key 에 대한 값을 패키지에서 생성하도록 해야함 (애트리뷰트)

## Doing
- [ ] (WidgetSystem) DataSourceService 구현
Expand All @@ -23,31 +23,44 @@
- [x] (WidgetSystem) WidgetContext 에서 위젯을 로드하는 기능 구현
- [x] (Organizer) Nuget 패키지에서 위젯을 읽고 로드하는 서비스 구현
- [x] DLL 로드
- [x] (WidgetSystem) DataSourceContext 구현

## Idea
- [ ] (Organizer) 위젯 세팅에서 위젯의 크기를 선택하여 위젯의 크기를 변경할 수 있도록 한다.
- [ ] (Widget)

# 📅 데이터소스
## Idea v1
- [ ] Executable DataSource
- [ ] WebSession DataSource
- [ ] ToDo DataSource

# 📅 위젯
## Idea
- [ ] 파일 열기 위젯
## Idea v1
- [x] 열기 위젯
- [ ] ToDo 위젯
- [ ] Python 위젯
- [ ] C# 위젯
- [ ] Windows 위젯
- [ ] WebView 위젯
- [ ] vscode 위젯
- [ ] PLC 위젯

## Idea v2
- [ ] 하드웨어 모니터링 위젯 추가

## TODO
- [ ] (파일열기 위젯) 커맨드 또는 쉘로 파일 열기 기능 추가
- [ ] (파일열기 위젯) 폴더 열기 기능 추가
- [ ] (파일열기 위젯) 폴더 열기 기능 추가
- [ ] (열기 위젯) 커맨드 또는 쉘로 파일 열기 기능 추가
- [ ] (열기 위젯) 열기 위젯에 Localization 추가
- [ ] (ToDo) ToDo 위젯에 Localization 추가

## Doing
- [ ] (타이머 위젯) 리셋 버튼 스타일 수정
- [ ] (타이머 위젯) 타이머 위젯 구현

## Done
- [ ] (타이머 위젯) 타이머 위젯 구현
- [x] (열기 위젯) 파일 열기 기능 추가
- [x] (열기 위젯) 폴더 열기 기능 추가
- [x] (열기 위젯) 링크 열기 기능 추가


# 📅 퍼블리싱
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows;

namespace Corathing.UI.WPF.Behaviors;

/// <summary>
/// Determines if the Dashboard selector (Pop up) should be open
/// Implements the <see cref="System.Windows.Data.IMultiValueConverter" />
/// </summary>
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
public class DelayedMultiBindingConverter : IMultiValueConverter
{
#region Public Methods

/// <summary>
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
/// </summary>
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>A converted value.If the method returns <see langword="null" />, the valid <see langword="null" /> value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.</returns>
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Any(value => value is not bool) || values.Length < 1 || !(bool)values[0])
return false;

for (var i = 1; i < values.Length; i++)
{
if ((bool)values[i])
return false;
}

return true;
}

/// <summary>
/// Converts a binding target value to the source binding values.
/// </summary>
/// <param name="value">The value that the binding target produces.</param>
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>An array of values that have been converted from the target value back to the source values.</returns>
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return [DependencyProperty.UnsetValue];
}

#endregion Public Methods
}
249 changes: 249 additions & 0 deletions src/Shared/Corathing.UI.WPF/Behaviors/DelayedMultiBindingExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
// Source from : WpfDashboardControl
// https://github.com/DustinBryant/WpfDashboardControl
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Markup;
using System.Windows.Threading;
using System.Windows;

namespace Corathing.UI.WPF.Behaviors;

/// <summary>
/// Provides a delayed multi-binding. This class cannot be inherited.
/// Implements the <see cref="System.Windows.Markup.MarkupExtension" />
/// Implements the <see cref="System.Windows.Data.IMultiValueConverter" />
/// Implements the <see cref="System.ComponentModel.INotifyPropertyChanged" />
/// </summary>
/// <seealso cref="System.Windows.Markup.MarkupExtension" />
/// <seealso cref="System.Windows.Data.IMultiValueConverter" />
/// <seealso cref="System.ComponentModel.INotifyPropertyChanged" />
[ContentProperty("Bindings")]
public sealed class DelayedMultiBindingExtension : MarkupExtension, IMultiValueConverter, INotifyPropertyChanged
{
#region Private Fields

private readonly DispatcherTimer _timer;

private object? _delayedValue;

private object? _startingValue;

private bool _startingValueInitialSet;

private object? _unDelayedValue;

#endregion Private Fields

#region Public Events

/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler? PropertyChanged;

#endregion Public Events

#region Public Properties

/// <summary>
/// Gets the bindings.
/// </summary>
/// <value>The bindings.</value>
public Collection<BindingBase> Bindings { get; }

/// <summary>
/// Gets the change count.
/// </summary>
/// <value>The change count.</value>
public int ChangeCount { get; private set; }

/// <summary>
/// Gets or sets the converter.
/// </summary>
/// <value>The converter.</value>
public IMultiValueConverter? Converter { get; set; }

/// <summary>
/// Gets or sets the converter culture.
/// </summary>
/// <value>The converter culture.</value>
public CultureInfo? ConverterCulture { get; set; }

/// <summary>
/// Gets or sets the converter parameter.
/// </summary>
/// <value>The converter parameter.</value>
public object? ConverterParameter { get; set; }

/// <summary>
/// Gets or sets the current value.
/// </summary>
/// <value>The current value.</value>
public object? CurrentValue
{
get => _delayedValue;
set
{
_delayedValue = _unDelayedValue = value;
_timer.Stop();
}
}

/// <summary>
/// Gets or sets the delay.
/// </summary>
/// <value>The delay.</value>
public TimeSpan Delay
{
get => _timer.Interval;
set => _timer.Interval = value;
}

/// <summary>
/// Gets or sets the mode.
/// </summary>
/// <value>The mode.</value>
public BindingMode Mode { get; set; }

/// <summary>
/// Gets or sets the starting value.
/// </summary>
/// <value>The starting value.</value>
public object? StartingValue
{
get => _startingValue;
set
{
if (_startingValueInitialSet)
return;

_startingValue = value;
CurrentValue = value;
_startingValueInitialSet = true;
}
}

/// <summary>
/// Gets or sets the update source trigger.
/// </summary>
/// <value>The update source trigger.</value>
public UpdateSourceTrigger UpdateSourceTrigger { get; set; }

#endregion Public Properties

#region Public Constructors

/// <summary>
/// Initializes a new instance of the <see cref="DelayedMultiBindingExtension"/> class.
/// </summary>
public DelayedMultiBindingExtension()
{
Bindings = new Collection<BindingBase>();
_timer = new DispatcherTimer();
_timer.Tick += Timer_Tick;
_timer.Interval = TimeSpan.FromMilliseconds(10);
}

#endregion Public Constructors

#region Public Methods

/// <summary>
/// Converts source values to a value for the binding target. The data binding engine calls this method when it propagates the values from source bindings to the binding target.
/// </summary>
/// <param name="values">The array of values that the source bindings in the <see cref="T:System.Windows.Data.MultiBinding" /> produces. The value <see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the source binding has no value to provide for conversion.</param>
/// <param name="targetType">The type of the binding target property.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>A converted value.If the method returns <see langword="null" />, the valid <see langword="null" /> value is used.A return value of <see cref="T:System.Windows.DependencyProperty" />.<see cref="F:System.Windows.DependencyProperty.UnsetValue" /> indicates that the converter did not produce a value, and that the binding will use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> if it is available, or else will use the default value.A return value of <see cref="T:System.Windows.Data.Binding" />.<see cref="F:System.Windows.Data.Binding.DoNothing" /> indicates that the binding does not transfer the value or use the <see cref="P:System.Windows.Data.BindingBase.FallbackValue" /> or the default value.</returns>
public object? Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
ArgumentNullException.ThrowIfNull(Converter);

var newValue = Converter.Convert(values.Take(values.Length - 1).ToArray(),
targetType,
ConverterParameter,
ConverterCulture ?? culture);

if (Equals(newValue, _unDelayedValue))
return _delayedValue;

_unDelayedValue = newValue;
_timer.Stop();
_timer.Start();

return _delayedValue;
}

/// <summary>
/// Converts a binding target value to the source binding values.
/// </summary>
/// <param name="value">The value that the binding target produces.</param>
/// <param name="targetTypes">The array of types to convert to. The array length indicates the number and types of values that are suggested for the method to return.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>An array of values that have been converted from the target value back to the source values.</returns>
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
ArgumentNullException.ThrowIfNull(Converter);

return [.. Converter.ConvertBack(value, targetTypes, ConverterParameter, ConverterCulture ?? culture)
, .. new object[] { ChangeCount }];
}

/// <summary>
/// When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
/// </summary>
/// <param name="serviceProvider">A service provider helper that can provide services for the markup extension.</param>
/// <returns>The object value to set on the property where the extension is applied.</returns>
public override object? ProvideValue(IServiceProvider serviceProvider)
{
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is not IProvideValueTarget valueProvider)
return null;

var bindingTarget = valueProvider.TargetObject as DependencyObject;
var bindingProperty = valueProvider.TargetProperty as DependencyProperty;

var multi = new MultiBinding
{
Converter = this,
Mode = Mode,
UpdateSourceTrigger = UpdateSourceTrigger
};

foreach (var binding in Bindings)
multi.Bindings.Add(binding);

multi.Bindings.Add(new Binding("ChangeCount")
{
Source = this,
Mode = BindingMode.OneWay
});

if (bindingTarget != null && bindingProperty != null)
BindingOperations.SetBinding(bindingTarget, bindingProperty, multi);

return bindingProperty == null ? multi : bindingTarget?.GetValue(bindingProperty);
}

#endregion Public Methods

#region Private Methods

private void Timer_Tick(object? sender, EventArgs e)
{
_timer.Stop();
_delayedValue = _unDelayedValue;
ChangeCount++;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ChangeCount)));
}

#endregion Private Methods
}
1 change: 1 addition & 0 deletions src/Shared/Corathing.UI.WPF/Corathing.UI.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
<PackageReference Include="MahApps.Metro" Version="2.4.10" />
<PackageReference Include="MahApps.Metro.IconPacks" Version="5.0.0" />
<PackageReference Include="Material.Icons.WPF" Version="2.1.10" />
Expand Down
Loading

0 comments on commit 00cb980

Please sign in to comment.