Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

share_holder

@share_holder
About
Posts
18
Topics
3
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • 2D FFT / DFT + NxN Convolution (image processing) [SOLVED] [modified]
    S share_holder

    Have you seen how does Matlab Function fft work? Source Code available and may be useful... Regards, D

    C# csharp java winforms com graphics

  • Multi-Form Set Correct Output
    S share_holder

    Thank you, I will try first option. Regards, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    V. wrote:

    - or find a way to find out who requested the information (maybe it is in the response) and dispatch the information to the correct form.

    That´s why I´ve post here, looking for some ideas to do this ;) But, each form has it´s facade, as I wrote in the Main() call:

    frmPpal form = new frmPpal(new DayTradeFacade());

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    Yes, you are right. But, I think it´s not relevant for setting the proper output window. I mean, facade is just the class for events, but each event is triggered to the proper form. I just need to focus in the proper form. I´ve got a FormList, so for example what I´ve done is:

    TTS_RealTime.FormsList[0].textBoxOutput1.WriteLine("Normal: " + openTime);

    Just need to set FormList[index] to the form from where the subcription was made. Any idea? Ty, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    Hello Wayne, I´ve just post some code in Bill´s answer, I hope it´s enough information; otherwise please tell me and I´ll post more code and explanations. Ty in advance, regards, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    Hello V. I´ve post a bit of code in the replay to Bill. Hope this helps, Regards, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    Well, sorry for the missed out information, I´ll try to post a bit of code now: Here is the code for opening several forms (3 in this case). By now its just using a "for" loop, but it will be managed with an UI control for opening as many forms as the user needs:

    static void Main()
    {

           FormsList = new List<frmPpal>();
           Conn\_control = new ConnectionController();
           for (int i = 0; i < 3; i++)
           {
               frmPpal form = new frmPpal(new DayTradeFacade());
               FormsList.Add(form);
               form.Show();
    
           }
           Application.Run();
    

    Now the code of the frmPPal.cs relative to Connect button and Subscribe button (Receive Data):

    private void buttonReconnect_Click(object sender, EventArgs e)
    {
    if (!Connected)
    {
    ThreadPool.QueueUserWorkItem(delegate
    {
    //These lines are for focusing the proper TextBox when connecting,
    DayTradeFacade.SetMessagesTextBox(textBoxMessages);
    DayTradeFacade.SetTesting1TextBox(textBoxOutput1);
    DayTradeFacade.SetTesting2TextBox(textBoxOutput2);

                    Facade.Account.AccountValueUpdated += UpdateListViewAccountValues;
                    Facade.Portfolio.PortfolioChanged += UpdateListViewPortfolio;
                    
                    Facade.ConnectToTws();
    
                }, null);
            }
            else
            {
               textBoxMessages.WriteLine("Already connected.");
            }
        }
    

    And now Receive Data:

    private void buttonSubscribeToPresetFutures_Click(object sender, EventArgs e)
    {
    if (!Connected)
    {
    textBoxMessages.WriteLine(NotConnectedErrorMessage);
    return;
    }
    if (!FuturesTradingHours.NowIsInsideTradingHours())
    {
    textBoxMessages.WriteLine(
    "Can only subscribe to futures between " + FuturesTradingHours.MarketOpenTime
    + " and " + FuturesTradingHours.FiveSecondPriceBarSubscriptionUnsubscribeTime + ".");
    return;
    }
    //DPT
    textBoxOutput1.Clear();
    //FIN

            Facade.SubscriptionManager.SubscribeToFiveSecondPriceBars(\_pres
    
    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    The main problem is that the API was not prepared for being used as multi-thread, and now if I connect and receive data in different forms, it shows all the data in the Output Window of the last Form that the user clicks on Receive Data Thanks, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    No, I will try to be more clear now. If I have, for example, 3 forms opened, the user can connect and receive data independently. The data tha is going to receive is different in time and size. Form1: Opened and Connected. Receiving Data = data1 from t=0; Form2: Opened and Connected. Receiving Data = data2 from t=1; Form3: Opened and Connected. Receiving Data = data3 from t=2; Once the three of them are receiving data, the 3 forms´ output windows must show the data that they are receiving, not syncronized between them and not the same data. I hope it´s better to understand now. Thanks, D.

    C# question json tutorial

  • Multi-Form Set Correct Output
    S share_holder

    Hi again! This is my scenario: I have an API that opens several forms (instances of the class frmPpal.cs) I save a FormList such as:

    FormsList = new List<frmPpal>();

    Once all forms are opened, user can push in a Connect button and also in a Receive Data button. When Receive Data is clicked, there is also an Output Window (in each form) which shows sequentially all the received data (each 5 seconds, aprox) My doubt is how can I set the proper Output Window (chosing from all the Forms that are opened) for showing the received data. For example, if I have 3 Forms, each one must show in its Output window the Data that it requested. All the Forms are opened and can be closed by user, and user can also click on Connect and Receive Data whenever he wants. Any ideas? Ty in advance. Regards, D.

    C# question json tutorial

  • Predicate Conditions for Find, First...Methods
    S share_holder

    Hi there, I´m trying to understand how Methods with Predicate and Conditions work; it´s a little confusing for me. For example, we have a 10-positions array of bytes, such as

    public byte[] Client_ID_List { get; private set; }

    , it´s initialized by:

    Client_ID_List = new byte[8];

    After a while, I want to find the first position in this array that has '0' value. I have seen that First method returns the first element that satisfies a condition, but I don´t really understand how Predicate argument works. Any help or simple example will be very useful. Or maybe any other idea to solve this issue. Kind Regards, D.

    C# help data-structures tutorial

  • Run Multiple Forms
    S share_holder

    I´ve seen this post update now, thanks bill. I have done this:

    public static List<frmPpal> FormsList { get; private set; }

        static void Main()
        {
    
            FormsList = new List<frmPpal>();
            for (int i = 0; i < 8; i++)
            {
                frmPpal form = new frmPpal(new DayTradeFacade());
                FormsList.Add(form);
                form.Show();
    
            }
    
            Application.Run();
    

    So now, I can access to the FormList from the other classes of the Project. But how can I know which one is active? I mean, from which one has the user called. ActiveForm doesnt seem to work properly because frmPpal is not a default Form. Any suggestions? Thank you for your time and help, Regards, D.

    C# question

  • Run Multiple Forms
    S share_holder

    Thanks Bill, that will be useful when handling the quantity of forms that must be launched or when they must be closed, but now I´m in a lower layer so I don´t care about it until I can handle the eight forms independently. Regards, D.

    C# question

  • Run Multiple Forms
    S share_holder

    Thanks Mark ;)

    C# question

  • Run Multiple Forms
    S share_holder

    Thanks Bill, Looks very useful the feature about checking the number of openforms for exiting the app. According to your question, I must develop this application to be able to open up to 8 different forms, because that´s the maximum number of simultaneous connections that the external server can handle from a client (just changing the client_id number). So, by now, I just have to open these 8 forms when launching the application and see how to handle them like they were independent one from the others. After this, I´ll do the upper layer for managing how many forms can be launched and all the control stuff. Thanks again for your time, Regards, D.

    C# question

  • Run Multiple Forms
    S share_holder

    I mean, Application.Run() has 3 overloads, one of them is Application.Run(Form mainForm). I want to call it simultaneously as many forms as I´ve opened before, but the problem is that Application.Run cannot be multiple-called. I hope it´s clear enough what I need and someone can help me. Ty, D.

    C# question

  • Run Multiple Forms
    S share_holder

    Thank you both guys, but there is a problem with this solution. Since Application.Run() operates with the same thread, it is not able to discriminate which is the form that is being used by user (buttons, data, client_id...) But I think that must be re-coded by me... Regards, D.

    C# question

  • Run Multiple Forms
    S share_holder

    Hi there! I´m developing an application to manage financial Data, but now I need it to open several connection threads from the same WinForm called several times. I´m triying to call Application.Run (new formPpal) several times from the static void Main(), but it doesn´t create the new form until the current one is closed. any ideas? Thank you! ;)

    C# question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups