Beispiel #1
0
        private void ExecuteRedo(object sender, ExecutedRoutedEventArgs e)
        {
            while (RedoHistory.Count > MaxItemsInHistory)
            {
                RedoHistory.RemoveAt(0);
            }

            if (RedoHistory.Count == 0)
            {
                return;
            }

            try
            {
                UndoHistory.Add(LayeredImage.SelectedBitmapLayer.Source);
                Bitmap bitmap = RedoHistory[RedoHistory.Count - 1];
                LayeredImage.SelectedBitmapLayer.UpdateSource(bitmap);
                RedoHistory.RemoveAt(RedoHistory.Count - 1);
                LayeredImage.Draw();
            }
            catch (ArgumentOutOfRangeException)
            {
                return;
            }
        }
Beispiel #2
0
        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            SelectItemTypeWindow itemTypeWindow = new SelectItemTypeWindow();

            itemTypeWindow.ShowDialog();
            ItemType itemType = itemTypeWindow.ItemType;

            Bitmap bitmap;

            if (IsArmorLike(itemType))
            {
                bitmap = new Bitmap(40, 1120);
            }
            else
            {
                CreateNewImageWindow imageWindow = new CreateNewImageWindow();
                imageWindow.ShowDialog();
                bitmap = imageWindow.CreatedBitmap;
            }

            FileDialog fileDialog = new FileDialog(FileDialog.DialogOptions.Save);

            if (fileDialog.SavePath == null)
            {
                return;
            }

            LayeredImage.Push(bitmap, itemType, fileDialog.SavePath, true);
            InitiateLayersStackPanel();
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Button     btn       = (Button)sender;
            StackPanel container = (StackPanel)VisualTreeHelper.GetParent(btn);

            ButtonJustDeleted = btn;
            int index = LayersStackPanel.Items.IndexOf(container);

            Console.WriteLine("LayersStackPanelHandler (1): btn " + btn.Name);

            if (index + 1 == LayeredImage.SelectedIndex)
            {
                LayeredImage.SelectedIndex = -1;
            }

            LayeredImage.Remove(index);
            InitiateLayersStackPanel();
        }
Beispiel #4
0
        private void UploadButton_Click(object sender, RoutedEventArgs e)
        {
            FileDialog dialog = new FileDialog(FileDialog.DialogOptions.Open);

            if (dialog.OpenPaths == null)
            {
                return;
            }

            foreach (string path in dialog.OpenPaths)
            {
                LayeredImage.Push(path);
            }

            InitiateLayersStackPanel();
            LayersStackPanel.SelectedIndex = LayersStackPanel.Items.Count - 1;
            LayeredImage.Draw();
        }
        private void LayersStackPanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = LayersStackPanel.SelectedIndex;

            LayeredImage.SelectedIndex = index;

            for (int i = 0; i < LayersStackPanel.Items.Count; i++)
            {
                ((StackPanel)LayersStackPanel.Items[i]).Background = new SolidColorBrush(Colors.Transparent);
            }

            try
            {
                ((StackPanel)LayersStackPanel.Items[index]).Background = new SolidColorBrush(Colors.LightSlateGray);
            }
            catch (ArgumentOutOfRangeException)
            {
            }

            LayeredImage.Draw();
        }
Beispiel #6
0
        /// <summary>
        /// Run when the user draws on the ImageControl.
        /// </summary>
        private void UserDrawsOnBitmap()
        {
            if (!IsDrawing)
            {
                return;
            }

            try
            {
                Bitmap bitmap = new Bitmap(LayeredImage.SelectedBitmapLayer.Source);

                System.Drawing.Point drawingPoint = GetMouseLocation();

                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
                    if (IsPainting)
                    {
                        g.FillRectangle(SolidBrushBrush, drawingPoint.X, drawingPoint.Y, BrushSize, BrushSize);
                    }
                    else
                    {
                        g.FillRectangle(TransparentBrush, drawingPoint.X, drawingPoint.Y, BrushSize, BrushSize);
                    }
                }

                LayeredImage.SelectedBitmapLayer.UpdateSource(bitmap);

                LayeredImage.Draw();
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Please select a layer.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #7
0
 public void InitiateImage()
 {
     LayeredImage = new LayeredImage(Properties.Resources.player10, ImageControl, NextPaneButton, PrevPaneButton, 40, 56);
 }