示例#1
0
 static void Main()
 {
     FormScan formscan = null;
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     formscan = new FormScan();
     if (!formscan.ExitRequested())
     {
         Application.Run(formscan);
     }
     formscan = null;
     Application.Exit();
 }
示例#2
0
        static void Main()
        {
            FormScan formscan = null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            formscan = new FormScan();
            if (!formscan.ExitRequested())
            {
                Application.Run(formscan);
            }
            formscan = null;
            Application.Exit();
        }
示例#3
0
        static void Main()
        {
            FormScan formscan = null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            formscan = new FormScan();


            var server = new WebSocketServer("ws://0.0.0.0:8181");

            server.Start(socket =>
            {
                clientSocket     = socket;
                socket.OnOpen    = () => formscan.Invoke(new MethodInvoker(formscan.Show));
                socket.OnClose   = () => formscan.Invoke(new MethodInvoker(formscan.Hide));
                socket.OnMessage = message => socket.Send(message);
            });
            NotifyIcon notifyIcon1 = new NotifyIcon();

            notifyIcon1.Icon            = new System.Drawing.Icon(@"scanner.ico");
            notifyIcon1.Text            = "GC Scan Module";
            notifyIcon1.Visible         = true;
            notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
            notifyIcon1.BalloonTipText  = "Module GC Scan est lancé !";
            notifyIcon1.BalloonTipTitle = "Information";
            notifyIcon1.ShowBalloonTip(1000);

            if (!formscan.ExitRequested())
            {
                Application.Run();
            }
            formscan = null;


            Application.Exit();
        }
示例#4
0
        public FormSetup(FormScan a_formscan, ref TWAIN a_twain, string a_szProductDirectory)
        {
            TWAIN.STS sts;
            string    szStatus;
            string    szCapability;
            string    szUsrUiSettings;

            // Init stuff...
            InitializeComponent();

            // More init stuff...
            this.FormClosing += new FormClosingEventHandler(FormSetup_FormClosing);

            // Init more stuff (the order matters).  ApplicationData means the following:
            // Windows:     C:\Users\USERNAME\AppData\Roaming (or C:\Documents and Settings\USERNAME\Application Data on XP)
            // Linux:       /home/USERNAME/.config (or /root/.config for superuser)
            // Mac OS X:    /Users/USERNAME/.config (or /var/root/.config for superuser)
            m_formscan          = a_formscan;
            m_twain             = a_twain;
            m_szTwainscanFolder = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "twain"), "twaincsscan");
            m_szSettingsFolder  = Path.Combine(m_szTwainscanFolder, "settings");
            m_szSettingsFolder  = Path.Combine(m_szSettingsFolder, a_szProductDirectory);
            if (!Directory.Exists(m_szTwainscanFolder))
            {
                try
                {
                    Directory.CreateDirectory(m_szTwainscanFolder);
                }
                catch (Exception exception)
                {
                    TWAINWorkingGroup.Log.Error("exception - " + exception.Message);
                    m_szTwainscanFolder = Directory.GetCurrentDirectory();
                }
            }

            // Restore values...
            m_textboxFolder.Text        = RestoreFolder();
            m_textboxUseUiSettings.Text = "";

            // Check for support of Custom DS Data...
            szStatus = "";
            TWAIN.TW_CAPABILITY twcapability = default(TWAIN.TW_CAPABILITY);
            m_twain.CsvToCapability(ref twcapability, ref szStatus, "CAP_CUSTOMDSDATA,0,0,0");
            sts          = m_twain.DatCapability(TWAIN.DG.CONTROL, TWAIN.MSG.GETCURRENT, ref twcapability);
            szCapability = m_twain.CapabilityToCsv(twcapability, true);
            if ((sts != TWAIN.STS.SUCCESS) || (!szCapability.EndsWith(",1") && !szCapability.EndsWith(",TRUE")))
            {
                m_labelUseUiSettings.Enabled   = false;
                m_textboxUseUiSettings.Enabled = false;
                m_buttonSaveUiSettings.Enabled = false;
                m_buttonUseUiSettings.Enabled  = false;
            }

            // Restore the last saved snapshot...
            else
            {
                m_textboxUseUiSettings.Text = RestoreSetting();
                if (m_textboxUseUiSettings.Text != "")
                {
                    szUsrUiSettings = Path.Combine(m_szSettingsFolder, m_textboxUseUiSettings.Text);
                    if (File.Exists(szUsrUiSettings))
                    {
                        m_formscan.RestoreSnapshot(szUsrUiSettings);
                    }
                    else
                    {
                        m_textboxUseUiSettings.Text = "";
                    }
                }
            }
        }