using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Serialization;
using CategoryTheory;
using DiagramUI;
using DiagramUI.Interfaces;
using DiagramUI.Utils;
using DiagramUI.Labels;
using Diagram.UI.Interfaces;
using DataPerformer;
using DataPerformer.Interfaces;
using ToolBox;
using Calculator;
using Chart;
using Chart.Interfaces;
using Chart.Drawing.Interfaces;
using Chart.Objects;
using Chart.Panels;
using DataPerformerUI.UserControls;
using DataPerformerUI.Interfaces;
namespace DataPerformerUI.Labels
{
/// <summary>
/// Label of graph
/// </summary>
[Serializable()]
public partial class GraphLabel : UserControlBaseLabel, IBlocking,
INonstandardLabel, IStartStop, IStartStopConsumer, IGraphLabel
{
#region Specific Fields
private DataConsumer consumer;
private string argument = "";
private string condition = "";
private Dictionary<string, string> dicText = new Dictionary<string, string>();
private Dictionary<string, string> texts = new Dictionary<string, string>();
private Dictionary<string, Color> colors = new Dictionary<string, Color>();
private Dictionary<string, bool> stepChart = new Dictionary<string, bool>();
private PictureBox pb = new PictureBox();
private Label lt = new Label();
private string start = "";
private string step = "";
private string stepCount = "";
private Forms.FormGraph form = null;
int dist = 0;
private string points = "";
UserControlGraph child;
#endregion
#region Ctor
/// <summary>
/// Default constructor
/// </summary>
public GraphLabel()
: base(typeof(DataConsumer), "", ResourceImage.Graph.ToBitmap())
{
}
/// <summary>
/// Deserialization constructor
/// </summary>
/// <param name="info">Serialization info</param>
/// <param name="context">Streaming context</param>
protected GraphLabel(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endregion
#region ISerializable Members
/// <summary>
/// ISerializable interface implementation
/// </summary>
/// <param name="info">Serialization info</param>
/// <param name="context">Streaming context</param>
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
info.AddValue("Colors", colors, typeof(Dictionary<string, Color>));
info.AddValue("Argument", argument, typeof(string));
info.AddValue("Condition", condition, typeof(string));
info.AddValue("Texts", texts, typeof(Dictionary<string, string>));
info.AddValue("Start", start, typeof(string));
info.AddValue("Step", step, typeof(string));
info.AddValue("StepCount", stepCount, typeof(string));
info.AddValue("Split", dist);
info.AddValue("StepChart", stepChart, typeof(Dictionary<string, bool>));
info.AddValue("Points", points);
}
#endregion
#region IBlocking Members
bool IBlocking.IsBlocked
{
get
{
IBlocking b = child;
return b.IsBlocked;
}
set
{
IBlocking b = child;
b.IsBlocked = value;
}
}
#endregion
#region Create form members
/// <summary>
/// Initialization
/// </summary>
new public void Initialize()
{
}
/// <summary>
/// Resize
/// </summary>
new public void Resize()
{
}
/// <summary>
/// Creates editor form
/// </summary>
public override void CreateForm()
{
form = new Forms.FormGraph(this);
}
/// <summary>
/// Editor form
/// </summary>
public override object Form
{
get
{
return form;
}
}
/// <summary>
/// Post operation
/// </summary>
public override void Post()
{
child.Post();
}
#endregion
#region Members
internal Dictionary<string, Color> Colors
{
get
{
return colors;
}
}
internal IDesktop OwnDesktop
{
set
{
desktop = value;
}
}
private void ResizeLabel(object sender, EventArgs e)
{
child.SetVisible();
}
void PreInit()
{
child.PreInit();
}
#endregion
#region Overriden Members
/// <summary>
/// Internal control
/// </summary>
protected override UserControl Control
{
get
{
child = new UserControlGraph(true);
this.Copy(child);
child.ParentLabel = this;
return child;
}
}
/// <summary>
/// Object
/// </summary>
public override ICategoryObject Object
{
get
{
return consumer;
}
set
{
if (!(value is DataConsumer))
{
CategoryException.ThrowIllegalSourceException();
}
consumer = value as DataConsumer;
consumer.Object = this;
child.Consumer = consumer;
}
}
/// <summary>
/// Load operation
/// </summary>
/// <param name="info">Serialization info</param>
/// <param name="context">Streaming context</param>
protected override void Load(SerializationInfo info, StreamingContext context)
{
base.Load(info, context);
try
{
colors = info.GetValue("Colors", typeof(Dictionary<string, Color>)) as Dictionary<string, Color>;
argument = info.GetValue("Argument", typeof(string)) as string;
condition = info.GetValue("Condition", typeof(string)) as string;
texts = info.GetValue("Texts", typeof(Dictionary<string, string>)) as Dictionary<string, string>;
start = info.GetValue("Start", typeof(string)) as string;
step = info.GetValue("Step", typeof(string)) as string;
stepCount = info.GetValue("StepCount", typeof(string)) as string;
dist = info.GetInt32("Split");
stepChart = info.GetValue("StepChart", typeof(Dictionary<string, bool>)) as Dictionary<string, bool>;
points = info.GetString("Points");
}
catch (Exception ex)
{
ex.Log();
}
}
#endregion
#region IGraphLabel Members
Dictionary<string, Color> IGraphLabel.Colors
{
get
{
return colors;
}
set
{
colors = value;
}
}
Dictionary<string, bool> IGraphLabel.StepChart
{
get
{
return stepChart;
}
set
{
stepChart = value;
}
}
string IGraphLabel.Argument
{
get
{
return argument;
}
set
{
argument = value;
}
}
int IGraphLabel.SplitDistance
{
get
{
return dist;
}
set
{
dist = value;
}
}
string IGraphLabel.Condition
{
get
{
return condition;
}
set
{
condition = value;
}
}
Dictionary<string, string> IGraphLabel.Texts
{
get
{
return texts;
}
set
{
texts = value;
}
}
string IGraphLabel.Start
{
get
{
return start;
}
set
{
start = value;
}
}
string IGraphLabel.Step
{
get
{
return step;
}
set
{
step = value;
}
}
string IGraphLabel.StepCount
{
get
{
return stepCount;
}
set
{
stepCount = value;
}
}
string IGraphLabel.Points
{
get
{
return points;
}
set
{
points = value;
}
}
#endregion
#region IStartStop Members
void IStartStop.Action(object type, bool start)
{
IStartStop ss = child;
ss.Action(type, start);
}
#endregion
#region IStartStopConsumer Members
public IStartStop StartStop
{
get
{
IStartStopConsumer ssc = child;
return ssc.StartStop;
}
set
{
IStartStopConsumer ssc = child;
ssc.StartStop = value;
}
}
#endregion
}
}