示例#1
0
        /// <summary>
        ///     Handles the Click event of the newMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void newMenuItem_Click(object sender, EventArgs e)
        {
            if (!PromptSave())
            {
                return;
            }

            if (_selectTemplateDialog.ShowDialog(this) == DialogResult.OK)
            {
                Template template = _selectTemplateDialog.Template;
                if (template == null)
                {
                    return;
                }

                ShapeSet shapes = template.CreateShapes();

                Tiling tiling = template.CreateTiling(
                    template.Tilings.Values.First(),
                    shapes,
                    CreateDefaultStyleManager(shapes));

                OpenTiling(tiling);

                IsDirty      = true;
                DocumentPath = null;
            }
        }
示例#2
0
        /// <summary>
        ///     Creates the tiling controller.
        /// </summary>
        /// <param name="tiling">The tiling.</param>
        /// <returns></returns>
        private TilingController CreateTilingController([NotNull] Tiling tiling)
        {
            Debug.Assert(tiling != null, "tiling != null");

            TilingController tc = new TilingController(tiling, this);

            tc.EditLine.OptionsChanged += TilingController_EditLineTool_OptionsChanged;
            tc.EditLine.ChangeLineOption.ValueChanged += v => _changeLineTypeCmb.SelectedItem = v;
            _changeLineTypeCmb.SelectedItem            = tc.EditLine.ChangeLineOption.Value;

            tc.StyleManagerChanged += (sender, args) => IsDirty = true;
            tc.CurrentToolChanged  += controller_CurrentToolChanged;
            _panTool        = new PanTool(tc, this);
            _selectTileTool = new SelectTileTool(tc);

            _toolBtns.Add(_panTool, _panToolBtn);

            UpdateTools();

            return(tc);
        }
示例#3
0
        /// <summary>
        ///     Handles the Click event of the openMenuItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void openMenuItem_Click(object sender, EventArgs e)
        {
            if (!PromptSave())
            {
                return;
            }

            if (_openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string documentPath = _openFileDialog.FileName;
                Debug.Assert(documentPath != null, "documentPath != null");

                try
                {
                    IImage thumbnail;
                    Tiling tiling = FileStorage.LoadTiling(documentPath, out thumbnail);

                    OpenTiling(tiling);
                    DocumentPath = documentPath;
                }
                catch (InvalidDataException ide)
                {
                    MessageBox.Show(
                        this,
                        "Error loading tiling",
                        $"A problem was found with the file '{Path.GetFileName(documentPath)}', could not load the tiling.\r\n\r\n{ide.Message}",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(
                        this,
                        "Error loading tiling",
                        $"A error occured while loading the file '{Path.GetFileName(documentPath)}'.\r\n\r\n{ex.Message}",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
        }
示例#4
0
        /// <summary>
        ///     Opens the tiling given for editing.
        /// </summary>
        /// <param name="tiling">The tiling.</param>
        private void OpenTiling([NotNull] Tiling tiling)
        {
            Debug.Assert(tiling != null, "tiling != null");

            lock (_lock)
            {
                try
                {
                    // Dont call the ViewBoundsChanged event handler while changing the tiling
                    _layoutSuspended = true;

                    // Reset view
                    _translate = _invTranslate = Matrix3x2.Identity;
                    _zoom      = 100f;
                    UpdateScale();

                    if (_tilingController == null)
                    {
                        _tilingController = CreateTilingController(tiling);
                    }
                    else
                    {
                        _tilingController.SetTiling(tiling);
                    }

                    ActiveController = _tilingController;

                    UpdateStyleManager(tiling.StyleManager);

                    IsDirty = false;
                }
                finally
                {
                    _layoutSuspended = false;
                }
            }
        }