private void LinedTextBox_UC_AutosaveTimerStart(object sender, LinedTBEventArgs e)
        {
            if (!autosaveTimerRunning)
            {
                autosaveTimerRunning = true;
            }

            var now = DateTime.Now;

            new Thread(() =>
            {
                for (int i = 0; i < Settings.Instance.AutosaveTime / 1000; i++)
                {
                    if (cancelAutoSave)
                    {
                        cancelAutoSave       = false;
                        autosaveTimerRunning = false;
                        return;
                    }

                    Thread.Sleep(1000);
                }

                if (Text == lastSavedText)
                {
                    autosaveTimerRunning = false;
                    cancelAutoSave       = false;
                    return;
                }

                var args = new LinedTBEventArgs();
                OnAutosaveTimerFinished(args);
            }).Start();
        }
        public void OnSaveAllOpenedFiles(LinedTBEventArgs e)
        {
            EventHandler <LinedTBEventArgs> handler = SaveAllOpenedFiles;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        public void OnSaveFile(LinedTBEventArgs e)
        {
            EventHandler <LinedTBEventArgs> handler = SaveFile;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        public void OnAutosaveTimerFinished(LinedTBEventArgs e)
        {
            EventHandler <LinedTBEventArgs> handler = AutosaveTimerFinished;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private void TextEditor_TextChanged(object sender, EventArgs e)
        {
            Text = TextEditor.Text;

            if (autosaveTimerRunning || IsAnalyzerResult) //Always keep autosave section at end of method
            {
                return;
            }

            if (fileJustOpened)
            {
                fileJustOpened = false;
                return;
            }

            autosaveTimerRunning = true;
            var args = new LinedTBEventArgs();

            args.TextBeforeSave = TextEditor.Text;
            OnAutosaveTimerStart(args);
        }
        private void LinedTextBox_UC_SaveFile(object sender, LinedTBEventArgs e)
        {
            if (manualSaveInProgress)
            {
                return;
            }

            if (autosaveTimerRunning)
            {
                cancelAutoSave = true;
            }

            if (Text == lastSavedText)
            {
                cancelAutoSave       = false;
                autosaveTimerRunning = false;
                return;
            }

            manualSaveInProgress = true;

            if (IsFromJet)
            {
                string projPath = ProjectData.Instance.WBP_Path;
                var    proj     = new Zip(projPath);

                string pathInZip = "/Jet_Mod/" + FilePath;

                if (proj.Archive.ContainsEntry(pathInZip))
                {
                    proj.Archive.RemoveEntry(pathInZip);
                }

                proj.Archive.AddEntry(pathInZip, Text);
                proj.Archive.Save();
            }

            lastSavedText        = Text;
            manualSaveInProgress = false;
        }
 private void LinedTextBox_UC_SaveAllOpenedFiles(object sender, LinedTBEventArgs e)
 {
     OnSaveFile(new LinedTBEventArgs());
 }
 private void LinedTextBox_UC_AutosaveTimerFinished(object sender, LinedTBEventArgs e)
 {
     autosaveTimerRunning = false;
     cancelAutoSave       = false;
     OnSaveFile(new LinedTBEventArgs());
 }