public R3ePoint GetValidPosition(PlaceholderModel placeholder, R3ePoint wantedPosition) { double validX = wantedPosition.X; double validY = wantedPosition.Y; int xMin = screenModel.Layout == ScreenLayoutType.SINGLE ? -1 : -3; int xMax = screenModel.Layout == ScreenLayoutType.SINGLE ? 1 : 3; int yMin = -1; int yMax = 1; // No check if placeholder is already outside the screen (case: we were in triple screen and switch to a single screen background, and at prompt we choose NOT to move placeholders in center screen. if (wantedPosition.X < xMin && placeholder.Position.X >= xMin) { validX = xMin; } else if (wantedPosition.X > xMax && placeholder.Position.X <= xMax) { validX = xMax; } if (wantedPosition.Y < yMin && placeholder.Position.Y >= yMin) { validY = yMin; } else if (wantedPosition.Y > yMax && placeholder.Position.Y <= yMax) { validY = yMax; } return(new R3ePoint(validX, validY)); }
internal void SetSelected(PlaceholderModel placeholder) { Selection = placeholder; UpdateData(); IsEnabled = true; }
public bool Matches(PlaceholderModel placeholder, ref string description, ScreenLayoutType layout, List <Fix> fixes) { if (this.layout == RuleLayoutType.SINGLE && layout != ScreenLayoutType.SINGLE || this.layout == RuleLayoutType.TRIPLE && layout != ScreenLayoutType.TRIPLE) { return(false); } // If no target specified, all targets are concerned. if (targets.Count > 0 && !targets.Contains(placeholder.Name)) { return(false); } bool isMatch = false; foreach (var part in parts) { if (part.Matches(placeholder)) { isMatch = true; description += (description.Length > 0 ? Environment.NewLine : "") + part.Description; fixes.AddRange(part.Fixes); } } return(isMatch); }
private static double GetOffsetXFromOutside(PlaceholderModel placeholder, ScreenPositionType targetScreen) { double zeroX = placeholder.Position.X + 3; if (zeroX < 0) { zeroX += 2; } double moduloX = zeroX % 2; double positionXInScreen = Math.Abs(moduloX); switch (targetScreen) { case ScreenPositionType.LEFT: return(positionXInScreen - 3 - placeholder.Position.X); case ScreenPositionType.RIGHT: return(positionXInScreen + 1 - placeholder.Position.X); case ScreenPositionType.CENTER: return(positionXInScreen - 1 - placeholder.Position.X); case ScreenPositionType.OUTSIDE: return(0); default: throw new Exception("Not implemented type."); } }
public void Execute() { PlaceholderModel placeholder = placeholderCollection.Get(args.Value); if (placeholder.ValidationResult.HasFix()) { placeholder.ApplyLayoutFix(); } }
public bool Matches(PlaceholderModel placeholder) { foreach (PropertyCheck check in checks) { if (!check.Matches(placeholder)) { return(false); } } return(true); }
public R3ePoint GetValidSize(PlaceholderModel placeholder, double wantedSize) { if (wantedSize < 0.1) { return(new R3ePoint(0.1, 0.1)); } if (wantedSize > 1) { return(new R3ePoint(1, 1)); } return(new R3ePoint(wantedSize, wantedSize)); }
internal void Unselect() { Selection = null; nameField.Content = ""; holdStepperEvent = true; stepperX.Value = stepperY.Value = stepperSize.Value = null; holdStepperEvent = false; holdPresetEvent = true; anchorPresets.SelectedItem = positionPresets.SelectedItem = null; holdPresetEvent = false; IsEnabled = false; }
public void Execute() { if (screenModel.Layout != ScreenLayoutType.TRIPLE) { return; } PlaceholderModel placeholder = collectionModel.Get(args.PlaceholderId); ScreenPositionType currentScreen = ScreenUtils.GetScreen(placeholder); R3ePoint screenOffset = ScreenUtils.ToScreenOffset(placeholder, args.ScreenType); R3ePoint newPosition = new R3ePoint(placeholder.Position.X + screenOffset.X, placeholder.Position.Y + screenOffset.Y); if (!newPosition.Equals(placeholder.Position)) { placeholder.Move(newPosition); } }
private double GetPropertyValue(PlaceholderModel placeholder) { switch (property) { case CheckPropertyType.X: return(placeholder.Position.X); case CheckPropertyType.Y: return(placeholder.Position.Y); case CheckPropertyType.SIZE: return(placeholder.Size.X); case CheckPropertyType.ANCHOR_X: return(placeholder.Anchor.X); case CheckPropertyType.ANCHOR_Y: return(placeholder.Anchor.Y); } throw new Exception("Unsupported property type."); }
public static ScreenPositionType GetScreen(PlaceholderModel placeholder) { double Px = placeholder.Position.X; double Ax = placeholder.Anchor.X; double Py = placeholder.Position.Y; if (Py < -1 || Py > 1) { return(ScreenPositionType.OUTSIDE); } if (Px == -1) { return(Ax > 0 ? ScreenPositionType.LEFT : ScreenPositionType.CENTER); } if (Px == 1) { return(Ax > 0 ? ScreenPositionType.CENTER : ScreenPositionType.RIGHT); } if (Px >= -3 && Px < -1) { return(ScreenPositionType.LEFT); } if (Px > -1 && Px < 1) { return(ScreenPositionType.CENTER); } if (Px > 1 && Px <= 3) { return(ScreenPositionType.RIGHT); } return(ScreenPositionType.OUTSIDE); }
public LayoutValidationResult Matches(PlaceholderModel placeholder) { bool isMatch = false; string description = ""; List <Fix> fixes = new List <Fix>(); foreach (var rule in rules) { if (rule.Matches(placeholder, ref description, screenModel.Layout, fixes)) { isMatch = true; } } if (isMatch) { return(LayoutValidationResult.GetInvalid(description, fixes)); } else { return(LayoutValidationResult.GetValid()); } }
public static R3ePoint ToScreenOffset(PlaceholderModel placeholder, ScreenPositionType targetScreen) { ScreenPositionType currentScreen = GetScreen(placeholder); // Replace placeholder Y in screen in case it's outside. double positionYInScreen = placeholder.Position.Y; if (placeholder.Position.Y < -1) { positionYInScreen = -1; } else if (placeholder.Position.Y > 1) { positionYInScreen = 1; } double offsetX = 0; double offsetY = positionYInScreen - placeholder.Position.Y; if (currentScreen == ScreenPositionType.OUTSIDE) { offsetX = GetOffsetXFromOutside(placeholder, targetScreen); } else { switch (targetScreen) { case ScreenPositionType.LEFT: if (currentScreen == ScreenPositionType.CENTER) { offsetX = -2; } else if (currentScreen == ScreenPositionType.RIGHT) { offsetX = -4; } break; case ScreenPositionType.RIGHT: if (currentScreen == ScreenPositionType.LEFT) { offsetX = 4; } else if (currentScreen == ScreenPositionType.CENTER) { offsetX = 2; } break; case ScreenPositionType.CENTER: if (currentScreen == ScreenPositionType.LEFT) { offsetX = 2; } else if (currentScreen == ScreenPositionType.RIGHT) { offsetX = -2; } break; case ScreenPositionType.OUTSIDE: offsetX = 0; break; default: throw new Exception("Not implemented type."); } } return(new R3ePoint(offsetX, offsetY)); }
internal bool Matches(PlaceholderModel placeholder) { return(operation.Matches(GetPropertyValue(placeholder))); }
public PlaceHolderUpdatedEventArgs(int eventId, PlaceholderModel placeholder) : base(eventId) { Placeholder = placeholder; }
internal List <PlaceholderModel> Parse(string hudOptionsPath) { int xmlVersion = GetXmlVersion(hudOptionsPath); if (xmlVersion < CURRENT_XML_VERSION) { UpdateXmlVersion(xmlVersion, hudOptionsPath); } Dictionary <string, PlaceholderModel> placeHolders = new Dictionary <string, PlaceholderModel>(); string fileContent = File.ReadAllText(hudOptionsPath); using (XmlReader xmlReader = XmlReader.Create(new StringReader(fileContent))) { while (xmlReader.ReadToFollowing("name")) { string name = xmlReader.ReadElementContentAsString(); if (!IsGeometricItem(name)) { continue; } GeometricItem item = GetGeometricItem(name); if (blackList.IsFiltered(item.Name)) { continue; } if (!placeHolders.ContainsKey(item.Name)) { PlaceholderModel placeholder = PlaceholderFactory.NewPlaceholder(item.Name); placeHolders.Add(placeholder.Name, placeholder); } xmlReader.ReadToFollowing("value"); xmlReader.MoveToFirstAttribute(); string valueType = xmlReader.Value; if (valueType != ValueType.VECTOR) { throw new Exception($"Expected value is a {ValueType.VECTOR}"); } xmlReader.MoveToContent(); string value = xmlReader.ReadElementContentAsString(); switch (item.ItemType) { case ItemType.POSITION: placeHolders[item.Name].Position = ParseVector(value); break; case ItemType.SIZE: placeHolders[item.Name].Size = ParseVector(value); break; case ItemType.ANCHOR: placeHolders[item.Name].Anchor = ParseVector(value); break; } } } return(placeHolders.Values.ToList()); }
public ValidationChangedEventArgs(int eventId, PlaceholderModel placeholder, LayoutValidationResult result) : base(eventId) { Placeholder = placeholder; Result = result; }
public void Execute() { PlaceholderModel model = collectionModel.Get(args.Value); selectionModel.Select(model); }
public SelectionModelEventArgs(int eventId, PlaceholderModel placeholder) : base(eventId) { Placeholder = placeholder; }
public void Execute() { PlaceholderModel placeholder = collectionModel.Get(args.View.Model.Id); placeholder.Move(moveValidator.GetValidPosition(placeholder, GetR3eLocation(args.Point))); }