using System;
using UnityEngine;

public class WindowPartsWindowVisible : WFCheckBox
{
	public bool windowVisible
	{
		get
		{
			return this.TargetWindow.visible;
		}
		set
		{
			this.TargetWindow.visible = value;
			if (this.TargetWindow.visible && !base.check)
			{
				base.check = true;
			}
			else if (!this.TargetWindow.visible && base.check)
			{
				base.check = false;
			}
		}
	}

	public override void Awake()
	{
		base.Awake();
	}

	public void Start()
	{
		if (this.TargetWindow != null)
		{
			this.TargetWindow.SetButtonEnabled(BasePhotoWindow.BtnType.Min, true, false);
			this.TargetWindow.GetButtonOnClickEventList(BasePhotoWindow.BtnType.Min).Add(delegate
			{
				if (this.TargetWindow.visible)
				{
					this.OnClockEvent();
				}
			});
		}
	}

	protected override void OnClockEvent()
	{
		this.TargetWindow.visible = !base.check;
		if (this.TargetWindow.visible)
		{
			this.TargetWindow.ActiveWindow();
		}
		base.OnClockEvent();
	}

	public virtual void Update()
	{
		if (this.overRideStartVisible != WindowPartsWindowVisible.OverRideStartVisible.Non)
		{
			bool flag = this.overRideStartVisible == WindowPartsWindowVisible.OverRideStartVisible.Visible;
			this.TargetWindow.visible = flag;
			base.check = flag;
			if (this.TargetWindow.visible)
			{
				this.TargetWindow.ActiveWindow();
			}
		}
		this.overRideStartVisible = WindowPartsWindowVisible.OverRideStartVisible.Non;
		if (this.TargetWindow.visible && !base.check)
		{
			base.check = true;
		}
		else if (!this.TargetWindow.visible && base.check)
		{
			base.check = false;
		}
	}

	[SerializeField]
	public BasePhotoWindow TargetWindow;

	[SerializeField]
	public WindowPartsWindowVisible.OverRideStartVisible overRideStartVisible;

	public enum OverRideStartVisible
	{
		Non,
		Visible,
		Invisible
	}
}
