fix(desktop): don't update until clicking save

This commit is contained in:
Anna 2020-11-12 15:13:36 -05:00
parent 7377da1bfd
commit 0bf316fe62
7 changed files with 58 additions and 20 deletions

View File

@ -83,15 +83,45 @@ namespace XIVChat_Desktop {
}
[JsonObject]
public class SavedServer {
public string Name { get; set; }
public string Host { get; set; }
public ushort Port { get; set; }
public class SavedServer : INotifyPropertyChanged {
private string name;
private string host;
private ushort port;
public string Name {
get => this.name;
set {
this.name = value;
this.OnPropertyChanged(nameof(this.Name));
}
}
public string Host {
get => this.host;
set {
this.host = value;
this.OnPropertyChanged(nameof(this.Host));
}
}
public ushort Port {
get => this.port;
set {
this.port = value;
this.OnPropertyChanged(nameof(this.Port));
}
}
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) {
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public SavedServer(string name, string host, ushort port) {
this.Name = name;
this.Host = host;
this.Port = port;
this.name = name;
this.host = host;
this.port = port;
}
protected bool Equals(SavedServer other) {

View File

@ -209,7 +209,6 @@ namespace XIVChat_Desktop {
private void SetMarkdownProcessing(bool on) {
this.ExportTab.ProcessMarkdown = on;
this.Repopulate();
}
private void RightArrow_Click(object sender, RoutedEventArgs e) {

View File

@ -65,7 +65,7 @@ namespace XIVChat_Desktop {
this.Close();
}
public static async Task<LicenceResponse> LicenceInfo(string key, bool increment = false) {
private static async Task<LicenceResponse> LicenceInfo(string key, bool increment = false) {
var uri = new Uri("https://api.gumroad.com/v2/licenses/verify");
var data = new Dictionary<string, string> {
["product_permalink"] = "kvQIw",

View File

@ -14,10 +14,10 @@
d:DataContext="{d:DesignInstance local:ManageServer}">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@ -34,7 +34,7 @@
Grid.Row="0"
Grid.Column="1"
x:Name="ServerName"
Text="{Binding Server.Name}" />
Text="{Binding Server.Name, Mode=OneTime}" />
<Label VerticalAlignment="Center"
Grid.Row="1"
@ -45,7 +45,7 @@
Grid.Row="1"
Grid.Column="1"
x:Name="ServerHost"
Text="{Binding Server.Host}" />
Text="{Binding Server.Host, Mode=OneTime}" />
<Label VerticalAlignment="Center"
Grid.Row="2"
@ -56,7 +56,7 @@
Grid.Row="2"
Grid.Column="1"
x:Name="ServerPort"
Text="{Binding Server.Port}"
Text="{Binding Server.Port, Mode=OneTime}"
ui:ControlHelper.PlaceholderText="14777" />
<WrapPanel Margin="0,8,0,0"
@ -75,4 +75,4 @@
</Button>
</WrapPanel>
</Grid>
</Window>
</Window>

View File

@ -56,6 +56,10 @@ namespace XIVChat_Desktop {
port
);
this.App.Config.Servers.Add(this.Server);
} else {
this.Server!.Name = serverName;
this.Server.Host = serverHost;
this.Server.Port = port;
}
this.App.Config.Save();

View File

@ -21,14 +21,16 @@
</Grid.RowDefinitions>
<TextBox Grid.Row="0"
x:Name="TabName"
Margin="0,0,0,8"
ui:ControlHelper.PlaceholderText="Name"
ui:ControlHelper.Header="Name"
Text="{Binding Tab.Name}" />
Text="{Binding Tab.Name, Mode=OneTime}" />
<CheckBox Grid.Row="1"
x:Name="MarkdownToggle"
Margin="0,0,0,8"
Content="Process messages as Markdown"
IsChecked="{Binding Tab.ProcessMarkdown}" />
IsChecked="{Binding Tab.ProcessMarkdown, Mode=OneTime}" />
<TabControl Grid.Row="2"
x:Name="Tabs" />
<Button Margin="0,8,0,0"

View File

@ -96,11 +96,14 @@ namespace XIVChat_Desktop {
}
private void Save_Click(object sender, RoutedEventArgs e) {
if (this.Tab.Name.Length == 0) {
if (this.TabName.Text.Length == 0) {
MessageBox.Show("Tab must have a name.");
return;
}
this.Tab.Name = this.TabName.Text;
this.Tab.ProcessMarkdown = this.MarkdownToggle.IsChecked ?? false;
if (this.isNewTab) {
this.App.Config.Tabs.Add(this.Tab);
}