Changing Vertex Fill Color on Selection/Deselection

Oct 28, 2009 at 1:43 PM

First, let me say that this package is AWESOME!

One gripe with it, though...  It's not easy to change the vertex fill color on selection/deselection...  I see the VertexSelectedColor property, but that only changes the border of the vertex...  I'm looking for a way to change the color of the entire vertex, since it can be hard to see an outline color change in a large graph.

I've hacked something together in the SelectionChange event to handle the selection, and it works well enough:

foreach (IVertex ThisVertex in ((NodeXLControl)sender).SelectedVertices)
{
     ThisVertex.SetValue(ReservedMetadataKeys.PerVertexPrimaryLabelFillColor, Color.FromArgb(255, 255, 255, 0));
}

_NodeXLControl.DrawGraph(false);

The de-selection, however, is giving me fits...  I coded something similar in the VertexClicked event to change the color back, but this fails if the deselection is done by clicking on the background of the graph.  It works just fine if I deselect a vertex by clicking on another vertex.

I'm wondering if it is possible to either put in a VertexSelectedFillColor property, or perhaps a SelectionChanging event which occurs when the selection is in the process of changing, but when SelectedVertices still contains the prior selection?


Thanks!


Gabe

Oct 28, 2009 at 2:31 PM

Check that...  I was digging around in the source, and saw that the TestWpfNodeXLControl app does exactly what I want to do, now I just have to figure out how it does it...

Gabe

Oct 28, 2009 at 5:16 PM

Gabe:

Can you use one of the solid shapes instead of an outline shape -- Disk vs. Circle, for example?  With the solid shapes, the vertex color (or selected color) fills the entire vertex.

-- Tony

Oct 28, 2009 at 5:22 PM

...unless you are using the Label shape, which behaves differently.  I can't tell from your code snippet if you're actually using labels.

By the way, we are in the process of redesigning our solid vs. outline shape scheme and how the various color options apply to them.  We want to simplify things and enable a few scenarios that are impossible today. 

-- Tony

Oct 29, 2009 at 1:34 PM

Yes, I am setting the PerVertexPrimaryLabel value, so that's what's going on...  So I'm guessing there is currently no way to display text as a primary label in the vertex and have the background of the label color/decolor automatically on selection?

Gabe

 

Oct 29, 2009 at 1:53 PM

Well, I went ahead and hacked a way to take care of this...  I added a VertexSelectedFillColor property to the NodeXLControl class, and it works beautifully...  does exactly what I want.

Now, how would I submit this change to be incorporated in the code?  I can't compile the entire project as-is, because I do not have access to Office 2007.

Thanks!

Gabe

 

Oct 29, 2009 at 6:03 PM
Edited Oct 29, 2009 at 6:05 PM

Gabe:

That is correct: There is currently no way to do what you want to do without customizing the code.

We are not able to accept contributions at this point, but thank you for offering.

You should be able to compile the entire NodeXL solution regardless of whether you have Office 2007 installed.  Office 2007 is required only if you want to run the solution's ExcelTemplate project.  If you are finding otherwise, please let me know.

-- Tony

Oct 29, 2009 at 6:09 PM

When I download the source, and load it initially in Visual Studio, I get the following error:

---------------------------
Microsoft Visual Studio
---------------------------
A compatible version of Microsoft Office is not installed on this computer. You must install the version of Office that is compatible with your project. In addition, repair the version of the Visual Studio Tools for Office runtime that is appropriate for your project by running the installation program and selecting the Repair option. The runtime is available at the Microsoft Download Center.
---------------------------
OK   Cancel   Help   
---------------------------

I am able to load the solution, but the ExcelTemplate project is listed as "Unavailable", and I get the following error when building:

Error    1    The referenced assembly "C:\Temp\nodexl-37890\NodeXL\ExcelTemplate\bin\Debug\Microsoft.NodeXL.ExcelTemplate.dll" was not found. If this assembly is produced by another one of your projects, please make sure to build that project before building this one.    UnitTests

If I remove the ExcelTemplate and UnitTests projects from the solution, I can compile just fine.

Gabe

Oct 29, 2009 at 6:19 PM

Gabe:

I didn't realize that!  In retrospect, I do have Office 2007 on all of my build machines and so I never noticed the requirement.

Thanks for letting me know.

-- Tony