我有一个在系统托盘中运行的WPF应用程序.我正在尝试创建一个上下文菜单,当您右键单击托盘中的图标时,该菜单会弹出.这是XAML:
<Window.Resources>
<ContextMenu x:Key="NotifierContextMenu" Placement="MousePoint">
<MenuItem Header="Exit" Click="Menu_Exit"/>
</ContextMenu>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)
这是代码隐藏:
void NotifyIcon_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
var menu = this.FindResource("NotifierContextMenu") as ContextMenu;
menu.IsOpen = true;
}
}
protected void Menu_Exit(object sender, RoutedEventArgs e)
{
NotifyIcon.Visible = false;
Application.Current.Shutdown();
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当您右键单击该图标时,它会抛出NotifierContextMenu无法找到的错误.我错过了什么?
使用MongoDB我正在查询距离纬度为25英里的家庭.
我第一次尝试使用near命令,如下所示:
var near = Query.Near("Coordinates", coordinates.Latitude, coordinates.Longitude, find.GetRadiansAway(), false);
var query = Collection().Find(near);
var listings = query.ToList();
Run Code Online (Sandbox Code Playgroud)
near附近的问题是它只返回100个列表,而我想返回坐标25英里内的所有列表.
我的下一次尝试是在内部使用:
var within = Query.WithinCircle("Coordinates", coordinates.Latitude, coordinates.Longitude, find.GetRadiansAway(), false);
var query = Collection().Find(within);
var listings = query.ToList();
Run Code Online (Sandbox Code Playgroud)
内部返回25英里范围内的所有列表,这很好,但是它并没有根据它们与中心坐标的距离来排序.
所以我的问题是,我如何充分利用这两个世界?如何获取25英里范围内的所有列表并按中心坐标的接近程度排序?
我有一个C#应用程序,需要尽快在某个域内抓取许多页面.我有一个Parallel.Foreach循环遍历所有URL(多线程)并使用下面的代码擦除它们:
private string ScrapeWebpage(string url, DateTime? updateDate)
{
HttpWebRequest request = null;
HttpWebResponse response = null;
Stream responseStream = null;
StreamReader reader = null;
string html = null;
try
{
//create request (which supports http compression)
request = (HttpWebRequest)WebRequest.Create(url);
request.Pipelined = true;
request.KeepAlive = true;
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
if (updateDate != null)
request.IfModifiedSince = updateDate.Value;
//get response.
response = (HttpWebResponse)request.GetResponse();
responseStream = response.GetResponseStream();
if (response.ContentEncoding.ToLower().Contains("gzip"))
responseStream = new GZipStream(responseStream, CompressionMode.Decompress);
else if (response.ContentEncoding.ToLower().Contains("deflate"))
responseStream = new DeflateStream(responseStream, CompressionMode.Decompress);
//read html.
reader …Run Code Online (Sandbox Code Playgroud) 使用MongoDB和最新的10gen C#驱动程序(CSharpDriver-1.3.1.4349),我正在尝试进行"就地"更新并获取结果中影响的文档数量.
public static long SaveListings(string state, bool isActive, DateTime updateDate)
{
var result = Collection().Update(
Query.And(
Query.EQ("State", state),
Query.And(
Query.EQ("IsActive", isActive),
Query.LT("UpdateDate", updateDate))),
Update.Set("IsActive", false), UpdateFlags.Multi);
return result != null ? result.DocumentsAffected : -1;
}
Run Code Online (Sandbox Code Playgroud)
由于某种原因,结果为null.如果我是从控制台执行此操作,我可以通过执行以下操作来获取行数:
db.Listing.update( { State: state.Abbreviation, IsActive: true, UpdateDate: { $lt: expiredDate } }, { $set: { IsActive: false } }, false, true);
var numRows = db.getLastErrorObj().n;
Run Code Online (Sandbox Code Playgroud)
知道我做错了什么,或者这是C#驱动程序中的错误?
我正在尝试检索GPS修复中使用的卫星数量.我已经实现了两种不同的方法,如下所示:
package ti.utils;
import android.app.Activity;
import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
public class Gps {
private static final int TWO_MINUTES = 1000 * 60 * 2;
private static Location Location;
public static int Satellites = -1;
public static void StartTracking(Activity activity)
{
final LocationManager locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
//listen for gps status changes.
GpsStatus.Listener gpsStatusListener = new GpsStatus.Listener() {
public void onGpsStatusChanged(int event) {
Log("In onGpsStatusChanged event: " + event);
if (event …Run Code Online (Sandbox Code Playgroud) 升级到最新版本的 React Native (0.70.3) 后,我的 Android 应用程序构建良好,但当我运行它时,出现以下错误。它引用了一个似乎位于react-native-video-with-ads npm 包中的类,这不是我使用的东西。我尝试手动安装此软件包,但仍然出现相同的错误。有任何想法吗?
2022-10-23 10:08:02.997 25180-25295/com.marriage365.app E/unknown:NativeModuleInitError: Failed to create NativeModule "UIManager"
java.lang.VerifyError: Verifier rejected class com.brentvatne.exoplayer.ReactExoplayerViewManager: android.view.View com.brentvatne.exoplayer.ReactExoplayerViewManager.createViewInstance(com.facebook.react.uimanager.ThemedReactContext) failed to verify: android.view.View com.brentvatne.exoplayer.ReactExoplayerViewManager.createViewInstance(com.facebook.react.uimanager.ThemedReactContext): [0x4] can't resolve returned type 'Reference: android.view.View' or 'Unresolved Reference: com.brentvatne.exoplayer.ReactExoplayerView' (declaration of 'com.brentvatne.exoplayer.ReactExoplayerViewManager' appears in /data/app/~~Nq33b85Ca7DH-MTNDVGU3Q==/com.marriage365.app-mNOnqtNxaI4Mm9muOh5Rig==/base.apk!classes2.dex)
at com.brentvatne.react.ReactVideoPackage.createViewManagers(ReactVideoPackage.java:42)
at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:928)
at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:75)
at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:159)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:147)
at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:502)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:478)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1240)
at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1182)
at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:136)
at …Run Code Online (Sandbox Code Playgroud) 有没有办法检查公共MSMQ是否为空?对于私人MSMQ,这很容易:
private bool IsQueueEmpty(string path)
{
bool isQueueEmpty = false;
var myQueue = new MessageQueue(path);
try
{
myQueue.Peek(new TimeSpan(0));
isQueueEmpty = false;
}
catch (MessageQueueException e)
{
if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout)
{
isQueueEmpty = true;
}
}
return isQueueEmpty;
}
Run Code Online (Sandbox Code Playgroud)
我如何对公共MSMQ进行同样的检查?如果我尝试使用上面的代码检查一个公共MSMQ,它会在峰值上给我一个错误:
System.ArgumentOutOfRangeException:Length不能小于零.
是否有谷歌地图api v3的https版本?我有一个使用https的网站,并且在IE中遇到令人讨厌的混合安全和非安全内容错误.我读到在v2中你必须付钱才能得到这个,但是没有看到任何关于v3的东西.
我在尝试连接查询中的多个表时遇到错误:
指定的LINQ表达式包含对与不同上下文关联的查询的引用
它令人困惑,因为它使我看起来在查询中使用不同的上下文但我不是:
public static IQueryable<Company> GetAll(bool supportsMMAT)
{
return from c in Context.Companies
join v in Context.Vehicles on c.CompanyIdNumber equals v.CompanyIdNumber
join mt in Context.ModemTypes on v.ModemTypeId equals mt.Id
where !c.CompanyShutOff
&& (!supportsMMAT || mt.Model == "MMAT")
select c;
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我正在使用EF4 CTP5代码第一种方法,如果这有任何区别......
将我所有的 Xamarin Android nuget 包升级到最新版本后,我现在收到以下构建错误:
/Users/justintoth/.nuget/packages/xamarin.build.download/0.4.11/build/Xamarin.Build.Download.targets(116,3):错误 MSB4062:“Xamarin.Build.Download.XamarinBuildAndroidAarRestore”任务可以不能从程序集 /Users/justintoth/.nuget/packages/xamarin.build.download/0.4.11/build/Xamarin.Build.Download.dll 加载。确认声明正确,程序集及其所有依赖项都可用,并且任务包含实现 Microsoft.Build.Framework.ITask 的公共类。
我已经看到其他对此错误的引用,这些开发人员能够清理解决方案、退出并重新启动 Visual Studio for Mac,或者重新启动他们的计算机。但是,我已经尝试了所有这三个,手动删除 bin / object 文件夹,甚至重新安装 Visual Studio for Mac 并且仍然遇到此构建错误。
android ×3
c# ×2
mongodb ×2
code-first ×1
contextmenu ×1
geospatial ×1
google-maps ×1
gps ×1
msmq ×1
react-native ×1
satellite ×1
wpf ×1
xamarin ×1