/
PutilovSy
/
CryptoMonitor
Обзор
Документация
Войти
/
PutilovSy
/
CryptoMonitor
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
CryptoMonitor/MainWindow.xaml
323 строки
20 KB
PutilovSy
fixes
04 июн 2026, 20:29
04 июн 2026, 20:29
0c0502d
Код
Авторство
О чём код?
<Window x:Class="CryptoMonitor.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ScottPlot="clr-namespace:ScottPlot.WPF;assembly=ScottPlot.WPF" xmlns:local="clr-namespace:CryptoMonitor" Title="CryptoMonitor" Height="500" Width="1000" WindowStartupLocation="CenterScreen" Background="{StaticResource BgDark}"> <Grid Margin="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"/> <ColumnDefinition Width="3*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <!-- Left Column: Search & DataGrid --> <Grid Grid.Column="0" Grid.Row="0" Margin="5"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <!-- Поиск и фильтры --> <Border Grid.Row="0" Margin="0,0,0,10" Background="{StaticResource PanelDark}" CornerRadius="6" BorderBrush="{StaticResource BorderColor}" BorderThickness="1"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" Background="Transparent" BorderThickness="0" Foreground="{StaticResource TextMain}" CaretBrush="White" Padding="10,8" FontSize="14" VerticalAlignment="Center" /> <TextBlock Grid.Column="0" Margin="15,0,0,0" IsHitTestVisible="False" Text="Поиск монеты..." Foreground="{StaticResource TextMuted}" VerticalAlignment="Center" FontSize="14"> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Visibility" Value="Collapsed"/> <Style.Triggers> <DataTrigger Binding="{Binding SearchText}" Value=""> <Setter Property="Visibility" Value="Visible"/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> <ToggleButton Grid.Column="1" IsChecked="{Binding ShowOnlyPortfolio}" Margin="5" Padding="15,4" Background="Transparent" BorderThickness="0" Foreground="{StaticResource TextMuted}" Cursor="Hand"> <ToggleButton.Style> <Style TargetType="ToggleButton"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <Border CornerRadius="4" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <TextBlock x:Name="tbStar" Text="☆" FontSize="18" Margin="0,0,8,0" VerticalAlignment="Center" Foreground="{StaticResource TextMuted}"/> <TextBlock Text="Портфель" FontSize="14" VerticalAlignment="Center" Foreground="{TemplateBinding Foreground}"/> </StackPanel> </Border> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Background" Value="#1AFFF176"/> <Setter Property="Foreground" Value="#FFF176"/> <Setter TargetName="tbStar" Property="Text" Value="★"/> <Setter TargetName="tbStar" Property="Foreground" Value="#FFC107"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#11FFFFFF"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ToggleButton.Style> </ToggleButton> </Grid> </Border> <!-- Таблица монет --> <Border Grid.Row="1" Background="{StaticResource PanelDark}" CornerRadius="8" BorderBrush="{StaticResource BorderColor}" BorderThickness="1" ClipToBounds="True"> <DataGrid ItemsSource="{Binding FilteredCoins}" SelectedItem="{Binding SelectedCoin}" AutoGenerateColumns="False" BorderThickness="0" IsReadOnly="True" SelectionMode="Single" GridLinesVisibility="Horizontal" Background="{StaticResource PanelDark}"> <DataGrid.Resources> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> <Setter Property="VerticalContentAlignment" Value="Center"/> </Style> </DataGrid.Resources> <DataGrid.Columns> <!-- Избранное (Портфель) --> <DataGridTemplateColumn Width="40"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ToggleButton IsChecked="{Binding IsFavorite, UpdateSourceTrigger=PropertyChanged}" Background="Transparent" BorderThickness="0" Cursor="Hand" HorizontalAlignment="Center" VerticalAlignment="Center"> <ToggleButton.Style> <Style TargetType="ToggleButton"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <Border Background="Transparent" Padding="5"> <TextBlock x:Name="starText" Text="☆" FontSize="20" Foreground="{StaticResource TextMuted}" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Text" Value="★" TargetName="starText"/> <Setter Property="Foreground" Value="#FFC107" TargetName="starText"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="#FFC107" TargetName="starText"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ToggleButton.Style> </ToggleButton> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTextColumn Header="Символ" Binding="{Binding Symbol}" Width="*"> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="10,0"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="TextTrimming" Value="CharacterEllipsis"/> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> <DataGridTextColumn Header="Цена" Binding="{Binding CurrentPrice, StringFormat={}{0:C}}" Width="1.2*"> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="10,0"/> <Setter Property="VerticalAlignment" Value="Center"/> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> <DataGridTextColumn Header="Изм (24ч)" Binding="{Binding PriceChangePercentage24h, StringFormat={}{0:F2}%}" Width="*"> <DataGridTextColumn.ElementStyle> <Style TargetType="TextBlock"> <Setter Property="Margin" Value="10,0"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="Foreground" Value="{Binding PriceChangePercentage24h, Converter={StaticResource ChangeColorConverter}}"/> <Setter Property="FontWeight" Value="SemiBold"/> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> </DataGrid.Columns> </DataGrid> </Border> </Grid> <Button Content="Анализ динамики" Grid.Row="1" Grid.Column="0" Margin="5,10,5,5" Command="{Binding OpenAnalysisCommand}" FontSize="14" FontWeight="SemiBold"/> <!-- Right column: Chart --> <Border Grid.Column="1" Grid.RowSpan="2" Margin="10,5,5,5" Background="{StaticResource PanelDark}" CornerRadius="8" BorderBrush="{StaticResource BorderColor}" BorderThickness="1"> <Grid> <!-- Отступы для графика, чтобы элементы контролов не мешали осям --> <ScottPlot:WpfPlot x:Name="CryptoPlot" Margin="10,48,10,10"/> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="15,15,0,0"> <StackPanel.Resources> <Style TargetType="RadioButton"> <Setter Property="Foreground" Value="{StaticResource TextMuted}"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Margin" Value="0,0,10,0"/> <Setter Property="Cursor" Value="Hand"/> <Setter Property="FontSize" Value="13"/> <Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="RadioButton"> <Border CornerRadius="4" Padding="12,6" Background="{TemplateBinding Background}"> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Border> </ControlTemplate> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter Property="Background" Value="{StaticResource AccentBlue}"/> <Setter Property="Foreground" Value="{StaticResource TextMain}"/> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="{StaticResource AccentHover}"/> </Trigger> </Style.Triggers> </Style> </StackPanel.Resources> <RadioButton Content="1 Д" IsChecked="{Binding SelectedDays, Converter={StaticResource EqualityConverter}, ConverterParameter=1}"/> <RadioButton Content="7 Д" IsChecked="{Binding SelectedDays, Converter={StaticResource EqualityConverter}, ConverterParameter=7}"/> <RadioButton Content="30 Д" IsChecked="{Binding SelectedDays, Converter={StaticResource EqualityConverter}, ConverterParameter=30}"/> <RadioButton Content="1 Год" IsChecked="{Binding SelectedDays, Converter={StaticResource EqualityConverter}, ConverterParameter=365}"/> </StackPanel> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0"> <Button x:Name="RefreshChartBtn" Width="30" Height="30" Margin="0,0,10,0" ToolTip="Обновить график" Click="RefreshChartBtn_Click" Foreground="{StaticResource TextMain}" Cursor="Hand"> <Button.Template> <ControlTemplate TargetType="Button"> <Border x:Name="border" Background="#2B3655" CornerRadius="15"> <TextBlock Text="⟳" Foreground="{TemplateBinding Foreground}" FontSize="18" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,-3,0,0"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter TargetName="border" Property="Background" Value="{StaticResource AccentHover}"/> <Setter Property="Foreground" Value="#0B132B"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> <Button x:Name="ToggleChartBtn" Content="📊 В свечи" Padding="15,6" FontSize="12" Background="#2B3655" Click="ToggleChartBtn_Click"/> </StackPanel> <!-- Подсказка об обновлении (защита от спама) --> <Border x:Name="UpdateHintBorder" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,55,15,0" Background="#334CAF50" BorderBrush="#4CAF50" BorderThickness="1" CornerRadius="6" Padding="15,6" Opacity="0" IsHitTestVisible="False"> <TextBlock Text="Данные уже обновлены" Foreground="White" FontSize="12" FontWeight="SemiBold"/> </Border> <!-- Подсказка о достижении лимита API (красная) --> <Border x:Name="RateLimitHintBorder" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,55,15,0" Background="#33F44336" BorderBrush="#F44336" BorderThickness="1" CornerRadius="6" Padding="15,6" Opacity="0" IsHitTestVisible="False"> <TextBlock Text="Лимит запросов API!" Foreground="White" FontSize="12" FontWeight="SemiBold"/> </Border> </Grid> </Border> <!-- Loading overlay --> <Border Grid.Column="1" Grid.RowSpan="2" Margin="10,5,5,5" CornerRadius="8" Background="#B30B132B" Visibility="{Binding IsLoadingCoins, Converter={StaticResource BoolToVisibility}}"> <Border Background="{StaticResource PanelDark}" CornerRadius="12" Padding="25,20" HorizontalAlignment="Center" VerticalAlignment="Center" BorderBrush="{StaticResource BorderColor}" BorderThickness="1" Effect="{DynamicResource DropShadowEffect}"> <StackPanel Orientation="Vertical"> <ProgressBar IsIndeterminate="True" Width="150" Height="4" Margin="0,0,0,15" Foreground="{StaticResource AccentHover}" Background="{StaticResource BgDark}" BorderThickness="0"/> <TextBlock Text="{Binding LoadingMessage}" HorizontalAlignment="Center" Foreground="{StaticResource TextMain}" FontSize="14"/> </StackPanel> </Border> </Border> </Grid> </Window>