2005-06-02 Peter Bartok <pbartok@novell.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / Application.cs
index 793ac9fd6ffc1ee47a4414fe10beb0d5f1e8b2ce..ec803801e8d41a06a57b2ad60dcdebf913086d00 100644 (file)
@@ -69,12 +69,12 @@ namespace System.Windows.Forms {
                        }
 
                        // Both calls are needed, one is for the WM, the other for our focus logic
-                       XplatUI.Activate(form.form_parent_window.window.Handle);
+                       XplatUI.Activate(form.window.Handle);
                        form.Activate();
 
                        while (control.MoveNext()) {
                                if ((((Control)control.Current).parent == null) && (((Control)control.Current).is_visible) && (((Control)control.Current).is_enabled)) {
-                                       if ((control.Current is Form.FormParentWindow)  && (((Form.FormParentWindow)control.Current)!=form.form_parent_window)) {
+                                       if ((control.Current is Form)  && (((Form)control.Current)!=form)) {
                                                XplatUI.EnableWindow(((Control)control.Current).window.Handle, false);
                                                toplevels.Enqueue((Control)control.Current);
                                        }
@@ -84,6 +84,28 @@ namespace System.Windows.Forms {
                        form.CreateControl();
 
                        while (!exiting && !form.end_modal && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
+                               if ((message_filters != null) && (message_filters.Count > 0)) {
+                                       Message m;
+                                       bool    drop;
+
+                                       drop = false;
+                                       m = new Message();
+                                       m.Msg = (int)msg.message;
+                                       m.HWnd = msg.hwnd;
+                                       m.LParam = msg.lParam;
+                                       m.WParam = msg.wParam;
+                                       for (int i = 0; i < message_filters.Count; i++) {
+                                               if (((IMessageFilter)message_filters[i]).PreFilterMessage(ref m)) {
+                                                       // we're dropping the message
+                                                       drop = true;
+                                                       break;
+                                               }
+                                       }
+                                       if (drop) {
+                                               continue;
+                                       }
+                               }
+
                                XplatUI.TranslateMessage(ref msg);
                                XplatUI.DispatchMessage(ref msg);
 
@@ -124,21 +146,13 @@ namespace System.Windows.Forms {
 
                public static string CompanyName {
                        get {
-                               StackTrace      st;
-
-                               if (Environment.OSVersion.Platform != (PlatformID)128) {
-                                       RegistryKey     key;
-                                       String          ret;
-
-                                       key=Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", false);
-                                       ret=(String)key.GetValue("RegisteredOrganization");
-
-                                       return ret;
-                                       
+                               AssemblyCompanyAttribute[] attrs = (AssemblyCompanyAttribute[]) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
+                               
+                               if ((attrs != null) && attrs.Length>0) {
+                                       return attrs[0].Company;
                                }
 
-                               st=new StackTrace();
-                               return st.GetFrame(st.FrameCount-1).GetMethod().DeclaringType.Namespace;
+                               return Assembly.GetEntryAssembly().GetName().Name;
                        }
                }
 
@@ -171,7 +185,7 @@ namespace System.Windows.Forms {
 
                public static string LocalUserAppDataPath {
                        get {
-                               return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+                               return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), CompanyName), ProductName), ProductVersion);
                        }
                }
 
@@ -224,7 +238,7 @@ namespace System.Windows.Forms {
 
                public static string UserAppDataPath {
                        get {
-                               return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+                               return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), CompanyName), ProductName), ProductVersion);
                        }
                }
 
@@ -252,6 +266,12 @@ namespace System.Windows.Forms {
                        XplatUI.EnableThemes();
                }
 
+#if NET_2_0
+               public static void EnableRTLMirroring () 
+               {
+               }
+#endif
+
                public static void Exit() {
                        XplatUI.Exit();
                }
@@ -304,13 +324,35 @@ namespace System.Windows.Forms {
 
                        if (form != null) {
                                // Both calls are needed, one is for the WM, the other for our focus logic
-                               XplatUI.Activate(form.form_parent_window.window.Handle);
+                               XplatUI.Activate(form.window.Handle);
                                form.Activate();
                        }
 
                        messageloop_started = true;
 
                        while (!exiting && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
+                               if ((message_filters != null) && (message_filters.Count > 0)) {
+                                       Message m;
+                                       bool    drop;
+
+                                       drop = false;
+                                       m = new Message();
+                                       m.Msg = (int)msg.message;
+                                       m.HWnd = msg.hwnd;
+                                       m.LParam = msg.lParam;
+                                       m.WParam = msg.wParam;
+                                       for (int i = 0; i < message_filters.Count; i++) {
+                                               if (((IMessageFilter)message_filters[i]).PreFilterMessage(ref m)) {
+                                                       // we're dropping the message
+                                                       drop = true;
+                                                       break;
+                                               }
+                                       }
+                                       if (drop) {
+                                               continue;
+                                       }
+                               }
+
                                XplatUI.TranslateMessage(ref msg);
                                XplatUI.DispatchMessage(ref msg);