Ejemplo n.º 1
0
 public MainWindow()
 {
     InitializeComponent();
     InitBoard();//ustala rozmiar grida na podstawie parametru SIZE i dodaje na planszę przyciski i etykiety
     _ObjectRandomizer          = new ObjectRandomizer(this);
     this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var reader = new ObjectRandomizer();
            Domain.Address domObj = new Domain.Address();
            reader.generateObjectRandomData<Domain.Address>(domObj);

            Domain.Company compObj = new Domain.Company();
            reader.generateObjectRandomData<Domain.Company>(compObj);

            var property = Builder<Domain.Property>
                                    .CreateNew()
                                    .With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus())
                                    .And(p => p.CountryCode = Randomizer.Address.GenerateRandomCountryCode())
                                    .And(p=> p.Addresses = (List<Domain.Address>)Builder<Domain.Address>
                                                            .CreateListOfSize(4)
                                                            .All().With(a => a.FullAddress = Randomizer.Address.GenerateRandomAddress())
                                                            .All().With(a => a.Country = Randomizer.Address.GenerateRandomCountry())
                                                            .Random(2).With(a=>a.Suite = Randomizer.Number.RandomIntMinMax(101,505).ToString())
                                                            .Random(2).With(a => a.Suite = null)
                                                            .Build())
                                    .Build();
            int maxElements;

            var mockData = Builder<Domain.Property>
                                    .CreateListOfSize(20)
                                    .All().With(p => p.PropertyID = Randomizer.Number.RandomIntMinMax(1, 9999999))
                                          .With(p => p.CountryCode = Randomizer.Address.GenerateRandomCountry())
                                          .With(p => p.Addresses = (List<Domain.Address>)Builder<Domain.Address>
                                                            .CreateListOfSize(Randomizer.Number.RandomIntMinMaxOut(2, 50, out maxElements))
                                                            .All()
                                                                .With(a => a.FullAddress = Randomizer.Address.GenerateRandomAddress())
                                                                .With(a => a.Country = Randomizer.Address.GenerateRandomCountry())
                                                                .Random(Randomizer.Number.RandomIntMinMax(1, maxElements/2)).With(a => a.Suite = Randomizer.Number.RandomIntMinMax(101, 505).ToString())
                                                                .Random(Randomizer.Number.RandomIntMinMax(1, maxElements / 2)).With(a => a.Suite = null)
                                                            .Build())
                                    .Random(2).With(p=>p.Addresses = new List<Domain.Address>())
                                    .TheFirst(5).With(p => p.ConstructionStatus = null)
                                    .TheNext(15).With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus())
                                    .Build();

            var json = JsonConvert.SerializeObject(mockData);

            reader.generateObjectRandomData<Domain.Property>(property);

            Type t = typeof(Domain.Property);
            MethodInfo[] methods = t.GetMethods();
            MemberInfo[] members = t.GetMembers();
            FieldInfo[] fields = t.GetFields();
            PropertyInfo[] properties = t.GetProperties();

            //var properties = Builder<Domain.Property>
            //                        .CreateListOfSize(500)
            //                        .All()
            //                        .With(p => p.ConstructionStatus = Randomizer.Property.GenerateRandomPropertyBuildingStatus())
            //                        .And(p => p.CountryCode = Randomizer.Address.GenerateRandomCountryCode())
            //                        .Build();

            var contacts = Builder<Contact>
                            .CreateListOfSize(700)
                            .All()
                            .With(c => c.FirstName = Randomizer.Person.GenerateRandomFirstName())
                            .And(c => c.LastName = Randomizer.Person.GenerateRandomLastName())
                            .And(c => c.BirthDate = Randomizer.Date.GenerateRandomBirthdateMinAge(18))
                            .And(c => c.EmailAddress = Randomizer.Person.GenerateRandomEmailForName(c.FirstName))
                            .And(c => c.PhoneNumber = Randomizer.Person.GenerateRandomPhone())
                            .Build();
        }
Ejemplo n.º 3
0
    const float normalizedSpacingsWidth    = .01f;  // there's two spacings atm

    void OnEnable()
    {
        // get script as serialized object
        targetScript = target as ObjectRandomizer;

        // calculate normalized weightings
        UpdateNormalizedWeightings();

        // init reorderable list
        list = new ReorderableList(serializedObject,
                                   serializedObject.FindProperty("objectInfos"),
                                   true, true, true, true);

        // add method for drawing list items
        list.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) => {
            // remember gui color
            Color guiColor = GUI.color;
            // get current element
            var element = list.serializedProperty.GetArrayElementAtIndex(index);
            // visual stuff
            rect.y += 2;             // move everything a bit for more space
            float rectWidth        = rect.width;
            float spacingWidth     = rectWidth * normalizedSpacingsWidth;
            float prefabWidth      = rectWidth * normalizedPrefabWidth;
            float weightingX       = prefabWidth + spacingWidth;
            float weightingWidth   = rectWidth * normalizedWeightingWidth;
            float progressBarX     = weightingX + weightingWidth + spacingWidth;
            float progressBarWidth = rectWidth * normalizedProgressBarWidth;

            // draw prefab
            EditorGUI.PropertyField(
                new Rect(rect.x, rect.y, prefabWidth, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("obj"), GUIContent.none);
            // draw weighting
            EditorGUI.PropertyField(
                new Rect(rect.x + weightingX, rect.y, weightingWidth, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("weighting"), GUIContent.none);
            // dirty hacks so that it's possible to change weighting values by dragging over the progress bars
            GUI.color = Color.clear;
            EditorGUI.PropertyField(
                new Rect(rect.x + progressBarX, rect.y, progressBarWidth, EditorGUIUtility.singleLineHeight),
                element.FindPropertyRelative("weighting"), new GUIContent("P"));
            GUI.color = guiColor;

            // draw progress bar for weighting
            EditorGUI.ProgressBar(
                new Rect(rect.x + progressBarX, rect.y, progressBarWidth, EditorGUIUtility.singleLineHeight),
                normalizedWeightings[index], "");
        };

        // update weightings when reordering list
        list.onReorderCallback = (ReorderableList l) => {
            UpdateNormalizedWeightings();
        };

        // set header
        list.drawHeaderCallback = (Rect rect) => {
            EditorGUI.LabelField(rect, "Weightings");
        };

        // override element adding to set default values
        list.onAddCallback = (ReorderableList l) => {
            var index = l.serializedProperty.arraySize;
            l.serializedProperty.arraySize++;
            l.index = index;
            var element = l.serializedProperty.GetArrayElementAtIndex(index);
            element.FindPropertyRelative("weighting").floatValue = 1f;
        };
    }