Twitterizer API 问题

发布于 2024-08-21 18:43:30 字数 308 浏览 4 评论 0原文

我最近在 Visual Studio 2008 中使用 C# WPF 尝试了很棒的 Twitterizer Twitter API。它大部分工作正常,但我确实有一些问题。

1)如何才能使登录屏幕成为登录时关闭的不同窗口,除非登录失败?

2)我怎样才能告诉用户他们的登录信息不正确?

3)如何让它保存用户的登录信息,以便他们不必再次输入?

4) 如何在用户发布状态时进行字符倒计时,并且如果超过 140 个字符则不发布?

抱歉,如果这些问题看起来有点幼稚。我不太擅长 C#,尤其是因为这是我第一次使用 WPF 框架。

I've recently been playing around with the awesome Twitterizer Twitter API using C# WPF in Visual Studio 2008. It's been working the most part, but I do have some questions about it.

1) How can I make it so that the login screen is a different windows that closes when you log in, unless there is a login failure?

2) How can I make it so that it tells the user that their login information is incorrect?

3) How can I make it save the user's login information so that they don't have to enter again?

4) How can I make a character countdown when a user is posting a status and not let it be posted if it is over 140 characters?

Sorry if these questions seem kind of noobish. i'm not very good at C#, especially since this is my first time using the WPF framework.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2024-08-28 18:43:30

这是几个问题。你应该分别询问他们。

如何登录不同的窗口

将新窗口添加到您的项目中。在那里实现您的登录屏幕。当应用程序启动时(或在适当的时候)显示新窗口。

如何显示登录错误消息

单击窗口中的“登录”按钮后,执行登录。如果失败(出现异常),则显示一个对话框,否则关闭登录窗口。

如何保存用户的登录信息

您应该将此类信息保存到受保护的存储中,而不是将其写入文件。登录成功后保存。当应用程序启动时加载它。

如何进行字符倒计时

将新的“CharactersLeft”依赖属性添加到您的用户控件或窗口。将 PropertyChangedCallback 添加到您的 Text 属性(我假设您有一个 - 它也应该是 DependencyProperty 并且您的 TextBox 应该绑定到它)。在PropetyChangedCallback 中,更新CharactersLeft 值。将 TextBlock 绑定到 CharactersLeft 值。

如果 CharactersLeft 为负数,如何阻止发布

如果您使用的是 ICommand,请实现 CanExecute。如果您使用的是 RoutedCommand,请实现 OnCanExecute。如果您直接处理按钮单击,请考虑改用命令,或在按钮按钮上设置触发器,以便在 CharactersLeft 小于零时将其禁用。 (为此,您将需要一个 IValueConverter,或者您可以只拥有一个单独的属性。)

This is several questions. You should ask them separately.

How to make Login a different window

Add a new Window to your project. Implement your login screen there. Show the new window when the app starts up (or whenever it is appropriate to do so).

How to display login error messages

When the "Log in" button is clicked in the window, execute the login. If it fails (you get an exception), display a dialog box, otherwise close the login window.

How to save the user's login information

You should save such information to the protected store instead of writing it to a file. Save it after a successful login. Load it when the application starts.

How to make a character countdown

Add a new "CharactersLeft" dependency property to your user control or window. Add a PropertyChangedCallback to your Text property (I assume you have one - it should be a DependencyProperty as well and your TextBox should be bound to it). In the PropetyChangedCallback, update the CharactersLeft value. Bind a TextBlock to the CharactersLeft value.

How to prevent posting if CharactersLeft is negative

If you are using an ICommand, implement CanExecute. If you are using a RoutedCommand, implement OnCanExecute. If you are directly handling the button click, consider using commands instead, or set a trigger on your button button so that it becomes disabled whenever CharactersLeft is less than zero. (You will need a IValueConverter for this, or you can just have a separate property.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文