c# - 如何首先打开一个窗口,而不是 WPF 中的 MainWindow(C#)
问题描述
因此,当我单击开始调试时,它显示的是我的主窗口而不是另一个窗口,这是我想要测试的。
这是主窗口代码。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using EasyExploits;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Linq.Expressions;
using MeguSploit;
namespace Exploit_Template
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Module m = new Module();
public MainWindow()
{
InitializeComponent();
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
using (StreamReader s = new StreamReader("./Bin/Languages/Lua.xshd"))
{
using (XmlTextReader reader = new XmlTextReader(s))
{
TextEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
}
DirectoryInfo di = new DirectoryInfo("./Scripts");
FileInfo[] f = di.GetFiles("*.txt");
foreach (FileInfo fi in f)
{
ListBox.Items.Add(fi.Name);
}
DirectoryInfo din = new DirectoryInfo("./Scripts");
FileInfo[] file = din.GetFiles("*.lua");
foreach (FileInfo fil in file)
{
ListBox.Items.Add(fil.Name);
}
}
private void Exit_Click(object sender, RoutedEventArgs e)
{
System.Windows.Application.Current.Shutdown();
}
private void Minimize_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void Load_Click(object sender, RoutedEventArgs e)
{
if (ListBox.SelectedIndex != -1)
{
TextEditor.Text = File.ReadAllText($"./Scripts/{ListBox.SelectedItem}");
}
}
private void Refresh_Click(object sender, RoutedEventArgs e)
{
ListBox.Items.Clear();
DirectoryInfo di = new DirectoryInfo("./Scripts");
FileInfo[] f = di.GetFiles("*.txt");
foreach (FileInfo fi in f)
{
ListBox.Items.Add(fi.Name);
}
DirectoryInfo din = new DirectoryInfo("./Scripts");
FileInfo[] file = din.GetFiles("*.lua");
foreach (FileInfo fil in file)
{
ListBox.Items.Add(fil.Name);
}
}
private void ExecuteL_Click(object sender, RoutedEventArgs e)
{
if (ListBox.SelectedIndex != -1)
{
m.ExecuteScript(File.ReadAllText($"./Scripts/{ListBox.SelectedItem}"));
}
}
private void Execute_Click(object sender, RoutedEventArgs e)
{
m.ExecuteScript(TextEditor.Text);
Status.Content = "Executed!";
}
private void Clear_Click(object sender, RoutedEventArgs e)
{
TextEditor.Text = "";
Status.Content = "Ready!";
}
private void OpenFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TextEditor.Text = File.ReadAllText(ofd.FileName);
}
}
private void ExecuteFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ef = new OpenFileDialog();
ef.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (ef.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
m.ExecuteScript(ef.FileName);
}
}
private void SaveFile_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
File.WriteAllText(sfd.FileName, TextEditor.Text);
}
}
private void Attach_Click(object sender, RoutedEventArgs e)
{
m.LaunchExploit();
Status.Content = "Injected!";
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}
这是我想首先开始的窗口。
using Exploit_Template;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MeguSploit
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
Process.Start("https://shrinkme.io/BWe0");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
if (Pass.Text == new WebClient().DownloadString("https://pastebin.com/raw/VTGJqX6k") || Pass.Text == "stefanradu2005eadminsiesmekrau")
{
MessageBox.Show("Thank you for using MeguSploit");
this.Hide();
MainWindow main = new MainWindow();
main.Show();
}
else
{
MessageBox.Show("Sorry the key is invalid", "Key Invalid");
}
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
}
}
我真的需要帮助,我是编程界的新手。提前致谢。我也不想从头开始,因为我会浪费很多时间。那将是最后的选择。
解决方案
StartupUri
将 App.xaml 中的从 MainWindow.xaml更改为 Window1.xaml
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyApp"
StartupUri="MainWindow.xaml">
</Application>
另请参阅相关文档
推荐阅读
- firebase - Firebase 身份验证用户存储在哪个地理位置?
- css - 高度动画在 CSS 示例中不起作用
- python - Python:带比较的条件
- curl - curl 输出 JSON 解析数据
- javascript - (Ubuntu/Linux) 如何使用 NodeJS 在后台运行 javascript 代码?
- html5-canvas - 跨浏览器在画布上绘制巨大图像的一部分
- excel - Excel 2016:使用功能区 XML 将分析组添加到 Windows 和 Mac 的自定义选项卡
- python - 在“while”循环中写入 HTML 文件时 Python“TypeError”
- c# - 强制方法等待计时器在c#中停止
- vue.js - 如何修改子Vue组件中的值