示例#1
0
        /// <summary>
        /// (Event) Occurs when the "Canvas > Atlas Size..." menu item is clicked.
        /// </summary>
        private void CanvasAtlasSizeMenuItem_Click(object sender, EventArgs e)
        {
            var dialog = new ChangeAtlasSizeDialog();

            dialog.ChosenSize = RenderTarget.Image.Size;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                File.SetAtlasSize(dialog.ChosenSize);
                RefreshRenderTarget();
            }
        }
示例#2
0
        /// <summary>
        /// Creates a new atlas.
        /// </summary>
        public void CreateNew()
        {
            TaskDialogResult shouldSaveFirst = CheckDiscard();

            switch (shouldSaveFirst)
            {
            case TaskDialogResult.Yes:
                bool saveOccurred = Save(File.LastFileName);

                if (!saveOccurred)
                {
                    return;
                }

                break;

            case TaskDialogResult.Cancel:
                return;
            }

            // User should select a new atlas size
            //
            var  dialog       = new ChangeAtlasSizeDialog();
            Size newAtlasSize = Size.Empty;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                newAtlasSize = dialog.ChosenSize;
            }
            else if (File == null)
            {
                newAtlasSize = new Size(2048, 2048); // FIXME: Replace with constants
            }
            else
            {
                return;
            }

            // Store a reference to the old file
            //
            WorkingFile oldFile = File;

            // Create a new file in its place
            //
            File = new WorkingFile();

            File.SetAtlasSize(newAtlasSize);

            File.Invalidated += File_Invalidated;
            File.Saved       += File_Saved;

            // Update the form
            //
            NodeListBox.Items.Clear();
            RefreshRenderTarget();
            UpdateTitle();

            // Dispose the old file if needed
            //
            if (oldFile != null)
            {
                DisposeWorkingFile(ref oldFile);
            }
        }