Esempio n. 1
0
 private void OnDialogOk(object sender, EventArgs eventArgs)
 {
     Command command = new LayerOffsetCommand(m_layer,
         new Location((int)m_nudOffsetHorizontal.Value, (int)m_nudOffsetVertical.Value),
         m_chkWrapHorizontal.Checked, m_chkWrapVertical.Checked);
     CommandHistory.Instance.Do(command);
 }
        public override void Do()
        {
            m_layer.Id          = m_newId;
            m_layer.Description = m_newDescription;
            m_layer.LayerSize   = m_newLayerSize;
            m_layer.TileSize    = m_newTileSize;
            m_layer.Visible     = m_newVisibility;
            m_layer.Properties.Clear();
            m_layer.Properties.CopyFrom(m_newProperties);

            if (m_layerAlignment != Alignment.TopLeft)
            {
                Location offset = Location.Origin;
                switch (m_layerAlignment)
                {
                case Alignment.Top:
                    offset.X = (m_newLayerSize.Width - m_oldLayerSize.Width) / 2;
                    break;

                case Alignment.TopRight:
                    offset.X = m_newLayerSize.Width - m_oldLayerSize.Width;
                    break;

                case Alignment.Left:
                    offset.Y = (m_newLayerSize.Height - m_oldLayerSize.Height) / 2;
                    break;

                case Alignment.Centre:
                    offset.X = (m_newLayerSize.Width - m_oldLayerSize.Width) / 2;
                    offset.Y = (m_newLayerSize.Height - m_oldLayerSize.Height) / 2;
                    break;

                case Alignment.Right:
                    offset.X = m_newLayerSize.Width - m_oldLayerSize.Width;
                    offset.Y = (m_newLayerSize.Height - m_oldLayerSize.Height) / 2;
                    break;

                case Alignment.BottomLeft:
                    offset.Y = m_newLayerSize.Height - m_oldLayerSize.Height;
                    break;

                case Alignment.Bottom:
                    offset.X = (m_newLayerSize.Width - m_oldLayerSize.Width) / 2;
                    offset.Y = m_newLayerSize.Height - m_oldLayerSize.Height;
                    break;

                case Alignment.BottomRight:
                    offset.X = m_newLayerSize.Width - m_oldLayerSize.Width;
                    offset.Y = m_newLayerSize.Height - m_oldLayerSize.Height;
                    break;
                }
                m_layerOffsetCommand = new LayerOffsetCommand(m_layer, offset, false, false);
                m_layerOffsetCommand.Do();
            }

            m_description = "Change properties for layer \"" + m_newId + "\"";
        }