using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
/// <summary>
/// 功能: 建立可取得未使用寬度之工具列物件。
/// 維護: 
/// [108/04/24][12:40] > 完成基礎代碼撰寫，未測試。
/// 建立於: 108/04/24
/// </summary>
namespace ETC_App1
{
    public partial class ETCToolStrip : ToolStrip
    {
        public ETCToolStrip()
        {
            InitializeComponent();
        }

        public int UnusedWidth
        {
            get
            {
                int width = Size.Width - Padding.Left - Padding.Right;

                for (int i = 0; i < Items.Count; i++)
                {
                    if (Items[i] is ToolStripTextBox || Items[i] is ToolStripComboBox) { continue; }
                    else if (Items[i] is ToolStripLabel)
                    {
                        ToolStripLabel item = Items[i] as ToolStripLabel;

                        width = width - item.Size.Width - item.Margin.Left - item.Margin.Right;
                    }
                    else if (Items[i] is ToolStripButton)
                    {
                        ToolStripButton item = Items[i] as ToolStripButton;

                        width = width - item.Size.Width - item.Margin.Left - item.Margin.Right;
                    }
                    else if (Items[i] is ToolStripSeparator)
                    {
                        ToolStripSeparator item = Items[i] as ToolStripSeparator;

                        width = width - item.Size.Width - item.Margin.Left - item.Margin.Right;
                    }
                }

                return width;
            }
        }
    }
}
