private void LoadButton_Click(object sender, EventArgs e) { using (OpenFileDialog openXML = new OpenFileDialog { Filter = "AHK Files|*.ahk", RestoreDirectory = true, Title = "Load a previously created rotation", Multiselect = false }) { var result = openXML.ShowDialog(); if (result != DialogResult.OK) { return; } // Convert location to XML folder location. var f = new FileInfo(openXML.FileName); var XmlFile = Path.ChangeExtension(Path.Combine(f.DirectoryName, "XML", f.Name), ".xml"); // Load XML file. var xml = new XmlFunctions(ahkDataSet); var loadResult = xml.Load(XmlFile); if (loadResult) { MessageBox.Show("Rotation loaded.", "Import completed."); } else { MessageBox.Show("Could not load XML file.", "Import failed."); } } }
private void StartLesson_Click(object sender, RoutedEventArgs e) { Button curButton = sender as Button; Expander expEl = spMain.FindName("Exp" + curButton.Name.Substring(3)) as Expander; int counter = 0; foreach (RadioButton radioButton in XmlFunctions.FindVisualChildren <RadioButton>(expEl)) { if (radioButton.IsChecked != true) { counter++; } else { break; } } LessonWindow lessonWind = new LessonWindow(_userInfo, expEl.Name, counter <= 3 ? (++counter) : 0); lessonWind.Owner = this; this.Hide(); lessonWind.ShowDialog(); _userInfo = UpdateUserInfo(_userInfo.Name); this.Show(); }
public MainWindow() { InitializeComponent(); Login loginWindow = new Login(); if (loginWindow.ShowDialog() == true) { _userInfo = UpdateUserInfo(loginWindow.userName); UserName.Content = "Привет, " + _userInfo.Name + "!"; } else { Application.Current.Shutdown(); } List <StatisticLesson> statisticLessons = XmlFunctions.XmlReader(true); foreach (StatisticLesson lesson in statisticLessons) { foreach (var userStatistick in lesson._usersInfo) { XmlFunctions.FindVisualChildren <Label>(GrdStatistick, lesson._lessonId - 1).Content += userStatistick._name + "\r\n"; XmlFunctions.FindVisualChildren <Label>(GrdStatistick, lesson._lessonId + 2).Content += userStatistick._commonTime.ToString().Substring(3) + " сек.\r\n"; //lbLess2.Content += userStatistick._commonTime + "\r\n"; } } tbctrlLessons.Height = this.Height - 140; }
private void AhkBuilderPlusPlus_Load(object sender, EventArgs e) { // Load settings. LoadSettings(); LoadClassList(); // Load previous session (if exists) var xml = new XmlFunctions(ahkDataSet); xml.Load(); // Check if visualizer was still running from previous crash. if (IsVisualizerRunning()) { KillVisualizer(); } // Move form to front. Activate(); // First time setup? if (BoxCenterHorizontalPosition.Text == "0" || BoxCenterVerticalPosition.Text == "0" || currentTier.Text == "0" || string.IsNullOrEmpty(ahkToggleKeyBox.Text)) { tabControl1.SelectTab(1); } }
public Login() { InitializeComponent(); List <string> userNames = XmlFunctions.XmlReader(); foreach (string Name in userNames) { cbUsers.Items.Add(Name); } cbUsers.Items.Add("Меня нет в списке!"); }
private void Expander_Expanded(object sender, RoutedEventArgs e) { Expander curExpander = sender as Expander; foreach (var expander in XmlFunctions.FindVisualChildren <Expander>(spMain)) { if (expander.Header != curExpander.Header) { expander.IsExpanded = false; } } }
private void AhkBuilderPlusPlus_FormClosing(object sender, FormClosingEventArgs e) { // Save settings. SaveSettings(); // Clean temp backup file. var xml = new XmlFunctions(ahkDataSet); xml.ClearBackup(); // Check if visualizer is still running. if (IsVisualizerRunning()) { KillVisualizer(); } }
private void BtnLogin_Click(object sender, RoutedEventArgs e) { var user = tbUserName.Text.Split(' '); if (user.Count() == 2) { user[0] = Char.ToUpper(user[0][0]) + user[0].Substring(1).ToLower(); user[1] = Char.ToUpper(user[1][0]) + user[1].Substring(1).ToLower(); string userN = user[0] + " " + user[1]; XmlFunctions.AddNewUser(userN); userName = userN; this.DialogResult = true; } else { MessageBox.Show("Нужно ввести имя и фамилию!"); } }
private UserInfo UpdateUserInfo(string userName) { _userInfo = XmlFunctions.XmlReader(userName); for (int i = 1; i <= 3; i++) { Grid curGrid = spMain.FindName("GrdLesson" + i) as Grid; int levelCounter = 0; ClearGridCels(curGrid); if (!(_userInfo.Lessons == null)) { foreach (Lesson lesson in _userInfo.Lessons) { if (lesson._lessonId == i) { foreach (var levelTime in lesson._levelTime) { Image imgChecked = new Image(); imgChecked.Source = new BitmapImage(new Uri(resourcesPath + "//checked.png")); imgChecked.Height = 20; curGrid.Children.Add(imgChecked); Grid.SetColumn(imgChecked, 1); Grid.SetRow(imgChecked, levelCounter); Label lbTime = new Label(); lbTime.Content = levelTime + " сек"; lbTime.FontSize = 14; curGrid.Children.Add(lbTime); Grid.SetColumn(lbTime, 2); Grid.SetRow(lbTime, levelCounter++); curGrid.Children[levelCounter].IsEnabled = true; } Expander expEl = spMain.FindName("ExpLesson" + lesson._lessonId) as Expander; } } } } return(_userInfo); }
private void Polygon_MouseLeave(object sender, MouseEventArgs e) { Path lastPoint = XmlFunctions.FindVisualChildren <Path>(cnvLesson, 1); if (lastPoint.IsMouseOver) { _counter = 0; foreach (Path path in XmlFunctions.FindVisualChildren <Path>(cnvLesson)) { path.IsEnabled = false; } StartWalk(sender, e); } else { DisablePath(); MessageBox.Show("Попробуй еще раз!"); } }
public void GetAllReferences() { var existingPath = @"Data\BSMLPractice.csproj"; var list = XmlFunctions.GetReferences(existingPath, true); foreach (var item in list) { string filePath = item.HintPath.Replace("$(BeatSaberDir)", @"H:\SteamApps\SteamApps\common\Beat Saber"); if (File.Exists(filePath)) { var assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(filePath); } Console.WriteLine(item.ToString(30)); } var otherList = BeatSaberTools.GetAvailableReferences(@"H:\SteamApps\SteamApps\common\Beat Saber"); foreach (var item in otherList) { Console.WriteLine(item.ToString(30)); } foreach (var item in list) { try { var check = otherList.Where(r => r.Name == item.Name).Single(); if (item.HintPath.Contains("$(BeatSaberDir)")) { Assert.AreEqual(check.RelativeDirectory, item.RelativeDirectory); } }catch (InvalidOperationException ex) { Console.WriteLine($"Exception: {item.Name}"); //throw ex; } } }
private void DisablePath() { Path walkPath = XmlFunctions.FindVisualChildren <Path>(cnvLesson, 2); walkPath.IsEnabled = false; }
private void WriteResultIntoXML() { XmlFunctions.UpdateXmlResult(_user.Name, _lesson, _level, lbTimer.Content.ToString()); }
private void AddButton_Click(object sender, EventArgs e) { // Check if a spell is selected. if (spellBox.SelectedItem == null) { MessageBox.Show("Please select a spell before pressing the add button.", "Spell error"); return; } // Check if a keybind is set. if (string.IsNullOrEmpty(bindingBox.Text)) { MessageBox.Show("Please set a keybind before pressing the add button.", "Keybind error"); return; } // Check if coordinates are good. var Scale = double.Parse(BoxSizeInPixels.Text) / 50; // 50 is the default pixel size for Hekili var FirstXCoordinate = BoxCenterHorizontalPosition.Text.ToPoint(-5, Scale); var FirstYCoordinate = BoxCenterVerticalPosition.Text.ToPoint(-12, Scale); var SecondXCoordinate = BoxCenterHorizontalPosition.Text.ToPoint(-5, Scale); var SecondYCoordinate = BoxCenterVerticalPosition.Text.ToPoint(12, Scale); if (FirstXCoordinate <= 0 || FirstXCoordinate > Screen.PrimaryScreen.Bounds.Width || FirstYCoordinate <= 0 || FirstYCoordinate > Screen.PrimaryScreen.Bounds.Height || SecondXCoordinate <= 0 || SecondXCoordinate > Screen.PrimaryScreen.Bounds.Width || SecondYCoordinate <= 0 || SecondYCoordinate > Screen.PrimaryScreen.Bounds.Height) { MessageBox.Show("Please make sure the X and Y offsets are correct, currently returns an offscreen coordinate.", "Offset error."); return; } // Turn off visualizer if its still on. if (IsVisualizerRunning()) { KillVisualizer(); } // Run pixelfinder. var pixelFinder = new PixelFinder(FirstXCoordinate, FirstYCoordinate, SecondXCoordinate, SecondYCoordinate); pixelFinder.Run(); try { // Add to table. ahkDataTable.Rows.Add(new Object[] { spellBox.SelectedItem.ToString(), bindingBox.Text, pixelFinder.pixelColors.Color1, pixelFinder.pixelColors.Color2 }); // Make tmp save. var xml = new XmlFunctions(ahkDataSet); xml.Save(); } catch (ConstraintException) { MessageBox.Show("A key binding with the same pixel color combination is already present in the table.", "Duplicate color combination error."); Activate(); return; } catch (Exception ex) { MessageBox.Show($"Can't add keybind because: {ex.Message}", "Error."); Activate(); return; } // Clear current keybind. bindingBox.Clear(); // Roll to caret AhkTable.FirstDisplayedScrollingRowIndex = AhkTable.RowCount - 1; // Activate main form again. Activate(); }
public DialogResult GenerateAHK() { if (string.IsNullOrEmpty(ahkToggleKeyBox.Text)) { MessageBox.Show("Please set an Ahk toggle key before generating an AHK file.", "Toggle key error"); return(DialogResult.Cancel); } if (classBox.SelectedItem == null) { MessageBox.Show("Please select a spec before generating an AHK file.", "Spec error"); return(DialogResult.Cancel); } // Check if coordinates are good. var Scale = double.Parse(BoxSizeInPixels.Text) / 50; // 50 is the default pixel size for Hekili var FirstXCoordinate = BoxCenterHorizontalPosition.Text.ToPoint(-5, Scale); var FirstYCoordinate = BoxCenterVerticalPosition.Text.ToPoint(-12, Scale); var SecondXCoordinate = BoxCenterHorizontalPosition.Text.ToPoint(-5, Scale); var SecondYCoordinate = BoxCenterVerticalPosition.Text.ToPoint(12, Scale); if (FirstXCoordinate <= 0 || FirstXCoordinate > Screen.PrimaryScreen.Bounds.Width || FirstYCoordinate <= 0 || FirstYCoordinate > Screen.PrimaryScreen.Bounds.Height || SecondXCoordinate <= 0 || SecondXCoordinate > Screen.PrimaryScreen.Bounds.Width || SecondYCoordinate <= 0 || SecondYCoordinate > Screen.PrimaryScreen.Bounds.Height) { MessageBox.Show("Please make sure the X and Y offsets are correct, currently returns an offscreen coordinate.", "Offset error."); return(DialogResult.Cancel); } if (ahkDataTable.Rows.Count == 0) { MessageBox.Show("Please add keybinds before generating an AHK file.", "Keybind error"); return(DialogResult.Cancel); } using (SaveFileDialog ahkFileLocation = new SaveFileDialog { FileName = $"{classBox.SelectedItem.ToString().Replace(" ", "")}.ahk", Filter = "AHK Files|*.ahk", RestoreDirectory = true, Title = "Select a location to save your AHK file." }) { var result = ahkFileLocation.ShowDialog(); if (result != DialogResult.OK) { return(result); } try { using (var ahkFile = new StreamWriter(ahkFileLocation.FileName, false)) { // Top part of the file. ahkFile.WriteLine("#Persistent"); ahkFile.WriteLine("Active := False"); ahkFile.WriteLine("Tickrate := 1000 / 60"); if (ahkToggleKeyBox.Text == "ScrollLock") { ahkFile.WriteLine("SetScrollLockState, AlwaysOff"); } if (ahkToggleKeyBox.Text == "CapsLock") { ahkFile.WriteLine("SetCapsLockState, AlwaysOff"); } ahkFile.WriteLine(""); ahkFile.WriteLine($"{ahkToggleKeyBox.Text}::"); ahkFile.WriteLine(" SetTimer, Rotation, % (Toggle:=!Toggle) ? Tickrate : \"Off\""); ahkFile.WriteLine(" Active := !Active"); ahkFile.WriteLine(""); ahkFile.WriteLine(" if (Active) {"); ahkFile.WriteLine($" TrayTip, {classBox.SelectedItem.ToString()}, Rotation activated, 5, 17"); ahkFile.WriteLine(" } else {"); ahkFile.WriteLine($" TrayTip, {classBox.SelectedItem.ToString()}, Rotation deactivated, 5, 17"); ahkFile.WriteLine(" }"); ahkFile.WriteLine("return"); ahkFile.WriteLine(""); ahkFile.WriteLine("Rotation:"); ahkFile.WriteLine(" WinWaitActive, World of Warcraft,"); // Get pixel locations. ahkFile.WriteLine($" PixelGetColor, CLRa, {FirstXCoordinate}, {FirstYCoordinate}"); ahkFile.WriteLine($" PixelGetColor, CLRb, {SecondXCoordinate}, {SecondYCoordinate}"); // Generate if chain of doom. var strings = GenerateAhkColorCheck(); foreach (var line in strings) { ahkFile.WriteLine(line); } ahkFile.WriteLine(" }"); ahkFile.WriteLine("return"); } } catch (Exception ex) { MessageBox.Show("There was an error while generating the AHK.", "Error."); MessageBox.Show(ex.Message, "Error."); return(DialogResult.Abort); } // Save as XML for later loading purposes. var f = new FileInfo(ahkFileLocation.FileName); // Create directory if it doesnt exist. var d = new DirectoryInfo(Path.Combine(f.DirectoryName, "XML")); if (!d.Exists) { d.Create(); } // Hide directory from user sight. d.Attributes = FileAttributes.Hidden; // Save XML. var XML = new XmlFunctions(ahkDataSet); var XmlFile = Path.ChangeExtension(Path.Combine(d.FullName, f.Name), ".xml"); XML.Save(XmlFile); return(result); } }