/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { Assembly a = Assembly.Load("Microsoft.Phone.InteropServices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e"); Type comBridgeType = a.GetType("Microsoft.Phone.InteropServices.ComBridge"); MethodInfo dynMethod = comBridgeType.GetMethod("RegisterComDll", BindingFlags.Public | BindingFlags.Static); object retValue = dynMethod.Invoke(null, new object[] { "liblw.dll", new Guid("E79018CB-46A6-432D-8077-8C0863533001") }); //uint retval = Microsoft.Phone.InteropServices.ComBridge.RegisterComDll("libwph.dll", new Guid("56624E8C-CF91-41DF-9C31-E25A98FAF464")); Imangodll instance = (Imangodll) new Cmangodll(); //Update messaging tiles int unread = 0; instance.getUnreadSMSCount(out unread); Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData(); data.Count = unread; foreach (var t in Microsoft.Phone.Shell.ShellTile.ActiveTiles.Where(t => t.NavigationUri.ToString().Contains("5B04B775-356B-4AA0-AAF8-6491FFEA5610"))) { t.Update(data); } //Update phone tile ScheduledActionService.LaunchForTest("ScheduledAgent", TimeSpan.FromMilliseconds(2200)); NotifyComplete(); }
// Do not add any additional code to this method private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) { // Set the root visual to allow the application to render if (RootVisual != RootFrame) { RootVisual = RootFrame; } // Remove this handler since it is no longer needed RootFrame.Navigated -= CompleteInitializePhoneApplication; if (e.Uri.OriginalString.Contains("&go=")) { string[] s = e.Uri.OriginalString.Split(new string[] { "&go=" }, StringSplitOptions.None); string str = s[1]; System.Reflection.Assembly asm = System.Reflection.Assembly.Load("Microsoft.Phone.InteropServices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e"); Type comBridgeType = null; comBridgeType = asm.GetType("Microsoft.Phone.InteropServices.ComBridge"); var dynMethod = comBridgeType.GetMethod("RegisterComDll", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); uint retval = (uint)dynMethod.Invoke(null, new object[] { "liblw.dll", new Guid("E79018CB-46A6-432D-8077-8C0863533001") }); Imangodll MyNativeCodeInstance = (Imangodll) new Cmangodll(); //MessageBox.Show(str); var re = MyNativeCodeInstance.StringCall("aygshell", "SHLaunchSessionByUri", "app://" + str); //Remove from the navigation list System.Threading.Thread.Sleep(1500); throw (new Exception()); } }
protected override void OnBeginStreaming(AudioTrack track, AudioStreamer streamer) { using (var store = IsolatedStorageFile.GetUserStoreForApplication()) { using (var stream = new IsolatedStorageFileStream("widgets.xml", FileMode.OpenOrCreate, store)) { using (var reader = new StreamReader(stream)) { try { var serial = new XmlSerializer(typeof(appdata)); appSettings = (appdata)serial.Deserialize(stream); } catch { appSettings = new appdata(); } } } } Assembly a = Assembly.Load("Microsoft.Phone.InteropServices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e"); Type comBridgeType = a.GetType("Microsoft.Phone.InteropServices.ComBridge"); MethodInfo dynMethod = comBridgeType.GetMethod("RegisterComDll", BindingFlags.Public | BindingFlags.Static); object retValue = dynMethod.Invoke(null, new object[] { "liblw.dll", new Guid("E79018CB-46A6-432D-8077-8C0863533001") }); instance = (Imangodll) new Cmangodll(); instance.MessageBox7("BG Agent Fired", "lockwidgets", 0, out o); checkForDataChange(); while (true) { System.Threading.Thread.Sleep(5000); if (instance.StringCall("aygshell", "SHIsLocked", "") == 1) { checkForDataChange(); } GC.Collect(); System.Diagnostics.Debug.WriteLine("1: " + Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage")); System.Diagnostics.Debug.WriteLine("1: " + Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage")); } }
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { uint retval = Microsoft.Phone.InteropServices.ComBridge.RegisterComDll("libwph.dll", new Guid("56624E8C-CF91-41DF-9C31-E25A98FAF464")); libwph = (Imangodll) new Cmangodll(); string str = ""; Rectangle rect = new Rectangle(); rect.Width = 62; rect.Height = 62; rect.Fill = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]); var stream = System.Windows.Application.GetResourceStream(new Uri("menu.folder", UriKind.Relative)); curMenu = new menu(); try { var serial = new XmlSerializer(typeof(menu)); curMenu = (menu)serial.Deserialize(stream.Stream); } catch { } int y = 0; foreach (appentry app in curMenu.apps) { StackPanel panel = new StackPanel(); panel.Orientation = System.Windows.Controls.Orientation.Horizontal; System.Windows.Media.Imaging.WriteableBitmap wb = new System.Windows.Media.Imaging.WriteableBitmap(62, 62); wb.Render(rect, null); Image img = new Image(); img.Margin = new Thickness(1, 1, 10, 1); img.Width = 62; img.Height = 62; /*System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(); * using (var file = store.OpenFile(app.guid + ".jpg", FileMode.Open, FileAccess.Read)) * { * bmp.SetSource(file); * //img.Source = Microsoft.Phone.PictureDecoder.DecodeJpeg(file); * }*/ System.Diagnostics.Debug.WriteLine(app.guid); System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(new Uri("/apps/" + app.guid + ".jpg", UriKind.Relative)); bmp.CreateOptions = System.Windows.Media.Imaging.BitmapCreateOptions.None; img.Source = bmp; wb.Render(img, null); wb.Invalidate(); img.Source = wb; img.VerticalAlignment = System.Windows.VerticalAlignment.Center; panel.Children.Add(img); TextBlock text = new TextBlock(); text.Text = app.name; text.FontSize = 31; text.FontWeight = FontWeights.Light; text.VerticalAlignment = System.Windows.VerticalAlignment.Center; panel.Children.Add(text); panel.Name = "panel_" + y; panel.Margin = new Thickness(1, 1, 1, 10); ListBoxItem foo = new ListBoxItem(); foo.Content = panel; foo.Tap += new EventHandler <GestureEventArgs>(panel_Tap); foo.Name = "danel_" + y; stackPanel1.Children.Add(foo); y += 1; wb = null; } PageTitle.Text = curMenu.name; PageTitle.Opacity = op; scrollViewer1.Opacity = op; scrollViewer1.Margin = new Thickness(46, top, 0, 0); tim = new System.Windows.Threading.DispatcherTimer(); tim.Interval = new TimeSpan(0, 0, 0, 0, 10); tim.Tick += new EventHandler(tim_Tick); tim.Start(); }