Page Index Toggle Pages: 1 [2] 3  Send TopicPrint
Very Hot Topic (More than 25 Replies) clipboard and ControlHost (Read 16285 times)
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #15 - Nov 21st, 2006 at 2:26pm
Print Post  
Excellent!

Thanks for your help

Dirk
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #16 - Nov 21st, 2006 at 3:46pm
Print Post  
I just tested the new code and only got partial success:

Bullets and Alignment are now working, but not FontStyle (bold, italic) FontSize and FontFamily.

See here



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #17 - Nov 22nd, 2006 at 6:06am
Print Post  
Strange, that works fine here. Do you still handle the CopyHostedControl event?

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #18 - Nov 22nd, 2006 at 6:55am
Print Post  
No, I removed it.
Should I leave it in?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #19 - Nov 22nd, 2006 at 8:27am
Print Post  
Nope, it should work without the event. Could you post the Rtf contents here?

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #20 - Nov 22nd, 2006 at 8:48am
Print Post  
Here's the RTF just before btChart.CopyToClipboard(false)

Quote:
"{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset2 Symbol;}}\r\n\\viewkind4\\uc1\\pard\\lang1031\\fs20  fds \\ul\\b afd \\ulnone\\b0\\i fdsafdsa \\i0\\fs28 fdsafds \\fs20 afdsa fd\\par\r\ns fdsa \\par\r\n\\pard\\qr fdsa fdsafdsaf\\par\r\n\\pard{\\pntext\\f1\\'B7\\tab}{\\*\\pn\\pnlvlblt\\pnf1\\pninde
nt0{\\pntxtb\\'B7}}\\fi-300\\li300  fds af\\par\r\n{\\pntext\\f1\\'B7\\tab} fdsaf\\par\r\n}\r\n"


and here, right before btChart.PasteFromClipboard(10, 10);

Quote:
"{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset2 Symbol;}}\r\n\\viewkind4\\uc1\\pard\\lang1031\\fs20  fds \\ul\\b afd \\ulnone\\b0\\i fdsafdsa \\i0\\fs28 fdsafds \\fs20 afdsa fd\\par\r\ns fdsa \\par\r\n\\pard\\qr fdsa fdsafdsaf\\par\r\n\\pard{\\pntext\\f1\\'B7\\tab}{\\*\\pn\\pnlvlblt\\pnf1\\pninde
nt0{\\pntxtb\\'B7}}\\fi-300\\li300  fds af\\par\r\n{\\pntext\\f1\\'B7\\tab} fdsaf\\par\r\n}\r\n"


If you need RTF from other locations too, just tell me

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #21 - Nov 22nd, 2006 at 9:31am
Print Post  
This works fine when copying plain RichTextBox controls. Maybe some property in your extended control clears the formatting when set? If the flowchart calls that property setter after the Rtf property one, the formatting will be lost. Try setting Rtf from the copy event again, just to be sure that Rtf is the last property assigned to.

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #22 - Nov 22nd, 2006 at 10:48am
Print Post  
Hi Stoyo,

I fear I didn't exactly understand what you want me to do.

Quote:
Maybe some property in your extended control ..


With extended Control do you mean my extended FlowChart control? If so, I've only overriden IsInputKey, so this shouldn't be a problem, right?

Quote:
Try setting Rtf from the copy event again

What do you mean with setting Rtf? Right now I do nothing with Rtf while copying and pasting.
Should I copy the content of RTF in my copytoClipboard method to a variable and set it again when pasting?

Here's my copy code:

Code
Select All
private void kopierenToolStripMenuItem_Click(object sender, EventArgs e)
{
  if (btChart.Selection.Objects.Count == 1)
  {
    if (btChart.ActiveObject.GetType() == typeof(Box))
    {
      ...
    }
    else if (btChart.ActiveObject.GetType() == typeof(ControlHost))
    {
        if (((btChart.ActiveObject as ControlHost).Control as MERichTextBox).Focused)
        {
          ...
        }
        else
        {
          btChart.CopyToClipboard(true);
        }
      }
    }
  }
 



I removed all unnecessary lines.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #23 - Nov 22nd, 2006 at 11:41am
Print Post  
I mean you inherit from the RichTextBox control, right? If you add some properties to your class, and any of them sets Lines or Text of the base RichTextBox class, they might clear the formatting if their values are copied after the Rtf value.

Now FlowChart.NET uses reflection to copy all properties from value and string types in the order returned by the reflection API. E.g. it used to copy first Rtf, and then Text, but setting Text has the side effect of loosing the formatting tags. So we added some code to skip the Text and Lines properties of RichText controls, and now copy&paste works fine in our tests.

Now if there is another property in your RichText-inherited class that coud clear the formatting, FlowChart.NET doesn't know about it and might set its value after the Rtf's one.

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #24 - Nov 22nd, 2006 at 12:23pm
Print Post  
okay, understood.

As far as I can see there are no new properties within the inherited Richtextbox that could set Text, Lines or RTF besides
protected override CreateParams CreateParams.
I don't know if this is causing the problem.

But I still need to know where I should re-set Rtf as you said ("Try setting Rtf from the copy event again"). Just before PasteFromClipboard RTf is still the same as before copying. So I am wondering where or when I should re-set RTF.

Sorry for taking so much of your time Smiley

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #25 - Nov 22nd, 2006 at 12:45pm
Print Post  
Set Rtf in the CopyHostedControl event handler. The event is raised just after FlowChart.NET copies the control's properties. So probably in that moment the clone's formatting will be already lost . But then if you copy Rtf from the original, the formatting should be restored.

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #26 - Nov 22nd, 2006 at 1:18pm
Print Post  
hmm, no success:

Here's the source RTF of a sample RichTextBox when running through CopyHostedControl when the ControlHost is copied:

Quote:
"{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\r\n\\viewkind4\\uc1\\pard\\tx300\\tx600\\tx900\\tx1200\\tx1500\\lang103
1\\fs20 DDD \\b\\fs20 EEE \\b0\\fs20 FFF\\par\r\n}\r\n"


And here's the destination RTF right after running through CopyHostedControl  when the Controlhost is pasted

Quote:
"{\\rtf1\\ansi\\ansicpg1252\\deff0{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}\r\n\\viewkind4\\uc1\\pard\\tx300\\tx600\\tx900\\tx1200\\tx1500\\lang103
1\\fs20 DDD \\b EEE \\b0 FFF\\par\r\n}\r\n"


Both are different. So it seems the rtf is not copied correctly.

Here's the source of the CopyHostedControl
Code
Select All
private void btChart_CopyHostedControl(object sender, CopyHostedControlEventArgs e)
{
MERichTextBox src = e.Source as MERichTextBox;
MERichTextBox dst = e.Destination as MERichTextBox;
if (src != null && dst != null)
{
dst.Rtf = src.Rtf;
}
} 



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #27 - Nov 22nd, 2006 at 5:39pm
Print Post  
Ok, please email me the latest version of your RichTextControl dll.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: clipboard and ControlHost
Reply #28 - Nov 23rd, 2006 at 11:39am
Print Post  
Hi Dirk,

Strange, but copy & paste works fine with your control in our test app. Are you sure your project correctly references the very-last dlls I sent you?

Stoyan
  
Back to top
 
IP Logged
 
ampersand
Junior Member
**
Offline



Posts: 55
Joined: Sep 21st, 2006
Re: clipboard and ControlHost
Reply #29 - Nov 23rd, 2006 at 11:51am
Print Post  
At least it's good to hear that it is working on your side. So the error must be somewhere else:

I use the following dll-Versions

flowchart.net.dll 4.2.1.29339
ruler.dll 4.2.1.29358

Dirk
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 3 
Send TopicPrint