Skip to content

Commit

Permalink
Added default tooltip.
Browse files Browse the repository at this point in the history
  • Loading branch information
Georgy Levchenko committed Mar 22, 2021
1 parent ebbe843 commit 0030b88
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<PackageReference Include="ScottPlot.WPF" Version="4.1.10-beta" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\DataAccess\SmartThermo.DataAccess.Sqlite\SmartThermo.DataAccess.Sqlite.csproj" />
<ProjectReference Include="..\..\SmartThermo.Core\SmartThermo.Core.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Prism.Commands;
using Prism.Regions;
using Prism.Services.Dialogs;
using SmartThermo.Core.Extensions;
using SmartThermo.Core.Mvvm;
using SmartThermo.Services.DeviceConnector;
using SmartThermo.Services.Notifications;
Expand All @@ -15,16 +14,7 @@ public class AnalyticsWindowViewModel : RegionViewModelBase
public AnalyticsWindowViewModel(IRegionManager regionManager, IDeviceConnector deviceConnector, INotifications notifications, IDialogService dialogService)
: base(regionManager, deviceConnector, notifications, dialogService)
{
SetSessionCommand = new DelegateCommand(SetSessionExecute);
}

private void SetSessionExecute()
{
DialogService.ShowNotification("SessionDialog", r =>
{
if (r.Result == ButtonResult.None)
Notifications.ShowInformation("Операция прервана пользователем.");
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,6 @@
Background="{DynamicResource SystemControlPageBackgroundChromeLowBrush}"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>

<StackPanel Margin="0,12,0,8" Orientation="Horizontal">
<Button Content="Выбрать сессию" Command="{Binding SetSessionCommand}" />
<Separator Margin="8" />
<TextBlock
Margin="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="Текущая сессия: 1212" />
</StackPanel>

<WpfPlot Grid.Row="1" Margin="0,8,0,0" />
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SmartThermo.Modules.DataViewer.Views.Represent"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
Expand Down Expand Up @@ -36,7 +37,6 @@
<Grid Margin="0,8,8,8" Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -150,6 +150,9 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
<Grid
Expand All @@ -159,7 +162,6 @@
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -273,6 +275,9 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
<Grid
Expand All @@ -282,7 +287,6 @@
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -396,16 +400,18 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
<Grid
Grid.Row="1"
Grid.Column="0"
Margin="8"
Margin="0,8,8,0"
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -519,16 +525,18 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
<Grid
Grid.Row="1"
Grid.Column="1"
Margin="8"
Margin="8,8,8,0"
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -642,16 +650,18 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
<Grid
Grid.Row="1"
Grid.Column="2"
Margin="8"
Margin="8,8,8,0"
Background="{DynamicResource SystemControlBackgroundChromeMediumBrush}">
<lvc:CartesianChart
Margin="8"
DataTooltip="{x:Null}"
DisableAnimations="True"
FontSize="12"
Hoverable="False"
Expand Down Expand Up @@ -765,6 +775,9 @@
</Setter>
</Style>
</lvc:CartesianChart.Style>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}" />
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
</Grid>
</Grid>
Expand All @@ -773,7 +786,6 @@
Grid.Column="1"
Margin="0,8,0,0"
Background="{DynamicResource SystemControlBackgroundBaseMediumLowBrush}" />

<DataGrid
Grid.Column="2"
Padding="8,8,0,0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using SmartThermo.Core.Extensions;
using SmartThermo.Core.Mvvm;
using SmartThermo.Modules.Dialog.SettingsDevice.Enums;
using SmartThermo.Modules.Dialog.SettingsDevice.Models;
using SmartThermo.Modules.Dialog.SettingsPort.Enums;
Expand All @@ -17,14 +17,8 @@

namespace SmartThermo.Modules.Dialog.SettingsDevice.ViewModels
{
public class SettingsDeviceDialogViewModel : BindableBase, IDialogAware
public class SettingsDeviceDialogViewModel : DialogViewModelBase
{
#region Event

public event Action<IDialogResult> RequestClose;

#endregion

#region Field

private readonly IDeviceConnector _deviceConnector;
Expand Down Expand Up @@ -164,8 +158,6 @@ public bool IsEnable
set => SetProperty(ref _isEnable, value);
}

public string Title => string.Empty;

public DelegateCommand WriteCommand { get; }

public DelegateCommand CancelCommand { get; }
Expand Down Expand Up @@ -279,12 +271,12 @@ private async void WriteExecute()
}

if (!isSuccessful)
RequestClose?.Invoke(new DialogResult(ButtonResult.None));
RaiseRequestClose(new DialogResult(ButtonResult.None));
}

private void CancelExecute()
{
RequestClose?.Invoke(new DialogResult(_isSettingsSet ? ButtonResult.None : ButtonResult.Cancel));
RaiseRequestClose(new DialogResult(_isSettingsSet ? ButtonResult.None : ButtonResult.Cancel));
}

private void UpdateGroupCheckItems(int value)
Expand Down Expand Up @@ -331,12 +323,7 @@ private void SetGroupCheckItems()
_dataGroupCheckItems[_relayNumberSelected - 1] = data;
}

public void OnDialogClosed()
{

}

public void OnDialogOpened(IDialogParameters parameters)
public override void OnDialogOpened(IDialogParameters parameters)
{
GetDeviceSettingsAsync();
}
Expand Down Expand Up @@ -382,8 +369,6 @@ private void GetDeviceSettingsAsync()
};
}

public bool CanCloseDialog() => true;

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Services\SmartThermo.Services.DeviceConnector\SmartThermo.Services.DeviceConnector.csproj" />
<ProjectReference Include="..\..\Services\SmartThermo.Services.Notifications\SmartThermo.Services.Notifications.csproj" />
<ProjectReference Include="..\..\SmartThermo.Core\SmartThermo.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="ToastNotifications">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using SmartThermo.Core.Mvvm;
using SmartThermo.Modules.Dialog.SettingsPort.Enums;
using SmartThermo.Services.DeviceConnector;
using SmartThermo.Services.DeviceConnector.Models;
Expand All @@ -13,14 +13,8 @@

namespace SmartThermo.Modules.Dialog.SettingsPort.ViewModels
{
public class SettingsPortDialogViewModel : BindableBase, IDialogAware
public class SettingsPortDialogViewModel : DialogViewModelBase
{
#region Event

public event Action<IDialogResult> RequestClose;

#endregion

#region Field

private readonly IDeviceConnector _deviceConnector;
Expand Down Expand Up @@ -48,8 +42,6 @@ public bool IsEnable
set => SetProperty(ref _isEnable, value);
}

public string Title => string.Empty;

public byte AddressDeviceSelected
{
get => _addressDeviceSelected;
Expand Down Expand Up @@ -151,10 +143,10 @@ private async void ConnectExecute()
IsEnable = true;
}

RequestClose?.Invoke(new DialogResult(ButtonResult.None));
RaiseRequestClose(new DialogResult(ButtonResult.None));
}

private void CancelExecute() => RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
private void CancelExecute() => RaiseRequestClose(new DialogResult(ButtonResult.Cancel));

private void UploadingDataSources()
{
Expand All @@ -174,18 +166,6 @@ private void SetDefaultSettings()
ParitySelected = Parity.None;
}

public void OnDialogClosed()
{

}

public void OnDialogOpened(IDialogParameters parameters)
{

}

public bool CanCloseDialog() => true;

#endregion
}
}
9 changes: 3 additions & 6 deletions src/SmartThermo.Core/Mvvm/DialogViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class DialogViewModelBase : BindableBase, IDialogAware
public event Action<IDialogResult> RequestClose;

private string _iconSource;
private string _title;
private string _title = string.Empty;

public string IconSource
{
Expand All @@ -23,15 +23,12 @@ public string Title
set => SetProperty(ref _title, value);
}

public virtual void RaiseRequestClose(IDialogResult dialogResult)
protected void RaiseRequestClose(IDialogResult dialogResult)
{
RequestClose?.Invoke(dialogResult);
}

public virtual bool CanCloseDialog()
{
return true;
}
public virtual bool CanCloseDialog() => true;

public virtual void OnDialogClosed()
{
Expand Down
3 changes: 0 additions & 3 deletions src/SmartThermo/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,5 @@ protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
// -Вынести стили диалоговых окон.
// -Загрузка данных для Analytics.
// -Переделка дизайна для Analytics и диалогового окна.
// -Сброс масштаба графиков.
// -Tooltip для графиков.
// -Перенос базового класса диалоговых окон.
}
}

0 comments on commit 0030b88

Please sign in to comment.