using BeWo.Core;
using BeWo.ServiceProxy;
using BeWo.View;
using BeWo.ViewModel;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.Extensions;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;

namespace BeWo
{
    /// <summary>
    /// Interaktionslogik für OpenOrSaveDialog.xaml
    /// </summary>
    public partial class UploadDialog : Window
    {
        public bool Upload;
        private string _Question;

        public string Question
        {
            get { return _Question; }
            set { _Question = string.Format("Möchten Sie die bearbeitete Datei im Pfad \"{0}\" Hochladen?", value); }
        }
        public int schalter;
        public bool erneutversuchen;

        public string pfad ="";


        public UploadDialog(string fileName, int iterator)
        {
            InitializeComponent();
            InitCommandBindings();
            Owner = GetWindow(BeWoApp.MainControl.ActiveView);
            schalter = iterator;
            if (schalter == 1)
            {
                Hochladebtn.Visibility = Visibility.Visible;
                Question = fileName;
                Hochladebtn.Content = "Hochladen";
               
            }
            if (schalter == 2) {
                _Question = string.Format("Bitte schließen sie zuerst das Bearbeitete Dokument.");
                Hochladebtn.Content = "Erneut Versuchen";
               
                erneutversuchen = true;
                pfad = fileName;
            }
            if (schalter == 3)
            {
                Hochladebtn.Visibility = Visibility.Visible;
                _Question = string.Format(fileName);
                Hochladebtn.Content = "Löschen";
                Abbrechbtn.Content = "Behalten";
             
            }

            DataContext = this;
          
        }

        private void InitCommandBindings()
        {
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => { Upload = false; Close(); }));
        }

        private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                DragMove();
            }
            catch (Exception){}
        }

        private void btn_Upload_Click(object sender, RoutedEventArgs e)
        {
            Upload = true;
            erneutversuchen = true;
            Close();
        }
    }
}
