using System;
using System.Collections.Generic;
using System.Drawing;
using FastReport.Cloud.StorageClient;
using FastReport.Messaging;
using FastReport.Wizards;
namespace FastReport.Utils
{
partial class ObjectInfo
{
#region Private Fields
private int imageIndex;
private int buttonIndex;
private int flags;
private bool multiInsert;
#endregion Private Fields
#region Public Properties
///
/// Image index.
///
public int ImageIndex
{
get { return imageIndex; }
set { imageIndex = value; }
}
///
/// Button index.
///
public int ButtonIndex
{
get { return buttonIndex; }
set { buttonIndex = value; }
}
///
/// Flags that will be used to create an object instance in the designer.
///
public int Flags
{
get { return flags; }
set { flags = value; }
}
///
/// Indicates whether this object can be inserted several times simultaneously.
///
///
/// This is applied to Line object only.
///
public bool MultiInsert
{
get { return multiInsert; }
set { multiInsert = value; }
}
#endregion Public Properties
#region Private Methods
private void UpdateDesign(Bitmap image, int imageIndex, int buttonIndex = -1)
{
ButtonIndex = buttonIndex;
ImageIndex = imageIndex;
if (image != null)
ImageIndex = Res.AddImage(image);
}
private void UpdateDesign(int flags, bool multiInsert, Bitmap image, int imageIndex, int buttonIndex = -1)
{
UpdateDesign(image, imageIndex, buttonIndex);
Flags = flags;
MultiInsert = multiInsert;
}
#endregion Private Methods
}
enum ItemWizardEnum : int
{
///
///
///
Report = 0,
///
///
///
ReportItem = 1,
///
///
///
Game = 2
}
partial class RegisteredObjects
{
#region Public Methods
///
/// Registers a new cloud storage client.
///
/// Type of cloud storage client.
/// Text for cloud storage client's menu item.
///
/// The obj must be of type.
///
///
///
/// // register own cloud storage client
/// RegisteredObjects.AddCloud(typeof(MyCloud), "My Cloud");
///
///
public static void AddCloud(Type obj, string text)
{
if (!obj.IsSubclassOf(typeof(Cloud.StorageClient.CloudStorageClient)))
{
throw new Exception("The 'obj' parameter must be of CloudStorageClient type.");
}
InternalAdd(obj, "", null, -1, text);
}
///
/// Registers a new messenger.
///
/// Type of messenger.
/// Text messenger's menu item.
///
/// The obj must be of type.
///
///
///
/// // register own messenger
/// RegisteredObjects.AddMessenger(typeof(MyMessenger), "My Messenger");
///
///
public static void AddMessenger(Type obj, string text)
{
if (!obj.IsSubclassOf(typeof(Messaging.MessengerBase)))
{
throw new Exception("The 'obj' parameter must be of MessengerBase type.");
}
InternalAddMessenger(obj, text);
}
internal static ObjectInfo InternalAddMessenger(Type obj, string text)
{
return InternalAdd(obj, "", null, -1, text);
}
///
/// Registers a new wizard.
///
/// Type of wizard.
/// Image for wizard item.
/// Text for wizard item.
/// true if this wizard creates some items in existing report.
///
/// The obj must be of type.
///
/// This example shows how to register own wizard that is used to create some items in the
/// current report. If you want to register a wizard that will be used to create a new report,
/// set the isReportItemWizard to false.
///
/// // register own wizard
/// RegisteredObjects.AddWizard(typeof(MyWizard), myWizBmp, "My Wizard", true);
///
///
public static void AddWizard(Type obj, Bitmap image, string text, bool isReportItemWizard)
{
if (!obj.IsSubclassOf(typeof(WizardBase)))
throw new Exception("The 'obj' parameter must be of WizardBase type.");
InternalAdd(obj, "", image, -1, text, isReportItemWizard ? 1 : 0, false);
}
#endregion Public Methods
#region Internal Methods
internal static ObjectInfo AddCloud(Type obj, string text, int imageIndex)
{
if (!obj.IsSubclassOf(typeof(Cloud.StorageClient.CloudStorageClient)))
{
throw new Exception("The 'obj' parameter must be of CloudStorageClient type.");
}
return InternalAdd(obj, "", null, imageIndex, text);
}
internal static ObjectInfo AddMessenger(Type obj, string text, int imageIndex)
{
if (!obj.IsSubclassOf(typeof(Messaging.MessengerBase)))
{
throw new Exception("The 'obj' parameter must be of MessengerBase type.");
}
return InternalAdd(obj, "", null, imageIndex, text);
}
internal static void AddWizard(Type obj, int imageIndex, string text, ItemWizardEnum itemWizardEnum)
{
InternalAdd(obj, "", null, imageIndex, text, (int)itemWizardEnum, false);
}
internal static FunctionInfo FindFunctionsRoot()
{
List list = new List();
Functions.EnumItems(list);
foreach (FunctionInfo item in list)
{
if (item.Name == "Functions")
return item;
}
return null;
}
#endregion Internal Methods
}
}