コード例 #1
0
ファイル: formMain.cs プロジェクト: polytronicgr/sketchit
        public EditorForm NewSourceFile(bool isOpeningFile)
        {
            EditorForm form = new EditorForm();

            form.MdiParent       = this;
            form.FormBorderStyle = FormBorderStyle.None;
            form.ControlBox      = false;
            form.Show();
            form.WindowState  = FormWindowState.Maximized;
            form.TextChanged += MdiChildTextChanged;

            if (!isOpeningFile)
            {
                NewFileCounter++;
                form.Text = "New Sketch " + NewFileCounter;
            }

            tabWindows.TabButtons.Add(new TabButton()
            {
                Text = form.Text,
                Tag  = form
            });

            form.Activate();

            return(form);
        }
コード例 #2
0
        public void AddExistingFile()
        {
            using (OpenFileDialog d = new OpenFileDialog())
            {
                d.Filter = "C# File|*.cs|Sketchbook Project|*.sbp";
                d.Title  = "Open File";

                if (d.ShowDialog() == DialogResult.OK)
                {
                    EditorForm form = GetActiveWindow() as EditorForm;

                    if (form == null || form.Editor.Modified || !string.IsNullOrEmpty(form.EditorText))
                    {
                        form = NewSourceFile(true);
                    }

                    using (TextReader reader = new StreamReader(d.OpenFile()))
                    {
                        form.FileName    = d.FileName;
                        form.Editor.Text = reader.ReadToEnd();
                        form.Editor.SetSavePoint();
                        reader.Close();
                    }

                    form.Activate();
                }
            }
        }
コード例 #3
0
ファイル: formMain.cs プロジェクト: sketchit/sketchit
        private void OpenProject()
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Filter = "SketchIt Project|*.sip";

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                NewProject(false);
                Project project = null;

                using (Status.Set(string.Format("Loading project '{0}...'", dialog.FileName)))
                {
                    using (TextReader reader = new StreamReader(dialog.FileName))
                    {
                        string json = reader.ReadToEnd();
                        project        = JsonConvert.DeserializeObject(json, typeof(Project)) as Project;
                        _projectFile   = dialog.FileName;
                        _resourceFiles = new List <ProjectFileReference>();
                    }

                    Directory.SetCurrentDirectory(new FileInfo(_projectFile).DirectoryName);

                    foreach (ProjectFileReference reference in project.Files)
                    {
                        EditorForm form = NewSourceFile(true);

                        using (TextReader reader = new StreamReader(reference.Name))
                        {
                            form.FileName    = new FileInfo(reference.Name).FullName;
                            form.Editor.Text = reader.ReadToEnd();
                            form.Editor.SetSavePoint();
                            reader.Close();
                        }
                    }

                    if (project.Resources != null)
                    {
                        _resourceFiles = new List <ProjectFileReference>(project.Resources);
                    }

                    Text = "SketchIt - " + project.Name;
                    Directory.SetCurrentDirectory(System.Windows.Forms.Application.StartupPath);

                    ResetPreviewTimer(false);
                }
            }
        }
コード例 #4
0
ファイル: formMain.cs プロジェクト: polytronicgr/sketchit
        internal void CodeChanged(EditorForm editor)
        {
            if (_previewTimer != null)
            {
                _previewTimer.Stop();
            }

            if (_previewTimer != null)
            {
                _previewTimer.Start();
            }

            Program.Parser.Parse();
        }
コード例 #5
0
ファイル: formMain.cs プロジェクト: sketchit/sketchit
 internal void CodeChanged(EditorForm editor)
 {
     _previewTimer?.Stop();
     _previewTimer?.Start();
 }