private void DrawTarget(Graphics g, Path path, PathTarget target, Rectangle rect, int row, int col, int rows, int cols) { var targetSize = new Size(rect.Width / cols, rect.Height / rows); var targetPosition = new Point(targetSize.Width * col + rect.X, targetSize.Height * row + rect.Y); var targetRect = new Rectangle(targetPosition, targetSize); if (target.SurroundTopology != null) { g.FillRectangle(new SolidBrush(Color.FromArgb(255, 106, 185, 0)), targetRect); } //else if (target.EyefinityTopology != null) // g.FillRectangle(new SolidBrush(Color.FromArgb(255, 99, 0, 0)), targetRect); else if (path.Targets.Length > 1) { g.FillRectangle(new SolidBrush(Color.FromArgb(255, 255, 97, 27)), targetRect); } else if (path.Position == Point.Empty) { g.FillRectangle(new SolidBrush(Color.FromArgb(255, 0, 174, 241)), targetRect); } else { g.FillRectangle(new SolidBrush(Color.FromArgb(255, 155, 155, 155)), targetRect); } g.DrawRectangle(new Pen(Color.FromArgb(125, 50, 50, 50), 2f), targetRect); }
/// <summary> /// Comprueba que los datos introducidos sean correctos /// </summary> private bool ValidateData() { bool validate = false; // Comprueba los datos introducidos if (Name.IsEmpty()) { DocWriterViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el nombre del archivo"); } else if (PathTarget.IsEmpty() || !System.IO.Directory.Exists(PathTarget)) { DocWriterViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el directorio"); } else if (!ProjectSource.IsEmpty() && (!ProjectSource.EndsWith(ProjectModel.FileName, StringComparison.CurrentCultureIgnoreCase) || !System.IO.File.Exists(ProjectSource))) { DocWriterViewModel.Instance.ControllerWindow.ShowMessage("Seleccione un nombre de proyecto válido"); } else { validate = true; } // Devuelve el valor que indica si los datos son correctos return(validate); }
public string GetEnvironmentVariable(string variable, PathTarget target, string @default = "") { #if (NETSTANDARD1_6) return(Environment.GetEnvironmentVariable(variable) ?? @default); #else return(Environment.GetEnvironmentVariable(variable, target.GetTarget()) ?? @default); #endif }
public void SetEnvironmentVariable(string variable, string value, PathTarget target) { #if (NETSTANDARD1_6) Environment.SetEnvironmentVariable(variable, value); #else Environment.SetEnvironmentVariable(variable, value, target.GetTarget()); #endif }
public DisplayRepresentation(PathTarget display) { Name = display.DisplayName; Path = display.DevicePath; IsAvailable = GetDisplay()?.IsAvailable ?? false; if (IsAvailable) { PossibleSettings = GetDisplay()?.GetPossibleSettings()?.ToArray() ?? new DisplayPossibleSetting[0]; } }
private IEnumerator UpdatePath(PathTarget pathTarget) { while (true) { if (pathTarget != null) { PathfindingManager.getInstance().RequestPath(transform.position, pathTarget.GetTarget(), GameManager.instance.GetCurrentGrid(), OnPathFound); } yield return(new WaitForSeconds(0.25f)); } }
private void DrawSurroundTopology(Graphics g, PathTarget target, Rectangle rect) { g.DrawRectangle(Pens.Black, rect); var targetSize = new Size(rect.Width / target.SurroundTopology.Columns, rect.Height / target.SurroundTopology.Rows); for (var i = 0; i < target.SurroundTopology.Displays.Length; i++) { var display = target.SurroundTopology.Displays[i]; var row = i / target.SurroundTopology.Columns; var col = i % target.SurroundTopology.Columns; var targetPosition = new Point(targetSize.Width * col + rect.X, targetSize.Height * row + rect.Y); var targetRect = new Rectangle(targetPosition, targetSize); g.DrawRectangle(Pens.Black, targetRect); switch (display.Rotation) { case Rotation.Rotate90: DrawString(g, "90°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; case Rotation.Rotate180: DrawString(g, "180°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; case Rotation.Rotate270: DrawString(g, "270°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; } if (!display.Overlap.IsEmpty) { DrawString(g, $"[{-display.Overlap.X}, {-display.Overlap.Y}]", targetRect.Size, new PointF(targetRect.X + PaddingY / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Near); } // Invert to real monitor resolution var res = ProfileIcon.NormalizeResolution(target.SurroundTopology.Resolution, display.Rotation); var str = $"{display.DisplayName}{Environment.NewLine}{res.Width}×{res.Height}"; DrawString(g, str, targetRect.Size, targetRect.Location); } }
/// <summary> /// Inicializa el ViewModel: propiedades, menús y comandos /// </summary> private void InitViewModel() { // Inicializa los comandos de página FirstPageCommand = CreateCommandForPage(nameof(FirstPageCommand)); NextPageCommand = CreateCommandForPage(nameof(NextPageCommand)); PreviousPageCommand = CreateCommandForPage(nameof(PreviousPageCommand)); LastPageCommand = CreateCommandForPage(nameof(LastPageCommand)); // Al cerrar el formulario, borrar el directorio temporal RequestClose += (sender, evntArgs) => { if (!PathTarget.IsEmpty() && System.IO.Directory.Exists(PathTarget)) { LibCommonHelper.Files.HelperFiles.KillPath(PathTarget); } }; }
public static EnvironmentVariableTarget GetTarget(this PathTarget self) { switch (self) { case PathTarget.User: return(EnvironmentVariableTarget.User); case PathTarget.Process: return(EnvironmentVariableTarget.Process); case PathTarget.Machine: return(EnvironmentVariableTarget.Machine); default: throw new ArgumentOutOfRangeException(nameof(self), self, $"Unknown {typeof(PathTarget).Name} value '{self}'."); } }
/// <summary> /// Comprueba que los datos introducidos sean correctos /// </summary> private bool ValidateData() { bool validate = false; // Comprueba los datos introducidos if (Title.IsEmpty()) { BookLibraryViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el título del libro"); } else if (PathTarget.IsEmpty()) { BookLibraryViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el directorio donde se debe crear el libro"); } else { validate = true; } // Devuelve el valor que indica si los datos son correctos return(validate); }
/// <summary> /// Obtiene un nombre de archivo completo relativo al proyecto eliminando el último directorio si es necesario /// </summary> private string GetRelativeFullFileName(string fileNameTarget) { string fileName = Path.GetFileNameWithoutExtension(fileNameTarget); string [] paths = PathTarget.Split('\\'); int intMaxIndex = paths.Length; string pathTarget = ""; // Ajusta el índice para obtener el último directorio if (paths.Length > 1 && fileName.EqualsIgnoreCase(paths [paths.Length - 1])) { intMaxIndex--; } // Crea el directorio for (int index = 0; index < intMaxIndex; index++) { pathTarget = pathTarget.AddWithSeparator(paths [index], "\\", false); } // Devuelve el nombre de archivo return(Path.Combine(pathTarget, fileNameTarget)); }
/// <summary> /// Comprueba que los datos introducidos sean correctos /// </summary> private bool ValidateData() { bool validate = false; // Comprueba los datos introducidos if (Name.IsEmpty()) { SourceEditorViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el nombre del archivo"); } else if (PathTarget.IsEmpty()) { SourceEditorViewModel.Instance.ControllerWindow.ShowMessage("Introduzca el directorio"); } else if (ProjectsDefinition.SelectedItem == null) { SourceEditorViewModel.Instance.ControllerWindow.ShowMessage("Seleccione un tipo de proyecto"); } else { validate = true; } // Devuelve el valor que indica si los datos son correctos return(validate); }
private void DrawTarget(Graphics g, Path path, PathTarget target, Rectangle rect, int row, int col, int rows, int cols) { var targetSize = new Size(rect.Width / cols, rect.Height / rows); var targetPosition = new Point(targetSize.Width * col + rect.X, targetSize.Height * row + rect.Y); var targetRect = new Rectangle(targetPosition, targetSize); if (target.SurroundTopology != null) { g.FillRectangle(new SolidBrush(Color.FromArgb(150, 106, 185, 0)), targetRect); } //else if (target.EyefinityTopology != null) // g.FillRectangle(new SolidBrush(Color.FromArgb(150, 99, 0, 0)), targetRect); else if (path.Targets.Length > 1) { g.FillRectangle(new SolidBrush(Color.FromArgb(150, 255, 97, 27)), targetRect); } else if (path.Position == Point.Empty) { g.FillRectangle(new SolidBrush(Color.FromArgb(150, 0, 174, 241)), targetRect); } else { g.FillRectangle(new SolidBrush(Color.FromArgb(255, 155, 155, 155)), targetRect); } g.DrawRectangle(Pens.Black, targetRect); var str = $"{target.DisplayName}{Environment.NewLine}{path.Resolution.Width}×{path.Resolution.Height}"; switch (target.Rotation) { case Rotation.Rotate90: DrawString(g, "90°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; case Rotation.Rotate180: DrawString(g, "180°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; case Rotation.Rotate270: DrawString(g, "270°", targetRect.Size, new PointF(targetRect.X - PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Far); break; } if (target.SurroundTopology != null) { var strSize = DrawString(g, str, targetRect.Size, new PointF(targetRect.X + PaddingX / 2, targetRect.Y + PaddingY / 2), StringAlignment.Near, StringAlignment.Near); DrawSurroundTopology(g, target, new Rectangle( targetRect.X + PaddingX, targetRect.Y + strSize.Height + PaddingY, targetRect.Width - 2 * PaddingX, targetRect.Height - strSize.Height - 2 * PaddingY)); } else { DrawString(g, str, targetRect.Size, targetRect.Location); } }
private void OnDisable() { target = null; currentPath = null; }
public void ThenTheCorrectTypeIsMapped(PathTarget input, EnvironmentVariableTarget expected) { var result = input.GetTarget(); Assert.That(result, Is.EqualTo(expected)); }