Skip to content

Commit

Permalink
Added linkhandler
Browse files Browse the repository at this point in the history
Handles links,
ignores images and displays links as italic
  • Loading branch information
daredloco committed Oct 23, 2020
1 parent 6732f33 commit 4f9b14a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion GitInstaller/GitInstaller/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<CheckBox Name="cb_preview" Content="Show Preview Releases" Grid.Row="4" VerticalAlignment="Center" />
<Button Name="bt_install" Grid.Row="9" Content="Install" />
<Label Content="Version Details:" Grid.Row="6" />
<RichTextBox Name="rtb_changes" Grid.Row="7">
<RichTextBox Name="rtb_changes" Grid.Row="7" IsReadOnly="True" IsDocumentEnabled="True">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0" />
Expand Down
26 changes: 16 additions & 10 deletions GitInstaller/GitInstaller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public MainWindow()
cb_versions.SelectionChanged += VersionChanged;
cb_preview.Checked += PreviewChecked;
cb_preview.Unchecked += PreviewUnchecked;
rtb_changes.IsReadOnly = true;
rtb_log.IsReadOnly = true;
bt_install.IsEnabled = false;
bt_install.Click += InstallClicked;
Expand Down Expand Up @@ -146,21 +145,28 @@ internal void UpdateChanges(Installer.GitRelease release)
newline = line.TrimStart('#');
para.FontWeight = FontWeights.ExtraBlack;
}
else if(Regex.IsMatch(line,""))

//Get Links and Images
Match match = Regex.Match(line, "!\\[.*\\]?\\(.*\\)");
while(match.Success)
{
Regex Pattern = new Regex("\\(.*\\)");
Match newmatch = Pattern.Match(match.Value);
string link = newmatch.Value.Trim('(',')');
WriteLog(match.Value + " => " + link);

if(link.EndsWith(".jpg") || link.EndsWith(".png"))
newline = "";
else
newline.Replace(match.Value, link);


match = match.NextMatch();
para.FontStyle = FontStyles.Italic;
}

para.Inlines.Add(newline);
rtb_changes.Document.Blocks.Add(para);
}

//Old
//string content = release.Body;
//Paragraph para = new Paragraph();
//para.Inlines.Add(content);
//rtb_changes.Document.Blocks.Clear();
//rtb_changes.Document.Blocks.Add(para);
}

internal void UpdateVersions(bool withpreviews)
Expand Down
4 changes: 2 additions & 2 deletions GitInstaller/GitInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.2.0")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]

0 comments on commit 4f9b14a

Please sign in to comment.