Fix file opening bugs, IE compatibility issues, and implement auto-incrementing version

This commit is contained in:
hOLOlu
2026-07-06 01:45:47 +03:00
parent 1de2054709
commit baeba9b26b
5 changed files with 306 additions and 235 deletions

View File

@@ -9,28 +9,48 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
namespace hMarkdown
{
public partial class Form1 : Form
{
private string startupFile = "";
public Form1(string fn)
{
InitializeComponent();
webBrowser.ScriptErrorsSuppressed = true;
this.DragEnter += Form1_DragEnter;
this.Resize += Form1_Resize;
this.Load += (s, e) => AdjustDosyaTextBoxWidth();
this.Load += Form1_Load;
if (!string.IsNullOrEmpty(fn)) {
startupFile = fn.Trim('"', ' ');
}
InitializeCustomControls();
SetMode(false);
if (fn.Length>0) {
tbDosya.Text = fn;
DosyaAc();
}
private void Form1_Load(object sender, EventArgs e)
{
AdjustDosyaTextBoxWidth();
// Set window title with dynamic version
string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
this.Text = $"hOLOlu Markdown Viewer (v{version})";
// WebBrowser kontrolünün ActiveX nesnesini ve dokümanını başlatmak için about:blank'e yönlendirip bekliyoruz.
webBrowser.Navigate("about:blank");
while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents();
}
if (!string.IsNullOrEmpty(startupFile)) {
tbDosya.Text = startupFile;
DosyaAc();
}
}
@@ -99,7 +119,15 @@ namespace hMarkdown
</div>
</body>
</html>";
webBrowser.DocumentText = result;
if (webBrowser.Document != null)
{
webBrowser.Document.OpenNew(true);
webBrowser.Document.Write(result);
}
else
{
webBrowser.DocumentText = result;
}
//webBrowser.Document.Body.Style.font = "font-family: Tahoma, Threbucet, Verdana; font-size: large;";
//webBrowser.Document.ExecCommand("SelectAll", false, "null");
@@ -109,6 +137,7 @@ namespace hMarkdown
private void tbGozat_Click(object sender, EventArgs e)
{
openFileDialog.FileName = "";
openFileDialog.Filter = "(*.md)|*.md|Tüm Dosyalar (*.*)|*.*";
openFileDialog.FilterIndex = 2;
openFileDialog.RestoreDirectory = true;
@@ -185,12 +214,10 @@ namespace hMarkdown
private void webBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
string file = e.Url.LocalPath.ToString();
if (file!="blank")
if (e.Url != null && e.Url.IsFile)
{
tbDosya.Text = file.Replace("file:///", ""); ;
string file = e.Url.LocalPath;
tbDosya.Text = file;
DosyaAc();
}
}