/// <summary> /// Shows the and hang. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="direction">The direction.</param> /// <param name="title">The title.</param> /// <param name="plot2DType">Type of the plot2 d.</param> /// <param name="closeShape">if set to <c>true</c> [close shape].</param> /// <param name="marker">The marker.</param> public static void ShowAndHang(IList <Vertex> vertices, double[] direction, string title = "", Plot2DType plot2DType = Plot2DType.Line, bool closeShape = true, MarkerType marker = MarkerType.Circle) { ShowAndHang(MiscFunctions.Get2DProjectionPoints(vertices, direction, false), title, plot2DType, closeShape, marker); }
private void shouldQuit(bool back) //check if this form was opened by form booking { FormCollection fc = Application.OpenForms; int count = 0; foreach (Form f in fc) { if (f.Visible) { count++; } } if (count > 1) // opened from booking form { this.Close(); } else { if (back) { CrecheMenu form = new CrecheMenu(); form.Show(); this.Hide(); } else { MiscFunctions.exit(); } } }
Vector3 SetCharacterPointOrVelocity() { Vector3 pointToGoTo = Vector3.zero; if (character.movementType == Character.MovementType.MoveToPoint && Input.GetMouseButton(1)) { pointToGoTo = MiscFunctions.FindMousePositionIn3DSpace(); //character.positionOrDirection = pointToGoTo; } else if (character.movementType == Character.MovementType.MoveToward) { float horizontalInput = Input.GetAxisRaw("Horizontal"); float verticalInput = Input.GetAxisRaw("Vertical"); Vector3 moveVector = new Vector3(horizontalInput, 0, verticalInput).normalized; if (moveVector != Vector3.zero) { pointToGoTo = moveVector; } else { pointToGoTo = character.transform.position; } } character.positionOrDirection = pointToGoTo; return(pointToGoTo); }
public static void DeleteVpks(IEnumerable <string> listOfVpksToDelete) { foreach (string vpk in listOfVpksToDelete.Where(avv => !avv.Contains(@"platform"))) { MiscFunctions.DeleteFile(vpk); } }
private void ScanCookies() { if (!Wizard.SqLiteLoaded) { return; } // Firefox 2 and below var fileList = new List <string>(); long nTotalSize = 0; foreach ( var cookiesFile in FirefoxProfilePaths.Select(firefoxProfilePath => $@"{firefoxProfilePath}\cookies.txt")) { Wizard.CurrentFile = cookiesFile; if (File.Exists(cookiesFile)) { if (MiscFunctions.IsFileValid(cookiesFile)) { fileList.Add(cookiesFile); nTotalSize += MiscFunctions.GetFileSize(cookiesFile); } } } if (fileList.Count > 0) { Wizard.StoreBadFileList("Firefox v2 Cookies", fileList.ToArray(), nTotalSize); } Wizard.StoreCleanDelegate(CleanCookies, "Cookies", 0); }
private void ScanCache() { string profilesDir = $@"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\Mozilla\Firefox\Profiles"; var fileList = new List <string>(); long nTotalSize = 0; if (Directory.Exists(profilesDir)) { foreach ( var fileCache in Directory.GetDirectories(profilesDir, "*.default") .Select(dir => $@"{dir}\Cache") .Where(Directory.Exists) .SelectMany(Directory.GetFiles)) { Wizard.CurrentFile = fileCache; fileList.Add(fileCache); nTotalSize += MiscFunctions.GetFileSize(fileCache); } } Wizard.StoreBadFileList("Internet Cache Files", fileList.ToArray(), nTotalSize); }
private void ScanInternetHistory() { if (!Wizard.SqLiteLoaded) { return; } // Firefox 2 and below var fileList = new List <string>(); long nTotalSize = 0; foreach ( var historyFile in FirefoxProfilePaths.Select(firefoxProfilePath => $@"{firefoxProfilePath}\history.dat")) { Wizard.CurrentFile = historyFile; if (File.Exists(historyFile)) { if (MiscFunctions.IsFileValid(historyFile)) { fileList.Add(historyFile); nTotalSize += MiscFunctions.GetFileSize(historyFile); } } } if (fileList.Count > 0) { Wizard.StoreBadFileList("Firefox v2 Internet History", fileList.ToArray(), nTotalSize); } Wizard.StoreCleanDelegate(CleanInternetHistory, "Clear Internet History", 0); }
private bool checkLength() { try { if (!MiscFunctions.insureValid(Fnametxt.Text.Length, 30)) { Error1txt.Visible = true; throw new LengthException("First name is too long! Max lenght 30 characters"); } else if (!MiscFunctions.insureValid(Snametxt.Text.Length, 30)) { error2txt.Visible = true; throw new LengthException("Second name is too long! Max lenght 30 characters"); } else if (!MiscFunctions.insureValid(addresstxt.Text.Length, 50)) { error5txt.Visible = true; throw new LengthException("Address is too long! Max lenght 50 characters"); } else { return(true); } } catch (LengthException ex) { MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// Create the Polygonal Faces for a new Tessellated Solid by extruding the given loop along the given normal. /// </summary> /// <param name="loops"></param> /// <param name="extrudeDirection"></param> /// <param name="extrusionHeight"></param> /// <param name="midPlane"></param> /// <returns></returns> public static List <PolygonalFace> ExtrusionFacesFrom3DLoops(this IEnumerable <IEnumerable <Vector3> > loops, Vector3 extrudeDirection, double extrusionHeight, bool midPlane = false) { // for consistency with adding the extrusionHeight to the base plane, negate if it comes in negative if (extrusionHeight < 0) { extrusionHeight = -extrusionHeight; extrudeDirection = -1 * extrudeDirection; } // find transform to the XY plane and store the backTransform (the transform back to the original) var transform = MiscFunctions.TransformToXYPlane(extrudeDirection, out var backTransform); // make paths, the 2D polygons represening the 3D loops var paths = loops.Select(loop => loop.ProjectTo2DCoordinates(transform, 0, true)); // the basePlaneDistance defines the plane closer to the origin. we can get this from the any input coordinate var basePlaneDistance = extrudeDirection.Dot(loops.First().First()); if (midPlane) { basePlaneDistance -= extrusionHeight / 2.0; } var polygons = paths.CreateShallowPolygonTrees(false); return(polygons.SelectMany(polygon => Extrude.ExtrusionFacesFrom2DPolygons(polygon, extrudeDirection, basePlaneDistance, extrusionHeight)).ToList()); }
public static void ExtractAndDelete(string theserverfolder) { ClientAndServer.ExtractResourcesForBoth(); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(theserverfolder)); ClientAndServer.DeleteVpks(ClientAndServer.Returnallvpks(theserverfolder)); string resourceData = Resources.delete; // var words = resourceData.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); string[] items = resourceData.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); Parallel.ForEach(items, lines => { string fun = Path.Combine(theserverfolder, lines); FileAttributes attr = 0; if (File.Exists(fun) || Directory.Exists(fun)) { attr = File.GetAttributes(fun); } if (attr.HasFlag(FileAttributes.Directory)) { MiscFunctions.DeleteDir(Path.Combine(theserverfolder, lines)); } else { MiscFunctions.DeleteFile(Path.Combine(theserverfolder, lines)); } }); }
private static void Paralleloneachgame(string sourcesdk2007Installdir, IEnumerable <string> storedlocations, string ocinstalldir) { Parallel.ForEach(storedlocations, game => { if (game == " ") { } else if (game.EndsWith("hl2")) { MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\hl2"); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir); NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\hl2", game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory); } else { string gamename = game.Split(Path.DirectorySeparatorChar).Last(); MiscFunctions.DeleteDir(sourcesdk2007Installdir + "\\" + gamename); ClientAndServer.Runoneachvpk(ClientAndServer.Returndirvpks(game), ocinstalldir); NativeMethods.Otherstuff.CreateSymbolicLink(sourcesdk2007Installdir + "\\" + gamename, game, NativeMethods.Otherstuff.SymbolicLinkFlag.Directory); if (gamename.Equals(@"cstrike")) { File.Create(ocinstalldir + "\\mounts\\css"); } else if (gamename.Equals(@"hl1")) { File.Create(ocinstalldir + "\\mounts\\hls"); } else { File.Create(ocinstalldir + "\\mounts\\" + gamename); } } }); }
public static CrossSectionSolid CreateConstantCrossSectionSolid(double[] buildDirection, double extrudeDistance, List <Vertex> layer3DAtStart, double sameTolerance, UnitType units) { //Since the start point may be along a negative direction, we have to add vectors instead of adding the extrudeDistance as is. var start = layer3DAtStart.First().Position.dotProduct(buildDirection); var endPoint = layer3DAtStart.First().Position.add(buildDirection.multiply(extrudeDistance)); var stepDistances = new Dictionary <int, double> { { 0, start }, { 1, endPoint.dotProduct(buildDirection) } }; var shape = new PolygonLight(MiscFunctions.Get2DProjectionPointsAsLight(layer3DAtStart, buildDirection)); if (shape.Area < 0) { shape = PolygonLight.Reverse(shape); } var layers2D = new Dictionary <int, List <PolygonLight> > { { 0, new List <PolygonLight> { shape } }, { 1, new List <PolygonLight> { shape } } }; return(new CrossSectionSolid(buildDirection, stepDistances, sameTolerance, layers2D, null, units)); }
private void Draw(object sender, PaintEventArgs e) { MiscFunctions.DrawLinesList(_lines, e.Graphics); if (_points.Count == 1) { _isDrawing = true; MiscFunctions.DrawLine(_points[0], _mousePosition, drawPan.CreateGraphics()); } else if (_points.Count == 2) { _isDrawing = false; MiscFunctions.DrawLine(_points[0], _points[1], e.Graphics); if (MiscFunctions.GetColorFromColorDialog(out var color, colorDialog)) { e.Graphics.Clear(SystemColors.Control); MiscFunctions.DrawLinesList(_lines, e.Graphics); SetLine(color, e.Graphics); } else { e.Graphics.Clear(SystemColors.Control); MiscFunctions.DrawLinesList(_lines, e.Graphics); } _points.Clear(); } }
public static void LauncherValidate(MartialClient c, InPacket p) { byte pinLength = p.ReadByte(); byte uNameLength = p.ReadByte(); byte passWLength = p.ReadByte(); p.ReadByte(); string pin = MiscFunctions.obscureString(p.ReadString(4)); string uN = MiscFunctions.obscureString(p.ReadString(16)); string pW = MiscFunctions.obscureString(p.ReadString(12)); Account account = new Account(); if (account.Load(uN, pW, pin) != Account.AccountLoadErrors.Success) { c.WriteRawPacket(Constants.accDoesntExist); Logger.WriteLog(Logger.LogTypes.HEmi, "Authorization error for [{0} | {1} | {2}]", uN, pW, pin); c.Close(); return; } Logger.WriteLog(Logger.LogTypes.HEmi, "User passed authorization [{0} | {1} | {2}]", uN, pW, pin); account.mClient = c; c.setAccount(account); account.LoadCharacters(); if (c.getAccount().characters.Count() > 0) { c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), false).Concat(Constants.emptyAccount).ToArray()); } c.WriteRawPacket(Constants.emptyAccount); c.WriteRawPacket(LoginPacketCreator.initAccount(c.getAccount())); }
/// <summary> /// Gets the minimum bounding cylinder using 13 guesses for the depth direction /// </summary> /// <param name="convexHullVertices">The convex hull vertices.</param> /// <returns>BoundingBox.</returns> public static BoundingBox MinimumBoundingCylinder(IList <Vertex> convexHullVertices) { // here we create 13 directions. just like for bounding box var directions = new List <double[]>(); for (var i = -1; i <= 1; i++) { for (var j = -1; j <= 1; j++) { directions.Add(new[] { 1.0, i, j }); } } directions.Add(new[] { 0.0, 0, 1 }); directions.Add(new[] { 0.0, 1, 0 }); directions.Add(new[] { 0.0, 1, 1 }); directions.Add(new[] { 0.0, -1, 1 }); var boxes = directions.Select(v => new BoundingBox { Directions = new[] { v }, Volume = double.PositiveInfinity }).ToList(); for (var i = 0; i < 13; i++) { boxes[i] = Find_via_ChanTan_AABB_Approach(convexHullVertices, boxes[i]); for (var j = 0; j < 3; j++) { var pointsOnFace_i = MiscFunctions.Get2DProjectionPoints(convexHullVertices, boxes[i].Directions[j]); } } var minVol = boxes.Min(box => box.Volume); return(boxes.First(box => box.Volume == minVol)); }
public static void SendMessage(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook SendMessage handling while not being ingame."); c.Close(); return; } Character chr = c.getAccount().activeCharacter; int messageType = p.ReadInt(); // identifier of message type maybe? string receiver = p.ReadString(20); // receiver name MiscFunctions.obscureString(receiver); if (!MySQLTool.NameTaken(receiver)) { return; } int messageLength = p.ReadInt(); // message length string message = p.ReadString(messageLength); MiscFunctions.obscureString(message); OutPacket op = new OutPacket(20); op.WriteInt(20); op.WriteShort(4); op.WriteShort(0x53); op.WriteInt(718349825); op.WriteInt(chr.getuID()); op.WriteInt(-1089732352); c.WriteRawPacket(op.ToArray()); }
public PolygonLight(IEnumerable <PointLight> points) { Path = new List <PointLight>(points); Area = MiscFunctions.AreaOfPolygon(Path); MaxX = double.MinValue; MinX = double.MaxValue; MaxY = double.MinValue; MinY = double.MaxValue; foreach (var point in Path) { if (point.X > MaxX) { MaxX = point.X; } if (point.X < MinX) { MinX = point.X; } if (point.Y > MaxY) { MaxY = point.Y; } if (point.Y < MinY) { MinY = point.Y; } } }
// Constructor public MainPage() { InitializeComponent(); BuildLocalizedApplicationBar(); // Initialize objects _loc = new LocationManager(); _miscFunctions = new MiscFunctions(); _unitConversions = new UnitConversions(); _mapUnitIndex = App.UserSettings.GetSetting(AppResources.UserSettingsMapUnits, 0); _prog = new ProgressIndicator(); SystemTray.SetIsVisible(this, true); SystemTray.SetProgressIndicator(this, _prog); MapUnits(_mapUnitIndex); if (Compass.IsSupported) { App.DispatcherTimer.Tick += DispatcherTimer_Tick; App.DispatcherTimer.Start(); _transformCompass = new RotateTransform(); imgCompass.Visibility = Visibility.Visible; } }
private void AddEditStaff_Load(object sender, EventArgs e) { populatecbx(); initcombo(); Timer.Start(); Timelbl.Text = DateTime.Now.ToLongTimeString(); MiscFunctions.buttonhover(this); }
private void MouseUpHandler(object sender, MouseEventArgs e) { _isMouseDown = false; if (_lines?.Count > 0 && !_paintingToolIsActive) { MiscFunctions.LogMoving(_lines[_objToMove - 1], eventPanel); } }
private bool AllInputsAreParseable() { var result = MiscFunctions.IsParseableNumber(tbVolume.Text) && MiscFunctions.IsParseableNumber(tbTemperature.Text) && MiscFunctions.IsParseableNumber(tbPressure.Text); return(result); }
public BoundingBox(double[] dimensions, Vector3[] directions, T minPointOnDirection0, T minPointOnDirection1, T minPointOnDirection2) : base(dimensions, directions, MiscFunctions.PointCommonToThreePlanes(directions[0].Normalize(), minPointOnDirection0.Dot(directions[0].Normalize()), directions[1].Normalize(), minPointOnDirection1.Dot(directions[1].Normalize()), directions[2].Normalize(), minPointOnDirection2.Dot(directions[2].Normalize()))) { }
public void SetVerticesByLayer(int i) { var layer = Layer3D[i] = new List <List <Vertex> >(); foreach (var polygon in Layer2D[i]) { layer.Add(MiscFunctions.GetVerticesFrom2DPoints(polygon.Path, Direction, StepDistances[i])); } }
/// <summary> /// Shows the specified vertices. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="direction">The direction.</param> /// <param name="title">The title.</param> /// <param name="plot2DType">Type of the plot2 d.</param> /// <param name="closeShape">if set to <c>true</c> [close shape].</param> /// <param name="marker">The marker.</param> public static void Show(IList <Vertex[]> vertices, double[] direction, string title = "", Plot2DType plot2DType = Plot2DType.Line, bool closeShape = true, MarkerType marker = MarkerType.Circle) { Show( vertices.Select(listsOfVerts => MiscFunctions.Get2DProjectionPoints(listsOfVerts, direction, false) ) .ToList(), title, plot2DType, closeShape, marker); }
/// <summary> /// Initializes a new instance of the <see cref="PolygonalFace" /> class. /// </summary> /// <param name="vertices">The vertices.</param> /// <param name="suggestedNormal">A guess for the normal vector.</param> /// <param name="connectVerticesBackToFace">if set to <c>true</c> [connect vertices back to face].</param> public PolygonalFace(IEnumerable <Vertex> vertices, Vector3 suggestedNormal, bool connectVerticesBackToFace = true) : this(vertices, connectVerticesBackToFace) { _normal = MiscFunctions.DetermineNormalForA3DPolygon(Vertices, Vertices.Count, out var reverseVertexOrder, suggestedNormal); if (reverseVertexOrder) { Vertices.Reverse(); } }
/// <summary> /// Cone /// </summary> /// <param name="facesAll">The faces all.</param> /// <param name="axis">The axis.</param> /// <param name="aperture">The aperture.</param> public Cone(List <PolygonalFace> facesAll, Vector3 axis, double aperture) : base(facesAll) { Axis = axis; Aperture = aperture; var faces = MiscFunctions.FacesWithDistinctNormals(facesAll); var numFaces = faces.Count; var axisRefPoints = new List <Vector3>(); var n1 = faces[0].Normal.Cross(axis); var n2 = faces[^ 1].Normal.Cross(axis);
private void OnClosingHandler(object sender, FormClosingEventArgs e) { if (!_isSaved) { if (MiscFunctions.SavingPictureMessageBox() == DialogResult.Yes) { ClickSave(sender, e); } } }
public ViewRoute() { InitializeComponent(); MapPreview.CartographicMode = App.UserSettings.GetSetting<MapCartographicMode>("MapCartographicMode", MapCartographicMode.Road); MapPreview.ColorMode = App.UserSettings.GetSetting<MapColorMode>("MapColorMode", MapColorMode.Light); _miscFunctions = new MiscFunctions(); _fileIo = new FileIO(); _trackDb = new TrackDataContext(TrackDataContext.DBConnectionString); MapPreview.DoubleTap += MapPreview_DoubleTap; }
private static BoundingCircle MaximumInnerCircleInHole(Polygon polygon, Point centerPoint) { var shortestDistance = double.MaxValue; //1. For every line on the path, get the closest point on the edge to the center point. // Skip if min distance to line (perpendicular) forms a point not on the line. foreach (var line in polygon.PathLines) { var v1 = line.ToPoint.Position.subtract(line.FromPoint.Position, 2); //Correctly ordering the points should yield a negative area if the circle is inside a hole or outside a positive polygon. //Note also that zero area will occur when the points line up, which we want to ignore (the line ends will be checked anyways) if (!MiscFunctions.AreaOfPolygon(new List <Point> { line.FromPoint, line.ToPoint, centerPoint }).IsLessThanNonNegligible()) { continue; } //Figure out how far the center point is away from the line double[] pointOnLine; var d = MiscFunctions.DistancePointToLine(centerPoint.Position, line.FromPoint.Position, v1, out pointOnLine); if (d > shortestDistance) { continue; } //Now we need to figure out if the lines intersect var tempPoint = new Point(pointOnLine[0], pointOnLine[1]); var tempLine = new Line(centerPoint, tempPoint, false); Point intersectionPoint; if (!MiscFunctions.LineLineIntersection(line, tempLine, out intersectionPoint)) { continue; } //if(intersectionPoint != tempPoint) throw new Exception("Error in implementation. This should always be true."); shortestDistance = d; } //2. For every point in path and every closest edge point find distance to center. // The shortest distance determines the diameter of the inner circle. foreach (var point in polygon.Path) { var d = MiscFunctions.DistancePointToPoint(point.Position, centerPoint.Position); if (d < shortestDistance) { shortestDistance = d; } } if (shortestDistance.IsPracticallySame(double.MaxValue)) { return(new BoundingCircle(0.0, centerPoint)); //Not inside any hole or outside any positive polygon } return(new BoundingCircle(shortestDistance, centerPoint)); }
/// <summary> /// Initializes a new instance of the <see cref="Cylinder" /> class. /// </summary> /// <param name="facesAll">The faces all.</param> /// <param name="axis">The axis.</param> public Cylinder(IEnumerable <PolygonalFace> facesAll, double[] axis) : base(facesAll) { Type = PrimitiveSurfaceType.Cylinder; var faces = MiscFunctions.FacesWithDistinctNormals(facesAll.ToList()); var n = faces.Count; var centers = new List <double[]>(); double[] center; double t1, t2; var signedDistances = new List <double>(); MiscFunctions.SkewedLineIntersection(faces[0].Center, faces[0].Normal, faces[n - 1].Center, faces[n - 1].Normal, out center, out t1, out t2); if (!center.Any(double.IsNaN) || center.IsNegligible()) { centers.Add(center); signedDistances.Add(t1); signedDistances.Add(t2); } for (var i = 1; i < n; i++) { MiscFunctions.SkewedLineIntersection(faces[i].Center, faces[i].Normal, faces[i - 1].Center, faces[i - 1].Normal, out center, out t1, out t2); if (!center.Any(double.IsNaN) || center.IsNegligible()) { centers.Add(center); signedDistances.Add(t1); signedDistances.Add(t2); } } center = new double[3]; center = centers.Aggregate(center, (current, c) => current.add(c, 3)); center = center.divide(centers.Count); /* move center to origin plane */ var distBackToOrigin = -1 * axis.dotProduct(center, 3); center = center.subtract(axis.multiply(distBackToOrigin), 3); /* determine is positive or negative */ var numNeg = signedDistances.Count(d => d < 0); var numPos = signedDistances.Count(d => d > 0); var isPositive = numNeg > numPos; var radii = new List <double>(); foreach (var face in faces) { radii.AddRange(face.Vertices.Select(v => MiscFunctions.DistancePointToLine(v.Position, center, axis))); } var averageRadius = radii.Average(); Axis = axis; Anchor = center; IsPositive = isPositive; Radius = averageRadius; }