public override StackPanel Create(DeterministicRandom random) { StackPanel stackPanel = new StackPanel(); ApplyCommonProperties(stackPanel, random); return(stackPanel); }
public override LinearColorKeyFrame Create(DeterministicRandom random) { LinearColorKeyFrame linearColorKeyFrame = new LinearColorKeyFrame(); ApplyColorKeyFrameProperties(linearColorKeyFrame, random); return(linearColorKeyFrame); }
private unsafe void DrawToBitmap(byte *buffer, uint size, DeterministicRandom random) { for (uint i = 0; i < size; i++) { buffer[i] = unchecked ((byte)random.Next()); } }
/// <summary> /// Create a InkCanvas. /// </summary> /// <param name="random"></param> /// <returns></returns> public override InkCanvas Create(DeterministicRandom random) { InkCanvas inkCanvas = new InkCanvas(); inkCanvas.Background = Background; HomelessTestHelpers.Merge(inkCanvas.Children, UIElementCollection); inkCanvas.DefaultDrawingAttributes = DefaultDrawingAttributes; inkCanvas.DefaultStylusPointDescription = DefaultStylusPointDescription; inkCanvas.EditingMode = random.NextEnum <InkCanvasEditingMode>(); inkCanvas.EditingModeInverted = random.NextEnum <InkCanvasEditingMode>(); inkCanvas.EraserShape = EraserShape; inkCanvas.MoveEnabled = random.NextBool(); inkCanvas.PreferredPasteFormats = PreferredPasteFormats; inkCanvas.ResizeEnabled = random.NextBool(); inkCanvas.Strokes = Strokes; inkCanvas.UseCustomCursor = random.NextBool(); inkCanvas.ActiveEditingModeChanged += new RoutedEventHandler(ActiveEditingModeChanged); inkCanvas.DefaultDrawingAttributesReplaced += new DrawingAttributesReplacedEventHandler(DefaultDrawingAttributesReplaced); inkCanvas.EditingModeChanged += new RoutedEventHandler(EditingModeChanged); inkCanvas.EditingModeInvertedChanged += new RoutedEventHandler(EditingModeInvertedChanged); inkCanvas.Gesture += new InkCanvasGestureEventHandler(Gesture); inkCanvas.SelectionChanged += new EventHandler(SelectionChanged); inkCanvas.SelectionChanging += new InkCanvasSelectionChangingEventHandler(SelectionChanging); inkCanvas.SelectionMoved += new EventHandler(SelectionMoved); inkCanvas.SelectionMoving += new InkCanvasSelectionEditingEventHandler(SelectionMoving); inkCanvas.SelectionResized += new EventHandler(SelectionResized); inkCanvas.SelectionResizing += new InkCanvasSelectionEditingEventHandler(SelectionResizing); inkCanvas.StrokeCollected += new InkCanvasStrokeCollectedEventHandler(StrokeCollected); inkCanvas.StrokeErased += new RoutedEventHandler(StrokeErased); inkCanvas.StrokeErasing += new InkCanvasStrokeErasingEventHandler(StrokeErasing); inkCanvas.StrokesReplaced += new InkCanvasStrokesReplacedEventHandler(StrokesReplaced); return(inkCanvas); }
public override VectorAnimation Create(DeterministicRandom random) { VectorAnimation vectorAnimation = new VectorAnimation(); if (random.NextBool()) { vectorAnimation.From = FromValue; } if (random.NextBool()) { vectorAnimation.To = ToValue; } if (random.NextBool()) { vectorAnimation.By = ByValue; } vectorAnimation.IsAdditive = IsAdditive; vectorAnimation.IsCumulative = IsCumulative; vectorAnimation.EasingFunction = EasingFunction; ApplyTimelineProperties(vectorAnimation, random); return(vectorAnimation); }
/// <summary> /// Create a simple DataTemplate which contains a Button and a Label in a StackPanel. /// Label content is the string Length. /// Button content is the string. /// </summary> /// <param name="random"></param> /// <returns></returns> public override DataTemplate Create(DeterministicRandom random) { DataTemplate dataTemplate = new DataTemplate(typeof(string)); FrameworkElementFactory panel = new FrameworkElementFactory(typeof(StackPanel)); FrameworkElementFactory label = new FrameworkElementFactory(typeof(Label)); //Bind string Length to Label content. Binding lengthBinding = new Binding("Length"); lengthBinding.Mode = BindingMode.OneWay; label.SetBinding(Label.ContentProperty, lengthBinding); FrameworkElementFactory button = new FrameworkElementFactory(typeof(Button)); //Bind string to Button content. Binding contentBinding = new Binding(); contentBinding.Mode = BindingMode.OneWay; button.SetBinding(Button.ContentProperty, contentBinding); panel.AppendChild(label); panel.AppendChild(button); dataTemplate.VisualTree = panel; return(dataTemplate); }
public override DiscreteInt32KeyFrame Create(DeterministicRandom random) { DiscreteInt32KeyFrame discreteInt32KeyFrame = new DiscreteInt32KeyFrame(); ApplyInt32KeyFrameProperties(discreteInt32KeyFrame, random); return(discreteInt32KeyFrame); }
public override TransformGroup Create(DeterministicRandom random) { TransformGroup transformGroup = new TransformGroup(); transformGroup.Children = TransformCollection; return(transformGroup); }
public override SizeAnimation Create(DeterministicRandom random) { SizeAnimation sizeAnimation = new SizeAnimation(); if (random.NextBool()) { sizeAnimation.From = FromValue; } if (random.NextBool()) { sizeAnimation.To = ToValue; } if (random.NextBool()) { sizeAnimation.By = ByValue; } sizeAnimation.IsAdditive = IsAdditive; sizeAnimation.EasingFunction = EasingFunction; if (FromValue.Height > ToValue.Height || FromValue.Width > ToValue.Width) { sizeAnimation.IsCumulative = false; } else { sizeAnimation.IsCumulative = IsCumulative; } ApplyTimelineProperties(sizeAnimation, random); return(sizeAnimation); }
/// <summary> /// Create a Uri using one of the files specified in ListOfFilesOnFileHost.xml. /// For Uris created with different files, modify ListOfFilesOnFileHost.xml. /// </summary> /// <param name="random"></param> /// <returns></returns> public override Uri Create(DeterministicRandom random) { XmlDocument document = new XmlDocument(); document.Load(filesOnFileHost); XmlNodeList files = document.GetElementsByTagName("File"); int fileCount = files.Count; if (fileCount == 0) { throw new InvalidOperationException(String.Format("File: {0} doesn't contain any File node.", filesOnFileHost)); } int fileIndex = random.Next(fileCount); XmlElement fileNode = files[fileIndex] as XmlElement; string filename = fileNode.GetAttribute("Name"); if (String.IsNullOrEmpty(filename)) { throw new InvalidOperationException(String.Format("File node : \n {0} doesn't have Name attribute.", fileNode.OuterXml)); } FileHost fileHost = new FileHost(); Uri uri = fileHost.GetUri(filename, Scheme); return(uri); }
public override DecimalAnimation Create(DeterministicRandom random) { DecimalAnimation decimalAnimation = new DecimalAnimation(); if (random.NextBool()) { decimalAnimation.From = FromValue; } if (random.NextBool()) { decimalAnimation.To = ToValue; } if (random.NextBool()) { decimalAnimation.By = ByValue; } decimalAnimation.IsAdditive = IsAdditive; decimalAnimation.IsCumulative = IsCumulative; decimalAnimation.EasingFunction = EasingFunction; ApplyTimelineProperties(decimalAnimation, random); return(decimalAnimation); }
public override LineBreak Create(DeterministicRandom random) { LineBreak lineBreak = new LineBreak(); ApplyInlineProperties(lineBreak, random); return(lineBreak); }
public override BitmapPalette Create(DeterministicRandom random) { if (Colors == null) { Colors = new List <Color>(); } if (random.NextBool()) { for (int i = 1; i <= random.Next(256) + 1; i++) { Colors.Add(Color.FromScRgb( (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); } } else { for (int i = 1; i <= random.Next(256) + 1; i++) { Colors.Add(random.NextStaticProperty <Colors, Color>()); } } return(new BitmapPalette(Colors)); }
public override MediaElement Create(DeterministicRandom random) { MediaElement mediaElement = new MediaElement(); mediaElement.Source = Uri; mediaElement.Volume = random.NextDouble(); mediaElement.ScrubbingEnabled = random.NextBool(); if (IsControledWithClock && Timeline != null) { mediaElement.Clock = Timeline.CreateClock(); } else { mediaElement.Source = Uri; } //Events mediaElement.BufferingEnded += new System.Windows.RoutedEventHandler(BufferingEnded); mediaElement.BufferingStarted += new System.Windows.RoutedEventHandler(BufferingStarted); mediaElement.MediaOpened += new System.Windows.RoutedEventHandler(MediaOpened); mediaElement.MediaFailed += new EventHandler <System.Windows.ExceptionRoutedEventArgs>(MediaFailed); mediaElement.MediaEnded += new System.Windows.RoutedEventHandler(MediaEnded); return(mediaElement); }
private Color RandomColor(DeterministicRandom random) { return(Color.FromArgb(unchecked ((byte)random.Next()), unchecked ((byte)random.Next()), unchecked ((byte)random.Next()), unchecked ((byte)random.Next()))); }
/// <summary> /// A heavy non-cached Visual tree value extraction from state /// </summary> /// <param name="desiredType"></param> /// <param name="random"></param> /// <returns></returns> public DependencyObject GetFromVisualTree(Type desiredType, DeterministicRandom random) { List <DependencyObject> matches = new List <DependencyObject>(); foreach (Window window in windowList) { List <DependencyObject> elements = HomelessTestHelpers.VisualTreeWalk(window); elements.Add(window); foreach (DependencyObject obj in elements) { if (desiredType.IsInstanceOfType(obj)) { matches.Add(obj); } } } if (matches.Count == 0) { return(null); } return(random.NextItem <DependencyObject>(matches)); }
public override ListItem Create(DeterministicRandom random) { ListItem listItem = null; if (Paragraph != null) { listItem = new ListItem(Paragraph); } else { listItem = new ListItem(); } ApplyTextElementFactory(listItem, random); HomelessTestHelpers.Merge(listItem.Blocks, Children); listItem.BorderBrush = BorderBrush; listItem.BorderThickness = BorderThickness; listItem.FlowDirection = random.NextEnum <FlowDirection>(); listItem.LineHeight = CreateValidLineHeight(LineHeight); listItem.LineStackingStrategy = random.NextEnum <LineStackingStrategy>(); listItem.Margin = Margin; listItem.Padding = Padding; listItem.TextAlignment = random.NextEnum <TextAlignment>(); return(listItem); }
public object MakeFromConstraint(Type targetType, string propertyName, DeterministicRandom random) { // ConstrainedDataSource source = constraintsTable.Get(TargetTypeAttribute.FindTarget(targetType), propertyName); return(source.GetData(random)); }
public override object GetData(DeterministicRandom r) { double rangeWidth = MaxWidth - MinWidth; double rangeHeight = MaxHeight - MinHeight; return(new Size(MinWidth + rangeWidth * r.NextDouble(), MinHeight + rangeHeight * r.NextDouble())); }
public override ColumnDefinition Create(DeterministicRandom random) { ColumnDefinition columnDefinition = new ColumnDefinition(); columnDefinition.Width = Width; return(columnDefinition); }
public override MaterialGroup Create(DeterministicRandom random) { MaterialGroup materialGroup = new MaterialGroup(); materialGroup.Children = MaterialCollection; return(materialGroup); }
public override DatePicker Create(DeterministicRandom random) { DatePicker datePicker = new DatePicker(); if (DisplayDate != null) { datePicker.DisplayDate = (DateTime)DisplayDate.GetData(random); } if (DisplayDateEnd != null) { datePicker.DisplayDateEnd = (DateTime)DisplayDateEnd.GetData(random); } if (DisplayDateStart != null) { datePicker.DisplayDateStart = (DateTime)DisplayDateStart.GetData(random); } datePicker.FirstDayOfWeek = FirstDayOfWeek; datePicker.IsTodayHighlighted = IsTodayHighlighted; if (SelectedDate != null) { datePicker.SelectedDate = (DateTime)SelectedDate.GetData(random); } datePicker.SelectedDateFormat = SelectedDateFormat; return(datePicker); }
public Sequence GetNext(IState state, DeterministicRandom random) { Sequence sequence = null; ConvenienceStressState stressState = (ConvenienceStressState)state; Queue <Type> possibleActions = stressState.GetActions(random); while (possibleActions.Count > 0 && sequence == null) { DiscoverableAction action = (DiscoverableAction)Activator.CreateInstance(possibleActions.Dequeue()); Trace.WriteLine("[DiscoverableActionSequencer]Populating Action."); bool hasValidInputs = PopulateDiscoverableInputs(action, random, stressState, 0); //Add action to sequence only CanPerform is true, and input has been created successfully. if (hasValidInputs && action.CanPerform()) { sequence = new Sequence(); sequence.AddAction(action); } } if (sequence == null) { throw new InvalidOperationException("Stress could not find a new Action to perform at this state."); } return(sequence); }
public override BitmapFrame Create(DeterministicRandom random) { BitmapFrame bitmapFrame = BitmapFrame.Create(Uri); bitmapFrame.Freeze(); return(bitmapFrame); }
public override FigureLength Create(DeterministicRandom random) { double randomDouble = random.NextDouble(); switch (random.NextEnum <FigureUnitType>()) { case FigureUnitType.Auto: return(new FigureLength()); case FigureUnitType.Pixel: return(new FigureLength(randomDouble * 300, FigureUnitType.Pixel)); case FigureUnitType.Column: return(new FigureLength(randomDouble * 3, FigureUnitType.Column)); case FigureUnitType.Content: return(new FigureLength(randomDouble, FigureUnitType.Content)); case FigureUnitType.Page: return(new FigureLength(randomDouble, FigureUnitType.Page)); default: goto case 0; } }
public override TabItem Create(DeterministicRandom random) { TabItem tabItem = new TabItem(); ApplyHeaderedContentControlProperties(tabItem); return(tabItem); }
public override InteropBitmap Create(DeterministicRandom random) { int width = random.Next(400) + 1; int height = random.Next(400) + 1; int bytesPerPixel = (int)((Format.BitsPerPixel + 7.0) / 8.0); uint bufferSizeInBytes = (uint)(width * height * bytesPerPixel); int stride = (int)(width * bytesPerPixel); IntPtr fileHandle = CreateFileMapping(INVALID_HANDLE_VALUE, IntPtr.Zero, PAGE_READWRITE, 0, bufferSizeInBytes, null); if (fileHandle == IntPtr.Zero) { throw new InvalidOperationException("Could not create a file mapping for the Interop Bitmap"); } unsafe { IntPtr viewHandle = MapViewOfFile(fileHandle, FILE_MAP_ALL_ACCESS, 0, 0, bufferSizeInBytes); byte * pixels = (byte *)viewHandle.ToPointer(); DrawToBitmap(pixels, bufferSizeInBytes, random); UnmapViewOfFile(viewHandle); } InteropBitmap bitmap = (InteropBitmap)System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection(fileHandle, width, height, Format, stride, 0); // store the file handle as a dependency property, so that the InteropBitmap action has access to it // and so that when the InteropBitmap is garbage collected, the handle will still be closed SafeFileHandle section = new SafeFileHandle(fileHandle, true); bitmap.SetValue(HandleProperty, section); return(bitmap); }
public override UIElement Create(DeterministicRandom random) { UIElement uIElement = new UIElement(); uIElement.AllowDrop = random.NextBool(); uIElement.ClipToBounds = random.NextBool(); uIElement.Focusable = random.NextBool(); uIElement.IsEnabled = random.NextBool(); uIElement.IsHitTestVisible = random.NextBool(); #if TESTBUILD_CLR40 uIElement.IsManipulationEnabled = random.NextBool(); #endif uIElement.Opacity = random.NextDouble(); uIElement.Visibility = random.NextEnum <Visibility>(); uIElement.Effect = Effect; uIElement.Clip = Geometry; uIElement.Opacity = random.NextDouble(); uIElement.OpacityMask = Brush; uIElement.RenderSize = Size; uIElement.RenderTransform = Transform; uIElement.RenderTransformOrigin = Point; uIElement.SnapsToDevicePixels = random.NextBool(); #if TESTBUILD_CLR40 uIElement.CacheMode = BitmapCache; #endif return(uIElement); }
public override BitmapEffectGroup Create(DeterministicRandom random) { BitmapEffectGroup bitmapEffectGroup = new BitmapEffectGroup(); bitmapEffectGroup.Children = this.BitmapEffectCollection; return(bitmapEffectGroup); }
public override Vector3DAnimation Create(DeterministicRandom random) { Vector3DAnimation vector3DAnimation = new Vector3DAnimation(); /* * Randomly combinate From, To, By */ if (random.NextBool()) { vector3DAnimation.By = ByValue; } if (random.NextBool()) { vector3DAnimation.From = FromValue; } if (random.NextBool()) { vector3DAnimation.To = ToValue; } vector3DAnimation.IsAdditive = random.NextBool(); vector3DAnimation.IsCumulative = random.NextBool(); ApplyTimelineProperties(vector3DAnimation, random); return(vector3DAnimation); }