This project is read-only.

Vertex Refresh

Aug 19, 2010 at 11:05 AM

Hi,

Firstly thankyou for creating such an excellent visualisation package.

I have a quick and likely a simple question:

I have a data template:

  <DataTemplate DataType="{x:Type PoCGraph:PocVertex}">

            <Border Name="vertexPanel"
                    Margin="2" Padding="4" CornerRadius="5, 5, 5, 5"
                    BorderThickness="2" BorderBrush="Black">


                <TextBlock Text="{Binding Path=ID}" TextAlignment="Center" Background="{Binding Path=Colour}"
                           FontSize="{Binding Path=HighlightFontSize}"/>
                
            </Border>

        </DataTemplate>

 i have a custom search routine:

 private void BtnZoomClick(object sender, RoutedEventArgs e) {
            // undo the last highlighting
            foreach (PocVertex vertex in this.GraphToVisualize.Vertices.Where(v => v.HighlightFontSize =="72")) {
                vertex.HighlightFontSize = "12";
            }
            // then do the new one :)
            foreach (PocVertex vertex in this.GraphToVisualize.Vertices.Where(v => v.ID.Contains(this.ZoomContent.Text))) {
                vertex.HighlightFontSize = "72";
            }

            this.graphLayout.InvalidateVisual(); // not sure what to call here...

        }
however the size of the font in the vertexes doesn't change (i have checked that HighlightFontSize is indeed updated)
i would hazard that i am not calling the right refresh method on the graphlayout. 
I have tried using HighlightFontSize as both an integer and a string field. I have also tried using ReLayout but sans success :(
Any help would be much appreciated
David
Sep 17, 2010 at 2:30 PM

i had a similar problem when updating the vertex background color (from a menu list) after clicking over a vertex.

I derived my vertex class from INotifyPropertyChanged and then add event that is raised when i modify the property (eg, I raise it when i change the background color)..i had this style, with a trigger that's activated when i mouse-click on a node (IsHighlighted is true when mouse button is pressed)

<Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">

<Style.Triggers>
            <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="true">
                <Setter Property="Background"  Value="{Binding Path=(UClib:myVertex.HighlightedBackgroundColor)}"/>
            </Trigger>
</Style.Triggers>

</Style>

and this data template (i set the color of the selected vertex by calling ClickOnNode)

<DataTemplate DataType="{x:Type UClib:myVertex}">
                <DockPanel>
                    <TextBlock MouseLeftButtonDown="ClickOnNode"
                           Text="{Binding Path=ID, Mode=OneWay, FallbackValue=VertexId}"
                           DockPanel.Dock="Top" HorizontalAlignment="Center"
                          />
               </DockPanel>
</DataTemplate>


and this is myVertex class 
namespace UClib
{
public class myVertex  :  INotifyPropertyChanged
{

      private String HighlightedBackgroundColor = "LightBlue";
      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

       protected void NotifyPropertyChanged(String info)
       {
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info));
        }

        public myVertex(string id)
        {
            ID = id;
            IsSelected = false;
           
        }

       public String HighlightedBackgroundColor
       { get { return highlightedBackColor; } set { if (value != highlightedBackColor) { highlightedBackColor = value; NotifyPropertyChanged("HighlightedBackgroundColor"); } } }
   } }
 
hope this can help you

Sep 17, 2010 at 2:38 PM

this post can help too (i used this to solve my problem)

http://graphsharp.codeplex.com/Thread/View.aspx?ThreadId=60657

Oct 13, 2010 at 4:42 PM

fildahui,

thanks for the link & code sample i have got this working now :-)

David

Dec 14, 2010 at 6:23 PM

i got this error when change what u said

Error 1 'ResourceDictionary' root element requires a x:Class attribute to support event handlers in the XAML file. Either remove the event handler for the MouseLeftButtonDown event, or add a x:Class attribute to the root element. Line 24 Position 24. H:\University\Evaluation Computing\project\GraphColoring\Graph\Resources\PocGraphDataTemplates.xaml 24 24 GraphColoring