using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Foo.Platform.Win32;

namespace Foo.WorkspaceMgr.Closers
{
    internal class Closer_Generic : IClose
    {
        #region IClose Members

        /// <summary>
        /// Sends a WM_QUERYENDSESSION to the Window that the Artifact Belongs To
        /// </summary>
        /// <param name="strArtifactLocation">location of the path + file to launch</param>
        /// <returns></returns>
        public FuncDepBoolType IQueryClose(string strArtifactLocation)
        {
            if (!String.IsNullOrEmpty(strArtifactLocation))
            {
                // To Do: Must get hWnd From RAT 
                IntPtr hWnd = IntPtr.Zero;
                if (Win32Functions.SendMessage(hWnd, (int)WindowMessage.WM_QUERYENDSESSION, IntPtr.Zero, IntPtr.Zero) != 0)
                {
                    return FuncDepBoolType.Success;
                }
                else
                {
                    return FuncDepBoolType.Failed;
                }
            }
            return FuncDepBoolType.ParametersInvalid;
        }

        /// <summary>
        /// Sends a WM_Close to the Window that the Artifact Belongs To
        /// </summary>
        /// <param name="strArtifactLocation">location of the path + file to launch</param>
        /// <returns></returns>
        public FuncDepBoolType IClose(string strArtifactLocation)
        {
            if (!String.IsNullOrEmpty(strArtifactLocation))
            {
                // To Do: Must get hWnd From RAT 
                IntPtr hWnd = IntPtr.Zero;
                if (Win32Functions.SendMessage(hWnd, (int)WindowMessage.WM_CLOSE, IntPtr.Zero, IntPtr.Zero) == 0)
                {
                    return FuncDepBoolType.Success;
                }
                else
                {
                    return FuncDepBoolType.Failed;
                }
            }
            return FuncDepBoolType.ParametersInvalid;
        }

        #endregion
    }
}
