Example #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded    -= Window_Loaded;
            this.Activated += Window_Activated; this.Deactivated += Window_Deactivated;
            IntPtr handle = new WindowInteropHelper(this).Handle;

            // Subclassing Window's WndProc http://blogs.msdn.com/nickkramer/archive/2006/03/18/554235.aspx
            HwndSource.FromHwnd(handle).AddHook(new HwndSourceHook(WndProc));             // Loga izvēlnes komandu notveršanai.
            SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

            MenuHelper.SystemMenuHandle = MenuHelper.GetSystemMenu(handle, false);
            MenuHelper.DeleteSystemSizeCommands(MenuHelper.SystemMenuHandle, true);
            // Pieliek programmas punktus.
            MenuHelper.SettingsMenuHandle = MenuHelper.CreatePopupMenu();
            // Ar tabulācijas zīmi atdalīts īsinājumtaustiņš.
            MenuHelper.InsertMenu(MenuHelper.SettingsMenuHandle, 0, MenuFlag.ByPosition | (Settings.Default.UseGuide ? MenuFlag.Checked:MenuFlag.Unchecked), new IntPtr(MenuHelper.GuideCommandId), "Rādīt raidījumu sarakstu	G");
            MenuHelper.InsertMenu(MenuHelper.SettingsMenuHandle, 1, MenuFlag.ByPosition | (Settings.Default.ShowClock ? MenuFlag.Checked:MenuFlag.Unchecked), new IntPtr(MenuHelper.ClockCommandId), "Rādīt laiku studijā	T");
            MenuHelper.InsertMenu(MenuHelper.SettingsMenuHandle, 2, MenuFlag.ByPosition | (Settings.Default.MuteOnLock ? MenuFlag.Checked:MenuFlag.Unchecked), new IntPtr(MenuHelper.LockCommandId), "Bloķējot izslēgt skaņu");
            MenuHelper.InsertMenu(MenuHelper.SettingsMenuHandle, 3, MenuFlag.ByPosition | (Settings.Default.UseSystemProxy ? MenuFlag.Checked:MenuFlag.Unchecked), new IntPtr(MenuHelper.ProxyCommandId), "Lietot sistēmas starpniekserveri");
            MenuHelper.InsertMenu(MenuHelper.SystemMenuHandle, 0, MenuFlag.ByPosition | MenuFlag.Popup, MenuHelper.SettingsMenuHandle, "Iestatījumi");
            MenuHelper.InsertMenu(MenuHelper.SystemMenuHandle, 1, MenuFlag.ByPosition | MenuFlag.String, new IntPtr(MenuHelper.AboutCommandId), "Par Radio");
            MenuHelper.InsertMenu(MenuHelper.SystemMenuHandle, 2, MenuFlag.ByPosition | MenuFlag.Separator, IntPtr.Zero, null);

            // Iestata pirmo kanālu šeit, lai Dispatcher.Invoke neuzkar programmu. BeginInvoke nav risinājums, jo tad paraleli izpildās kods, kuram jānotiek secīgi.
            await SetChannel(channel).ConfigureAwait(false);

            notFirstChannel = true;
        }
Example #2
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);
            IntPtr handle = new WindowInteropHelper(this).Handle;

            MenuHelper.DeleteSystemSizeCommands(MenuHelper.GetSystemMenu(handle, false), false); // Savādāk izmēra komandas pa reizei kļūst pieejamas.
            SetWindowLong(handle, -16 /*GWL_STYLE*/, 0x00C00000 | 0x00080000);                   // WS_CAPTION | WS_SYSMENU vai lietot this.ResizeMode=NoResize.
            // http://stackoverflow.com/a/3364875
            // Palūdz noņemt ikonu.
            SendMessage(handle, 0x0080 /*WM_SETICON*/, new IntPtr(0 /*ICON_SMALL*/), IntPtr.Zero);
            SendMessage(handle, 0x0080 /*WM_SETICON*/, new IntPtr(1 /*ICON_BIG*/), IntPtr.Zero);
            // Nomaina loga stilu uz tādu, kuram nav ikonas, bet ir ierastie virsraksta izmēri salīdzinot ar Tool Window stilu.
            SetWindowLong(handle, -20 /*GWL_EXSTYLE*/, 0x0001 /*WS_EX_DLGMODALFRAME*/);
            // Atjaunina loga neklienta daļu, lai izmaiņas uzzīmētos.
            SetWindowPos(handle, IntPtr.Zero, 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0004 | 0x0020);             // SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED
        }