我可以将windos转换为web应用程序 [英] hot can i convert windos froms to web applicaation

查看:63
本文介绍了我可以将windos转换为web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个人

我必须将Windows应用程序转换为Web应用程序和一个表单的代码。但我该如何转换呢?

它是在PictureBox工具后面写的,所以哪个工具在网络工具中遇到它。



使用系统;使用System.Drawing 
;
使用System.Windows.Forms;
使用DPUruNet;

命名空间UareUSampleCSharp
{
公共部分类捕获:表格
{
///< summary>
///保持主窗体包含所有SDK操作共有的许多功能。
///< / summary>
public Form_Main _sender;


public Capture()
{
InitializeComponent();
}

///< summary>
///初始化表单。
///< / summary>
///< param name =sender>< / param>
///< param name =e>< / param>
private void Capture_Load(object sender,EventArgs e)
{
//重置变量
pbFingerprint.Image = null;

if(!_sender.OpenReader())
{
this.Close();
}

if(!_sender.StartCaptureAsync(this.OnCaptured))
{
this.Close();
}
}

///< summary>
///捕获指纹时的处​​理程序。
///< / summary>
///< param name =captureResult>包含有关指纹捕获的信息和数据< / param>
public void OnCaptured(CaptureResult captureResult)
{
try
{
//检查捕获质量,如果不好则抛出错误。
如果(!_sender.CheckCaptureResult(captureResult))返回;

//创建位图
foreach(fid.Fiv fiv in captureResult.Data.Views)
{
SendMessage(Action.SendBitmap,_sender.CreateBitmap(fiv。 RawImage,fiv.Width,fiv.Height));
}
}
catch(exception ex)
{
//发送错误信息,然后关闭表格
SendMessage(Action.SendMessage,错误: + ex.Message);
}
}

///< summary>
///关闭窗口。
///< / summary>
private void btnBack_Click(System.Object sender,System.EventArgs e)
{
this.Close();
}

///< summary>
///关闭窗口。
///< / summary>
private void Capture_Closed(object sender,EventArgs e)
{
_sender.CancelCaptureAndCloseReader(this.OnCaptured);
}

#region SendMessage
private enum Action
{
SendBitmap,
SendMessage
}
private delegate void SendMessageCallback(Action action,object payload);
private void SendMessage(Action action,object payload)
{
try
{
if(this.pbFingerprint.InvokeRequired)
{
SendMessageCallback d = new SendMessageCallback(SendMessage);
this.Invoke(d,new object [] {action,payload});
}
else
{
switch(action)
{
case Action.SendMessage:
MessageBox.Show((string)payload) ;
休息;
case Action.SendBitmap:
pbFingerprint.Image =(Bitmap)payload;
pbFingerprint.Refresh();
休息;
}
}
}
catch(例外)
{
}
}
#endregion

private void pbFingerprint_Click(object sender,EventArgs e)
{

}
}
}

解决方案

你无法真正转换它。应用程序的概念非常非常不同。 ASP.NET应用程序开发起来要困难得多,因为编程模型完全不同,因为有客户端和服务器部分,而且HTTP是无状态。您可以从头开始编写应用程序,只使用大多数现有代码进行引用。应该抛弃与UI相关的所有内容,其他所有内容都可以重复使用。我希望,在您现有的应用程序中,UI与其他代码完全隔离。如果没有,你必须从头开始写几乎所有的东西;在这种情况下,明确隔离下一个项目中的UI。



-SA


hii everyone
i have to convert windows application to web application and this code of one form. but how can i convert it?
it is written behind PictureBox tool, so which tool meet it in web tools.

using System;
using System.Drawing;
using System.Windows.Forms;
using DPUruNet;

namespace UareUSampleCSharp
{
    public partial class Capture : Form
    {
        /// <summary>
        /// Holds the main form with many functions common to all of SDK actions.
        /// </summary>
        public Form_Main _sender;


        public Capture()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Initialize the form.
        /// </summary>
        ///<param name="sender"></param>
        /// <param name="e"></param>
        private void Capture_Load(object sender, EventArgs e)
        {
            // Reset variables
            pbFingerprint.Image = null;

            if (!_sender.OpenReader())
            {
                this.Close();
            }

            if (!_sender.StartCaptureAsync(this.OnCaptured))
            {
                this.Close();
            }
        }

        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        public void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult)) return;

                // Create bitmap
                foreach (Fid.Fiv fiv in captureResult.Data.Views)
                {
                    SendMessage(Action.SendBitmap, _sender.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }

        /// <summary>
        /// Close window.
        /// </summary>
        private void btnBack_Click(System.Object sender, System.EventArgs e)
        {
            this.Close();
        }

        /// <summary>
        /// Close window.
        /// </summary>
        private void Capture_Closed(object sender, EventArgs e)
        {
            _sender.CancelCaptureAndCloseReader(this.OnCaptured);
        }

        #region SendMessage
        private enum Action
        {
            SendBitmap,
            SendMessage
        }
        private delegate void SendMessageCallback(Action action, object payload);
        private void SendMessage(Action action, object payload)
        {
            try
            {
                if (this.pbFingerprint.InvokeRequired)
                {
                    SendMessageCallback d = new SendMessageCallback(SendMessage);
                    this.Invoke(d, new object[] { action, payload });
                }
                else
                {
                    switch (action)
                    {
                        case Action.SendMessage:
                            MessageBox.Show((string)payload);
                            break;
                        case Action.SendBitmap:
                            pbFingerprint.Image = (Bitmap)payload;
                            pbFingerprint.Refresh();
                            break;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
        #endregion

        private void pbFingerprint_Click(object sender, EventArgs e)
        {

        }
    }
}

解决方案

You cannot really "convert" it. The concepts of the application is very, very different. ASP.NET applications are much harder to develop, because programming model it totally different, because there are client and server parts, and because HTTP is stateless. The best you can do it writing the application from scratch, using most you existing code only for references. Everything related to UI should be thrown out, everything else can be re-used. I hope, in you existing application, UI was perfectly isolated from other code. If not, you have to write from scratch pretty much everything; in this case, clearly isolate UI in your next project.

—SA


这篇关于我可以将windos转换为web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆