diff --git a/EbayListingTool/Views/MainWindow.xaml b/EbayListingTool/Views/MainWindow.xaml index 7c43bb2..f3c85ae 100644 --- a/EbayListingTool/Views/MainWindow.xaml +++ b/EbayListingTool/Views/MainWindow.xaml @@ -4,7 +4,7 @@ xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:local="clr-namespace:EbayListingTool.Views" - Title="eBay Listing Tool — UK" + Title="eBay Listing Tool - UK" Height="820" Width="1180" MinHeight="600" MinWidth="900" WindowStartupLocation="CenterScreen" @@ -61,101 +61,49 @@ - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + + - - + @@ -169,16 +117,15 @@ HorizontalAlignment="Center" VerticalAlignment="Center"/> - - - - - - - - @@ -282,6 +177,13 @@ + + diff --git a/EbayListingTool/Views/MainWindow.xaml.cs b/EbayListingTool/Views/MainWindow.xaml.cs index d1175c3..9ddfe0b 100644 --- a/EbayListingTool/Views/MainWindow.xaml.cs +++ b/EbayListingTool/Views/MainWindow.xaml.cs @@ -15,34 +15,29 @@ public partial class MainWindow : MetroWindow private readonly BulkImportService _bulkService; private readonly SavedListingsService _savedService; private readonly EbayPriceResearchService _priceService; - private readonly PriceLookupService _priceLookupService; + private readonly PriceLookupService _priceLookupService; public MainWindow() { InitializeComponent(); var config = App.Configuration; - _auth = new EbayAuthService(config); - _categoryService = new EbayCategoryService(_auth); - _listingService = new EbayListingService(_auth, _categoryService); - _aiService = new AiAssistantService(config); - _bulkService = new BulkImportService(); - _savedService = new SavedListingsService(); + _auth = new EbayAuthService(config); + _categoryService = new EbayCategoryService(_auth); + _listingService = new EbayListingService(_auth, _categoryService); + _aiService = new AiAssistantService(config); + _bulkService = new BulkImportService(); + _savedService = new SavedListingsService(); _priceService = new EbayPriceResearchService(_auth); _priceLookupService = new PriceLookupService(_priceService, _savedService, _aiService); - // Photo Analysis tab — no eBay needed - PhotoView.Initialise(_aiService, _savedService, _priceService); - PhotoView.UseDetailsRequested += OnUseDetailsRequested; + var defaultPostcode = config["Ebay:DefaultPostcode"] ?? ""; - // Saved Listings tab - SavedView.Initialise(_savedService, _priceLookupService); + NewListingView.Initialise(_listingService, _categoryService, _aiService, _auth, + _savedService, defaultPostcode); - // New Listing + Bulk tabs - SingleView.Initialise(_listingService, _categoryService, _aiService, _auth); - BulkView.Initialise(_listingService, _categoryService, _aiService, _bulkService, _auth); + SavedView.Initialise(_savedService, _priceLookupService, _listingService, _auth); - // Try to restore saved eBay session _auth.TryLoadSavedToken(); UpdateConnectionState(); } @@ -52,7 +47,7 @@ public partial class MainWindow : MetroWindow private async void ConnectBtn_Click(object sender, RoutedEventArgs e) { ConnectBtn.IsEnabled = false; - SetStatus("Connecting to eBay…"); + SetStatus("Connecting to eBay..."); try { var username = await _auth.LoginAsync(); @@ -68,14 +63,14 @@ public partial class MainWindow : MetroWindow finally { ConnectBtn.IsEnabled = true; - UpdateConnectionState(); // always sync UI to actual auth state + UpdateConnectionState(); } } private void DisconnectBtn_Click(object sender, RoutedEventArgs e) { _auth.Disconnect(); - _listingService.ClearCache(); // clear cached policy/location IDs for next login + _listingService.ClearCache(); UpdateConnectionState(); SetStatus("Disconnected from eBay."); } @@ -83,50 +78,42 @@ public partial class MainWindow : MetroWindow private void UpdateConnectionState() { var connected = _auth.IsConnected; - - // Per-tab overlays (Photo Analysis tab has no overlay) NewListingOverlay.Visibility = connected ? Visibility.Collapsed : Visibility.Visible; - BulkOverlay.Visibility = connected ? Visibility.Collapsed : Visibility.Visible; - - ConnectBtn.Visibility = connected ? Visibility.Collapsed : Visibility.Visible; - DisconnectBtn.Visibility = connected ? Visibility.Visible : Visibility.Collapsed; if (connected) { - StatusDot.Fill = new SolidColorBrush(Colors.LimeGreen); - StatusLabel.Text = $"eBay: {_auth.ConnectedUsername}"; - StatusBarDot.Fill = new SolidColorBrush(Colors.LimeGreen); - StatusBarEbay.Text = $"eBay: {_auth.ConnectedUsername}"; + StatusBarDot.Fill = new SolidColorBrush(Colors.LimeGreen); + StatusBarEbay.Text = $"eBay: {_auth.ConnectedUsername}"; StatusBarEbay.Foreground = new SolidColorBrush(Colors.LimeGreen); + DisconnectBtn.Visibility = Visibility.Visible; } else { - StatusDot.Fill = new SolidColorBrush(Colors.Gray); - StatusLabel.Text = "eBay: not connected"; - StatusBarDot.Fill = new SolidColorBrush(Color.FromRgb(0x88, 0x88, 0x88)); - StatusBarEbay.Text = "eBay: disconnected"; + StatusBarDot.Fill = new SolidColorBrush(Color.FromRgb(0x88, 0x88, 0x88)); + StatusBarEbay.Text = "eBay: disconnected"; StatusBarEbay.Foreground = (Brush)FindResource("MahApps.Brushes.Gray5"); + DisconnectBtn.Visibility = Visibility.Collapsed; } } - // ---- Photo Analysis → New Listing handoff ---- + // ---- File menu ---- - private void OnUseDetailsRequested(PhotoAnalysisResult result, IReadOnlyList photoPaths, decimal price) + private void BulkImport_Click(object sender, RoutedEventArgs e) { - SingleView.PopulateFromAnalysis(result, photoPaths, price); // Q1: forward all photos + // BulkImportWindow is created in Task 7; placeholder for now + MessageBox.Show("Bulk Import coming in the next step.", "Bulk Import", + MessageBoxButton.OK, MessageBoxImage.Information); } - public void SwitchToNewListingTab() - { - MainTabs.SelectedItem = NewListingTab; - } + private void Exit_Click(object sender, RoutedEventArgs e) => Close(); - public void RefreshSavedListings() - { - SavedView.RefreshList(); - } - - // ---- Helpers ---- + // ---- Public interface for child views ---- public void SetStatus(string message) => StatusBar.Text = message; + + public void SwitchToNewListingTab() => MainTabs.SelectedItem = NewListingTab; + + public void RefreshDrafts() => SavedView.RefreshList(); + + public void RefreshSavedListings() => RefreshDrafts(); // backwards compat for NewListingView }