Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        private void ImageOptions_Checked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = (RadioButton)sender;

            try
            {
                switch (radioButton.Name)
                {
                case "ImageOptions_RadioButtonArmor":
                    LayeredImage.Mode = LayeredImage.DrawingMode.Armor;
                    break;

                case "ImageOptions_RadioButtonItem":
                    LayeredImage.Mode = LayeredImage.DrawingMode.Item;
                    break;
                }

                LayeredImage.Draw();
            }
            catch (NullReferenceException)
            {
            }
        }