tgjones / gemini

Gemini is an IDE framework similar in concept to the Visual Studio Shell. It uses AvalonDock and has an MVVM architecture based on Caliburn Micro.
Other
1.1k stars 299 forks source link

GraphEditor Settings #272

Open Goicox opened 7 years ago

Goicox commented 7 years ago

Dear All,

I am new to Gemini and I would like to add a settings page to the graphEditor. For instance, I would like to change the graphEditor background color or remove the grid, etc. with a settings view. However, I have noticed that some of these properties are embedded in the Generic.xaml located in:

gemini/src/Gemini.Modules.GraphEditor/Themes/

What would be the best way to do this?

Thank you in advance, Javier

luferau commented 7 years ago

Javier, GraphControl class as a successor of Control class (see Gemini.Modules.GraphEditor/Controls/GraphControl.cs) has Background properties. For example see GraphView.xaml located in Gemini.Demo.Views

<local:GraphControl x:Name="GraphControl" Background="Gray" ...

To remove the grid you probably need to change Generic.xaml file. This code responsible for grid:

 <Border.Background>
    <VisualBrush TileMode="Tile" 
             Viewport="0,0,25,25" ViewportUnits="Absolute"
             Viewbox="0,0,25,25" ViewboxUnits="Absolute">
        <VisualBrush.Visual>
            <Border BorderThickness="0 0 1 1"
            Height="25" Width="25">
            <Border.BorderBrush>
            <SolidColorBrush Color="#77A9A9A9" />
        </Border.BorderBrush>
    </Border>
 </VisualBrush.Visual>
 </VisualBrush>
 </Border.Background>

You can add Visibility="Hidden" properties to prevent the grid being seen.

<Border BorderThickness="0 0 1 1" Height="25" Width="25" Visibility="Hidden">

Or it is better to make a binding, for example like this https://stackoverflow.com/questions/36991311/binding-for-border-visibility-hidden-in-wpf

Goicox commented 7 years ago

Aliaksei, thank you for your reply and suggestions. The thing that confuses me is that there are graph properties defined in the Generic.xaml, but others are related to GraphView.xaml (as in the demo example) like the item's background or label background.

I would like to change / access all these properties using a setting page inside Tools/Options/

What do you recommend for this? Thank you, Javier

luferau commented 7 years ago

You need to create two properties in your GraphViewModel.cs and bind their in GraphView.xaml Like this

<local:GraphControl x:Name="GraphControl" Background="{Binding BackgroundColor}"

Goicox commented 7 years ago

Great! But how should I do with other properties defined in the Generic.xaml (e.g. grid visibility or spacing)?