using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 System.Reflection;

// Ooganizer Namespaces
using Foo.Platform;
using Foo.Platform.Interacters;

namespace Foo.ClientServices.ButtonWPForm.ButtonFormPages
{
    /// <summary>
    /// Interaction logic for ButtonFormPage_AddEdit.xaml
    /// </summary>
    public partial class Page_AddEdit : Page, IButtonFormPage
    {
        #region IButtonFormPage
        public ButtonForm ParentWPFContainer { get { return _ButtonForm; } set { _ButtonForm = value; } }
        private ButtonForm _ButtonForm = null;
        #endregion

        // Declare the Log4net Variable        
        private static log4net.ILog Log = Logger.GetLog4NetInterface(MethodBase.GetCurrentMethod().DeclaringType);

        public Page_AddEdit()
        {
            InitializeComponent();
        }

        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (ParentWPFContainer == null)
            {
                Log.Debug(string.Format("{0}() - ParentWPFContainer is null this should never happen", MethodBase.GetCurrentMethod().Name));
                return;
            }

            // Set the Artifact Properties 
            //txtTitle.Text = ParentWPFContainer.ArtifactTitle;
            
            // se
            //txtLocation.Text = ParentWPFContainer.ArtifactLocation;
            //txtLocation.ScrollToEnd();

            // Add all workspaces to the combo selection
            //foreach (Ooganizer.API.Workspace wspace in SrvrCommon.Workspaces)
            //    comboWorkspaces.Items.Add(wspace.Name);

            ////
            // Default to the current Workspace or 0 if none are loaded
            ////
            //if (ParentWPFContainer.CurrentWorkspaceName == "")
            //    comboWorkspaces.SelectedIndex = 0;
            //else
            //    comboWorkspaces.SelectedValue = ParentWPFContainer.CurrentWorkspaceName;            
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            BHInteracter.SetW32ButtonToNewState(ParentWPFContainer.HookedWindow, BHInteracter.BUTTON_HOOK_STATE.BUTTON_ADD);
            ParentWPFContainer.Close();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            //SrvrCommon.AddArtifactToWorkspace(txtTitle.Text, txtLocation.Text, ParentWPFContainer.SnapShot, ParentWPFContainer.CurrentWorkspaceName);
            //BHInteracter.SetW32ButtonToNewState(ParentWPFContainer.HookedWindow, BHInteracter.BUTTON_HOOK_STATE.BUTTON_DELETE);
            ParentWPFContainer.Close();
        }      
    }
}
