samuelGrahame / ClassicForms

ClassicForms - Compile and Run your Windows Forms applications on the browser.
Apache License 2.0
35 stars 4 forks source link

nice repo #1

Closed gitlsl closed 5 years ago

gitlsl commented 6 years ago

~... if web server can response form click event will be better?... some crud with web server seems very cool

samuelGrahame commented 6 years ago

yeah well, that is one think i might implement, To do this - i might just have it so you set in your application - where your asp.net server is. so when a form is first loaded - it will register and get a Unique ID. because each element has a unique name because the form is generated from the designer.

One thing tho, I don't want to force a network layer. (so that people can have client side code)

samuelGrahame commented 6 years ago

not sure if this is okay.

what about this:

`[ServerSide] private void button9_Click(object sender, EventArgs e) { var arg = e as ServerEventArgs;

        if(arg != null)
        {
            var result = arg.Result;
        }

    }`

just mark the method assigned to the event. - it will hit server side, then invoke the local event when done.

gitlsl commented 6 years ago

@samuelGrahame yes just as normal winform app ,
we can give a network layer interface and a default implement

samuelGrahame commented 6 years ago

@gitlsl I have setup a custom button - which is just inherited from button:

` public class ServerButton : Button { public event SeverSendingEventHandler Sending; public event SeverSentEventHandler Sent;

    protected override void OnClick(EventArgs e)
    {

if BRIDGE

        if (!ServerButtonHelper.OnClickServer(this))
            base.OnClick(e);

endif

    }

    public void RaiseSendingEvent(SeverSendingEventArgs e)
    {
        if(Sending != null)
        {
            Sending.Invoke(this, e);
        }
    }

    public void RaiseSentEvent(ServerSentEventArgs e)
    {
        if (Sent != null)
        {
            Sent.Invoke(this, e);
        }
    }

    public bool IsSendingEventNull()
    {
        return Sending == null;
    }

    public bool IsSentEventNull()
    {
        return Sent == null;
    }
}

`

and the usage is like this:

` private void serverButton1_Sending(object sender, SeverSendingEventArgs e) { e.Data = "this is a test"; e.ContentType = "text/plain";
}

    private void serverButton1_Sent(object sender, ServerSentEventArgs e)
    {
        if(e.ex != null)
        {

        }
    }

`

i think this is a good start. - and using the attribute. it might be good for just simple gets.

etc click a button to change a state of an object - etc unlock or lock a document.