Page Index Toggle Pages: [1] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) Working with containers! (Read 19255 times)
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Working with containers!
Feb 3rd, 2012 at 5:06pm
Print Post  

  ContainerNode c = form.Factory.CreateContainerNode(200,200, 0, 0);
           c.Bounds = new Rect(e.MousePosition, new Size(200, 200));
           c.Text = "Test";
           c.TextBrush = MyPink;
           c.TextAlignment = TextAlignment.Center;
           c.CaptionBrush = MyWhite;
           c.CaptionHeight = 25;
           c.Foldable = false;
           c.AutoShrink = false;
           c.Brush = Brushes.Red;
           c.FontSize = 14;
           c.Constraints.MinWidth = 200;
           c.Constraints.MinHeight = 100;
           c.FontFamily = new FontFamily("Arial");
           c.HandlesStyle = HandlesStyle.Custom;
           c.Selected = true;
           c.Folded = false;   



I start work with container, and found some problems.
In first play i want the container have body of one color and border of other color.
This no is possible?

Also like you can see, i have folded and foldable false.
I do this due i no want use the little button on the right corner, is very little and non confortable.
I want when user click on the header of the container all header act like a button for fold unfold.

Is possible that?


Finally you can see the text no is vertically centered.
Why
How fix?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #1 - Feb 6th, 2012 at 1:03pm
Print Post  
Quote:
I start work with container, and found some problems. In first play i want the container have body of one color and border of other color. This no is possible?


It's not possible at this time.

Quote:
Also like you can see, i have folded and foldable false.
I do this due i no want use the little button on the right corner, is very little and non confortable. I want when user click on the header of the container all header act like a button for fold unfold.


Handle NodeClicked:

Code
Select All
private void OnNodeClicked(object sender, NodeEventArgs e)
{
	var ctr = e.Node as ContainerNode;
	if (ctr != null &&
		e.MousePosition.Y < ctr.Bounds.Top + ctr.CaptionHeight)
		ctr.Folded = !ctr.Folded;
} 



Quote:
Finally you can see the text no is vertically centered.


c.TextVerticalAlignment = AlignmentY.Center;

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #2 - Feb 6th, 2012 at 4:41pm
Print Post  
Thank you so much, like always your repply help a lot.

Anyway i found a problem, wit this:
private void OnNodeClicked(object sender, NodeEventArgs e)
{
     var ctr = e.Node as ContainerNode;
     if (ctr != null &&
           e.MousePosition.Y < ctr.Bounds.Top + ctr.CaptionHeight)
           ctr.Folded = !ctr.Folded;
}


If you make faster clicks, you cna see contaner some times no react, please test and you can see.
You have to make 3 clicks some tmes for unfold and fold again.
Why?
Example, create container, fold the container, now click to unfold and inmediatly click for fold again.
You cna see the problem.


I have the text aligned in Y axis now, but after change c.Foldable = false; now the text is not correct aligned in the X axis ot incenter is a little mover to the left form the center.
How can align text in X axis? i cnat find any option for do that.

ANother trouble container have. If i locate container in the bottom postion of my diagram, when i unfold, this go out of the screen!
No way to fix that?
Containr should be opened n the top directon if is located at bottom
Is possible correct this?

Is to much request please add this options to the container:

1- option for change color of border.
2- option for select thikness of border.
3- option for change color of fill HEADER
4- option for change color of BODY container fill.

I HOPPE CAN PUT THIS ON THE TO DO Kiss
« Last Edit: Feb 10th, 2012 at 7:47am by PDM. »  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #3 - Feb 17th, 2012 at 3:49am
Print Post  
BUG:

c.Foldable = false;

When i save the diagram, and open again, container appear with that circle with arrow for fold and unfold.
That not should be happen.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #4 - Feb 17th, 2012 at 6:09pm
Print Post  
0) You might get NodeDoubleClicked events if you click too fast.
1) Set c.Stroke.
2) Set c.StrokeThickness.
3) This version adds CaptionBackBrush property:
https://mindfusion.eu/_beta/wpfdiag28a.zip
4) Set c.Brush.
5) The version above should serialize the foldable flag.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #5 - Feb 18th, 2012 at 11:40pm
Print Post  
Thank you so much, this work perfect.
Just found few problems and limitations make container less suefull in some situations:

c.TextAlignment = TextAlignment.Center;

The text no is correctly cenetered, is a little moved to the left when use center and use foldabe false.

The other problem i see, happen when container is folded and then resize unfolded.
By example:

I unfold container, then resize, then locate some objects inside, then fold.
If i resize now the container when is folded objects inside not are showed and container not work how should be.
I think resize container when is folded no have any sense and any practical use so is ok, but i need prevent this happen, i need prevent resize when container is folded.
How can prevent container be resizable when is folded?
I just want drag and move when is folded, but no want resize enabled when is folded.
Some sugestion?
Can add this like feature please?

Fnally the other problem i see is a lack of feature make the container right now less usefull under some situations.
When open container close to the bottom of diagram, the container go outisde of the diagram.
Really be good if this can be improved or fixed.
By example if container is located at botom position, when is unfolded should be unfolded in in upward direction, in that way contianrs can be used on anyportion of the screen.
With current behaviour only can be used on top, or in the middle of screen or something like that.

Can implement please some behaviour for make container can open in any oposite direction when is near to bottom borders?
I mean open in oposite direction if contaner unfolded not fit im portion of the screen available.
A simple and probably the best workaround for this, is rotate the container, but when i rotate more prolmes come.
By example if I rotate 180 degres, the text appear inverted, the fold and unfold (captionsection) remain on top of the container, and contaner continue unfold out of screen. ; (
I think rotate contianer will be the best option, if container automatically continue working when is rotated. This feature add a great fucntionality to container and fix the limitation I explain aboout container go out of scree when is unfolded near to bottom, lef or righ or the sreen.


Aditional to this problem i found a possible bugs:

Create container in same way I create:

ContainerNode c = form.Factory.CreateContainerNode(100,100,100,100);
c.Bounds = new Rect(e.MousePosition, new Size(100, 100));
c.Folded = false;
c.Foldable = false;
c.AutoShrink = false;
c.Text = "Test";
c.TextAlignment = TextAlignment.Center;
c.CaptionBrush = Brushes.White;
c.CaptionHeight = 25;
c.Stroke = Brushes.Red;
c.Brush = Brushes.Black;
c.StrokeThickness = 3;
c.CaptionBackBrush = Brushes.Red;
c.FontSize = 14;
c.Constraints.MinWidth = 100;
c.Constraints.MinHeight = 100;
c.FontFamily = new FontFamily("Arial");
c.HandlesStyle = HandlesStyle.Custom;
c.TextVerticalAlignment = AlignmentY.Center;
c.MinimumSize = new Size(100, 100);
c.Selected = true;



For fold and unfold i use this method:

private void OnNodeClicked(object sender, NodeEventArgs e)
{
     var ctr = e.Node as ContainerNode;
     if (ctr != null &&
           e.MousePosition.Y < ctr.Bounds.Top + ctr.CaptionHeight)
           ctr.Folded = !ctr.Folded;
}


Now, create a container, then fold, then copy and paste.
When unfold the copyed container, contianer just is resized to very little size.

Letme know if can reproduce this possible bug, this bug only happen when container is empty


If container have some object inside, when copy and paste when is folded, the border disappear!
Also, size is wrong, position of object incorrect.

Please check.


Best regards.

« Last Edit: Feb 19th, 2012 at 9:04pm by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #6 - Feb 20th, 2012 at 12:34pm
Print Post  
This build should center the caption correctly when a container is not foldable:
https://mindfusion.eu/_beta/wpfdiag28a.zip

Containers are designed to resize automatically to accommodate their child nodes and they do not allow manual resize. If you set HandlesStyle to Custom to enable resizing, you will run into all sort of problems. If you only need to draw custom handles, keep style to Custom but allow only move operations from the HitTestAdjustmentHandles event.

If a container is near the diagram bottom boundary, you can either enlarge the diagram or move the container upwards from the ContainerUnfolded event handler.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #7 - Feb 21st, 2012 at 2:13am
Print Post  
I understand the concept of not work with resize and use by example with AutoShrink.

The problem with autoshrink is really work bad for 2 reasons.

The object draged inside the diagram, touch the border od container and autotrink always catch the object an resize not leaving any marging.

If by example AutoShrink have configurable marging in pixels:
example
AutoShrinkMargin = 10;

That be ultra usefull.
I know this is only cosmetic thing but cosmetic is always important in a software.
Can please add this feature?

The second problem with AutoShrink is when you drag object, close to border of container, is very easy, object go out of container, object should be go out only when object is 100% out of container.
Right now that not happen and is very easy move object out of container by accident or error.
Can be this fixed?



About this comment:
If a container is near the diagram bottom boundary, you can either enlarge the diagram or move the container upwards from the ContainerUnfolded event handler.
Please can show a code example?
Best regards.
« Last Edit: Feb 21st, 2012 at 2:52pm by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #8 - Feb 21st, 2012 at 3:05pm
Print Post  
1. Containers already have a Margin property.
2. A child node is removed only if you drag it entirely out of its container, so that their bounding rectangles do not intersect.
3.
Code
Select All
void diagram_ContainerUnfolded(object sender, NodeEventArgs e)
{
	Rect nodeRect = e.Node.Bounds;
	Rect diagRect = diagram.Bounds;
	if (nodeRect.Bottom > diagRect.Bottom)
		e.Node.Move(nodeRect.X, diagRect.Bottom - nodeRect.Height);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #9 - Feb 21st, 2012 at 3:37pm
Print Post  
1. Ups! sorry i not see container marging before, no idea why, probably for not read more lol.
Is great, now margin is fixed and work perfect!!

2. Really sorry but no is how work here, inmediate after i put out of container more of 25% of object, object go out of container, i cna create a video for you if you want see this.
Im testing with custom UserControl. (nodes are UserControl)
Can be related?

3 Thank you for the example i test soon.


I need check why my diagram objects go out of teh container when i justdrag a little more of 25% of object.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #10 - Feb 21st, 2012 at 3:42pm
Print Post  
Sorry, my autorepply.
Yes! is related, when i use a simple shape not have the problem and node shape go out of container only when i put all the node shape 100% out of container.
When i use like a node a custom UserControl, container work wrong and after i drag just a little more of arround 25% of custom node, over the container border limits, the object go out !

Can be this fixed?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #11 - Feb 22nd, 2012 at 9:13am
Print Post  
If you are using DiagramNodeAdapters to show user controls, perhaps your user control size doesn't match the node's Bounds size. Check the SizeSyncMode property for a couple of options you have. Also make sure you don't use fixed-size elements in your control templates, and apply dynamic layouts using grid or stack panels instead of placing child elements at fixed positions.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #12 - Feb 22nd, 2012 at 10:41am
Print Post  
Yes i use daigram nodeadapter., example:


Code
Select All
 var bshape = new BlackShape();
           var node = new DiagramNodeAdapter(form, bshape);
           node.Bounds = new Rect(e.MousePosition, new Size(100, 100));
           form.Nodes.Add(node);
           node.Constraints.MinWidth = 100;
           node.Constraints.MinHeight = 100;
           node.HandlesStyle = HandlesStyle.Custom;
           node.Selected = true;

 



I try using
node.SizeSyncMode = SizeSyncMode.Measure;
or
node.SizeSyncMode = SizeSyncMode.Arrange;
or
node.SizeSyncMode = SizeSyncMode.SetSize;


What im trying is correct?

This is the only one problem i need fix for star use containers, i try this and not work.


Also more problems come, your example code no is usefull.
I first place, event no is fired only is fired, only is fired if use c.Foldable = true;
If is set to false, not work due event never is fired., im talking of this:
Code
Select All
 private void form_ContainerUnfolded(object sender, NodeEventArgs e)
        {
            Rect nodeRect = e.Node.Bounds;
            Rect diagRect = form.Bounds;
            if (nodeRect.Bottom > diagRect.Bottom)
            e.Node.Move(nodeRect.X, diagRect.Bottom - nodeRect.Height);

        }

 



Also, tis solution is useless, for simple reason, when i locate container close to the border, and open, the container move from the postion, the problem is when you fold again , the container should remain in orignal position (caption header), but that not happen due this solution just move the continer but never return to original position where is located.
Container should reamin in same position.

Thank you so much for your help Stoyo, but this not work.
Container really need some rework for make better how work right now.
« Last Edit: Feb 23rd, 2012 at 8:15am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Working with containers!
Reply #13 - Feb 22nd, 2012 at 12:42pm
Print Post  
You will have to make your BlackShape control adapt to the node size. Check if some of the panels used inside it doesn't have fixed Width and Height. If there's such panel, remove the Width/Height setters so that it fills whatever size the parent control has.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Working with containers!
Reply #14 - Feb 22nd, 2012 at 12:51pm
Print Post  
Stoyo, the size of custom object match with the size of handlers and cover 100% the size of node.
No idea why this happen, but should not happen.
Also i tested, this same with example provided from MINDFUSION called FORM EDITOR.
I added container and test with button, and see same problem.

When drag by example a BUTTON, from isnide tof container over the border of container, the same problem happen.

Also you see my last update in this post?
Probably I editing that post in same moment when you are writing your repply, please check, the last post I do before this.

« Last Edit: Feb 23rd, 2012 at 9:42am by PDM. »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint