Giter Site home page Giter Site logo

oaz / avaloniagraphcontrol Goto Github PK

View Code? Open in Web Editor NEW
237.0 237.0 19.0 620 KB

A graph layout panel for AvaloniaUI

Home Page: https://oaz.github.io/AvaloniaGraphControl/

License: Other

C# 92.61% Shell 0.61% CSS 3.35% HTML 2.34% JavaScript 1.09%

avaloniagraphcontrol's People

Contributors

kibnet avatar oaz avatar roberthusak avatar rstm-sf avatar wieslawsoltes 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  avatar

avaloniagraphcontrol's Issues

Proposal to add ability to use a different brush for some edges

Hi.

I want to be able to color some edges in my graph differently. I've found that it's possible to change the color of all edges using Styles, but I haven't figured out how to color an edge separately. Please enlighten me, if you have the solution.

If not, I propose that we expand the Edge class to take a brush color and use that in the Connection class for setting the Brush property. I can submit a pull request if you think it's a good idea. Please say so if you think another approach is needed.

Regards, Kristian.

Context menu for edges

I would like to add a context menu to remove edges.
I'm not sure if it is the best way, but I added this to the GraphPanel:

<agc:GraphPanel.DataTemplates>
	<DataTemplate DataType="{x:Type agc:Edge}">
		<agc:Connection>
			<agc:Connection.ContextMenu>
				<ContextMenu>
					<MenuItem Command="{Binding $parent.DataContext.RemoveEdge}" CommandParameter="{Binding}" Header="Remove edge"/>
				</ContextMenu>
			</agc:Connection.ContextMenu>
		</agc:Connection>
	</DataTemplate>
</agc:GraphPanel.DataTemplates>

The binding to a method works if I use the code behind and Click="MyMethod", but how do I bind to a view model method (with the xaml above, the context menu item is disabled)?
When I use Command="{Binding RemoveEdge}", the menu item is enabled, but the viewmodel method doesn't get called.

I need to pass the edge somehow as parameter. With the code behind approach the Edge is the DataContext property of MenuItem (which is the sender:

public void MyMethod(object sender, Avalonia.Interactivity.RoutedEventArgs e)
{
}

Another question is if it is possible to specify the thickness of the connection line? I only saw a Brush property. Since the line is pretty thin it would be helpful to make it a bit thicker on hover.

Drag and Drop

In MSAGL, it allows you to drag and drop/ move the nodes around. With this it doesn't seem to let me. Is there anything I can add to allow me to do that?

Usage in ScrollViewer causes InvalidOperationException

Hi, thanks for this great project ๐Ÿ‘ I just have an issue when using it as a child of ScrollViewer, e.g. when modifying MainWindow.xaml in the sample the following way:

...
    </StackPanel>
    <ScrollViewer Grid.Column="0" Grid.Row="1">
      <agc:GraphPanel Background="WhiteSmoke" Graph="{Binding SelectedItem, ElementName=graphs}" Zoom="{Binding Value, ElementName=zoomer}" LayoutMethod="{Binding SelectedItem, ElementName=layoutMethods}">
...
      </agc:GraphPanel>
    </ScrollViewer>
  </Grid>
...

The following exception is thrown:

System.InvalidOperationException
  HResult=0x80131509
  Message=Invalid size returned for Measure.
  Source=Avalonia.Layout
  StackTrace:
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Controls.Presenters.ScrollContentPresenter.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at Avalonia.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at Avalonia.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV, Boolean& hasDesiredSizeUChanged)
   at Avalonia.Controls.Grid.MeasureOverride(Size constraint)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding, Thickness borderThickness)
   at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Controls.Primitives.VisualLayerManager.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding)
   at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding, Thickness borderThickness)
   at Avalonia.Controls.Border.MeasureOverride(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.Layoutable.MeasureOverride(Size availableSize)
   at Avalonia.Controls.Window.MeasureOverride(Size availableSize)
   at Avalonia.Controls.WindowBase.MeasureCore(Size availableSize)
   at Avalonia.Layout.Layoutable.Measure(Size availableSize)
   at Avalonia.Layout.LayoutManager.Measure(ILayoutable control)
   at Avalonia.Layout.LayoutManager.ExecuteInitialLayoutPass(ILayoutRoot root)
   at Avalonia.Controls.Window.Show()
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode)
   at AvaloniaGraphControlSample.Program.Main(String[] args) in C:\iolevel\playground\AvaloniaGraphControl\sample\Program.cs:line 13

I'll attach a PR which should fix it.

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.