<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Framework;
using Framework.Interfaces;
using System.IO;

namespace GUI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, IMainForm 
    {
        public MainWindow()
        {
            InitializeComponent();
            mediaController = new MediaController(this);

            seekbarCursorCanvas.Height = seekbarCanvas.Height;
            seekbarCursorCanvas.Width = seekbarCanvas.Width / 50;
            Canvas.SetLeft(seekbarCursorCanvas, Canvas.GetLeft(seekbarCanvas));
            Canvas.SetTop(seekbarCursorCanvas, Canvas.GetTop(seekbarCanvas));

            UpdateButtonStates();
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        
        private void previousButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Prev();
        }

        private void playButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Play();
        }

        private void stopButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Stop();
        }

        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Next();
        }

        private void settingsButton_Click(object sender, RoutedEventArgs e)
        {
            Settings settingdlg = new Settings();

            settingdlg.ShowDialog();
            if (settingdlg.DialogResult.HasValue && settingdlg.DialogResult.Value)
            {
                string dir = settingdlg.directoryTextBox.Text;
                if (Directory.Exists(dir))
                {
                    string[] songs = DirectoryBrowser.getSongs(dir);
                    //will start automatically 
                    worker = new ClassifierThread(songs);

                }
                //Handle the settings changed
            }
            UpdateButtonStates();
        }

        private void seekbarCursorCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // TODO
        }

        private void seekbarCursorCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            //TODO
        }

        private void seekbarCursorCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            //TODO
        }

        private void seekbarCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            double percent = 0;
            double form_width = this.seekbarCanvas.Width;
            double form_x_start = Canvas.GetLeft(this.seekbarCanvas);
            percent = (e.GetPosition(this).X - form_x_start) / form_width;
            mediaController.Seek(percent);
        }

        private void WindowControlCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            WindowMovement.moveWindow(this, e);
        }

        public void updateMetaDataLabels(SongDTO song)
        {
            Album.Content = song.songTag.getAlbum();
            Artist.Content = song.songTag.getArtist();
            this.durationLabel.Content = song.songTag.getDuration().ToString(@"mm\:ss");
            //metadataLabels.Thumbnail.Image = songDTO.songTag.getThumbnail();
            this.titleLabel.Content = song.songTag.getTitle();
            setTimeLabel(new TimeSpan(0));
        }

        public void setTimeLabel(TimeSpan time)
        {
            string result = time.ToString(@"mm\:ss");
            this.currentTimeLabel.Content = result;
        }

        public void UpdateCursor(double percent)
        {
            int x = (int)((seekbarCanvas.Width / 50) * 49 * percent);
            Canvas.SetLeft(seekbarCursorCanvas, x);
        }

        private MediaController mediaController = null;

        private double Positivity
        {
            get<commit_msg>Fixed a type. Updates album and artist labels correctly<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Framework;
using Framework.Interfaces;
using System.IO;

namespace GUI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window, IMainForm 
    {
        public MainWindow()
        {
            InitializeComponent();
            mediaController = new MediaController(this);

            seekbarCursorCanvas.Height = seekbarCanvas.Height;
            seekbarCursorCanvas.Width = seekbarCanvas.Width / 50;
            Canvas.SetLeft(seekbarCursorCanvas, Canvas.GetLeft(seekbarCanvas));
            Canvas.SetTop(seekbarCursorCanvas, Canvas.GetTop(seekbarCanvas));

            UpdateButtonStates();
        }

        private void closeButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        
        private void previousButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Prev();
        }

        private void playButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Play();
        }

        private void stopButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Stop();
        }

        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            mediaController.Next();
        }

        private void settingsButton_Click(object sender, RoutedEventArgs e)
        {
            Settings settingdlg = new Settings();

            settingdlg.ShowDialog();
            if (settingdlg.DialogResult.HasValue && settingdlg.DialogResult.Value)
            {
                string dir = settingdlg.directoryTextBox.Text;
                if (Directory.Exists(dir))
                {
                    string[] songs = DirectoryBrowser.getSongs(dir);
                    //will start automatically 
                    worker = new ClassifierThread(songs);

                }
                //Handle the settings changed
            }
            UpdateButtonStates();
        }

        private void seekbarCursorCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // TODO
        }

        private void seekbarCursorCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            //TODO
        }

        private void seekbarCursorCanvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            //TODO
        }

        private void seekbarCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            double percent = 0;
            double form_width = this.seekbarCanvas.Width;
            double form_x_start = Canvas.GetLeft(this.seekbarCanvas);
            percent = (e.GetPosition(this).X - form_x_start) / form_width;
            mediaController.Seek(percent);
        }

        private void WindowControlCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            WindowMovement.moveWindow(this, e);
        }

        public void updateMetaDataLabels(SongDTO song)
        {
            albumLabel.Content = song.songTag.getAlbum();
            artistLabel.Content = song.songTag.getArtist();
            this.durationLabel.Content = song.songTag.getDuration().ToString(@"mm\:ss");
            //metadataLabels.Thumbnail.Image = songDTO.songTag.getThumbnail();
            this.titleLabel.Content = song.songTag.getTitle();
            setTimeLabel(new TimeSpan(0));
        }

        public void setTimeLabel(TimeSpan time)
        {
            string result = time.ToString(@"mm\:ss");
            this.currentTimeLabel.Content = result;
        }

        public void UpdateCursor(double percent)
        {
            int x = (int)((seekbarCanvas.Width / 50) * 49 * percent);
            Canvas.SetLeft(seekbarCursorCanvas, x);
        }

        private MediaController mediaController = null;

        private double Positivity
        {
            get
{'fraction_non_alphanumeric': 0.08369790467418835, 'fraction_numerical': 0.0018420446695832373, 'mean_word_length': 2.0184155663655314, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326000', 'n_tokens_mistral': 2249, 'n_tokens_neox': 2142, 'n_words': 459}