Intentando crear un tema oscuro. Aun no funciona correctamente.
This commit is contained in:
parent
34fb7ac2c3
commit
47e9d5bbbd
12
App.xaml
12
App.xaml
|
@ -1,9 +1,7 @@
|
|||
<Application x:Class="DirectoryCreator.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:DirectoryCreator"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application x:Class="DirectoryCreator.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:DirectoryCreator"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
</Application>
|
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
|
@ -5,12 +5,9 @@
|
|||
xmlns:viewmodels="clr-namespace:DirectoryCreator.ViewModels" mc:Ignorable="d" Title="Editor de Configuraciones"
|
||||
Height="600" Width="800" WindowStartupLocation="CenterOwner">
|
||||
|
||||
<Window.Resources>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Padding" Value="10,5" />
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
<Window.Icon>
|
||||
<BitmapImage UriSource="/Assets/app.png" />
|
||||
</Window.Icon>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
|
@ -21,14 +18,15 @@
|
|||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Configuración general -->
|
||||
<StackPanel Grid.Row="0">
|
||||
<DockPanel>
|
||||
<TextBlock Text="Nombre de Configuración:" VerticalAlignment="Center" />
|
||||
<TextBox Text="{Binding ConfigDescription, UpdateSourceTrigger=PropertyChanged}" Margin="10,0,0,0"
|
||||
MinWidth="200" />
|
||||
</DockPanel>
|
||||
<CheckBox Content="Tema Oscuro" IsChecked="{Binding IsDarkTheme}" Margin="5" />
|
||||
</DockPanel>
|
||||
|
||||
<DockPanel Margin="0,10,0,0">
|
||||
<TextBlock Text="Ruta Base:" VerticalAlignment="Center" />
|
||||
<Button Content="..." Command="{Binding SelectBasePathCommand}" DockPanel.Dock="Right" Padding="5,0"
|
||||
|
|
|
@ -12,10 +12,32 @@
|
|||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Assets\app.png" />
|
||||
<None Remove="Themes\**" />
|
||||
<Resource Include="Themes\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="folderConfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Themes\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -5,43 +5,63 @@
|
|||
xmlns:viewmodels="clr-namespace:DirectoryCreator.ViewModels" mc:Ignorable="d" Title="Crear Directorios Base"
|
||||
Height="300" Width="500" WindowStartupLocation="CenterScreen">
|
||||
|
||||
<Window.DataContext>
|
||||
<viewmodels:MainWindowViewModel />
|
||||
</Window.DataContext>
|
||||
<Window.Icon>
|
||||
<BitmapImage UriSource="/Assets/app.png" />
|
||||
</Window.Icon>
|
||||
|
||||
<Grid Margin="20">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<TextBlock Text="Configuración:" VerticalAlignment="Center" />
|
||||
<ComboBox Margin="10,0" ItemsSource="{Binding AvailableConfigurations}"
|
||||
SelectedItem="{Binding SelectedConfiguration}" DisplayMemberPath="Description" MinWidth="200" />
|
||||
<Button Content="Editar Configuraciones" Command="{Binding EditConfigurationsCommand}" Padding="10,5" />
|
||||
</StackPanel>
|
||||
<!-- Barra superior con el tema -->
|
||||
<Border Background="{DynamicResource SecondaryBackground}" Padding="5">
|
||||
<DockPanel LastChildFill="True">
|
||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<TextBlock Text="Tema Oscuro" Margin="0,0,5,0" VerticalAlignment="Center" />
|
||||
<CheckBox IsChecked="{Binding IsDarkTheme}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock Grid.Row="2" Text="Last Project:" />
|
||||
<TextBlock Grid.Row="2" Margin="100,0,0,0" Text="{Binding LastProjectNumber}" />
|
||||
<!-- Contenido principal -->
|
||||
<Grid Grid.Row="1" Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="4" Text="Base Path:" />
|
||||
<TextBlock Grid.Row="4" Margin="100,0,0,0" Text="{Binding BasePath}" />
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<TextBlock Text="Configuración:" VerticalAlignment="Center" />
|
||||
<ComboBox Margin="10,0" ItemsSource="{Binding AvailableConfigurations}"
|
||||
SelectedItem="{Binding SelectedConfiguration}" DisplayMemberPath="Description" MinWidth="200"
|
||||
VerticalContentAlignment="Center" />
|
||||
<Button Content="Editar Configuraciones" Command="{Binding EditConfigurationsCommand}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="6" Text="New Project Name:" />
|
||||
<TextBox Grid.Row="6" Margin="100,0,0,0" Text="{Binding NewProjectName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock Grid.Row="2" Text="Last Project:" />
|
||||
<TextBlock Grid.Row="2" Margin="100,0,0,0" Text="{Binding LastProjectNumber}" />
|
||||
|
||||
<StackPanel Grid.Row="8" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="Abrir Carpeta Base" Command="{Binding OpenBaseFolderCommand}" Padding="20,10"
|
||||
Margin="0,0,10,0" />
|
||||
<Button Content="Crear Directorios" Command="{Binding CreateDirectoriesCommand}" Padding="20,10" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="4" Text="Base Path:" />
|
||||
<TextBlock Grid.Row="4" Margin="100,0,0,0" Text="{Binding BasePath}" />
|
||||
|
||||
<TextBlock Grid.Row="6" Text="New Project Name:" />
|
||||
<TextBox Grid.Row="6" Margin="100,0,0,0"
|
||||
Text="{Binding NewProjectName, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<StackPanel Grid.Row="8" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="Abrir Carpeta Base" Command="{Binding OpenBaseFolderCommand}" Padding="20,10"
|
||||
Margin="0,0,10,0" />
|
||||
<Button Content="Crear Directorios" Command="{Binding CreateDirectoriesCommand}" Padding="20,10" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
|
@ -1,12 +1,28 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DirectoryCreator.Models;
|
||||
using DirectoryCreator.ViewModels;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Windows;
|
||||
|
||||
namespace DirectoryCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MainWindowViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace DirectoryCreator.ViewModels
|
||||
{
|
||||
public partial class MainWindowViewModel : ObservableObject
|
||||
|
@ -31,6 +47,8 @@ namespace DirectoryCreator.ViewModels
|
|||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
IsDarkTheme = Properties.Settings.Default.IsDarkTheme;
|
||||
ThemeManager.SetTheme(IsDarkTheme);
|
||||
AvailableConfigurations = new ObservableCollection<FolderConfig>();
|
||||
LoadConfigurations();
|
||||
}
|
||||
|
@ -165,11 +183,11 @@ namespace DirectoryCreator.ViewModels
|
|||
}
|
||||
|
||||
LastProjectNumber = lastProject;
|
||||
NewProjectName = lastValidNumber >= 0 ? $"{(lastValidNumber + 1):000} - " : "001 - ";
|
||||
NewProjectName = lastValidNumber >= 0 ? $"{(lastValidNumber + 1):00} - " : "01 - ";
|
||||
|
||||
if (lastValidNumber < 0)
|
||||
{
|
||||
MessageBox.Show("No se encontró una secuencia válida de al menos 3 números consecutivos.\nSe iniciará desde 001.",
|
||||
MessageBox.Show("No se encontró una secuencia válida de al menos 3 números consecutivos.\nSe iniciará desde 01.",
|
||||
"Información", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
|
@ -212,6 +230,17 @@ namespace DirectoryCreator.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isDarkTheme;
|
||||
|
||||
partial void OnIsDarkThemeChanged(bool value)
|
||||
{
|
||||
ThemeManager.SetTheme(value);
|
||||
// Opcional: Guardar la preferencia del usuario
|
||||
Properties.Settings.Default.IsDarkTheme = value;
|
||||
Properties.Settings.Default.Save();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void CreateDirectories()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace DirectoryCreator.Properties
|
||||
{
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool IsDarkTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((bool)(this["IsDarkTheme"]));
|
||||
}
|
||||
set
|
||||
{
|
||||
this["IsDarkTheme"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DirectoryCreator.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="IsDarkTheme" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
|
@ -0,0 +1,36 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace DirectoryCreator
|
||||
{
|
||||
public static class ThemeManager
|
||||
{
|
||||
public static void SetTheme(bool isDarkTheme)
|
||||
{
|
||||
var app = Application.Current;
|
||||
var mergedDicts = app.Resources.MergedDictionaries;
|
||||
|
||||
// Ruta al tema oscuro
|
||||
var darkThemeUri = new Uri("Themes/DarkTheme.xaml", UriKind.Relative);
|
||||
|
||||
// Primero, removemos el tema oscuro si existe
|
||||
for (int i = mergedDicts.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var currentDict = mergedDicts[i];
|
||||
if (currentDict.Source != null && currentDict.Source.Equals(darkThemeUri))
|
||||
{
|
||||
mergedDicts.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
// Si se solicita el tema oscuro, lo agregamos
|
||||
if (isDarkTheme)
|
||||
{
|
||||
var darkTheme = new ResourceDictionary
|
||||
{
|
||||
Source = darkThemeUri
|
||||
};
|
||||
mergedDicts.Add(darkTheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Colores para el tema oscuro -->
|
||||
<SolidColorBrush x:Key="WindowBackground" Color="#1E1E1E"/>
|
||||
<SolidColorBrush x:Key="WindowForeground" Color="#FFFFFF"/>
|
||||
<SolidColorBrush x:Key="PrimaryBackground" Color="#2D2D2D"/>
|
||||
<SolidColorBrush x:Key="SecondaryBackground" Color="#333333"/>
|
||||
<SolidColorBrush x:Key="BorderBrush" Color="#404040"/>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="#3E3E3E"/>
|
||||
<SolidColorBrush x:Key="ButtonBackgroundHover" Color="#4A4A4A"/>
|
||||
<SolidColorBrush x:Key="TextBoxBackground" Color="#2D2D2D"/>
|
||||
|
||||
<!-- Estilos para controles principales -->
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="Background" Value="{StaticResource WindowBackground}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Background" Value="{StaticResource WindowBackground}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Border">
|
||||
<Setter Property="Background" Value="{StaticResource WindowBackground}"/>
|
||||
</Style>
|
||||
|
||||
<!-- Estilos para controles interactivos -->
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Background" Value="{StaticResource ButtonBackground}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Background" Value="{StaticResource TextBoxBackground}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBox">
|
||||
<Setter Property="Background" Value="{StaticResource TextBoxBackground}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="Background" Value="{StaticResource TextBoxBackground}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Foreground" Value="{StaticResource WindowForeground}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
12
Window1.xaml
12
Window1.xaml
|
@ -1,12 +0,0 @@
|
|||
<Window x:Class="DirectoryCreator.Window1"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:DirectoryCreator"
|
||||
mc:Ignorable="d"
|
||||
Title="Window1" Height="450" Width="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
|
@ -1,27 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace DirectoryCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
public partial class Window1 : Window
|
||||
{
|
||||
public Window1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue