using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public class WindowPartsInputSliderSet : MonoBehaviour
{
	public void Awake()
	{
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			WindowPartsInputSliderSet.SliderAndInputSet target_obj = this.SliderAndInput[i];
			this.SliderAndInput[i].Object.onChangeValue.Add(delegate(float val)
			{
				WindowPartsInputSliderSet.SliderAndInputSet target_obj = target_obj;
				for (int k = 0; k < this.onChangeValue.Count; k++)
				{
					this.onChangeValue[k](target_obj, val);
				}
			});
		}
		this.btn_list_.Clear();
		if (this.ResetBtn != null)
		{
			this.btn_list_.Add(this.ResetBtn);
			EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnReset));
			EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
			eventDelegate.parameters[0].value = "リセット";
			this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
		}
		if (this.CopyBtn != null)
		{
			this.btn_list_.Add(this.CopyBtn);
			EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnCopy));
			EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
			eventDelegate.parameters[0].value = "コピー";
			this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
		}
		if (this.PasteBtn != null)
		{
			this.btn_list_.Add(this.PasteBtn);
			EventDelegate.Add(this.btn_list_[this.btn_list_.Count - 1].onClick, new EventDelegate.Callback(this.OnPaste));
			EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
			eventDelegate.parameters[0].value = "ペースト";
			this.btn_list_[this.btn_list_.Count - 1].gameObject.GetComponent<UIEventTrigger>().onHoverOver.Add(eventDelegate);
		}
		for (int j = 0; j < this.btn_list_.Count; j++)
		{
			EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
			EventDelegate.Add(this.btn_list_[j].gameObject.GetComponent<UIEventTrigger>().onRelease, new EventDelegate.Callback(this.OnMouseHoverOut));
		}
		this.OnReset();
	}

	public void SetValue(string name, float value)
	{
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			if (!(this.SliderAndInput[i].Name != name))
			{
				this.SliderAndInput[i].Object.value = value;
				break;
			}
		}
	}

	public float GetValue(string name)
	{
		float result = 0f;
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			if (!(this.SliderAndInput[i].Name != name))
			{
				result = this.SliderAndInput[i].Object.value;
				break;
			}
		}
		return result;
	}

	public PhotoSliderAndInput GetSliderAndInput(string name)
	{
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			if (!(this.SliderAndInput[i].Name != name))
			{
				return this.SliderAndInput[i].Object;
			}
		}
		return null;
	}

	public void OnReset()
	{
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			this.SliderAndInput[i].Object.ResetValue();
		}
	}

	public void OnCopy()
	{
		StringWriter stringWriter = new StringWriter();
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			stringWriter.WriteLine(this.SliderAndInput[i].Object.value);
		}
		for (int j = 0; j < this.onCopyEvent.Count; j++)
		{
			this.onCopyEvent[j](stringWriter);
		}
		BasePhotoWindowManager.SetCopyData(this.copy_data_title, stringWriter.ToString());
	}

	public void OnPaste()
	{
		string copyData = BasePhotoWindowManager.GetCopyData(this.copy_data_title);
		if (string.IsNullOrEmpty(copyData))
		{
			return;
		}
		StringReader stringReader = new StringReader(copyData);
		for (int i = 0; i < this.SliderAndInput.Length; i++)
		{
			this.SliderAndInput[i].Object.value = float.Parse(stringReader.ReadLine());
		}
		for (int j = 0; j < this.onPasteEvent.Count; j++)
		{
			this.onPasteEvent[j](stringReader);
		}
	}

	public void OnMouseHoverIn(string text)
	{
		MouseExposition @object = MouseExposition.GetObject();
		@object.text = text;
	}

	public void OnMouseHoverOut()
	{
		MouseExposition @object = MouseExposition.GetObject();
		@object.text = string.Empty;
	}

	public new bool enabled
	{
		get
		{
			return this.SliderAndInput[0].Object.enabled;
		}
		set
		{
			for (int i = 0; i < this.SliderAndInput.Length; i++)
			{
				this.SliderAndInput[i].Object.enabled = value;
			}
			if (this.ResetBtn != null)
			{
				this.ResetBtn.isEnabled = value;
			}
			if (this.CopyBtn != null)
			{
				this.CopyBtn.isEnabled = value;
			}
			if (this.PasteBtn != null)
			{
				this.PasteBtn.isEnabled = value;
			}
		}
	}

	public bool visible
	{
		get
		{
			return base.gameObject.activeSelf;
		}
		set
		{
			base.gameObject.SetActive(value);
		}
	}

	public string copy_data_title
	{
		get
		{
			return this.CopyDataTitle;
		}
	}

	public WindowPartsInputSliderSet.SliderAndInputSet[] SliderAndInput;

	public UIButton ResetBtn;

	public UIButton CopyBtn;

	public UIButton PasteBtn;

	public string CopyDataTitle = "WindowPartsInputSliderSet";

	public List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>> onChangeValue = new List<Action<WindowPartsInputSliderSet.SliderAndInputSet, float>>();

	public List<Action<StringWriter>> onCopyEvent = new List<Action<StringWriter>>();

	public List<Action<StringReader>> onPasteEvent = new List<Action<StringReader>>();

	private List<UIButton> btn_list_ = new List<UIButton>();

	[Serializable]
	public class SliderAndInputSet
	{
		public string Name;

		public PhotoSliderAndInput Object;
	}
}
