Keeping the same size of objects

<!–[if gte mso 10]>
<>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:“Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:“Calibri”,“sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}

<![endif]–><!–[if gte mso 9]><>
<w:Word>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:Trackatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfInvalid>false</w:SaveIfInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DonotPromoteQF/>
<w:LidThemeOther>PL</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplex>X-NONE</w:LidThemeComplex>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndark/>
<w:EnableKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:Word>
</><![endif]–><!–[if gte mso 10]>
<>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:“Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:“Calibri”,“sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}

<![endif]–><!–[if gte mso 9]><>
<w:Word>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:Trackatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfInvalid>false</w:SaveIfInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DonotPromoteQF/>
<w:LidThemeOther>PL</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplex>X-NONE</w:LidThemeComplex>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndark/>
<w:EnableKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:Word>
</><![endif]–><!–[if gte mso 10]>
<>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:“Table Normal”;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:“Calibri”,“sans-serif”;
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:“Times New Roman”;
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}

<![endif]–>

Hi

I’m trying to convert an application using GoDiagram (Win) into Silverlight one and having some issues. The win app is able to show a number of points (represented as icons), move them in any place of the Diagram and keeps the size of the icons unchanged regardless of the current document scale (when document scale changes the app changes the size of the Icon so visually the size stays unchanged). I noticed that in goXam I have no possibility to move object (Icon) in a place I want. When diagram is zoomed in I can move the object only into a specific place – it looks like there is an invisible grid or something…. This probably is the causes of another issues:

1) After changing the size of Icon (in response to document scale change) it is sometimes obscured

2) Selection doesn’t reflect the actual size of the Icon

<span style=“font-size: 11pt; font-family: “Calibri”,“sans-serif”;” lang=“EN-US”><p =“MsoListParagraph”>

It is implemented in the following way:

void PanelViewportBoundsChanged(object sender, RoutedPropertyChangedEventArgs<Rect> e)

{

foreach (var visualObject in this.Model.VisualObjectList)

{

if (visualObject is Element)

{

((Element)visualObject).CurrentScale = this.diagram1.Panel.Scale; //notify visual Element that the scale has changed

}

}

}

public class Element

{

public double CurrentScale

{

get { return this._currentScale; }

set

{

if (this._currentScale != value)

{

this._currentScale = value;

this.OnPropertyChanged("Width");

this.OnPropertyChanged("Height");

}

}

}

public double Width

{

get { return this._width / this._currentScale; }

}

public double Height

{

get { return this._height / this._currentScale; }

}

public Brush Fill

{

get

{

return new ImageBrush { ImageSource = new BitmapImage(new Uri(this.ImageLink)) };

}

}

}

XAML:

<ResourceDictionary

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:go="clr-namespace:Northwoods.GoXam;assembly=Northwoods.GoSilverlight">

<DataTemplate x:Key="SelectionAdornentDataTemplate">

<Path go:NodePanel.Figure="None" Stroke="Green" StrokeThickness="{Binding Path=Data.SelectionThickness}" go:Part.Selectable="False" UseLayoutRounding="False"/>

</DataTemplate>

<go:DataTemplateDictionary x:Key="VisualObjectTemplates">

<DataTemplate x:Key="ElementDataTemplate">

<Path x:Name="Shape" go:NodePanel.Figure="Rectangle"

go:Part.SelectionAdorned="True"

UseLayoutRounding ="False"

go:Node.Location="{Binding Path=Data.Location}"

go:Part.SelectionAdornmentTemplate="{StaticResource SelectionAdornentDataTemplate}"

go:Part.Editable="True"

go:Part.Movable="True"

go:Part.Deletable="False"

Fill="{Binding Path=Data.Fill}"

Width="{Binding Path=Data.Width}"

Height="{Binding Path=Data.Height}"

>

</Path>

</DataTemplate>

</go:DataTemplateDictionary>

</ResourceDictionary>

Can anyone help me? How can I disable the ‘grid’ effect?

Thanks

Marcin

I’m not sure what you mean by “the grid effect”. You haven’t specified any background grid for the Diagram, have you?

Does your Element class implement INotifyPropertyChanged? The code you quoted doesn’t seem to, and yet it calls OnPropertyChanged, which isn’t defined.

[QUOTE=walter]I’m not sure what you mean by “the grid effect”. You haven’t specified any background grid for the Diagram, have you?
[/quote]
“The grid
effect”: when the diagram is zoomed in (scale around 40-50) then when dragging
the point (represented by icon) the position of the point doesn’t reflect the
current position of mouse cursor, it changes from point to point. It looks to
me like some rounding subroutine is executed to get the position coordinates in
the whole pixels…

I haven’t defined any grid for the diagram. Here is the XAML definition:

[QUOTE=walter]Does your Element class implement INotifyPropertyChanged? The code you quoted doesn’t seem to, and yet it calls OnPropertyChanged, which isn’t defined.
[/quote]
Yes it does
– I didn’t copy the whole implementation of the Element class but it implements
INotifyPropertyChanged interface.

Whenever scale is changed (see PanelViewportBoundsChanged method) the appearance of visual elements is changed by setting CurrentScale property. The setter of that property changes Height and Width properties which are bound through Data Template “ElementDataTemplate” ( Width="{Binding Path=Data.Width}", Height="{Binding Path=Data.Height}”). This works quite good if the current scale is between (0.5 and 5) but when the scale is bigger the problems come out.

I should add that the same pattern is used to change the thickness of the Selection Adornment when the Point is selected.

The goal I want to achieve is to have some visual objects independent from the current diagram scale. I don’t want the selection adornment of those objects to be changed as well. The stroke thickness should be unchanged. I noticed that in some cases the object and the adornment got unsynchronized (object is displayed in one place and its adornment in onother) but when the scale changes a little they got synchronized again.

I’m not sure if this is something with my code or maybe this is a bug in goXam.

Best regards

Marcin

GoXam isn’t really designed to work at such large scales. But when I try zooming way in in some of the sample applications of GoWpfDemo, everything seems to work reasonably well. Everything looks sharp and reshaping a link, for example, works smoothly. But I do notice that resizing a node does seem to do so in multiples.

My guess is that at such large scales, something causes elements to be aligned to values rounded to integers. At a Scale of 50, each unit of model coordinates scales up to 50 device-independent-pixels on the screen. Maybe there is some conflicting use of SnapsToDevicePixels and UseLayoutRounding. That will require some more investigation. You could try explicitly setting SnapsToDevicePixels=“False”.

Well, the reason the ResizingTool limits resizing to multiples of 1 model coordinate unit is because ResizingTool.ComputeCellSize defaults to 1x1. I think this is desirable because one normally doesn’t want fractional sizing of nodes.

(That’s the default if there’s no specific value for ResizingTool.CellSize and if there’s no specific value for Node.ResizeCellSize and if there’s no Node behind the node which has DragOverSnapEnabled defined and if there’s no Diagram.GridSnapEnabled. But you probably don’t care about how grid snapping works, or even how the ResizingTool works.)

The DraggingTool does not seem to impose any such “gridding”. When one zooms in the node locations can have fractional values.