Code Monkey home page Code Monkey logo

richcanvas's Introduction

🚧 Work is in progress for v3.0.0. A lot of changes and stuff coming out, also most of, if not all open issues will be addressed.
Thank you for your patience!πŸ™

RichCanvas

NuGet NuGet License

WPF Control library - Infinite canvas with panning, zooming, scrolling and other customizable functions, designed for MVVM.

πŸ“₯ Installation

Use the nuget package manager to install RichCanvas.

Install-Package RichCanvas

⭐ Features

  • Designed for MVVM
  • No dependencies other than WPF
  • Optimized for interactions with hundreds of elements
  • Zoom, Pan, Scroll and other out of the box functionalities
  • Select and Move elements
  • Lots of configurable dependency properties
  • Ready to draw

πŸ’» Demo

Example of an app that uses RichCanvas:

A design tool where you can draw different things like: images, text, lines, rectangles, bezier with basic features.

It is a simple application just to show how you can interact with the library.

DEMO

πŸ“ Documentation

API Reference can be found here.

Wiki

License

MIT

❀ Contributing

Feel free to help with documentation, bug reports, pull requests or new/missing features ideas.

richcanvas's People

Contributors

mircea21s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

richcanvas's Issues

Setting the panning key is not working

When setting the panning key, you can't pan the canvas with the provided key. Panning is only possible when using the panning key and the space bar at the same time. The reason of this bug is at PanningGrid.cs:334.

You should remove Keyboard.IsKeyDown(Key.Space). You could add Keyboard.IsKeyDown(_parent.PanningKey) as replacement, but _parent.IsPanning already checks if the key is pressed.

Stretch Image

Hello,
I have to stretch Image instead of mantein aspect ratio. How I can do this in RichCanvas?
Thank you very much
Best regards

null reference exception when left-clicking

Hi, I've got your code mostly working, but I think I'm missing something. I'm trying to do something very simple - just want to use the zooming and panning functionality right now, and eventually drawing boxes on the images for cropping purposes.

We already have images loading and appearing, using the regular System Image control and setting the image's Uri in the view model. Here's how I have the xaml right now:

    <rc:RichItemsControl ItemsSource="{Binding RichCanvasItems}">
        <Image Source="{Binding ImageSource.Uri}"/>
    </rc:RichItemsControl>

And in the view model:

public ObservableCollection<IImageSource> RichCanvasItems { get; set; }

OnImageLoad(Uri uri) {
            if (RichCanvasItems == null) {
                RichCanvasItems = new ObservableCollection<IImageSource>();
            }
            RichCanvasItems.Clear();

            ImageSource.Uri = uri;
            RichCanvasItems.Add(ImageSource);
}

ImageSource's type is our own interface and just contains the uri for the image. This code actually all works, and the image is loaded and appears. I can zoom and pan it by holding control or space and the left mouse button. In fact I don't even need the ObservableCollection in that code above, it still works the same.

The problem is when I just left click on the image or the empty area around it. The program crashes with a null reference in RichCanvas.dll, so I can't quite see exactly what's going wrong. My guess is it's trying to select something or maybe draw the image even though it's already there? Thank you for any help.

The image automatically fits in the middle of the canvas

Hi,
I want to realize that the picture automatically adapts to the canvas, so that the picture is in the middle of the canvas, is there a way to get the width and height of the RichItemsControl or other methods to achieve this function?
whether I can do it with an extension method that changes coordinates similar to what ShouldBringIntoView does (as the MakeVisible method does)
Trouble you again,Thank you so much.
Best Wishes!

Crash in SelectBySelectionRectangle

Hi,

I added your RichItemsControl version 2.3.0 from NuGet to my .NET6 WFP project.

<richCanvas:RichItemsControl Grid.Column="0" />

Everything looks fine so far.

If I run my program and do a mouse selection, an exception is thrown in RichItemsControl::SelectBySelectionRectangle() because the "SelectedItems" collection is "null" and you directly call ".get_Count()" on it, or at least this is what my debugger tells me.

First question: Could you please prevent the exception.
Second question: Is there a way to disable selection at all?

Thanks in advance.

Best regards,
Marcel

Improving AutoPanning

Currently, with AutoPanning, when performing a "selection" operation, the mouse must be moved outside of the "RichItemsControl" in order to activate AutoPanning. This can potentially result in situations where, when the window is in full-screen mode and the "RichItemsControl" is at the window's edge, there is no space for the mouse to move further outward, preventing AutoPanning from occurring.

Therefore, it is recommended to optimize the triggering mechanism for AutoPanning so that it doesn't require moving outside of the "RichItemsControl." Instead, it should be activated when the mouse is near the edge within the "RichItemsControl."

Translated by Chat GPT.Hope it hasn't been translated incorrectly.

Can not compile

Please check the file.

  <ItemGroup>
    <None Include="..\..\..\..\Users\Mircea\OneDrive\Desktop\logoRichCanvas.png">
      <Pack>True</Pack>
      <PackagePath></PackagePath>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="..\.editorconfig" Link=".editorconfig" />
  </ItemGroup>

Disable scroll to negative direction

How can I disable scroll in negative directions? In other case how can I limit scroll only in our maximum width and Height setting in RichCanvas?
Thank you.

Image as background of canvas

Hello,

I did not found it anywhere, but it is possible to add an image as the background and not as an ImageVisual?

Thanks for reply!

ResizeAdorner not visible on Image

Hi,
using Demo, ResizeAdorner is not visible on Image after selecting it.
Can you check it? Or can you explain how to activate it on Image?

Thank you.

Line x2-y2

Hello,

I want to find x2-y2 position of line as point and with left + width and top + height couldn't get the correct x2-y2 values. Any ideas to find that?

The names 'RichItemsControl' and 'RichItemContainer' seem to be reversed.

It seems that the meanings of the names 'RichItemsControl' and 'RichItemContainer' have been reversed.
Containers are like boxes that hold and organize stuff, such as Grid or StackPanel. Controls are the things you can interact with, such as Button or TextBox.
By the way, I'm just starting to learn WPF, so this might be a wrong suggestion

The lines have uneven thickness

Maybe due to the boundary constraints of the "RichItemContainer", some of the edges of the lines get clipped, which makes it look a bit weird. Is there an easy fix for this?
RichCanvas Issue3
RichCanvas Issue15

Moving items does not work if there is more than one RichItemsControl

Hello, I'd like to report a bug. It seems that when the running app has more than one RichCanvas, only the newest one works as intended.

To demonstrate, I modified the RichCanvasDemo application to have two different canvases. The bottom canvas works as expected, but the top canvas doesn't allow elements to be clicked on, dragged, resized, etc.

image

In case it helps at all, here's what Snoop says the order of events are when attempting to click on the rectangle. (left is the not working canvas, right is the working one) It seems that MouseDown never gets fired on the rectangle.

image

Any idea why this might be happening?

ItemContainer isn't moving and border is not showing

Hello! I tried placing an Itemcontainer inside the richitemscontrol and when I try using drag and drop the item isn't moving.
Here's my code:
<richCanvas:RichItemsControl EnableGrid="True" GridSpacing="5" x:Name="TestCanvas" Scale="1" EnableSnapping="True"> <richCanvas:RichItemContainer Width="65" Height="65" Foreground="Red" BorderBrush="Red" IsDraggable="True" IsSelectable="True" > <TextBlock>Hello</TextBlock> </richCanvas:RichItemContainer> </richCanvas:RichItemsControl>

Can't draw rectangle on picture for the first time.

Hi,
Today is our second communication, Trouble you again. haha~
When I add an image to the canvas, and set IsSelectable = false and IsDraggable = false , and then want to be able to draw a rectangle on the image, the first time I always fail to draw a rectangle, after the first time it's normal. How can I fix this, is there a problem between the priority of moving the picture and drawing the rectangle?
Best Wishes!

ScrollViewer scrollbar visibility not applied

In our use case, we'd like to hide the scrollbars of the ScrollViewer in the RichItemsControl. We are using:
ScrollViewer.VerticalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollBarVisibility="Hidden" properties.

These unfortunately do nothing yet. Is there anything we're missing?

Move the mouse to draw

Hello, I am using Rich Canvas. I have one question.
Is there a function to draw lines or Rectangle by moving the mouse? Or do I have to implement it myself?

Problem with arrow keys

Hi,
with an Image selected, if I press down, left, right or up keys, application freeze.

Can you check it?

Thank you.

The graphic being drawn is not displayed sometimes.

When triggered by the DrawingEnded event and executing the DrawEndedCommand to repeat the drawing, a strange phenomenon occurs:

During the drawing process, under normal circumstances, as you move the mouse, a graphic that changes in size with the mouse's position is displayed.
However, in some cases, while moving the mouse, the graphic being drawn is not displayed, and it only appears after releasing the mouse to indicate that the drawing is complete.

For instance, if I click the button "Draw xx" three times before starting to draw, it will not display every third time. In other words, it won't display on the 4th, 8th, 12th... drawing
If I start drawing after the first click, it will not display every other time. In other words, it won't display on the 2nd, 4th, 6th, 8th... drawing.

This phenomenon occurs in both the RichCanvasDemo and my own project.
Why does this phenomenon occur, and are there any solutions?

20231019_133918.mp4

How to draw multiple rectangles in a row?

Hi, Is it possible to click the draw rectangle button once and then draw multiple rectangles in a row?
I tried to execute OnDrawCommand after the DrawEnded event, but it would result in not being able to select the drawn rectangle and occasionally there would be a drag instead of a draw rectangle.
Best Wishes!

ReSize Bug

When I use scaling, changing the size causes a drop point error.

Code: RichCanvasDemo

bandicam.2024-06-17.18-54-44-010.mp4

Problem with snapping without EnableSnapping

Thanks for creating awesome library
I'm not sure if the title correct but I don't know how to describe this
I have a RichCanvas with default properties, but the dragging beavior is not what I expected (as I experienced in demo App)
The Container and Drag Selection Rectangle only show their position snap to 1 pixel, even I change GridSpacing to bigger or smaller number, the update tick remain the same as 1 unit
<richcanvas:RichItemsControl EnableGrid="true" GridSpacing="1" MaxScale="100" MinScale="0.1" ></richcanvas:RichItemsControl>

Recording.2023-05-22.165459.mp4

The only thing that I changed is AttachedAdorner and it's long ago( I want to remove Resize adorner thumb for some reason I didn't even remember πŸ˜… )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.