//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// WFX satellite library | Author: Sergei Y.Kitáev
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.ComponentModel;

using WF = System.Windows.Forms;
using DRW = System.Drawing;

using CommonHelpers;

namespace WFX {

//**************************************************************************************************
/// <summary>
/// </summary>
public partial class ConsoleBox: WF.Panel {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
[DefaultValue(ConsolePictureBox.DefaultForegroundColor)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ConsoleColor ForegroundColor
{
   get { return ConsolePictureBox.ForegroundColor; }
   set { ConsolePictureBox.ForegroundColor = value; }
}

/// <exception cref="InvalidOperationException" />
[DefaultValue(ConsolePictureBox.DefaultBackgroundColor)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public ConsoleColor BackgroundColor
{
   get { return ConsolePictureBox.BackgroundColor; }
   set { ConsolePictureBox.BackgroundColor = value; }
}

/// <exception cref="InvalidOperationException" />
/// <exception cref="ArgumentOutOfRangeException" />
[DefaultValue(ConsolePictureBox.MaxLinesDefault)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int MaxLines
{
   get { return ConsolePictureBox.MaxLines; }
   set { ConsolePictureBox.MaxLines = value; }
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
/// <exception cref="ArgumentOutOfRangeException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public DRW.Font FixedFont
{
   get { return ConsolePictureBox.FixedFont; }
   set { ConsolePictureBox.FixedFont = value; }
}

//--------------------------------------------------------------------------------------------------

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsConsoleInitialized
{
   get { return ConsolePictureBox.IsInitialized; }
}

/// <exception cref="InvalidOperationException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public HConsole Console
{
   get { return ConsolePictureBox.Console; }
}

/// <exception cref="InvalidOperationException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int RecommendedWidth
{
   get { return ConsolePictureBox.RecommendedContainerWidth; }
}

/// <exception cref="InvalidOperationException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int RecommendedWidthCorrection
{
   get { return ConsolePictureBox.RecommendedContainerWidthCorrection; }
}

/// <exception cref="InvalidOperationException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int AccurateHeightIncrement
{
   get { return ConsolePictureBox.AccurateHeightIncrement; }
}

/// <exception cref="InvalidOperationException" />
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public int AccurateHeightDecrement
{
   get { return ConsolePictureBox.AccurateHeightDecrement; }
}

//==================================================================================================

public ConsoleBox()
{
   AutoScroll = true;
   if ( Handle != null )
      _ConsolePictureBox_ = new ConsolePictureBox( this );
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
public void VerifyInitialized()
{
   ConsolePictureBox.VerifyInitialized();
}

/// <exception cref="InvalidOperationException" />
public void VerifyNotInitialized()
{
   ConsolePictureBox.VerifyNotInitialized();
}

//--------------------------------------------------------------------------------------------------

/// <exception cref="InvalidOperationException" />
public HProxyConsoleSettings PrepareProxyConsoleSettings()
{
   return ConsolePictureBox.PrepareProxyConsoleSettings();
}

/// <exception cref="ArgumentNullException" />
/// <exception cref="ArgumentException" />
/// <exception cref="HNullValueException" />
/// <exception cref="InvalidOperationException" />
public void Initialize(HConsole preparedProxyConsole)
{
   ConsolePictureBox.Initialize( preparedProxyConsole );
}

//==================================================================================================

protected override void OnParentChanged(EventArgs e)
{
   base.OnParentChanged( e ); BackColor = ConsolePictureBox.BackColor;
}
/*
protected override void OnMouseWheel(WF.MouseEventArgs e)
{
   base.OnMouseWheel( e );
HDebug.Print("Delta: {0}",e.Delta);
   if ( e.Delta == 0 )
      return;
   var position = AutoScrollPosition;
   AutoScrollPosition = new DRW.Point( position.X,
      position.Y + _ConsolePictureBox_.LineHeight * (e.Delta > 0 ? -1 : 1) );
   Invalidate();
}

protected override void OnMouseEnter(EventArgs e)
{
   base.OnMouseEnter( e );
HDebug.Print("OnMouseEnter");
   Focus();
}
*/
//==================================================================================================

/// <exception cref="HOperationFailedException" />
ConsolePictureBox ConsolePictureBox
{
   get
   {
      if ( _ConsolePictureBox_ == null )
         throw new HOperationFailedException(
            "Консольный бокс недоступен по причине недействительного оконного дескриптора "+
            "на момент инициализации (конструктор \"ConsolePictureBox\")." );
      return _ConsolePictureBox_;
   }
}

//==================================================================================================

readonly ConsolePictureBox
   _ConsolePictureBox_;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // ConsoleBox
//**************************************************************************************************

} // WFX
