refactor(desktop): clean up some code
This commit is contained in:
parent
f86bb6a516
commit
0637b7e516
|
@ -8,7 +8,9 @@ namespace XIVChat_Desktop {
|
|||
public partial class ConnectDialog {
|
||||
public App App => (App)Application.Current;
|
||||
|
||||
public ConnectDialog() {
|
||||
public ConnectDialog(Window owner) {
|
||||
this.Owner = owner;
|
||||
|
||||
this.InitializeComponent();
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using XIVChatCommon;
|
||||
|
||||
namespace XIVChat_Desktop.Controls {
|
||||
|
@ -40,7 +39,7 @@ namespace XIVChat_Desktop.Controls {
|
|||
set => this.SetValue(ShowTimestampsProperty, value);
|
||||
}
|
||||
|
||||
public static void PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
private static void PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
// Clear current textBlock
|
||||
if (!(d is MessageTextBlock textBlock)) {
|
||||
return;
|
||||
|
|
|
@ -127,10 +127,7 @@ namespace XIVChat_Desktop {
|
|||
}
|
||||
|
||||
private void Connect_Click(object sender, RoutedEventArgs e) {
|
||||
var dialog = new ConnectDialog {
|
||||
Owner = this,
|
||||
};
|
||||
dialog.ShowDialog();
|
||||
new ConnectDialog(this).ShowDialog();
|
||||
}
|
||||
|
||||
private void Disconnect_Click(object sender, RoutedEventArgs e) {
|
||||
|
|
|
@ -343,12 +343,18 @@ namespace XIVChat_Desktop {
|
|||
var isLeft = false;
|
||||
var isRight = false;
|
||||
|
||||
// A left-flanking delimiter run is a delimiter run that is (1) not followed by Unicode whitespace, and either (2a) not followed by a punctuation character, or (2b) followed by a punctuation character and preceded by Unicode whitespace or a punctuation character. For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.
|
||||
// A left-flanking delimiter run is a delimiter run that is (1) not followed by Unicode whitespace, and
|
||||
// either (2a) not followed by a punctuation character, or (2b) followed by a punctuation character and
|
||||
// preceded by Unicode whitespace or a punctuation character. For purposes of this definition, the beginning
|
||||
// and the end of the line count as Unicode whitespace.
|
||||
if (!followedByWhitespace && (!followedByPunctuation || (followedByPunctuation && (precededByWhitespace || precededByPunctuation)))) {
|
||||
isLeft = true;
|
||||
}
|
||||
|
||||
// A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and either (2a) not preceded by a punctuation character, or (2b) preceded by a punctuation character and followed by Unicode whitespace or a punctuation character. For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.
|
||||
// A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and
|
||||
// either (2a) not preceded by a punctuation character, or (2b) preceded by a punctuation character and
|
||||
// followed by Unicode whitespace or a punctuation character. For purposes of this definition, the beginning
|
||||
// and the end of the line count as Unicode whitespace.
|
||||
if (!precededByWhitespace && (!precededByPunctuation || (precededByPunctuation && (followedByWhitespace || followedByPunctuation)))) {
|
||||
isRight = true;
|
||||
}
|
||||
|
|
|
@ -11,39 +11,7 @@ using Inline = System.Windows.Documents.Inline;
|
|||
|
||||
namespace XIVChat_Desktop {
|
||||
public class MessageFormatter {
|
||||
private static readonly BitmapFrame FontIcon =
|
||||
BitmapFrame.Create(new Uri("pack://application:,,,/Resources/fonticon_ps4.tex.png"));
|
||||
|
||||
public static readonly DependencyProperty FormattedTextProperty = DependencyProperty.RegisterAttached(
|
||||
"FormattedText",
|
||||
typeof(ServerMessage),
|
||||
typeof(MessageFormatter)
|
||||
// new PropertyMetadata(null, FormattedTextPropertyChanged)
|
||||
);
|
||||
|
||||
public static void SetFormattedText(DependencyObject textBlock, ServerMessage value) {
|
||||
textBlock.SetValue(FormattedTextProperty, value);
|
||||
}
|
||||
|
||||
public static string GetFormattedText(DependencyObject textBlock) {
|
||||
return (string)textBlock.GetValue(FormattedTextProperty);
|
||||
}
|
||||
|
||||
// private static void FormattedTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
// // Clear current textBlock
|
||||
// if (!(d is TextBlock textBlock)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// textBlock.ClearValue(TextBlock.TextProperty);
|
||||
// textBlock.Inlines.Clear();
|
||||
//
|
||||
// // Create new formatted text
|
||||
// var lineHeight = textBlock.FontFamily.LineSpacing * textBlock.FontSize;
|
||||
// foreach (var inline in ChunksToTextBlock(lineHeight, (ServerMessage)e.NewValue)) {
|
||||
// textBlock.Inlines.Add(inline);
|
||||
// }
|
||||
// }
|
||||
private static readonly BitmapFrame FontIcon = BitmapFrame.Create(new Uri("pack://application:,,,/Resources/fonticon_ps4.tex.png"));
|
||||
|
||||
public static IEnumerable<Inline> ChunksToTextBlock(ServerMessage message, double lineHeight, bool processMarkdown, bool showTimestamp) {
|
||||
var elements = new List<Inline>();
|
||||
|
|
Loading…
Reference in New Issue