This repository has been archived on 2026-07-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
OutlookAddin/src/OutlookAddin.UI/Dialogs/SettingsDialog.xaml.cs
T
PointStar 7aa96c99a3 feat(about): logs + settings paths open the folder in Explorer
The two %APPDATA% / %LOCALAPPDATA% paths in Settings → אודות are now
hyperlinks. Click to open the folder (creates it lazily if it's not
there yet, so the link works before the first log is written).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-24 19:43:24 +03:00

66 lines
2.1 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Documents;
using MarcusLaw.OutlookAddin.UI.ViewModels;
namespace MarcusLaw.OutlookAddin.UI.Dialogs
{
public partial class SettingsDialog : Window
{
private SettingsViewModel? _viewModel;
public SettingsDialog()
{
InitializeComponent();
}
public SettingsDialog(SettingsViewModel viewModel) : this()
{
AttachViewModel(viewModel);
}
public void AttachViewModel(SettingsViewModel viewModel)
{
if (_viewModel != null)
{
_viewModel.RequestClose -= OnRequestClose;
_viewModel.ApiKeyReader = null;
}
_viewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
DataContext = _viewModel;
_viewModel.RequestClose += OnRequestClose;
_viewModel.ApiKeyReader = () => ApiKeyBox.Password;
if (!string.IsNullOrEmpty(_viewModel.InitialApiKey))
{
ApiKeyBox.Password = _viewModel.InitialApiKey;
}
}
private void OnRequestClose(object? sender, EventArgs e)
{
DialogResult = _viewModel?.DialogResult;
Close();
}
private void OnOpenFolderHyperlink(object sender, RoutedEventArgs e)
{
if (!(sender is Hyperlink h) || !(h.Tag is string raw)) return;
try
{
var path = Environment.ExpandEnvironmentVariables(raw);
// Create the folder lazily so the link works even on the very
// first run, before any log has been written.
if (!Directory.Exists(path)) Directory.CreateDirectory(path);
Process.Start(new ProcessStartInfo("explorer.exe", "\"" + path + "\"") { UseShellExecute = true });
}
catch (Exception ex)
{
MessageBox.Show("פתיחת התיקייה נכשלה: " + ex.Message, "Klear",
MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
}