Ejemplo n.º 1
0
        private void panDestination_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = e.Data.GetData(DataFormats.FileDrop) as string[];
            if (files != null && files.Length > 0 && File.Exists(files[0]))
            {
                using (Image source = Image.FromFile(files[0]))
                {
                    Bitmap bitmap = new Bitmap(source.Width, source.Height);
                    bitmap.SetResolution(source.HorizontalResolution, source.VerticalResolution);

                    using (Graphics graphics = Graphics.FromImage(bitmap))
                    {
                        graphics.Clear(Color.Transparent);
                        graphics.DrawImage(source, 0, 0);
                    }

                    pbxCanvas.Image = bitmap;
                }

                m_properties          = new TilesetProperties();
                m_properties.TileSize = 32;
                m_properties.Width    = pbxCanvas.Image.Width / m_properties.TileSize;
                m_properties.Height   = pbxCanvas.Image.Height / m_properties.TileSize;

                RefreshGUI();
            }
        }
Ejemplo n.º 2
0
 public FormNew(List <TilesetProperties> presets, TilesetProperties tp)
     : this(presets)
 {
     nudWidth.Value    = tp.Width;
     nudHeight.Value   = tp.Height;
     nudTileSize.Value = tp.TileSize;
 }
Ejemplo n.º 3
0
        private void cbxPreset_SelectedIndexChanged(object sender, EventArgs e)
        {
            TilesetProperties selected = cbxPreset.SelectedItem as TilesetProperties;

            if (selected != null)
            {
                nudWidth.Value    = selected.Width;
                nudHeight.Value   = selected.Height;
                nudTileSize.Value = selected.TileSize;
            }
        }
Ejemplo n.º 4
0
        private void OpenSettings()
        {
            try
            {
                if (!Directory.Exists(this.SettingsPath))
                {
                    Directory.CreateDirectory(this.SettingsPath);
                }

                ConfigGroup settings = ConfigGroup.Create("Settings");
                if (File.Exists(this.SettingsFilePath))
                {
                    settings = ConfigGroup.Load(this.SettingsFilePath, ConfigFormat.Xml);
                }

                Screen screen = Screen.FromHandle(this.Handle);

                ConfigGroup main = settings.SetGroup("Main");
                this.Width  = main.ReadInt32("Width", this.Width);
                this.Height = main.ReadInt32("Height", this.Height);
                this.Left   = main.ReadInt32("Left", screen.WorkingArea.Width / 2 - this.Width / 2);
                this.Top    = main.ReadInt32("Top", screen.WorkingArea.Height / 2 - this.Height / 2);

                ConfigGroup last = settings.SetGroup("Last");
                m_lastTileSize      = last.ReadInt32("TileSize", 32);
                m_lastTileSetWidth  = last.ReadInt32("TileSetWidth", 10);
                m_lastTileSetHeight = last.ReadInt32("TileSetHeight", 10);
                m_lastPath          = last.ReadString("Path", null);
                m_lastDrawTileSize  = last.ReadInt32("DrawTileSize", 32);

                m_presets = new List <TilesetProperties>();

                ConfigGroup presets = settings.SetGroup("Presets");
                foreach (ConfigGroup preset in presets.Groups)
                {
                    TilesetProperties tp = new TilesetProperties();
                    tp.Width    = preset.ReadInt32("Width", 10);
                    tp.Height   = preset.ReadInt32("Height", 10);
                    tp.TileSize = preset.ReadInt32("TileSize", 32);
                    m_presets.Add(tp);
                }

                this.splitContainer1.SplitterDistance = main.ReadInt32("Splitter", splitContainer1.SplitterDistance);

                ConfigGroup misc = settings.SetGroup("Misc");
                tbbTargetRaster.Checked = misc.ReadBool("Raster", true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Die Einstellungen konnten nicht geöffnet werden.\n" + ex.Message, "Fehler",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void mniSavePreset_Click(object sender, EventArgs e)
        {
            TilesetProperties tp = new TilesetProperties();

            tp.Width    = (int)nudWidth.Value;
            tp.Height   = (int)nudHeight.Value;
            tp.TileSize = (int)nudTileSize.Value;

            m_presets.Add(tp);

            cbxPreset.Items.Add(tp);
            cbxPreset.SelectedIndex = (cbxPreset.Items.Count - 1);
        }
Ejemplo n.º 6
0
        private void tbbTargetResize_Click(object sender, EventArgs e)
        {
            using (FormNew dialog = new FormNew(m_presets, m_properties))
            {
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    TilesetProperties tp = new TilesetProperties();
                    tp.Width    = dialog.TileSetWidth;
                    tp.Height   = dialog.TileSetHeight;
                    tp.TileSize = dialog.TileSize;

                    ChangeSize(tp);
                }
            }
        }
Ejemplo n.º 7
0
 static TilesetProperties()
 {
     Predefined = new TilesetProperties[]
     {
         new TilesetProperties()
         {
             Width = 10, Height = 10, TileSize = 32
         },
         new TilesetProperties()
         {
             Width = 12, Height = 24, TileSize = 32
         },
         new TilesetProperties()
         {
             Width = 32, Height = 24, TileSize = 32
         }
     };
 }
Ejemplo n.º 8
0
        private void ChangeSize(TilesetProperties tp)
        {
            Bitmap bitmap = new Bitmap(tp.Width * tp.TileSize, tp.Height * tp.TileSize);

            bitmap.SetResolution(pbxCanvas.Image.HorizontalResolution, pbxCanvas.Image.VerticalResolution);

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphics.Clear(Color.Transparent);
                graphics.DrawImage(pbxCanvas.Image, 0, 0);
            }

            pbxCanvas.Image   = bitmap;
            this.m_properties = tp;

            tileset.TileSize = new Size(m_properties.TileSize, m_properties.TileSize);

            pbxCanvas.Refresh();
        }
Ejemplo n.º 9
0
        private void tbbTargetOpen_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Title           = "Tileset öffnen";
                dialog.Filter          = "Unterstüzte Formate|*.bmp;*.png;*.jpg";
                dialog.CheckFileExists = true;
                dialog.CheckPathExists = true;

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        using (Image source = Image.FromFile(dialog.FileName))
                        {
                            Bitmap bitmap = new Bitmap(source.Width, source.Height);
                            bitmap.SetResolution(source.HorizontalResolution, source.VerticalResolution);

                            using (Graphics graphics = Graphics.FromImage(bitmap))
                            {
                                graphics.Clear(Color.Transparent);
                                graphics.DrawImage(source, 0, 0);
                            }

                            pbxCanvas.Image = bitmap;
                        }

                        m_properties          = new TilesetProperties();
                        m_properties.TileSize = 32;
                        m_properties.Width    = pbxCanvas.Image.Width / m_properties.TileSize;
                        m_properties.Height   = pbxCanvas.Image.Height / m_properties.TileSize;

                        RefreshGUI();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Fehler beim öffnen der Date.\n" + ex.Message, "Fehler",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void NewTileset(TilesetProperties tp)
        {
            m_properties = tp;

            Bitmap bitmap = new Bitmap(
                m_properties.Width * m_properties.TileSize,
                m_properties.Height * m_properties.TileSize,
                PixelFormat.Format32bppArgb);

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                graphics.Clear(Color.Transparent);
            }

            pbxCanvas.Image = bitmap;

            tileset.TileSize = new Size(m_properties.TileSize, m_properties.TileSize);

            RefreshGUI();
        }
Ejemplo n.º 11
0
        private void tbbTargetNew_Click(object sender, EventArgs e)
        {
            using (FormNew dialog = new FormNew(m_presets))
            {
                dialog.TileSetWidth  = m_lastTileSetWidth;
                dialog.TileSetHeight = m_lastTileSetHeight;
                dialog.TileSize      = m_lastTileSize;

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    m_lastTileSetWidth  = dialog.TileSetWidth;
                    m_lastTileSetHeight = dialog.TileSetHeight;
                    m_lastTileSize      = dialog.TileSize;
                    m_lastDrawTileSize  = dialog.TileSize;

                    TilesetProperties tp = new TilesetProperties();
                    tp.Width    = dialog.TileSetWidth;
                    tp.Height   = dialog.TileSetHeight;
                    tp.TileSize = dialog.TileSize;

                    NewTileset(tp);
                }
            }
        }