ctrl+Z problem

4 posts, 0 answers
  1. Vishal
    Vishal avatar
    9 posts
    Member since:
    Feb 2012

    Posted 29 Aug 2013 Link to this post

    Hi,
    I am using the diagram control in my xaml file and i have two shapes(any) . there is one textbox  to set the raddiagramshape fontsize property.

    so in xaml i have implemented this like as follows

    Text="{Binding Path=SelectedItem.FontSize,ElementName=frontdiagram,Mode=TwoWay}"

    when i select any shape in diagram then textbox show the current fontsize of that shape and when i change the value from the textbox then it is changing the fontsize of the current selected shape .

    the problem is if I selected more than one shapes then it won't work meaning it is changing the font of only one shape. so to achieve this i have took the selectionchanged even of the diagram control on shape selection change i am getting the collection of selected items and then i am able to do the font change for every selected item but undo is not working in this case. when i press ctrl + z then it won't undo the last action for fontchange . how to achieve this and why this is happening .
    if i am using xaml code to achieve then multiple selected font couldn't reflect but undo work and if i use the codebehind to solve the problem then undo couldn't work
    Note : - setting pane do provide this feature meaning if you select the two shapes and change the font then it will change for both shapes and undo also work in that . This same thing i want to implement for this textbox.
    please help.
  2. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 03 Sep 2013 Link to this post

    Hi Vishal,

    Please accept my apology for the late response. 

    The reason why changing the RadDiagramShapes' font size is not an undoable action is that when you use the code-behind setting of the FontSize property the change is not put in the RadDiagram's Undo/Redo stack. On the other hand if you use the SettingsPane it uses UndoableDelegateCommand internally which comes from RadDiagram's core assembly and that's why the change of the font size is put in the Undo/Redo stack.

    One possible approach to make the undo/redo work is to create you own command of type UndoableDelegateCommand.

    Please examine the attached project, where I have implemented the suggested approach.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vishal
    Vishal avatar
    9 posts
    Member since:
    Feb 2012

    Posted 19 Sep 2013 Link to this post

    Hi,
    I have downloaded your solution but when i do something on diagram then it throw' exception and even i didn't get the use of creating only one command for font.
    the question for me is if i have multiple shapes on diagram and at the same time i selected all of them and change any property of them like color , font , fontfamily then in I am iterating the diagram shapes and change the property for the selected all items and it is changing properly but when i press ctrl + z then it should undo all right so its not doing so. but with setting pane it is possible.
  5. Stefan
    Admin
    Stefan avatar
    89 posts

    Posted 23 Sep 2013 Link to this post

    Hi Vishal,

    Please accept my apologies for the not correct working project. It seems I have put a wrong condition in the "if" used in the diagram_SelectionChanged. I edited the project and reattached it.

    The logic about the properties like color, font , font family is the same like the logic about the font size - when they are change using the SettingsPane the event comes from the RadDiagram's core assembly and it is registered in the RadDiagram's Undo/Redo stack and that's why those events are undoable.

    In the attached example I have added two Listboxes binded for the RadDiagram's Undo/Redo stack
    and a button which changes the background and the foreground of the selected shapes. You can see that there is no event put in the RadDiagram's Undo/Redo stack when the button is clicked. However if you change any property from the SettingsPane there is an events put in this stack.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top