Exemple #1
0
        private void Window_FormClosed(object sender, FormClosedEventArgs e)
        {
            if ((Form)this == (Form)Global.Desktop)
            {
                HotKeyUtil.UnregisterAllHotKey();
            }
            if (showdialog_callback_ != null && !(showdialog_callback_ is DBNull))
            {
                Utility.CallFunc(showdialog_callback_, IWindow);
                showdialog_callback_ = null;
            }

            if (Owner != null && !Owner.Enabled)
            {
                Owner.Enabled = true;
            }

            js_window_callback_.OnClosed.Call(js_window_callback_);

            Browser.Dispose();
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
            }
        }
Exemple #2
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == 0x0006)
     {
         js_window_callback_.OnActivated.Call((Int32)m.WParam, (Int32)m.LParam);
     }
     else if (m.Msg == 0x011F)
     {
         if (current_context_menu_ != null && (((Int32)m.WParam >> 16) & 0xFFFF) == 0xFFFF && m.LParam == (IntPtr)0)
         {
             current_context_menu_.OnCommand.CallAll("", "");
             current_context_menu_ = null;
         }
         return;
     }
     try
     {
         if (!Global.Desktop.IsDisposed && m.HWnd == Global.Desktop.Handle)
         {
             if (m.Msg == 0x312)
             {
                 HotKey hk = HotKeyUtil.FindHotKey(m.WParam.ToInt32());
                 if (hk != null)
                 {
                     int action = HotKeyUtil.FindHotKeyAction(hk);
                     if (action == 1)
                     {
                         if (SessionImpl.Instance.GetSessionID() != "")
                         {
                             object singletonForm = SessionImpl.Instance.GetGlobal("SingletonForm");
                             Utility.InvokeMethod(singletonForm, "ShowMainForm");
                         }
                     }
                     else if (action == 2)
                     {
                         object core  = Global.Desktop.Core;
                         object impl  = Utility.GetProperty(core, "UnreadMsgBoxImpl");
                         int    count = (int)Utility.InvokeMethod(impl, "GetUnreadMsgCount", new object[] { });
                         if (count > 0)
                         {
                             Utility.InvokeMethod(impl, "OpenFirst", new object[] { });
                         }
                         else
                         {
                             if (SessionImpl.Instance.GetSessionID() != "")
                             {
                                 object singletonForm = SessionImpl.Instance.GetGlobal("SingletonForm");
                                 Utility.InvokeMethod(singletonForm, "ShowMainForm");
                             }
                         }
                     }
                 }
             }
         }
     }
     catch
     {
     }
     base.WndProc(ref m);
 }
Exemple #3
0
        static void Main(string[] args)
        {
            Global.CmdLineParams = GetCmdLineParams(args);

            Global.ChatWith          = Global.CmdLineParams.ContainsKey("chatwith") ? Global.CmdLineParams["chatwith"] : "";
            Global.CreateTempAccount = Global.CmdLineParams.ContainsKey("createaccount");
            Global.EmbedCode         = Global.CmdLineParams.ContainsKey("embedcode") ? Int32.Parse(Global.CmdLineParams["embedcode"]) : 0;

            SettingConf.Instance.Load();
            Global.ServiceUrl = SettingConf.Instance.ServiceUrl;
            Global.ResPath    = SettingConf.Instance.ResPath;
            Global.AppPath    = SettingConf.Instance.AppPath;
            Global.ResUrl     = Global.ServiceUrl + Global.AppPath;
            if (!Global.ResUrl.EndsWith("/"))
            {
                Global.ResUrl += "/";
            }
            Global.ResUrl += Global.ResPath;

//#if !DEBUG
//			if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Native.dll")))
//			{
//				LoadPackages(SettingConf.Instance.ServiceUrl);
//			}
//#endif

            bool isUpdate = false;

            try
            {
                isUpdate = CheckUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("检测更新时发生错误:{0}", ex.Message), "错误");
                return;
            }

            if (!isUpdate)
            {
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Global.TrayIconMenu = new ContextMenu();
                MenuItem menuItem1 = new MenuItem();
                menuItem1.Text   = "退出";
                menuItem1.Click += new EventHandler(menuItem1_Click);
                Global.TrayIconMenu.MenuItems.AddRange(new MenuItem[] { menuItem1 });

                Global.TrayIcon             = new NotifyIcon();
                Global.TrayIcon.Icon        = Properties.Resources.TrayGred;
                Global.TrayIcon.Visible     = false;
                Global.TrayIcon.ContextMenu = Global.TrayIconMenu;
                Global.TrayIcon.Text        = "";
                Global.TrayIcon.MouseClick += new MouseEventHandler(TrayIcon_Click);
                Global.TrayIcon.MouseMove  += new MouseEventHandler(TrayIcon_MouseMove);

                Global.Desktop                  = new AppWnd();
                Global.Desktop.FormClosed      += new FormClosedEventHandler(Desktop_FormClosed);
                Global.Desktop.ShowInTaskbar    = false;
                Global.Desktop.PageLoad        += new AppWnd.PageLoadDelegate(Desktop_PageLoad);
                Global.Desktop.HandleCreated   += new EventHandler(Desktop_HandleCreated);
                Global.Desktop.HandleDestroyed += new EventHandler(Desktop_HandleDestroyed);
                Global.Desktop.LoadPage(Global.ResUrl + "/Client.htm");

                Global.TrayIcon.Visible = true;

                HotKeyUtil.RegisterAllHotKey();

                ResponsesHandler.Instance.SetState("Status", "Online");

                Application.Run();
            }
            else
            {
                System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "Update.exe");
            }
        }