Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Fixed some issues
Browse files Browse the repository at this point in the history
Fixed some Combobox related issues.
  • Loading branch information
AndyFilter committed Mar 9, 2021
1 parent 61b8178 commit 2099be5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DialogueMaker/Controls/UserNotification.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" IsHitTestVisible="False" Margin="0,5,0,0">
<Grid x:Name="Grid" IsHitTestVisible="False">
<Border Background="#FFD4D4D4" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" CornerRadius="8">
<Border x:Name="Border" Background="#FFD4D4D4" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" CornerRadius="8">
<TextBlock x:Name="NotificationLabel" Text="This is a very long text to test the program's functions" TextWrapping="Wrap" Padding="4,4,4,4" FontFamily="Montserrat Medium" Foreground="Black" FontSize="14"/>
</Border>
<Grid.RenderTransform>
Expand Down
14 changes: 7 additions & 7 deletions DialogueMaker/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<StackPanel DockPanel.Dock="Top" HorizontalAlignment="Stretch" Orientation="Horizontal">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Bottom">
<Label Content="Select Project:"/>
<ComboBox Name="ProjectsBox" MinWidth="150" SelectionChanged="ProjectSelectionChanged">
<ComboBox Name="ProjectsBox" MinWidth="150" SelectionChanged="ProjectSelectionChanged" MaxWidth="200">
<!--<ComboBoxItem Content="Item 1" Selector.IsSelected="True"/>-->
</ComboBox>
</StackPanel>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="20,0,0,0">
<Label Content="Name:"/>
<TextBox x:Name="ProjectNameBox" Text="" MinWidth="150" MaxLines="1" TextWrapping="NoWrap" MaxWidth="250" InputScope="FileName" Template="{StaticResource TextBoxBaseControlTemplate}"/>
<TextBox x:Name="ProjectNameBox" Text="" MinWidth="150" MaxLines="1" TextWrapping="NoWrap" MaxWidth="450" InputScope="FileName" Template="{StaticResource TextBoxBaseControlTemplate}"/>
</StackPanel>
<Button x:Name="ProjectCreate" Content="Create" Margin="20,0,20,0" VerticalAlignment="Bottom" IsEnabled="False" Click="CreateProjectClicked" Style="{StaticResource NormalButton}"/>
</StackPanel>
Expand Down Expand Up @@ -104,7 +104,7 @@
</StackPanel>
<StackPanel Margin="0,0,20,0">
<Label Content="Type:"/>
<ComboBox x:Name="NpcTypeBox" ItemsSource="{Binding NpcType}" SelectionChanged="TypeChanged">
<ComboBox x:Name="NpcTypeBox" ItemsSource="{Binding NpcType}" SelectionChanged="TypeChanged" MinWidth="140">
<ComboBoxItem IsSelected="True">Foreground</ComboBoxItem>
<ComboBoxItem>Background</ComboBoxItem>
</ComboBox>
Expand Down Expand Up @@ -135,19 +135,19 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical">
<TextBox x:Name="ButtonBox1" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged"/>
<TextBox x:Name="ButtonBox1" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged" Template="{StaticResource TextBoxBaseControlTemplate}"/>
<ComboBox x:Name="ButtonCombo1" SelectionChanged="NextNodeChanged"/>
</StackPanel>
<StackPanel Grid.Column="2" >
<TextBox x:Name="ButtonBox2" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged"/>
<TextBox x:Name="ButtonBox2" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged" Template="{StaticResource TextBoxBaseControlTemplate}"/>
<ComboBox x:Name="ButtonCombo2" SelectionChanged="NextNodeChanged"/>
</StackPanel>
<StackPanel Grid.Row="2">
<TextBox x:Name="ButtonBox3" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged"/>
<TextBox x:Name="ButtonBox3" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged" Template="{StaticResource TextBoxBaseControlTemplate}"/>
<ComboBox x:Name="ButtonCombo3" SelectionChanged="NextNodeChanged"/>
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="2">
<TextBox x:Name="ButtonBox4" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged"/>
<TextBox x:Name="ButtonBox4" Text="" Margin="0,0,0,5" TextChanged="ChoiceTextChanged" Template="{StaticResource TextBoxBaseControlTemplate}"/>
<ComboBox x:Name="ButtonCombo4" SelectionChanged="NextNodeChanged"/>
</StackPanel>
</Grid>
Expand Down
23 changes: 18 additions & 5 deletions DialogueMaker/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text.Json;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace DialogueMaker
{
Expand Down Expand Up @@ -48,6 +49,18 @@ private void CreateNotification(string Text, Structs.NotifType Type)

(noti.FindName("NotificationLabel") as TextBlock).Text = Text;

switch (Type)
{
case Structs.NotifType.Information:
break;

case Structs.NotifType.Warning:
(noti.FindName("Border") as Border).Background = (Brush)FindResource("NotifWarning");
break;
case Structs.NotifType.Alert:
break;
}

NotificationPanel.Children.Add(noti);
DockPanel.SetDock(noti, Dock.Bottom);
}
Expand Down Expand Up @@ -338,8 +351,8 @@ private List<Label> GetAllDialoguesOfNpc(Structs.NPC Npc)
if (node == CurrentNode)
continue;
label = new Label();
text = node.Text.Substring(0, Math.Min(node.Text.Length, 25));
if (node.Text.Length >= 25)
text = node.Text.Substring(0, Math.Min(node.Text.Length, 16));
if (node.Text.Length >= 16)
{
text += "...";
}
Expand Down Expand Up @@ -865,7 +878,6 @@ private async void LoadProjectData()
label = new Label();
label.DataContext = ProjectData;
label.Content = ProjectData.Name;
label.Padding = new Thickness(3);
label.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
label.MaxHeight = label.DesiredSize.Height;
ProjectsBox.Items.Add(label);
Expand All @@ -880,6 +892,7 @@ private async void LoadProjectData()
ProjectsBox.SelectedItem = label;
}
}

//if(ProjectsBox.Items.Count > 1)
// ProjectsBox.SelectedIndex = 1;
}
Expand Down Expand Up @@ -987,7 +1000,7 @@ private void CreateProjectClicked(object sender, RoutedEventArgs e)
}
}
}
else if (ProjectCreate.Content.ToString() == "Save" && Utils.UserDataPath.GetDirectories().Any(s => ProjectName.Equals(s.Name)))
else if (ProjectCreate.Content.ToString() == "Save" && Utils.UserDataPath.GetDirectories().Any(s => ProjectName.Equals(s.Name)) && CurrentProject.Name == ProjectName)
{
foreach (DirectoryInfo Dir in Utils.UserDataPath.GetDirectories())
{
Expand Down Expand Up @@ -1016,7 +1029,7 @@ private void CreateProjectClicked(object sender, RoutedEventArgs e)
}
else
{
ProjectNameBox.Text = CurrentProject.Name;
CreateNotification("Project with this name already exists", Structs.NotifType.Warning);
}
}

Expand Down
26 changes: 11 additions & 15 deletions DialogueMaker/Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<SolidColorBrush x:Key="DeleteButtonColorHover" Color="#FC5C65"/>
<SolidColorBrush x:Key="GradientStartButton" Color="#E040FB"/>
<SolidColorBrush x:Key="GradientStopButton" Color="#AD1457"/>
<SolidColorBrush x:Key="NotifWarning" Color="#DA4167"/>

<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{StaticResource FontColor}"/>
Expand Down Expand Up @@ -261,16 +262,15 @@
</ControlTemplate>

<ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
<Border x:Name="PART_ContentHost" Focusable="False" Background="{StaticResource LightBackground}" />
<Border x:Name="PART_ContentHost" Focusable="False" Background="{StaticResource LightBackground}"/>
</ControlTemplate>

<Style x:Key="{x:Type ComboBox}" TargetType="{x:Type ComboBox}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="false"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="MinWidth" Value="120"/>
<Setter Property="MinHeight" Value="20"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Template">
Expand Down Expand Up @@ -304,17 +304,16 @@
FontSize="14"
FontFamily="Montserrat"/>
<Popup
Name="Popup"
Name="Popup"
Placement="Bottom"
IsOpen="{TemplateBinding IsDropDownOpen}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Slide">

<Grid Name="DropDown"
<Grid Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
Width="{Binding Path=ActualWidth,RelativeSource={RelativeSource TemplatedParent}}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border
x:Name="DropDownBorder" CornerRadius="0,0,10,10"
Margin="10,0,10,0"
Expand Down Expand Up @@ -362,21 +361,18 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border Name="Border"
Padding="3,5,3,5"
Padding="3,4,3,4"
SnapsToDevicePixels="true"
Margin="10,0,10,0">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="true">
<Setter TargetName="Border" Property="Background" Value="{StaticResource LightBackground}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#888888"/>
</Trigger>
<Trigger Property="Content" Value="PASS">
<Setter Property="Foreground" Value="Yellow"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand All @@ -394,7 +390,7 @@
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="10,2"/>
Margin="10,2" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
Expand Down

0 comments on commit 2099be5

Please sign in to comment.