public override void Update(double secondsElapsed, KeyUtils keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false) { base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse); if (listen) { if(skip > 0) { skip--; return; } WinAPI.VirtualKeyShort[] buttons = keyUtils.KeysThatWentUp(); if (buttons.Length > 0) { Key = buttons[0]; listen = false; } } }
public static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); Console.Title = "SteamMonsterGame"; Console.WriteLine("> Waiting for steam to start up..."); while (!ProcUtils.ProcessIsRunning("Steam")) Thread.Sleep(250); proc = new ProcUtils("Steam", WinAPI.ProcessAccessFlags.QueryLimitedInformation); hWnd = IntPtr.Zero; Console.WriteLine("> Waiting for steam-window to start up..."); do hWnd = WinAPI.FindWindowByCaption(hWnd, "Steam"); while (hWnd == IntPtr.Zero); Console.WriteLine("> Initializing utils"); keys = new KeyUtils(); lastClickerPos = new Vector2(); Console.WriteLine("> Initializing overlay"); using (overlay = new SharpDXOverlay()) { overlay.ChildControls.Clear(); Console.WriteLine("> Attaching overlay"); overlay.Attach(hWnd); overlay.TickEvent += overlay_TickEvent; overlay.DrawOnlyWhenInForeground = false; overlay.BeforeDrawingEvent += overlay_BeforeDrawingEvent; Console.WriteLine("> Setting up fonts"); SharpDXRenderer renderer = overlay.Renderer; renderer.CreateFont("smallFont", "Century Gothic", 12f); renderer.CreateFont("tallFont", "Century Gothic", 16f); Console.WriteLine("> Initializing controls"); InitializeComponent(); Console.WriteLine("> Setting up controls"); lblCaption.Font = renderer.GetFont("tallFont"); lblDescription.Font = renderer.GetFont("smallFont"); btnToggleMenu.Font = renderer.GetFont("smallFont"); wndWindow.Font = renderer.GetFont("tallFont"); lblAutomation.Font = renderer.GetFont("smallFont"); chbAutoClicker.Font = renderer.GetFont("smallFont"); chbMoveMouse.Font = renderer.GetFont("smallFont"); rdbUsePost.Font = renderer.GetFont("smallFont"); rdbUseSend.Font = renderer.GetFont("smallFont"); lblVisuals.Font = renderer.GetFont("smallFont"); chbVisDrawClicker.Font = renderer.GetFont("smallFont"); lblPerformance.Font = renderer.GetFont("smallFont"); lblFpsLogic.Font = renderer.GetFont("smallFont"); lblFpsLogicAverage.Font = renderer.GetFont("smallFont"); lblFpsDraw.Font = renderer.GetFont("smallFont"); lblFpsDrawAverage.Font = renderer.GetFont("smallFont"); pnlPanel.ChildControls.Clear(); pnlPanel.AddChildControl(lblCaption); pnlPanel.AddChildControl(lblDescription); pnlPanel.InsertSpacer(); pnlPanel.AddChildControl(btnToggleMenu); wndWindow.Panel.AddChildControl(lblAutomation); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(chbAutoClicker); wndWindow.Panel.AddChildControl(chbMoveMouse); wndWindow.Panel.AddChildControl(rdbUsePost); wndWindow.Panel.AddChildControl(rdbUseSend); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblVisuals); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(chbVisDrawClicker); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblPerformance); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblFpsLogic); wndWindow.Panel.AddChildControl(pgbFpsLogic); wndWindow.Panel.AddChildControl(lblFpsLogicAverage); wndWindow.Panel.AddChildControl(lblFpsDraw); wndWindow.Panel.AddChildControl(pgbFpsDraw); wndWindow.Panel.AddChildControl(lblFpsDrawAverage); overlay.ChildControls.Add(pnlPanel); overlay.ChildControls.Add(wndWindow); overlay.ChildControls.Add(clkWindow); Console.WriteLine("> Running overlay (close this console to terminate!)"); System.Windows.Forms.Application.Run(overlay); } }
public override void Update(double secondsElapsed, KeyUtils keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false) { if (this.Parent != null) this.Width = Parent.Width - this.MarginLeft - this.MarginRight - Parent.MarginLeft - Parent.MarginRight; base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse); }
public static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); while (!ProcUtils.ProcessIsRunning("Clicker Heroes")) Thread.Sleep(250); InitializeComponent(); proc = new ProcUtils("Clicker Heroes", WinAPI.ProcessAccessFlags.QueryLimitedInformation); keys = new KeyUtils(); lastClickerPos = new Vector2(); using (overlay = new SharpDXOverlay()) { overlay.ChildControls.Clear(); overlay.Attach(proc.Process.MainWindowHandle); overlay.TickEvent += overlay_TickEvent; overlay.DrawOnlyWhenInForeground = false; overlay.BeforeDrawingEvent += overlay_BeforeDrawingEvent; SharpDXRenderer renderer = overlay.Renderer; renderer.CreateFont("smallFont", "Century Gothic", 12f); renderer.CreateFont("tallFont", "Century Gothic", 16f); lblCaption.Font = renderer.GetFont("tallFont"); lblDescription.Font = renderer.GetFont("smallFont"); btnToggleMenu.Font = renderer.GetFont("smallFont"); wndWindow.Font = renderer.GetFont("tallFont"); lblAutomation.Font = renderer.GetFont("smallFont"); chbAutoClicker.Font = renderer.GetFont("smallFont"); chbAutoSpells.Font = renderer.GetFont("smallFont"); rdbUsePost.Font = renderer.GetFont("smallFont"); rdbUseSend.Font = renderer.GetFont("smallFont"); lblVisuals.Font = renderer.GetFont("smallFont"); chbVisDrawClicker.Font = renderer.GetFont("smallFont"); chbVisDrawLevels.Font = renderer.GetFont("smallFont"); lblPerformance.Font = renderer.GetFont("smallFont"); lblFpsLogic.Font = renderer.GetFont("smallFont"); lblFpsLogicAverage.Font = renderer.GetFont("smallFont"); lblFpsDraw.Font = renderer.GetFont("smallFont"); lblFpsDrawAverage.Font = renderer.GetFont("smallFont"); segments.Width = overlay.Width; segments.Height = overlay.Height; pnlPanel.ChildControls.Clear(); pnlPanel.AddChildControl(lblCaption); pnlPanel.AddChildControl(lblDescription); pnlPanel.InsertSpacer(); pnlPanel.AddChildControl(btnToggleMenu); wndWindow.Panel.AddChildControl(lblAutomation); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(chbAutoClicker); wndWindow.Panel.AddChildControl(chbAutoSpells); wndWindow.Panel.AddChildControl(rdbUsePost); wndWindow.Panel.AddChildControl(rdbUseSend); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblVisuals); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(chbVisDrawClicker); wndWindow.Panel.AddChildControl(chbVisDrawLevels); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblPerformance); wndWindow.Panel.InsertSpacer(); wndWindow.Panel.AddChildControl(lblFpsLogic); wndWindow.Panel.AddChildControl(pgbFpsLogic); wndWindow.Panel.AddChildControl(lblFpsLogicAverage); wndWindow.Panel.AddChildControl(lblFpsDraw); wndWindow.Panel.AddChildControl(pgbFpsDraw); wndWindow.Panel.AddChildControl(lblFpsDrawAverage); overlay.ChildControls.Add(pnlPanel); overlay.ChildControls.Add(segments); overlay.ChildControls.Add(wndWindow); System.Windows.Forms.Application.Run(overlay); } }
public override void Update(double secondsElapsed, KeyUtils keyUtils, Vector2 cursorPoint, bool checkMouse = false) { base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse); }
internal byte[] GenerateConnectToken(IPEndPoint[] addressList, double time, int expirySeconds, int serverTimeout, ulong sequence, ulong clientID, byte[] userData) { if (userData.Length > 256) { throw new ArgumentOutOfRangeException("User data cannot be larger than 256 bytes"); } if (addressList == null) { throw new NullReferenceException("Address list cannot be null"); } else if (addressList.Length == 0) { throw new ArgumentOutOfRangeException("Address list cannot be empty"); } else if (addressList.Length > Defines.MAX_SERVER_ADDRESSES) { throw new ArgumentOutOfRangeException("Address list cannot contain more than " + Defines.MAX_SERVER_ADDRESSES + " entries"); } NetcodePrivateConnectToken privateConnectToken = new NetcodePrivateConnectToken(); privateConnectToken.ClientID = clientID; // generate random crypto keys byte[] clientToServerKey = new byte[32]; byte[] serverToClientKey = new byte[32]; KeyUtils.GenerateKey(clientToServerKey); KeyUtils.GenerateKey(serverToClientKey); privateConnectToken.ClientToServerKey = clientToServerKey; privateConnectToken.ServerToClientKey = serverToClientKey; privateConnectToken.UserData = new byte[256]; Buffer.BlockCopy(userData, 0, privateConnectToken.UserData, 0, userData.Length); privateConnectToken.ConnectServers = new ConnectTokenServerEntry[addressList.Length]; for (int i = 0; i < privateConnectToken.ConnectServers.Length; i++) { privateConnectToken.ConnectServers[i] = new ConnectTokenServerEntry() { AddressType = addressList[i].AddressFamily == AddressFamily.InterNetwork ? NetcodeAddressType.IPv4 : NetcodeAddressType.IPv6, Endpoint = addressList[i] }; } byte[] privateConnectTokenBytes = new byte[1024]; using (var writer = ByteArrayReaderWriter.Get(privateConnectTokenBytes)) { privateConnectToken.Write(writer); } ulong createTimestamp = (ulong)Math.Truncate(time); ulong expireTimestamp = createTimestamp + (ulong)expirySeconds; byte[] encryptedPrivateToken = new byte[1024]; PacketIO.EncryptPrivateConnectToken(privateConnectTokenBytes, protocolID, expireTimestamp, sequence, privateKey, encryptedPrivateToken); NetcodePublicConnectToken publicToken = new NetcodePublicConnectToken(); publicToken.ProtocolID = protocolID; publicToken.CreateTimestamp = createTimestamp; publicToken.ExpireTimestamp = expireTimestamp; publicToken.ConnectTokenSequence = sequence; publicToken.PrivateConnectTokenBytes = encryptedPrivateToken; publicToken.ConnectServers = privateConnectToken.ConnectServers; publicToken.ClientToServerKey = clientToServerKey; publicToken.ServerToClientKey = serverToClientKey; publicToken.TimeoutSeconds = (uint)serverTimeout; byte[] publicTokenBytes = new byte[2048]; using (var writer = ByteArrayReaderWriter.Get(publicTokenBytes)) { publicToken.Write(writer); } return(publicTokenBytes); }
static void Main(string[] args) { m_bWork = true; keyUtils = new KeyUtils(); MemUtils = new ExternalUtilsCSharp.MemUtils(); MemUtils.UseUnsafeReadWrite = true; Thread thread = new Thread(new ThreadStart(Loop)); thread.IsBackground = true; thread.Start(); Console.WriteLine("Press ESC to exit"); while (!m_bWork) Thread.Sleep(250); Console.WriteLine("Waiting for thread to exit..."); thread.Join(); Console.WriteLine("Bye."); }
internal static bool HasPressedKeyBinding(this Command command) { var bindings = ((object[])command.Bindings).Cast <string>(); return(KeyUtils.ParseBindings(bindings).Any(b => b.IsPressed())); }
public static void Main(string[] args) { System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); PrintSuccess("[>]=-- Zat's CSGO-ESP"); KeyUtils = new KeyUtils(); ConfigUtils = new CSGOConfigUtils(); ConfigUtils.SetValue("espEnabled", true); ConfigUtils.SetValue("espBox", false); ConfigUtils.SetValue("espSkeleton", true); ConfigUtils.SetValue("espName", false); ConfigUtils.SetValue("espHealth", true); ConfigUtils.SetValue("aimEnabled", true); ConfigUtils.SetValue("aimKey", WinAPI.VirtualKeyShort.XBUTTON1); ConfigUtils.SetValue("aimToggle", false); ConfigUtils.SetValue("aimHold", true); ConfigUtils.SetValue("aimFov", 30f); ConfigUtils.SetValue("aimSmoothEnabled", true); ConfigUtils.SetValue("aimSmoothValue", 0.2f); ConfigUtils.SetValue("aimFilterSpotted", false); ConfigUtils.SetValue("aimFilterSpottedBy", false); ConfigUtils.SetValue("aimFilterEnemies", true); ConfigUtils.SetValue("aimFilterAllies", false); ConfigUtils.SetValue("rcsEnabled", true); ConfigUtils.SetValue("rcsForce", 100f); ConfigUtils.ReadSettingsFromFile("euc_csgo.cfg"); PrintInfo("> Waiting for CSGO to start up..."); while (!ProcUtils.ProcessIsRunning("csgo")) Thread.Sleep(250); ProcUtils = new ProcUtils("csgo", WinAPI.ProcessAccessFlags.VirtualMemoryRead | WinAPI.ProcessAccessFlags.VirtualMemoryWrite | WinAPI.ProcessAccessFlags.VirtualMemoryOperation); MemUtils = new ExternalUtilsCSharp.MemUtils(); MemUtils.Handle = ProcUtils.Handle; PrintInfo("> Waiting for CSGOs window to show up..."); while ((hWnd = WinAPI.FindWindowByCaption(hWnd, "Counter-Strike: Global Offensive")) == IntPtr.Zero) Thread.Sleep(250); ProcessModule clientDll, engineDll; PrintInfo("> Waiting for CSGO to load client.dll..."); while ((clientDll = ProcUtils.GetModuleByName(@"bin\client.dll")) == null) Thread.Sleep(250); PrintInfo("> Waiting for CSGO to load engine.dll..."); while ((engineDll = ProcUtils.GetModuleByName(@"engine.dll")) == null) Thread.Sleep(250); Framework = new Framework(clientDll, engineDll); PrintInfo("> Initializing overlay"); using (SHDXOverlay = new SharpDXOverlay()) { SHDXOverlay.Attach(hWnd); SHDXOverlay.TickEvent += overlay_TickEvent; InitializeComponents(); SharpDXRenderer renderer = SHDXOverlay.Renderer; TextFormat smallFont = renderer.CreateFont("smallFont", "Century Gothic", 10f); TextFormat largeFont = renderer.CreateFont("largeFont", "Century Gothic", 14f); TextFormat heavyFont = renderer.CreateFont("heavyFont", "Century Gothic", 14f, FontStyle.Normal, FontWeight.Heavy); windowMenu.Font = smallFont; windowMenu.Caption.Font = largeFont; windowGraphs.Font = smallFont; windowGraphs.Caption.Font = largeFont; windowSpectators.Font = smallFont; windowSpectators.Caption.Font = largeFont; graphMemRead.Font = smallFont; graphMemWrite.Font = smallFont; for (int i = 0; i < ctrlPlayerESP.Length; i++) { ctrlPlayerESP[i].Font = heavyFont; SHDXOverlay.ChildControls.Add(ctrlPlayerESP[i]); } ctrlRadar.Font = smallFont; windowMenu.ApplySettings(ConfigUtils); SHDXOverlay.ChildControls.Add(ctrlRadar); SHDXOverlay.ChildControls.Add(windowMenu); SHDXOverlay.ChildControls.Add(windowGraphs); SHDXOverlay.ChildControls.Add(windowSpectators); SHDXOverlay.ChildControls.Add(cursor); PrintInfo("> Running overlay"); System.Windows.Forms.Application.Run(SHDXOverlay); } ConfigUtils.SaveSettingsToFile("euc_csgo.cfg"); }
public void NBitcoinKey_Generation_Test() { Key nbKey = KeyUtils.CreateNBEcKey(); Assert.NotNull(nbKey); }
public override EffectLayer Render(IGameState gamestate) { EffectLayer sc_assistant_layer = new EffectLayer("Shortcut Assistant"); Keys[] heldKeys = Global.InputEvents.PressedKeys; Tree <Keys> _childKeys = Properties.ShortcutKeysTree; foreach (var key in heldKeys) { if (_childKeys != null) { _childKeys = _childKeys.ContainsItem(Properties.MergeModifierKey ? KeyUtils.GetStandardKey(key) : key); } } if (_childKeys != null && _childKeys.Item != Keys.None) { Keys[] shortcutKeys; if (Properties.PresentationType == ShortcutAssistantPresentationType.ProgressiveSuggestion) { shortcutKeys = _childKeys.GetChildren(); } else { shortcutKeys = _childKeys.GetAllChildren(); } if (shortcutKeys.Length > 0) { if (Properties.DimBackground) { sc_assistant_layer.Fill(Properties.DimColor); } sc_assistant_layer.Set(Utils.KeyUtils.GetDeviceKeys(shortcutKeys, true, !Console.NumberLock), Properties.PrimaryColor); sc_assistant_layer.Set(Utils.KeyUtils.GetDeviceKeys(heldKeys, true), Properties.PrimaryColor); } } return(sc_assistant_layer); }
public async Task <ActionResult> SavePhotos(IEnumerable <HttpPostedFileBase> files, IEnumerable <int> rotations, string serviceType, Guid?cardId, string title, string comment) { // Find out the action to redirect to on error. We use the referrer string. RedirectToAction seems accept a case-insensitive parameter. var referrerAction = (Request.UrlReferrer.Segments.Skip(2).Take(1).SingleOrDefault() ?? "Index").Trim('/'); //referrerAction = referrerAction.First().ToString().ToUpper() + referrerAction.Substring(1).ToLower(); // var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext)); if (files == null || files.All(i => i == null)) { return(RedirectToAction(referrerAction, new { error = "no_file" })); } if (files.Count() != rotations.Count()) { return(RedirectToAction(referrerAction, new { error = "wrong_rotations" })); } var items = files .Select((i, idx) => new { File = i, Rotation = rotations.ElementAt(idx) }) // There may be empty form parts from input elements with no file selected. .Where(i => i.File != null); if (!items.All(i => i.File.ContentType == MediaType.Jpeg)) { return(RedirectToAction(referrerAction, new { error = "wrong_file_format" })); } var userId = this.GetUserId(); var userKey = KeyUtils.IntToKey(userId); var timeKey = KeyUtils.GetTimeAsBase32(); var page = 1; // Pages start counting from 1. var blobNames = new List <string>(); foreach (var item in items) { using (var inputStream = item.File.InputStream) { var blobName = String.Format("{0}/{1}/{2}.original.jpg", userKey, timeKey, page); await AzureStorageUtils.UploadBlobAsync(inputStream, AzureStorageUtils.ContainerNames.Artifacts, blobName, MediaType.Jpeg); using (var memoryStream = new MemoryStream()) { /* I am not sure about using JpegBitmapDecoder. Because of the native code dependencies, the PresentationCore and WindowsBase assemblies need to be distributed as x86 and x64, so AnyCPU may be not possible? */ inputStream.Seek(0, SeekOrigin.Begin); using (var image = Image.FromStream(inputStream)) { RotateFlipType rotateFlipType = RotateFlipType.RotateNoneFlipNone; switch (item.Rotation) { case -1: rotateFlipType = RotateFlipType.Rotate270FlipNone; break; case 1: rotateFlipType = RotateFlipType.Rotate90FlipNone; break; default: break; } ; if (rotateFlipType != RotateFlipType.RotateNoneFlipNone) { image.RotateFlip(rotateFlipType); } // We re-encode the image to decrease the size. var codec = ImageCodecInfo.GetImageEncoders().FirstOrDefault(c => c.FormatID == ImageFormat.Jpeg.Guid); var encoderParams = new EncoderParameters(1); // Highest quality is 100. Quality affects the file size. Do not change it until you have exprimented. int quality = 50; // Do not pass inline. This parameter is passed via pointer and it has to be strongly typed. encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, quality); image.Save(memoryStream, codec, encoderParams); //image.Save(memoryStream, ImageFormat.Jpeg); } memoryStream.Seek(0, SeekOrigin.Begin); blobName = String.Format("{0}/{1}/{2}.jpg", userKey, timeKey, page); await AzureStorageUtils.UploadBlobAsync(memoryStream, AzureStorageUtils.ContainerNames.Artifacts, blobName, MediaType.Jpeg); blobNames.Add(blobName); } page++; } } var artifact = String.Join(",", blobNames); var exerciseId = await ExerciseUtils.CreateExercise(artifact, userId, serviceType, ArtifactType.Jpeg, 0, title, cardId, comment); return(RedirectToAction("View", "Exercises", new { Id = exerciseId })); }
// TODO OBSOLETE. Do not rename the files parameter. The form inputs are bounded by this name. public async Task <ActionResult> SaveRecordings(IEnumerable <HttpPostedFileBase> files, string serviceType, Guid?cardId, string title, string comment) { /* * 1. Validate input. * 2. Save the original media files to blobs. * 3. Call the remote transcoding service. The service converts files to MP3, merges them into a single file, saves it to a blob and returns its name and the recording's duration. * 4. Create a database record. * 5. Redirect to the exercise page. */ // 1. Validate input. // Find out the action to redirect to on error. We use the referrer string. RedirectToAction seems accept a case-insensitive parameter. var referrerAction = (Request.UrlReferrer.Segments.Skip(2).Take(1).SingleOrDefault() ?? "Index").Trim('/'); //referrerAction = referrerAction.First().ToString().ToUpper() + referrerAction.Substring(1).ToLower(); // var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext)); if (files == null || files.All(i => i == null)) { return(RedirectToAction(referrerAction, new { error = "no_file" })); } // There may be empty form parts from input elements with no file selected. var originalFiles = files.Where(i => i != null); var contentType = originalFiles .Select(i => i.ContentType) .Distinct() .Single() ; var acceptedContentTypes = (new[] { MediaType.Mpeg, MediaType.Mp3, MediaType.Amr, MediaType.Gpp, MediaType.QuickTime }); if (!acceptedContentTypes.Contains(contentType)) { return(RedirectToAction(referrerAction, new { error = "wrong_file_format" })); } // 2. Save the original media files to blobs. var userId = this.GetUserId(); var userIdKey = KeyUtils.IntToKey(userId); var timeKey = KeyUtils.GetTimeAsBase32(); var index = 0; var extension = MediaType.GetExtension(contentType); //var blobNames = new List<string>(); foreach (var file in originalFiles) { using (var inputStream = file.InputStream) { // The directory structure in the Blob Storage is userIdKey/timeKey/index.ext. Runnymede.Helper.Controllers.RecordingsController.Get() relies on this structure. var blobName = String.Format("{0}/{1}/{2}.{3}", userIdKey, timeKey, index, extension); await AzureStorageUtils.UploadBlobAsync(inputStream, AzureStorageUtils.ContainerNames.Artifacts, blobName, file.ContentType); index++; } } // 3. Call the remote transcoding service. var host = ConfigurationManager.AppSettings["RecorderHost"]; var urlFormat = "http://{0}/api/recordings/transcoded/?userIdKey={1}&timeKey={2}&extension={3}&count={4}"; var url = String.Format(urlFormat, host, userIdKey, timeKey, extension, originalFiles.Count()); HttpClient client = new HttpClient(); HttpResponseMessage response = await client.GetAsync(url); if (!response.IsSuccessStatusCode) { return(RedirectToAction(referrerAction, new { error = "transcoding_error" })); } // Error is returned as HTML. Then we get error here: No MediaTypeFormatter is available to read an object of type 'JObject' from content with media type 'text/html'. var recordingDetails = await response.Content.ReadAsAsync <RecordingDetails>(); // Make sure the duration is known. If the transcoder has failed to parse the ffmpeg logs, it returns DurationMsec = 0. if (recordingDetails.TotalDuration == 0) { // Read the blob and try to determine the duration directly. recordingDetails.TotalDuration = await RecordingUtils.GetMp3Duration(AzureStorageUtils.ContainerNames.Artifacts, recordingDetails.BlobName); } // 4. Create a database record. var exerciseId = await ExerciseUtils.CreateExercise(recordingDetails.BlobName, userId, serviceType, ArtifactType.Mp3, recordingDetails.TotalDuration, title, cardId, comment); // 5. Redirect to the exercise page. return(RedirectToAction("View", "Exercises", new { Id = exerciseId })); }
private void showMeshDetails() { string meshName = ""; // Translate selection back into af am etc switch (cmbSimAge.Text) { case "Baby": meshName += "b"; break; case "Toddler": meshName += "p"; break; case "Child": meshName += "c"; break; case "Teen": meshName += "t"; break; case "Young Adult": meshName += "y"; break; case "Adult": meshName += "a"; break; case "Elder": meshName += "e"; break; case "All Ages": meshName += "u"; break; } switch (cmbSimGender.Text) { case "Female": meshName += "f"; break; case "Male": meshName += "m"; break; case "Unisex": meshName += "u"; break; } if (cmbMeshName.Text == "* Custom") { //if (this.isNew == false) //{ //meshName += casPartSrc.meshName; //} txtCasPartName.Text = casPartSrc.meshName; txtMeshName.Text = casPartSrc.meshName; txtCasPartInstance.Text = "0x" + MadScience.StringHelpers.HashFNV64(meshName).ToString("X16"); picMeshPreview.Image = null; picMeshPreview.Invalidate(); } else { if (cmbPartTypes.Text == "(none)") { meshName += cmbMeshName.Text; } else { meshName += cmbPartTypes.Text + cmbMeshName.Text; } txtCasPartName.Text = meshName; txtMeshName.Text = meshName; scrollPanelToThumb(meshName); for (int i = 0; i < this.lookupList.Items.Length; i++) { filesFile f = lookupList.Items[i]; if (f.fullCasPartname == meshName) { txtCasPartInstance.Text = f.instanceid; break; } } picMeshPreview.Image = null; picMeshPreview.Invalidate(); // Find thumbnail if (File.Exists(Path.Combine(Application.StartupPath, Path.Combine("cache", meshName + ".png")))) { Stream picMeshPreviewStream = File.OpenRead(Path.Combine(Application.StartupPath, Path.Combine("cache", meshName + ".png"))); picMeshPreview.Image = Image.FromStream(picMeshPreviewStream); picMeshPreviewStream.Close(); } else { extractCASThumbnail(meshName); } } if (this.isNew == true) { // Attempt to load the existing caspart into memory so we can extract data later. Stream casPartFile = File.Open(Path.Combine(Application.StartupPath, Path.Combine("casparts", txtCasPartName.Text + ".caspart")), FileMode.Open, FileAccess.Read, FileShare.Read); casPartFile cPartFile = new casPartFile(); this.casPartSrc = cPartFile.Load(casPartFile); casPartFile.Close(); } for (int i = 0; i < checkedListAge.Items.Count; i++) { checkedListAge.SetItemChecked(i, false); } for (int i = 0; i < checkedListCategory.Items.Count; i++) { checkedListCategory.SetItemChecked(i, false); } for (int i = 0; i < checkedListCategoryExtended.Items.Count; i++) { checkedListCategoryExtended.SetItemChecked(i, false); } for (int i = 0; i < checkedListGender.Items.Count; i++) { checkedListGender.SetItemChecked(i, false); } for (int i = 0; i < checkedListOther.Items.Count; i++) { checkedListOther.SetItemChecked(i, false); } for (int i = 0; i < checkedListType.Items.Count; i++) { checkedListType.SetItemChecked(i, false); } // Get the Mesh links for the first LOD Stream meshStream = Stream.Null; // Use the VPXY to get the mesh lod Stream vpxyStream = KeyUtils.findKey(casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY], 0); if (StreamHelpers.isValidStream(vpxyStream)) { VPXYFile vpxyFile = new VPXYFile(vpxyStream); // Get the first VPXY internal link if (vpxyFile.vpxy.linkEntries.Count >= 1 && vpxyFile.vpxy.linkEntries[0].tgiList.Count >= 1) { meshStream = KeyUtils.findKey(vpxyFile.vpxy.linkEntries[0].tgiList[0], 0); } vpxyStream.Close(); } if (StreamHelpers.isValidStream(meshStream)) { lstMeshTGILinks.Items.Clear(); SimGeomFile simgeomfile = new SimGeomFile(meshStream); // Always put the bumpmap in the first position and get it from the MTNF //int bumpmapPos = -1; //int tgiAddNo = 0; for (int i = 0; i < simgeomfile.simgeom.mtnfChunk.entries.Count; i++) { if (simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash == (uint)FieldTypes.NormalMap) { ListViewItem item = new ListViewItem(); item.SubItems.Add(Enum.GetName(typeof(FieldTypes), simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash)); item.Text = simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].ToString(); if (simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].typeId == 0x00B2D882) { item.Tag = "texture"; } else { item.Tag = ""; } //bumpmapPos = (int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]; lstMeshTGILinks.Items.Add(item); break; } } for (int i = 0; i < simgeomfile.simgeom.mtnfChunk.entries.Count; i++) { if (simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash != (uint)FieldTypes.NormalMap) { foreach (uint fieldHash in Enum.GetValues(typeof(FieldTypes))) { if (fieldHash == simgeomfile.simgeom.mtnfChunk.entries[i].fieldTypeHash) { if (simgeomfile.simgeom.mtnfChunk.entries[i].dwords.Count > 0) { ListViewItem item = new ListViewItem(); item.SubItems.Add(Enum.GetName(typeof(FieldTypes), fieldHash)); item.Text = simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].ToString(); if (simgeomfile.simgeom.keytable.keys[(int)simgeomfile.simgeom.mtnfChunk.entries[i].dwords[0]].typeId == 0x00B2D882) { item.Tag = "texture"; } else { item.Tag = ""; } lstMeshTGILinks.Items.Add(item); } break; } } } } /* * if (bumpmapPos > -1) * { * ListViewItem item = new ListViewItem(); * item.SubItems.Add("Bump Map"); * item.Text = simgeomfile.simgeom.keytable.keys[bumpmapPos].ToString(); * if (simgeomfile.simgeom.keytable.keys[bumpmapPos].typeId == 0x00B2D882) * { * item.Tag = "texture"; * } * else * { * item.Tag = ""; * } * lstMeshTGILinks.Items.Add(item); * tgiAddNo++; * } * * for (int i = 0; i < simgeomfile.simgeom.keytable.keys.Count; i++) * { * if (i != bumpmapPos) * { * ListViewItem item = new ListViewItem(); * tgiAddNo++; * //item.SubItems.Add("TGI #" + tgiAddNo); * //item.SubItems.Add("TGI #" + (i + 1)); * item.Text = simgeomfile.simgeom.keytable.keys[i].ToString(); * if (simgeomfile.simgeom.keytable.keys[i].typeId == 0x00B2D882) * { * item.Tag = "texture"; * } * else * { * item.Tag = ""; * } * lstMeshTGILinks.Items.Add(item); * } * } */ } lstCasPartDetails.Items.Clear(); // Populate the CAS Part Details addCasPartItem("Mesh Name", casPartSrc.meshName); toolStripStatusLabel2.Text = casPartSrc.meshName; addCasPartItem("Clothing Order", casPartSrc.clothingOrder.ToString()); addCasPartItem("CAS Part Type", casPartSrc.clothingType.ToString() + " (0x" + casPartSrc.clothingType.ToString("X8") + ")"); addCasPartItem("Type", casPartSrc.typeFlag.ToString() + " (0x" + casPartSrc.typeFlag.ToString("X8") + ")"); addCasPartItem("Age/Gender", casPartSrc.ageGenderFlag.ToString() + " (0x" + casPartSrc.ageGenderFlag.ToString("X8") + ")"); addCasPartItem("Clothing Category", casPartSrc.clothingCategory.ToString() + " (0x" + casPartSrc.clothingCategory.ToString("X8") + ")"); addCasPartItem("Unk String", casPartSrc.unkString); addCasPartItem("Unk2", casPartSrc.unk2.ToString()); addCasPartItem("TGI Index Body Part 1", casPartSrc.tgiIndexBodyPart1.ToString()); addCasPartItem("TGI Index Body Part 2", casPartSrc.tgiIndexBodyPart2.ToString()); addCasPartItem("TGI Index Blend Info Fat", casPartSrc.tgiIndexBlendInfoFat.ToString()); addCasPartItem("TGI Index Blend Info Fit", casPartSrc.tgiIndexBlendInfoFit.ToString()); addCasPartItem("TGI Index Blend Info Thin", casPartSrc.tgiIndexBlendInfoThin.ToString()); addCasPartItem("TGI Index Blend Info Special", casPartSrc.tgiIndexBlendInfoSpecial.ToString()); addCasPartItem("Unk5", casPartSrc.unk5.ToString()); addCasPartItem("VPXY", casPartSrc.tgiIndexVPXY.ToString()); //tgi64 tempvpxy = (tgi64)casPartSrc.tgi64list[casPartSrc.tgiIndexVPXY]; //txtVPXYPrimary.Text = "key:" + tempvpxy.typeid.ToString("X8") + ":" + tempvpxy.groupid.ToString("X8") + ":" + tempvpxy.instanceid.ToString("X16"); addCasPartItem("Count 2", casPartSrc.count2.ToString()); for (int i = 0; i < casPartSrc.count2; i++) { unkRepeat unk = (unkRepeat)casPartSrc.count2repeat[i]; addCasPartItem("#" + i.ToString() + ": unkNum ", unk.unkNum.ToString()); addCasPartItem("#" + i.ToString() + ": unk2", unk.unk2.ToString()); addCasPartItem("#" + i.ToString() + ": unkRepeatInner", unk.unkRepeatInnerCount.ToString()); for (int j = 0; j < unk.unkRepeatInnerCount; j++) { intTriple iT = (intTriple)unk.unkRepeatInnerLoop[j]; addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": One", iT.one.ToString()); addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": Two", iT.two.ToString()); addCasPartItem("#" + i.ToString() + "." + j.ToString() + ": Three", iT.three.ToString()); } } addCasPartItem("TGI Index Diffuse", casPartSrc.tgiIndexDiffuse.ToString()); addCasPartItem("TGI Index Specular", casPartSrc.tgiIndexSpecular.ToString()); addCasPartItem("Diffuse Links", casPartSrc.count3.ToString()); for (int i = 0; i < casPartSrc.count3; i++) { byte cRepeat = (byte)casPartSrc.count3repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } addCasPartItem("Specular Links", casPartSrc.count4.ToString()); for (int i = 0; i < casPartSrc.count4; i++) { byte cRepeat = (byte)casPartSrc.count4repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } addCasPartItem("Count 5", casPartSrc.count5.ToString()); for (int i = 0; i < casPartSrc.count5; i++) { byte cRepeat = (byte)casPartSrc.count5repeat[i]; addCasPartItem("#" + i.ToString(), cRepeat.ToString()); } for (int i = 0; i < chkDesignType.Items.Count; i++) { chkDesignType.SetItemChecked(i, false); } for (int i = 0; i < casPartSrc.count6; i++) { MadScience.Wrappers.ResourceKey tgi = casPartSrc.tgi64list[i]; string tgiType = MadScience.Helpers.findMetaEntry(tgi.typeId).shortName; Console.WriteLine(tgi.typeId.ToString() + " " + tgiType); if (tgi.typeId == 0x0333406C) { if (tgi.instanceId == 0x52E8BE209C703561) { chkDesignType.SetItemChecked(0, true); } if (tgi.instanceId == 0xE37696463F6B2D6E) { chkDesignType.SetItemChecked(1, true); } if (tgi.instanceId == 0x01625DDC220C08C6) { chkDesignType.SetItemChecked(2, true); } } addCasPartItem("TGI #" + i.ToString() + " " + tgiType, tgi.ToString()); } // Category flags if ((casPartSrc.typeFlag & 0x1) == 0x1) { checkedListType.SetItemChecked(0, true); // Hair } if ((casPartSrc.typeFlag & 0x2) == 0x2) { checkedListType.SetItemChecked(1, true); // Scalp } if ((casPartSrc.typeFlag & 0x4) == 0x4) { checkedListType.SetItemChecked(2, true); // Face Overlay } if ((casPartSrc.typeFlag & 0x8) == 0x8) { checkedListType.SetItemChecked(3, true); // Body } if ((casPartSrc.typeFlag & 0x10) == 0x10) { checkedListType.SetItemChecked(4, true); // Accessory } switch (casPartSrc.clothingType) { case 1: checkedListClothingType.SetItemChecked(0, true); break; case 2: checkedListClothingType.SetItemChecked(1, true); break; case 3: checkedListClothingType.SetItemChecked(2, true); break; case 4: checkedListClothingType.SetItemChecked(3, true); break; case 5: checkedListClothingType.SetItemChecked(4, true); break; case 6: checkedListClothingType.SetItemChecked(5, true); break; case 7: checkedListClothingType.SetItemChecked(6, true); break; case 11: checkedListClothingType.SetItemChecked(7, true); break; case 12: checkedListClothingType.SetItemChecked(8, true); break; case 13: checkedListClothingType.SetItemChecked(9, true); break; case 14: checkedListClothingType.SetItemChecked(10, true); break; case 15: checkedListClothingType.SetItemChecked(11, true); break; case 16: checkedListClothingType.SetItemChecked(12, true); break; case 17: checkedListClothingType.SetItemChecked(13, true); break; case 18: checkedListClothingType.SetItemChecked(14, true); break; case 19: checkedListClothingType.SetItemChecked(15, true); break; case 20: checkedListClothingType.SetItemChecked(16, true); break; case 21: checkedListClothingType.SetItemChecked(17, true); break; case 22: checkedListClothingType.SetItemChecked(18, true); break; case 24: checkedListClothingType.SetItemChecked(19, true); break; case 25: checkedListClothingType.SetItemChecked(20, true); break; case 26: checkedListClothingType.SetItemChecked(21, true); break; case 29: checkedListClothingType.SetItemChecked(22, true); break; case 30: checkedListClothingType.SetItemChecked(23, true); break; case 31: checkedListClothingType.SetItemChecked(24, true); break; } if ((casPartSrc.ageGenderFlag & 0x1) == 0x1) { checkedListAge.SetItemChecked(0, true); // Baby } if ((casPartSrc.ageGenderFlag & 0x2) == 0x2) { checkedListAge.SetItemChecked(1, true); // Toddler } if ((casPartSrc.ageGenderFlag & 0x4) == 0x4) { checkedListAge.SetItemChecked(2, true); // Child } if ((casPartSrc.ageGenderFlag & 0x8) == 0x8) { checkedListAge.SetItemChecked(3, true); // Teen } if ((casPartSrc.ageGenderFlag & 0x10) == 0x10) { checkedListAge.SetItemChecked(4, true); // YoungAdult } if ((casPartSrc.ageGenderFlag & 0x20) == 0x20) { checkedListAge.SetItemChecked(5, true); // Adult } if ((casPartSrc.ageGenderFlag & 0x40) == 0x40) { checkedListAge.SetItemChecked(6, true); // Elder } if ((casPartSrc.ageGenderFlag & 0x1000) == 0x1000) { checkedListGender.SetItemChecked(0, true); // Male } if ((casPartSrc.ageGenderFlag & 0x2000) == 0x2000) { checkedListGender.SetItemChecked(1, true); // Female } if ((casPartSrc.ageGenderFlag & 0x100000) == 0x100000) { checkedListOther.SetItemChecked(0, true); // LeftHanded } if ((casPartSrc.ageGenderFlag & 0x200000) == 0x200000) { checkedListOther.SetItemChecked(1, true); // RightHanded } if ((casPartSrc.ageGenderFlag & 0x10000) == 0x10000) { checkedListOther.SetItemChecked(2, true); // Human } if ((casPartSrc.clothingCategory & 0x1) == 0x1) { checkedListCategory.SetItemChecked(0, true); // Naked } if ((casPartSrc.clothingCategory & 0x2) == 0x2) { checkedListCategory.SetItemChecked(1, true); // Everyday } if ((casPartSrc.clothingCategory & 0x4) == 0x4) { checkedListCategory.SetItemChecked(2, true); // Formalwear } if ((casPartSrc.clothingCategory & 0x8) == 0x8) { checkedListCategory.SetItemChecked(3, true); // Sleepwear } if ((casPartSrc.clothingCategory & 0x10) == 0x10) { checkedListCategory.SetItemChecked(4, true); // Swimwear } if ((casPartSrc.clothingCategory & 0x20) == 0x20) { checkedListCategory.SetItemChecked(5, true); // Athletic } if ((casPartSrc.clothingCategory & 0x40) == 0x40) { checkedListCategory.SetItemChecked(6, true); // Singed } if ((casPartSrc.clothingCategory & 0x100) == 0x100) { checkedListCategory.SetItemChecked(7, true); // Career } if ((casPartSrc.clothingCategory & 0xFFFF) == 0xFFFF) { checkedListCategory.SetItemChecked(8, true); // All } if ((casPartSrc.clothingCategory & 0x100000) == 0x100000) { checkedListCategoryExtended.SetItemChecked(0, true); // ValidForMaternity } if ((casPartSrc.clothingCategory & 0x200000) == 0x200000) { checkedListCategoryExtended.SetItemChecked(1, true); // ValidForRandom } if ((casPartSrc.clothingCategory & 0x400000) == 0x400000) { checkedListCategoryExtended.SetItemChecked(2, true); // IsHat } if ((casPartSrc.clothingCategory & 0x800000) == 0x800000) { checkedListCategoryExtended.SetItemChecked(3, true); // IsRevealing } if ((casPartSrc.clothingCategory & 0x1000000) == 0x1000000) { checkedListCategoryExtended.SetItemChecked(4, true); // IsHiddenInCas } saveAsToolStripMenuItem.Enabled = true; btnDumpFromFullbuild2.Enabled = true; lstStencilPool.Items.Clear(); // Default all stencil boxes to blank for (int i = 1; i <= 15; i++) { if (stencilPool.Count < i) { stencilPool.Add(new stencilDetails()); } //updateStencilBoxes(i, new stencilDetails()); } // Calculate all the stencils so we can build up the stencil pool int curStencilNum = 1; for (int i = 0; i < casPartSrc.xmlChunk.Count; i++) { if (debugModeToolStripMenuItem.Checked) { Helpers.logMessageToFile(casPartSrc.xmlChunkRaw[i].ToString().Replace("/><", "/>" + Environment.NewLine + "<")); } xmlChunkDetails chunk = (xmlChunkDetails)casPartSrc.xmlChunk[i]; if (!inStencilList(chunk.stencil.A)) { updateStencilBoxes(curStencilNum, chunk.stencil.A); curStencilNum++; } if (!inStencilList(chunk.stencil.B)) { updateStencilBoxes(curStencilNum, chunk.stencil.B); curStencilNum++; } if (!inStencilList(chunk.stencil.C)) { updateStencilBoxes(curStencilNum, chunk.stencil.C); curStencilNum++; } if (!inStencilList(chunk.stencil.D)) { updateStencilBoxes(curStencilNum, chunk.stencil.D); curStencilNum++; } if (!inStencilList(chunk.stencil.E)) { updateStencilBoxes(curStencilNum, chunk.stencil.E); curStencilNum++; } if (!inStencilList(chunk.stencil.F)) { updateStencilBoxes(curStencilNum, chunk.stencil.F); curStencilNum++; } } for (int i = curStencilNum; i <= 15; i++) { //if (stencilPool.Count < i) { stencilPool.Add(new stencilDetails()); } updateStencilBoxes(i, new stencilDetails()); } if (this.casPartSrc.xmlChunkRaw.Count == 0) { label8.Visible = true; listView1.Enabled = false; //btnDumpFromFullbuild2.Enabled = false; btnAddNewDesign.Enabled = false; btnDeleteDesign.Enabled = false; } else { label8.Visible = false; listView1.Enabled = true; //btnDumpFromFullbuild2.Enabled = true; btnAddNewDesign.Enabled = true; btnDeleteDesign.Enabled = true; this.casPartNew = (casPart)OX.Copyable.ObjectExtensions.Copy(casPartSrc); //this.casPartNew = (casPart)casPartSrc.Copy(); if (this.isNew) { this.casPartNew.xmlChunk.Clear(); this.casPartNew.xmlChunkRaw.Clear(); lastSelected = -1; listView1.Items.Clear(); lstTextureDetails.Items.Clear(); lstOtherDetails.Items.Clear(); //btnAddNewDesign_Click(this, null); } } }
private void Init() { Keys = new KeyUtils(); Mouse = new MouseHook(); Mouse.InstallHook(); }
public override void Update(double secondsElapsed, KeyUtils keyUtils, SharpDX.Vector2 cursorPoint, bool checkMouse = false) { base.Update(secondsElapsed, keyUtils, cursorPoint, checkMouse); if (this.Visible) { //this.ContentLayout.ApplyLayout(this); float width = 0, height = 0; Control<SharpDXRenderer, Color, Vector2, TextFormat> lastControl = null; for (int i = 0; i < this.ChildControls.Count; i++) { var control = this.ChildControls[i]; if (!control.Visible) continue; if (lastControl == null) { control.X = control.MarginLeft + this.MarginLeft; control.Y = control.MarginTop; } else { control.X = lastControl.X; control.Y = lastControl.Y + lastControl.Height + lastControl.MarginBottom + control.MarginTop; } lastControl = control; if (this.DynamicWidth) if (control.Width + control.MarginLeft + control.MarginRight > width) width = control.Width + control.MarginLeft + control.MarginRight; } if (this.DynamicHeight) if (lastControl != null) height = lastControl.Y + lastControl.Height + lastControl.MarginBottom; if (this.DynamicWidth) this.Width = width + this.MarginLeft + this.MarginRight; if (this.DynamicHeight) this.Height = height + this.MarginBottom; } else { this.Height = 0; } }
static void Main(string[] args) { ProcUtils proc; KeyUtils keys = new KeyUtils(); CHConfig config = new CHConfig(); config.ReadSettingsFromFile("chconfig.cfg"); bool clicker = true, drawing = true, randomize = false, firstRun = true, castSpells = false, advanceLevels = true; Random random = new Random(); Point[] trail = new Point[16]; while (!keys.KeyIsDown(WinAPI.VirtualKeyShort.F10)) { Console.Clear(); Console.WriteLine("Controls:\n" + "F10: Terminate\n" + "F9: Toggle auto-clicker\n" + "F8: Toggle drawing\n" + "F7: Toggle randomization\n" + "Num9/Num6: Increase/decrease clicker-offset (x)\n" + "Num8/Num5: Increase/decrease clicker-offset (y)\n" + "F6: Save window-size and -position and clicker-offsets\n" + "F5: Apply saved window-size and -position to game-window\n" + "F4: Toggle spell-casting"); firstRun = true; Console.WriteLine("Wait for ClickerHeroes to start..."); while (!ProcUtils.ProcessIsRunning("Clicker Heroes")) { Thread.Sleep(500); } proc = new ProcUtils("Clicker Heroes", WinAPI.ProcessAccessFlags.VirtualMemoryOperation); Console.WriteLine("Wait for ClickerHeroes' window to show up..."); while (proc.Process.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(500); } while (ProcUtils.ProcessIsRunning("Clicker Heroes")) { Thread.Sleep(8); keys.Update(); if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F9)) clicker = !clicker; if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F8)) drawing = !drawing; if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F7)) randomize = !randomize; if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F4)) castSpells = !castSpells; if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F3)) advanceLevels = !advanceLevels; if (keys.KeyWentUp(WinAPI.VirtualKeyShort.NUMPAD8)) config.SetValue("offsetY", config.GetValue<int>("offsetY") + 1); if (keys.KeyWentUp(WinAPI.VirtualKeyShort.NUMPAD5)) config.SetValue("offsetY", config.GetValue<int>("offsetY") - 1); if (keys.KeyWentUp(WinAPI.VirtualKeyShort.NUMPAD9)) config.SetValue("offsetX", config.GetValue<int>("offsetX") + 1); if (keys.KeyWentUp(WinAPI.VirtualKeyShort.NUMPAD6)) config.SetValue("offsetY", config.GetValue<int>("offsetY") + 1); if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F5)) { firstRun = true; config.ReadSettingsFromFile("chconfig.cfg"); } WinAPI.WINDOWINFO info = new WinAPI.WINDOWINFO(); if (!WinAPI.GetWindowInfo(proc.Process.MainWindowHandle, ref info)) continue; if (firstRun) { if (config.GetValue<int>("windowHeight") != 0 || config.GetValue<int>("windowWidth") != 0 || config.GetValue<int>("windowX") != 0 || config.GetValue<int>("windowY") != 0) { WinAPI.SetWindowPos(proc.Process.MainWindowHandle, IntPtr.Zero, config.GetValue<int>("windowX"), config.GetValue<int>("windowY"), config.GetValue<int>("windowWidth"), config.GetValue<int>("windowHeight"), 0); } for (int i = 0; i < trail.Length; i++) trail[i] = new Point(0, 0); firstRun = false; } if (keys.KeyWentUp(WinAPI.VirtualKeyShort.F6)) { config.SetValue("windowWidth", info.rcWindow.Right - info.rcWindow.Left); config.SetValue("windowHeight", info.rcWindow.Bottom - info.rcWindow.Top); config.SetValue("windowX", info.rcWindow.Left); config.SetValue("windowY", info.rcWindow.Top); config.SaveSettingsToFile("chconfig.cfg"); } int width = info.rcClient.Right - info.rcClient.Left; int height = info.rcClient.Bottom - info.rcClient.Top; int sin = (int)(Math.Sin(DateTime.Now.TimeOfDay.TotalSeconds * 10) * width * 0.06); int cos = (int)(Math.Cos(DateTime.Now.TimeOfDay.TotalSeconds * 10) * height * 0.07); int randomD = (int)Math.Sqrt(Math.Sqrt(width * height)); int click_x = (int)(width * 0.725) + sin + config.GetValue<int>("offsetX"); int click_y = (int)(height * 0.55) + cos + config.GetValue<int>("offsetY"); if (randomize) { random = new Random(random.Next(0, (int)Environment.TickCount)); click_x += random.Next(0, randomD) * (random.Next(0, 2) == 1 ? 1 : -1); click_y += random.Next(0, randomD) * (random.Next(0, 2) == 1 ? 1 : -1); } if (advanceLevels && clicker) { int x = (int)(width * 0.81); int y = (int)(height * 0.06); int lParam = WinAPI.MakeLParam(x, y); int wParam = 0; WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_LBUTTONDOWN, wParam, lParam); WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_LBUTTONUP, wParam, lParam); } if (clicker) { int lParam = WinAPI.MakeLParam(click_x, click_y); int wParam = 0; WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_LBUTTONDOWN, wParam, lParam); WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_LBUTTONUP, wParam, lParam); } if (castSpells) { for (uint i = 0; i < 10; i++) { uint key = (uint)WinAPI.VirtualKeyShort.KEY_0 + i; uint scanCode = WinAPI.MapVirtualKey(key, 0); uint lParam = lParam = (0x00000001 | (scanCode << 16)); WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_KEYDOWN, (int)key, (int)lParam); WinAPI.SendMessage(proc.Process.MainWindowHandle, (uint)WinAPI.WindowMessage.WM_KEYUP, (int)key, (int)lParam); } } if (drawing) { Point[] tmp = new Point[trail.Length]; Array.Copy(trail, 1, tmp, 0, trail.Length - 1); trail = tmp; trail[trail.Length - 1] = new Point(click_x, click_y); try { using (Graphics g = Graphics.FromHwnd(proc.Process.MainWindowHandle)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.DrawRectangle(Pens.Black, width / 2f, 0, width / 2f, height); StringBuilder builder = new StringBuilder(); builder.AppendLine("ClickerHeroes - ExternalUtilsCSharp"); builder.AppendFormat("Autoclicker: {0}\n", clicker.ToString()); builder.AppendFormat("Randomize: {0}\n", randomize.ToString()); builder.AppendFormat("Cast spells: {0}\n", castSpells.ToString()); builder.AppendFormat("Offsets (x,y): {0} {1}\n", config.GetValue<int>("offsetX").ToString(), config.GetValue<int>("offsetY").ToString()); builder.AppendFormat("Current Window size (w,h): {0} {1}\n", (info.rcWindow.Right - info.rcWindow.Left).ToString(), (info.rcWindow.Bottom - info.rcWindow.Top).ToString()); builder.AppendFormat("Current Window coords (x,y): {0} {1}\n", info.rcWindow.Left.ToString(), info.rcWindow.Top.ToString()); builder.AppendFormat("Saved Window size (w,h): {0} {1}\n", config.GetValue<int>("windowWidth").ToString(), config.GetValue<int>("windowHeight").ToString()); builder.AppendFormat("Saved Window coords (x,y): {0} {1}", config.GetValue<int>("windowX").ToString(), config.GetValue<int>("windowY").ToString()); using (Font fnt = new Font("Courier New", 8)) { string text = builder.ToString(); SizeF size = g.MeasureString(text, fnt); g.FillRectangle(Brushes.Black, width / 2f, 0, size.Width + 8, size.Height + 8); g.DrawString(text, fnt, Brushes.Red, width / 2f + 4, 4); } for (int i = trail.Length - 1; i >= 1; i--) { if (trail[i].X != 0 && trail[i].Y != 0 && trail[i - 1].X != 0 && trail[i - 1].Y != 0) { g.DrawLine(Pens.Red, trail[i], trail[i - 1]); } } g.FillEllipse(Brushes.Red, click_x - 8, click_y - 8, 16, 16); int x = (int)(width * 0.81); int y = (int)(height * 0.06); g.FillEllipse(Brushes.Red, x - 8, y - 8, 16, 16); } } catch (Exception ex) { Console.WriteLine("Drawing failed: {0}", ex.Message); } } } } }
public async Task <IHttpActionResult> GetPresentation(int id) { // TODO. Enable CORS on the Azure blob and download presentation directly using AJAX. +http://odetocode.com/blogs/scott/archive/2014/03/31/http-clients-and-azure-blob-storage.aspx // +http://blog.cynapta.com/2013/12/cynapta-azure-cors-helper-free-tool-to-manage-cors-rules-for-windows-azure-blob-storage/ var blob = AzureStorageUtils.GetBlob(AzureStorageUtils.ContainerNames.Presentations, KeyUtils.IntToKey(id)); var text = await blob.DownloadTextAsync(); //var text = await AzureStorageUtils.GetBlobAsText(AzureStorageUtils.ContainerNames.Presentations, KeyUtils.IntToKey(id)); return(new RawStringResult(this, text, RawStringResult.TextMediaType.PlainText)); }