using System;
using System.Collections;
using System.IO;
namespace Netron.Diagramming.Core {
// ----------------------------------------------------------------------
///
/// Our custom "clipboard" for copying diagram elements (or anything else
/// for that matter) to.
///
// ----------------------------------------------------------------------
public static class NetronClipboard {
// ------------------------------------------------------------------
///
/// The items on the clipboard.
///
// ------------------------------------------------------------------
static ArrayList items = new ArrayList();
// ------------------------------------------------------------------
///
/// Gets the collection of all items.
///
// ------------------------------------------------------------------
public static ArrayList Items {
get {
return items;
}
}
// ------------------------------------------------------------------
///
/// Adds the item to the collection.
///
/// object
/// int
// ------------------------------------------------------------------
public static int Add(object item) {
return items.Add(item);
}
public static int AddStream(MemoryStream stream) {
return items.Add(stream);
}
// ------------------------------------------------------------------
///
/// Clears the collection.
///
// ------------------------------------------------------------------
public static void Clear() {
items.Clear();
}
// ------------------------------------------------------------------
///
/// Returns if we have any items of the type specified.
///
/// Type
/// bool
// ------------------------------------------------------------------
public static bool ContainsData(Type type) {
foreach (Object obj in items) {
if (obj.GetType() == type) {
return true;
}
}
return false;
}
// ------------------------------------------------------------------
///
/// Gets all items of the type specified.
///
///
///
// ------------------------------------------------------------------
public static ArrayList GetAll(Type type) {
ArrayList subitems = new ArrayList();
foreach (Object obj in items) {
if (obj.GetType() == type) {
subitems.Add(obj);
}
}
return subitems;
}
// ------------------------------------------------------------------
///
/// Returns the FIRST item found that has the type specified.
///
/// Type
/// object
// ------------------------------------------------------------------
public static object Get(Type type) {
foreach (Object obj in items) {
if (obj.GetType() == type) {
return obj;
}
}
return null;
}
public static MemoryStream GetMemoryStream() {
foreach (object obj in items) {
if (obj is MemoryStream) {
return obj as MemoryStream;
}
}
return null;
}
}
}