<commit_before>﻿using System;

namespace Effekseer.GUI.Dialog
{
	class SaveOnDisposing : IRemovableControl
    {
		string title = string.Empty;
        string message = string.Empty;
        string id = "###saveOnDisposing";

        bool opened = true;

        bool isFirstUpdate = true;
              
		public bool ShouldBeRemoved { get; private set; } = false;

		Action disposed = null;

		public SaveOnDisposing(Action disposed)
		{
			title = "Warning";
			var format = Resources.GetString("ConfirmSaveChanged");
			message = string.Format(format, System.IO.Path.GetFileName(Core.FullPath));

			this.disposed = disposed;
			Manager.AddControl(this);
		}

		public void Update()
		{
			if (isFirstUpdate)
            {
                Manager.NativeManager.OpenPopup(id);
                isFirstUpdate = false;
            }

            if (Manager.NativeManager.BeginPopupModal(title + id, ref opened, swig.WindowFlags.AlwaysAutoResize))
            {
                Manager.NativeManager.Text(message);

				Manager.NativeManager.Separator();

                if (Manager.NativeManager.Button("Yes", 100))
				{
					if(Commands.Overwrite())
					{<commit_msg>Fixed a bug shows multiple window when clicking a close button<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Effekseer.GUI.Dialog
{
	class SaveOnDisposing : IRemovableControl
    {
		string title = string.Empty;
        string message = string.Empty;
        string id = "###saveOnDisposing";

        bool opened = true;

        bool isFirstUpdate = true;
              
		public bool ShouldBeRemoved { get; private set; } = false;

		Action disposed = null;

		public SaveOnDisposing(Action disposed)
		{
			title = "Warning";
			var format = Resources.GetString("ConfirmSaveChanged");
			message = string.Format(format, System.IO.Path.GetFileName(Core.FullPath));

			this.disposed = disposed;

			// if already show window, don't add control
			if(Manager.Controls.Internal.Any(_=>_ is SaveOnDisposing))
			{
				return;
			}

			Manager.AddControl(this);
		}

		public void Update()
		{
			if (isFirstUpdate)
            {
                Manager.NativeManager.OpenPopup(id);
                isFirstUpdate = false;
            }

            if (Manager.NativeManager.BeginPopupModal(title + id, ref opened, swig.WindowFlags.AlwaysAutoResize))
            {
                Manager.NativeManager.Text(message);

				Manager.NativeManager.Separator();

                if (Manager.NativeManager.Button("Yes", 100))
				{
					if(Commands.Overwrite())
					{
{'fraction_non_alphanumeric': 0.10193990110308102, 'fraction_numerical': 0.002282236591860023, 'mean_word_length': 2.525469168900804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1365619', 'n_tokens_mistral': 841, 'n_tokens_neox': 734, 'n_words': 161}