Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Clipboard with multiple appointments (Read 5357 times)
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Clipboard with multiple appointments
Jan 22nd, 2008 at 1:19pm
Print Post  
Hey, hope someone can help.


The clipboard example is ace for CnP one appointment. How can I CnP multiple appointments?

e.g. copy the itemCollection into the clipboard.

Thanks.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Clipboard with multiple appointments
Reply #1 - Jan 22nd, 2008 at 1:58pm
Print Post  
For example, you can create a new data class, similar to the ItemData class defined in the Clipboard example. The following code should give you an idea:

Code
Select All
class ItemsData
{
	public ItemsData(ArrayList items)
	{
		this.items = items;
	{

	public ArrayList Items
	{
		get { return items; }
	}

	private ArrayList items;
} 


Then create an array consisting of individual ItemData objects each of which corresponds to an item in the multiple selection and pass this array to the constructor of a new ItemsData object. Then put the newly created ItemsData object in the Clipboard instead of a single ItemData.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Clipboard with multiple appointments
Reply #2 - Jan 22nd, 2008 at 2:29pm
Print Post  
Ok, looking good, on the right track...

I'm looping through the collection..

Code
Select All
foreach (Item i in ic)
{
	  i.SaveTo(writer, new SerializationContext(this._calendarold.Schedule));
	  //copiedApp.Add(i);
}
 



The new class accepts an ArrayList, but the Item has a .SaveTo method to save to the steam, which is then buffered into the data object (clipboard).


Sorry, i see it, but the coin hasn't dropped. (I'm having one of those days)
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Clipboard with multiple appointments
Reply #3 - Jan 22nd, 2008 at 3:01pm
Print Post  
You just create one ItemData object for each individual item in the selection, exactly the same way they are created in the sample. Instead of setting the ItemData object directly to the clipboard however, you push them in an ArrayList and pass this array list to an ItemsData object (from the class defined in my previous post). Finally you put this ItemsData object to the clipboard.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Clipboard with multiple appointments
Reply #4 - Jan 22nd, 2008 at 6:17pm
Print Post  
I realise this is on the boundry of the product, however any help here is much appreciated. When it seems to copy to the clipboard, when I'm pasting oo is always null. ???
Code
Select All
object oo = data.GetData(formats[0]);
 


Always seems to return null. Which points to that I'm not streaming in the objects properly.

My "copy" method
Code
Select All
foreach (Item i in ic)
{
     i.SaveTo(writer, new SerializationContext(this._calendarold.Schedule));
     copiedApp.Add(i);
}

writer.Close();
DataObject data = new DataObject(new ItemsData(copiedApp));
Clipboard.SetDataObject(data, true);


 





My CnP classes
Code
Select All
[Serializable]
    public class ItemData
    {
        public ItemData(string type, byte[] data)
        {
            _type = type;
            _data = data;
        }


        public string Type
        {
            get { return _type; }
        }

        public byte[] Data
        {
            get { return _data; }
        }


        private string _type;
        private byte[] _data;
    }
    [Serializable]
    public class ItemsData
    {
        public ItemsData(ArrayList items)
        {
            this._items = items;
        }
        private ArrayList _items;

    public ArrayList Items

    {


    get { return this._items; }

    }
    }
 



I've tried all sorts of different variations to the above, without any success...  Sad
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Clipboard with multiple appointments
Reply #5 - Jan 23rd, 2008 at 6:21am
Print Post  
Here is a modified version of the Clipboard sample which is able to perform multiple items Copy/Paste:

https://mindfusion.org/_samples/_sample_MultiClipboard.zip

Hope it is helpful.

Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Clipboard with multiple appointments
Reply #6 - Jan 23rd, 2008 at 10:22am
Print Post  
Thanks Meppy, above the call of duty, and I thank you for it...

In my app i'm using a inherited  appointment class. I've tried to apply it to you sample. I've just added a enumerator property, when copy'd and pasted, doesn't seem to come through.

https://rss.01792.org/clipboard_problem.zip.

The objects appear to paste through however if you break on the :
Code
Select All
newItem.LoadFrom(reader, context);
 


the property defaults to the "Allday" enum value. Undecided

Thanks for all your patient help. Smiley
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Clipboard with multiple appointments
Reply #7 - Jan 23rd, 2008 at 10:54am
Print Post  
You need to implement the serialization and deserialization of your custom fields to the binary stream. Simply add the following lines of code to the definition of your class:

Code
Select All
public override void SaveTo(System.IO.BinaryWriter writer, SerializationContext context)
{
	base.SaveTo(writer, context);

	writer.Write((int)_stype);
}

public override void LoadFrom(System.IO.BinaryReader reader, SerializationContext context)
{
	base.LoadFrom(reader, context);

	_stype = (ScheduleType)reader.ReadInt32();
} 


Meppy
  
Back to top
 
IP Logged
 
Milo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 29
Joined: Jul 16th, 2007
Re: Clipboard with multiple appointments
Reply #8 - Jan 23rd, 2008 at 2:10pm
Print Post  
Thats peachy Meppy, it seems to obvious now... Roll Eyes

I'm so out of my depth with Winforms apps.



Thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint