Jump to content
Software FX Community

To questions about ToolBarObj and Personalizing a Chart


User (Legacy)

Recommended Posts

- On the ToolBarObj

I can disable the Print button on the ToolBar with :

mainChart.Commands[(int) SoftwareFX.ChartFX.CommandID.Print].Enabled =

false; But I want to hide it and turn it back on later. I havn't found the

the Visible attribute to turn it off... How is this done ... Do I have to

remove it from the toolbar an add it again when I wnat to use it?

- Personalizing a Chart

Is it possible to get the XML code for in Personalizing a Chart int a string

varible. I am using one Settings.xml file for all my settings in my

program. Many charts can be opened in program. What I need is to get the

personalizing code for all the users charts and put it ino this file

(settings.xml) and then when I open my program again I need to restore this

code from my settings file and open the charts as it was when my user closed

it? Is this possible?

Thank you very much

Best regards

Kristjan

Link to comment
Share on other sites

  • 3 weeks later...

I use the Perzonilised options to save settings for my chart in my own 

settings file. (I used the snippet above, thank you very much) It seems to

me that the PriceStudies and TechnicalStudies does not save in the

personlized xml-file. What is the best way to save the chart with the

financial studies(panes)?

Another question

I have a problem with TechnicalStudies and PriceStudies and price studies

when I change the dates in my chart. Do I have to recalculate the

PriceStudies and TechnicalStudies when I change the dates or..?

In my program I bind the data with the data and choose certain dates. If I

open A technical studie f.ex. MACD or Volume and change dates after that

then I have a crash. I use the same process to set upp the chart and bind

the data if I change the Dates.

The Error:

Specified argument was out of the range of valid values.

Parameter name: Index was out of range. Must be non-negative and less than

the size of the collection.

mscorlib

at System.Collections.CollectionBase.RemoveAt(Int32 index)

at SoftwareFX.ChartFX.UserLegendBoxItemCollection.RemoveAt(Int32 index)

at

SoftwareFX.ChartFX.UserLegendBoxItemCollection.Remove(UserLegendBoxItem

item)

at SoftwareFX.ChartFX.Financial.WinForms.Analytical.3L(Study X9, Int32

XA, Int32 XB)

at SoftwareFX.ChartFX.Financial.WinForms.Study.4Q(Boolean ZT)

at SoftwareFX.ChartFX.Financial.WinForms.PricesStudy.set_Visible(Boolean

value)

at SoftwareFX.ChartFX.Financial.WinForms.Analytical.2N(Object VK,

CategoryEventArgs VL)

at SoftwareFX.ChartFX.CategBar.WinForms.CategoryBar.R(Category AK,

ICategoryObject AL, CategoryEvent AM, Int32 AN, Int32 AO)

at SoftwareFX.ChartFX.CategBar.WinForms.CategoryBar.0B(Category BG,

ICategoryObject BH, CategoryEvent BI, Int32 BJ, Int32 BK)

at SoftwareFX.ChartFX.CategBar.WinForms.CategoryList.06(MouseEventArgs

DG)

at SoftwareFX.ChartFX.CategBar.WinForms.CategoryBar.06(MouseEventArgs BF)

at SoftwareFX.ChartFX.G.OnMouseUp(MouseEventArgs e)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons

button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,

IntPtr wparam, IntPtr lparam)

"Software FX Support" <support@softwarefx.com> wrote in message

news:Ytc62iiuFHA.1332@webserver3.softwarefx.com...

> Kristj

Link to comment
Share on other sites

No worry for the delay, just thanks for the answer.

I have a problem when I use the code you gave me, regarding that I want to

save my Technical studies in my settings file.

My code is like this :

private string ExportChartSettings()

{

mainChart.TemplateMask |= FileMask.Extensions | FileMask.Tools;

MemoryStream memStream = new MemoryStream();

mainChart.Export(FileFormat.BinaryTemplate,memStream);

string sTemplate = System.Convert.ToBase64String(memStream.ToArray());

memStream.Close();

return sTemplate;

}

private void ImportChartSettings( string sTemplate )

{

MemoryStream memStream = new MemoryStream();

byte[] buffer = Convert.FromBase64String( sTemplate );

MemoryStream stream = new MemoryStream( buffer );

mainChart.Import(stream);

memStream.Close();

}

If I try to export my settings everything works fine, and I get my

settingstring. Then I try to recover my settings with ImportChartSettings I

get this error::

Do you have any Idea what is going on here?

Index was outside the bounds of the array.

ChartFX.Base

at SoftwareFX.ChartFX.CommandBar.H(Int32 6B)

at SoftwareFX.ChartFX.CommandBar.G(Int32 6A)

at SoftwareFX.ChartFX.Base.ToolItem.set_CommandID(Int32 value)

at SoftwareFX.ChartFX.Base.ToolItem.set_5U(ToolBar C5)

at SoftwareFX.ChartFX.Base.ToolBar.7(Boolean AS, IPersistBase AT)

at SoftwareFX.ChartFX.00.7D(String 1AP, Object 1AQ, String 1AR, ObjFlags

1AS, Int64 1AT)

at SoftwareFX.ChartFX.00.Serialize(String sName, Object obj, String

sType, ObjFlags flags)

at SoftwareFX.ChartFX.Financial.WinForms.Y.8Y(Boolean 0PD, IPersistBase

0PE)

at SoftwareFX.ChartFX.Financial.WinForms.Financial.0B(Boolean 0Q6,

IPersistBase 0Q7)

at SoftwareFX.ChartFX.00.7D(String 1AP, Object 1AQ, String 1AR, ObjFlags

1AS, Int64 1AT)

at SoftwareFX.ChartFX.00.Serialize(String sName, Object obj, String

sType, ObjFlags flags)

at SoftwareFX.ChartFX.ExtensionManager.35(Boolean 2B0, IPersistBase 2B1)

at SoftwareFX.ChartFX.00.7D(String 1AP, Object 1AQ, String 1AR, ObjFlags

1AS, Int64 1AT)

at SoftwareFX.ChartFX.00.Serialize(String sName, Object obj, String

sType, ObjFlags flags)

at SoftwareFX.ChartFX.ChartCore.FL(Boolean 1TE, IPersistBase 1TF, Boolean

1TG)

at SoftwareFX.ChartFX.ChartCore.GA(IPersistBase 1UH)

at SoftwareFX.ChartFX.ChartCore.Import(FileFormat format, Stream stream)

at SoftwareFX.ChartFX.ChartCore.Import(Stream stream)

at Client.AnalyzeNewForm.ImportChartSettings(String sTemplate) in

c:\vss\client\analyzenewform.cs:line 3266

at Client.AnalyzeNewForm.button2_Click(Object sender, EventArgs e) in

c:\vss\client\analyzenewform.cs:line 4057

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons

button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,

IntPtr wparam, IntPtr lparam)

I think I have found out the problem regarding the second question, I'll

comae back on that later if I have to, thanx anyway.

Best regards

Kristj

post-2107-13922381038928_thumb.gif

Link to comment
Share on other sites

Thank you very much for your time and help.

The problem her is :

If I format my chart .. add some buttons on the toolbar and remove others,

then it will crash.

If I run import and export without formating the chart everything seems to

work??

Any suggestion?

Best regards

Kristjan

private string ExportChartSettings(){

mainChart.TemplateMask |= FileMask.Extensions /*| FileMask.Tools*/;

MemoryStream memStream = new MemoryStream();

mainChart.Export(FileFormat.BinaryTemplate,memStream);

string s = memStream.Length.ToString();

string sTemplate = System.Convert.ToBase64String(memStream.ToArray());

memStream.Flush();

memStream.Close();

mainChart.TemplateMask &= ~FileMask.Extensions /*| FileMask.Tools*/;

return sTemplate;}

private void ImportChartSettings( string sTemplate ){

mainChart.TemplateMask |= FileMask.Extensions /*| FileMask.Tools*/;

MemoryStream memStream = new MemoryStream();

byte[] buffer = Convert.FromBase64String( sTemplate );

MemoryStream stream = new MemoryStream( buffer );

string s = stream.Length.ToString();

mainChart.Import(stream);

memStream.Flush();

memStream.Close();

mainChart.TemplateMask &= ~FileMask.Extensions /*| FileMask.Tools*/;}

private void FormatChart(){

mainFinancial.ToolBarObj[2] = (int) CommandID.PrintDialog;

// New buttons

SoftwareFX.ChartFX.CommandBar cmds = mainFinancial.ToolBarObj.Commands;

int nPict = cmds.AddPicture(imageListMenu.Images[3]);

cmds[20].Style = CommandStyle.Transposed;

cmds[20].Picture = nPict;

mainFinancial.ToolBarObj[4] = 20;

nPict = cmds.AddPicture(imageListMenu.Images[5]);

cmds[21].Style = CommandStyle.Transposed;

cmds[21].Picture = nPict;

mainFinancial.ToolBarObj[5] = 21;

// Disable other buttons

mainFinancial.ToolBarObj.RemoveAt(16);

mainFinancial.ToolBarObj.RemoveAt(6);

mainFinancial.ToolBarObj.RemoveAt(0);

mainChart.Commands[(int) CommandID.ExportClipboard].RemoveSubCommand(0);

mainChart.Commands[(int) CommandID.ContextMenuBack].RemoveSubCommand(7);

mainChart.Commands[(int) CommandID.ContextMenuBack].RemoveSubCommand(4);

mainChart.Commands[(int) CommandID.ContextMenuBack].RemoveSubCommand(0);

mainChart.Commands[(int) CommandID.ContextMenuSeries].RemoveSubCommand(0);

mainChart.Commands[(int) CommandID.ContextMenuAxis].RemoveSubCommand(2);

mainChart.Commands.AddCommand(4);

mainChart.Commands[22].Style = CommandStyle.Transposed;

nPict = cmds.AddPicture(imageListMenu.Images[0]);

mainChart.Commands[22].Picture = nPict;

mainChart.Commands[(int)

CommandID.ContextMenuSeries].InsertSubCommands(1,1);

mainChart.Commands[(int) CommandID.ContextMenuSeries].SubCommandID[1] =

(int) SoftwareFX.ChartFX.CommandID.ExportClipboard;

mainChart.Commands[(int)

CommandID.ContextMenuSeries].InsertSubCommands(1,1);

mainChart.Commands[(int) CommandID.ContextMenuSeries].SubCommandID[1] = 22;

mainChart.Commands[(int) CommandID.ContextMenuBack].InsertSubCommands(1,0);

mainChart.Commands[(int) CommandID.ContextMenuBack].SubCommandID[0] = (int)

SoftwareFX.ChartFX.CommandID.ExportClipboard;

mainChart.Commands[(int) CommandID.ContextMenuBack].InsertSubCommands(1,0);

mainChart.Commands[(int) CommandID.ContextMenuBack].SubCommandID[0] = 22;

// Set Chart

mainChart.BackColor = Color.White;

mainChart.InsideColor = Color.White;

mainChart.LineWidth = 0;

mainChart.UserLegendBoxObj.Docked = Docked.Bottom;

mainChart.UserLegendBox = true;

mainChart.AxisY.Gridlines = true;

mainChart.AxisY.Grid.Color = Color.FromArgb(240,240,240);

mainChart.Highlight.Enabled = false;

SoftwareFX.ChartFX.DataEditor dataEditor = mainChart.DataEditorObj;

dataEditor.Alignment = SoftwareFX.ChartFX.ToolAlignment.Center;

dataEditor.Docked = SoftwareFX.ChartFX.Docked.Bottom;

mainChart.SmoothFlags = SoftwareFX.ChartFX.SmoothFlags.None;

mainChart.DataEditorObj.ShowMarkers = false;

mainChart.DataEditorObj.ShowHeader = true;

mainChart.SerLegBoxObj.ToolBorder = SoftwareFX.ChartFX.ToolBorder.External;

mainChart.Font = new Font( "arial", 7 , FontStyle.Regular);

mainChart.DataEditorObj.Font=new System.Drawing.Font("arial",7);}

"Software FX Support" <support@softwarefx.com> wrote in message

news:m8dew1X1FHA.3504@webserver3.softwarefx.com...

> Yes.

> You need to set the TemplateMask when you read (Import) as well.

> The code should be exactly the same just replace export with import and

> also you will need to seek to the beginning of the stream(which you are

> doing when you create a new memorystream from your buffer).

>

> -c

>

> "Kristj

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Hello Charles

One question

When I am saving my chart settings (with this code below) the lengt of the

string is from 70K to 170K, is it possible to reduce the size?

I only need to save general settings and the extension part. Should I use

the flags and wich one?

Can I disable some features with this code?

mainChart.TemplateMask &= ~FileMask.Data | ~FileMask.DataBind;

Best regards

Kristj

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...