예제 #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (Parent == null)
            {
                Parent = AutomationElement.RootElement;
            }

            try
            {
                if (Parent == AutomationElement.RootElement)
                {
                    Scope = TreeScope.Children;
                }

                var controls = ObjectFinder.FindControls(this);

                if (controls.Count != 0)
                {
                    WriteObject(controls, true);
                }
                else
                {
                    ErrorHandler.ThrowTerminatingError(new ErrorRecord(new Exception("No control found."), "SearchError", ErrorCategory.ObjectNotFound, this), this);
                }
            }
            catch (Exception e)
            {
                ErrorHandler.ThrowTerminatingError(new ErrorRecord(e, "SearchError", ErrorCategory.NotSpecified, this), this);
                return;
            }
        }
예제 #2
0
    // Use this for initialization
    /// <summary>
    /// Loads system components and finds the droid ship + its mouse components.
    /// </summary>
    void Start()
    {
        /*var rectTransform = healthBar.GetComponent<RectTransform> ();
         * // Set initial positions so we know what the maximum value is.
         * healthInitialXPos = rectTransform.position.x;
         * energyInitialXPos = rectTransform.position.x;
         *
         * healthPos = rectTransform.position;
         * // Get the width of the bars - should be the same for both.
         * barWidth = rectTransform.rect.size.x;
         * //barWidth *= 10; // Scaling. I'm not sure how to do this better at this time.
         */

        //find or create these system components
        level          = ObjectFinder.FindOrCreateComponent <LevelManager> ();
        loader         = ObjectFinder.FindOrCreateLevelLoader();
        eventPublisher = ObjectFinder.FindOrCreateComponent <EventPublisher> ();

        //find the player to get the the mouse components and ship behaviour
        var ship = GameObject.Find("Player");

        xaxis         = ship.GetComponent <MouseLook> ();
        yaxis         = GameObject.Find("Attachments").GetComponent <MouseLook> ();
        shipBehaviour = ship.GetComponent <ShipBehaviour> ();

        //initialize the sensitivity to whatever is currently set in the editor
        sens = xaxis.sensitivityX;
        //initialize our molecule_tag -> texture mapping
        moleculeForTexture = new Dictionary <string, Texture>()
        {
            { "Water", waterTexture },
            { "Methane", methaneTexture }
        };
    }
예제 #3
0
        private async void PlayBtn_Click(object sender, RoutedEventArgs e)
        {
            ListViewItem   listViewItem = new ObjectFinder().GetParentObject <ListViewItem>((AppBarButton)sender, "");
            HtmlNodesClass content      = (HtmlNodesClass)listViewItem.DataContext;

            List <LyricClass> lyricClasses = await new LyricCreator().GetVOALyric(content.ID);

            Ins_PlayItem.ins_PlayItem.ID             = content.ID;
            Ins_PlayItem.ins_PlayItem.Date           = content.Date;
            Ins_PlayItem.ins_PlayItem.TitleEN        = content.TitleEN;
            Ins_PlayItem.ins_PlayItem.TitleCN        = content.TitleCN;
            Ins_PlayItem.ins_PlayItem.NetImagePath   = content.NetImagePath;
            Ins_PlayItem.ins_PlayItem.LocalImagePath = content.LocalImagePath;
            Ins_PlayItem.ins_PlayItem.Lyric          = lyricClasses;
            //Ins_PlayItem.ins_PlayItem.TotalTime= Convert.ToInt32(Ins_PlayItem.ins_PlayItem.Lyric[Ins_PlayItem.ins_PlayItem.Lyric.Count() - 1].Timing);
            Ins_PlayItem.ins_PlayItem.Status = "play";

            //Ins_PlayItem.mediaPlayer.Source = MediaSource.CreateFromUri(new Uri("http://static.iyuba.com/sounds/minutes/" + Ins_PlayItem.ins_PlayItem.ID + ".mp3"));
            //Ins_PlayItem.mediaPlayer.Source = MediaSource.CreateFromUri(new Uri("http://118.190.169.68/sounds/voa/" + Ins_PlayItem.ins_PlayItem.Date.Split('-')[0] + Ins_PlayItem.ins_PlayItem.Date.Split('-')[1] + "/" + Ins_PlayItem.ins_PlayItem.ID + ".mp3"));
            MediaSource mediaSource = MediaSource.CreateFromUri(new Uri("http://118.190.169.68/sounds/voa/" + Ins_PlayItem.ins_PlayItem.Date.Split('-')[0] + Ins_PlayItem.ins_PlayItem.Date.Split('-')[1] + "/" + Ins_PlayItem.ins_PlayItem.ID + ".mp3"));

            Ins_PlayItem.mediaPlaybackItem = new MediaPlaybackItem(mediaSource);

            var props = Ins_PlayItem.mediaPlaybackItem.GetDisplayProperties();

            props.Type = Windows.Media.MediaPlaybackType.Music;

            props.MusicProperties.Title  = content.TitleCN;
            props.MusicProperties.Artist = content.TitleEN;
            props.Thumbnail = RandomAccessStreamReference.CreateFromUri(new Uri(content.NetImagePath));
            Ins_PlayItem.mediaPlaybackItem.ApplyDisplayProperties(props);
            Ins_PlayList.mediaPlaybackList.Items.Add(Ins_PlayItem.mediaPlaybackItem);
            Ins_PlayItem.mediaPlayer.Source = Ins_PlayList.mediaPlaybackList;
            Ins_PlayItem.mediaPlayer.Play();
        }
 // Use this for initialization
 void Start()
 {
     m_behaviour    = GetComponent <CartoonBehaviour>();
     m_spinRate     = m_behaviour.m_spinRate;
     m_content      = new GUIContent(m_text);
     eventPublisher = ObjectFinder.FindOrCreateComponent <EventPublisher>();
 }
예제 #5
0
    public static EnergyBarUGUIBase Instantiate(Object parent, EnergyBarUGUIBase barPrefab, ObjectFinder canvasFinder, ObjectFinder cameraFinder, Transform attachPoint, bool networkInstantiate, int networkGroup) {
        EnergyBarUGUIBase bar;

#if !(UNITY_FLASH || UNITY_NACL || UNITY_METRO || UNITY_WP8 || UNITY_WEBGL)
        if (networkInstantiate) {
            bar = Network.Instantiate(barPrefab, barPrefab.transform.position, barPrefab.transform.rotation, networkGroup) as EnergyBarUGUIBase;
        } else {
            bar = Instantiate(barPrefab) as EnergyBarUGUIBase;
        }
#else
        bar = Instantiate(barPrefab) as EnergyBarUGUIBase;
#endif
        if (canvasFinder.chosenMethod == ObjectFinder.Method.ByType) {
            bar.transform.SetParent((canvasFinder.Lookup<Canvas>(parent)).transform, true);
        } else {
            bar.transform.SetParent((canvasFinder.Lookup<Transform>(parent)), true);
        }

        var followObject = bar.GetComponent<EnergyBarFollowObject>();
        if (followObject == null) {
            followObject = bar.gameObject.AddComponent<EnergyBarFollowObject>();
        }

        followObject.worldCamera = cameraFinder;
        followObject.followObject = attachPoint.gameObject;

        return bar;
    }
예제 #6
0
        static void LoadNextElementActivity()
        {
            if (mNextElement != null)
            {
                IElement elementToShow = ObjectFinder.GetIElement(mNextElement);
                mNextElement = null;

                RemoveCurrentElement();

                ContentManagerName = StringFunctions.IncrementNumberAtEnd(ContentManagerName);

                try
                {
                    if (BeforeElementLoaded != null)
                    {
                        BeforeElementLoaded(elementToShow);
                    }


                    CurrentElement = new ElementRuntime(elementToShow, null, null, OnBeforeVariableSet, OnAfterVariableSet);

                    if (AfterElementLoaded != null)
                    {
                        SpriteManager.AddPositionedObject(CurrentElement);
                        AfterElementLoaded(CurrentElement.AssociatedIElement);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error loading element " + elementToShow + ":\n\n" + e.ToString());
                }
            }
        }
예제 #7
0
        public void get_date_time_for_day_and_time_3()
        {
            DateTime date = ObjectFinder.GetDateTime("Wednesday 14:30");

            date.DayOfWeek.ShouldEqual(DayOfWeek.Wednesday);
            date.Date.AddHours(14).AddMinutes(30).ShouldEqual(date);
            (date >= DateTime.Today).ShouldBeTrue();
        }
예제 #8
0
        public void is_a_test_input()
        {
            var finder = new ObjectFinder();

            Cell.For <Address>("address").IsTestVariable(finder).ShouldBeFalse();
            Cell.For <ITestContext>("context").IsTestVariable(finder).ShouldBeFalse();
            Cell.For <int?>("age").IsTestVariable(finder).ShouldBeTrue();
            Cell.For <int>("age").IsTestVariable(finder).ShouldBeTrue();
            Cell.For <DateTime>("time").IsTestVariable(finder).ShouldBeTrue();
            Cell.For <DateTime?>("time").IsTestVariable(finder).ShouldBeTrue();
        }
예제 #9
0
    static void Init()
    {
        if (_allFinders == null)
        {
            _allFinders = new List <AFinder>();
        }

        // Get existing open window or if none, make a new one:
        ObjectFinder window = (ObjectFinder)EditorWindow.GetWindow(typeof(ObjectFinder));

        window.Show();
    }
예제 #10
0
        private List <Combine> GetPotentialMatchs(Movable fruit1, Movable fruit2, GameObject[,] allObjects, int matchCount)
        {
            ObjectFinder finder = new ObjectFinder();

            mover.ChangeFruits(fruit1, fruit2, false, true);
            List <Combine> matchList = finder.GetCombinedObjects(allObjects);

            if (matchList.Count > 0)
            {
                ClearExcess(matchList);
            }

            if (matchList.Count > matchCount)
            {
                mover.ChangeFruits(fruit1, fruit2, false, true);
                return(matchList);
            }
            mover.ChangeFruits(fruit1, fruit2, false, true);
            return(null);
        }
예제 #11
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            try
            {
                var controls = ObjectFinder.FindControls(this);
                if (controls.Count != 0)
                {
                    WriteObject(controls, true);
                }
                else
                {
                    ErrorHandler.ThrowTerminatingError(new ErrorRecord(new Exception("No control found."), "SearchError", ErrorCategory.ObjectNotFound, this), this);
                }
            }
            catch (Exception e)
            {
                ErrorHandler.ThrowTerminatingError(new ErrorRecord(e, "SearchError", ErrorCategory.NotSpecified, this), this);
                return;
            }
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            Entity targetActiveStats = ObjectFinder.FindObject(this.fieldInfo, property) as Entity;

            if (!property.isExpanded)
            {
                return(EditorGUIUtility.singleLineHeight);
            }
            SerializedProperty prop = property.FindPropertyRelative("m_Description");
            float height            = EditorGUI.GetPropertyHeight(prop, true);
            int   statCount         = 0;

            foreach (Stat stat in targetActiveStats.Stats)
            {
                if (stat.IsDefault)
                {
                    continue;
                }
                statCount++;
            }
            return(EditorGUIUtility.singleLineHeight * (statCount + 2) + height);
        }
예제 #13
0
        public static void Bind([NotNull] this LambdaExpression lambdaExpression, [CanBeNull] object value)
        {
            if (lambdaExpression == null)
            {
                throw new ArgumentNullException(nameof(lambdaExpression));
            }

            var memberExpression = lambdaExpression.MemberExpression();
            var obj = ObjectFinder.FindObject(lambdaExpression);

            switch (memberExpression.Member)
            {
            case PropertyInfo property:
                if (property.CanWrite)
                {
                    property.SetValue(obj, value);
                }
                // This is a readonly property. We try to write directly to the backing-field.
                else
                {
                    var bindingFlags = BindingFlags.NonPublic | (obj == null ? BindingFlags.Static : BindingFlags.Instance);
                    var backingField = (obj?.GetType() ?? property.DeclaringType).GetField($"<{property.Name}>k__BackingField", bindingFlags);
                    if (backingField == null)
                    {
                        throw ("BackingFieldNotFoundException", $"Property {property.Name.QuoteWith("'")} does not have a default backing field.").ToDynamicException();
                    }
                    backingField.SetValue(obj, value);
                }
                break;

            case FieldInfo field:
                field.SetValue(obj, value);
                break;

            default:
                throw new ArgumentException($"Member must be either a {nameof(MemberTypes.Property)} or a {nameof(MemberTypes.Field)}.");
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Entity targetActiveStats = ObjectFinder.FindObject(this.fieldInfo, property) as Entity;

            position.height = EditorGUIUtility.singleLineHeight;
            if (targetActiveStats == null)
            {
                return;
            }
            if (property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label, true))
            {
                EditorGUI.indentLevel++;
                Stat[] stats = targetActiveStats.Stats;
                Array.Sort(stats, (s1, s2) => { return(s1.ModTypeIdentifier.CompareTo(s2.ModTypeIdentifier)); });
                foreach (Stat stat in stats)
                {
                    if (stat.IsDefault)
                    {
                        continue;
                    }
                    position.y += EditorGUIUtility.singleLineHeight;
                    string text = string.Format("{0} = {1} / {2} ({3}|{4}|{5}|{6})", stat.ModTypeIdentifier, stat.Current, stat.Calculated, stat.Flat, stat.Increased, stat.More, stat.FlatExtra);
                    EditorGUI.LabelField(position, text);
                }
                position.y += EditorGUIUtility.singleLineHeight;
                targetActiveStats.CanTick = EditorGUI.Toggle(position, "CanTick?", targetActiveStats.CanTick);
                position.y += EditorGUIUtility.singleLineHeight;
                SerializedProperty prop = property.FindPropertyRelative("m_Description");
                position.height = EditorGUI.GetPropertyHeight(prop, true);
                EditorGUI.PropertyField(position, prop, true);
                EditorGUI.indentLevel--;
            }
            property.serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(property.serializedObject.targetObject);
            //base.OnGUI(position, property, label);
        }
예제 #15
0
 public FixtureLibrary()
 {
     _finder = new ObjectFinder();
 }
 // Use this for initialization
 void Start()
 {
     loader = ObjectFinder.FindOrCreateLevelLoader();
 }
예제 #17
0
        public void is_a_test_input()
        {
            var finder = new ObjectFinder();

            Cell.For<Address>("address").IsTestVariable(finder).ShouldBeFalse();
            Cell.For<ITestContext>("context").IsTestVariable(finder).ShouldBeFalse();
            Cell.For<int?>("age").IsTestVariable(finder).ShouldBeTrue();
            Cell.For<int>("age").IsTestVariable(finder).ShouldBeTrue();
            Cell.For<DateTime>("time").IsTestVariable(finder).ShouldBeTrue();
            Cell.For<DateTime?>("time").IsTestVariable(finder).ShouldBeTrue();
        }
예제 #18
0
 public FixtureLibrary()
 {
     _finder = new ObjectFinder();
 }
예제 #19
0
 public void SetUp()
 {
     finder = new TestContext().Finder;
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (popupStyle == null)
            {
                popupStyle = new GUIStyle(GUI.skin.GetStyle("PaneOptions"));
                popupStyle.imagePosition = ImagePosition.ImageOnly;
            }

            label    = EditorGUI.BeginProperty(position, label, property);
            position = EditorGUI.PrefixLabel(position, label);

            EditorGUI.BeginChangeCheck();

            //property.serializedObject.Update();

            SerializedProperty spIdentifier = property.FindPropertyRelative("m_Identifier");


            // Calculate rect for configuration button
            Rect buttonRect = new Rect(position);

            buttonRect.yMin += popupStyle.margin.top;
            buttonRect.width = popupStyle.fixedHeight + popupStyle.margin.right;
            position.xMin    = buttonRect.xMax + popupStyle.margin.right;
            property.serializedObject.ApplyModifiedProperties();
            object           obj              = ObjectFinder.FindObject(this.fieldInfo, property);
            IEnumerable      enumerable       = obj as IEnumerable;
            ObjectIdentifier objectIdentifier = obj as ObjectIdentifier;

            if (enumerable != null)
            {
                int index = 0;
                int.TryParse(property.propertyPath.Last((c) => c != ']').ToString(), out index);
                foreach (var enumObj in enumerable)
                {
                    if (index == 0)
                    {
                        objectIdentifier = enumObj as ObjectIdentifier;
                        break;
                    }
                    index--;
                }
            }

            //ObjectIdentifier objectIdentifier = GetValue(GetParent(property), property.name) as ObjectIdentifier;

            // Store old indent level and set it to 0, the PrefixLabel takes care of it
            int indent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            //if (Event.current.commandName.Equals("ObjectSelectorUpdated"))
            //{
            //    UnityEngine.Object g = EditorGUIUtility.GetObjectPickerObject();
            //    Debug.Log(g);
            //}

            if (objectIdentifier != null)
            {
                List <CoreObject> coreObjects = new List <CoreObject>();
                Type[]            types       = objectIdentifier.GetSupportedTypes();
                if (types != null)
                {
                    foreach (Type type in types)
                    {
                        UnityEngine.Object[] foundObjects = Resources.FindObjectsOfTypeAll(type);
                        foreach (UnityEngine.Object foundObject in foundObjects)
                        {
                            CoreObject foundCoreObject = foundObject as CoreObject;
                            if (foundCoreObject)
                            {
                                coreObjects.Add(foundCoreObject);
                            }
                        }
                    }
                }
                coreObjects.Sort((first, second) => { return(first.Identifier.CompareTo(second.Identifier)); });
                string[]    names = new string[coreObjects.Count];
                GenericMenu gm    = new GenericMenu();
                for (int i = 0; i < coreObjects.Count; i++)
                {
                    names[i] = coreObjects[i].Identifier;
                    FuncData funcData = new FuncData();
                    funcData.Property = spIdentifier;
                    funcData.Value    = names[i];
                    gm.AddItem(new GUIContent(names[i].Replace('.', '/')), false, OnItemChoosed, funcData);
                }
                if (GUI.Button(buttonRect, GUIContent.none, popupStyle))
                {
                    gm.DropDown(buttonRect);

                    //EditorGUIUtility.ShowObjectPicker<CoreObject>(null, false, "", 0);
                }
                //spIdentifier.stringValue = EditorGUI.TextField(position, spIdentifier.stringValue);

                Event evt = Event.current; switch (evt.type)
                {
                case EventType.DragUpdated:
                case EventType.DragPerform:
                    if (!position.Contains(evt.mousePosition))
                    {
                        return;
                    }

                    if (DragAndDrop.objectReferences.Length != 1)
                    {
                        return;
                    }
                    CoreObject coreObject = DragAndDrop.objectReferences[0] as CoreObject;
                    if (!coreObject)
                    {
                        return;
                    }

                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                    if (evt.type == EventType.DragPerform)
                    {
                        DragAndDrop.AcceptDrag();

                        spIdentifier.stringValue = coreObject.Identifier;
                        spIdentifier.serializedObject.ApplyModifiedProperties();
                        property.serializedObject.ApplyModifiedProperties();
                    }
                    break;
                }
                EditorGUI.PropertyField(position, spIdentifier, GUIContent.none);
            }
            if (EditorGUI.EndChangeCheck())
            {
                property.serializedObject.ApplyModifiedProperties();
            }

            EditorGUI.indentLevel = indent;
            EditorGUI.EndProperty();
        }
예제 #21
0
 public void get_date_time_from_24_hour_time()
 {
     ObjectFinder.GetDateTime("14:30").ShouldEqual(DateTime.Today.AddHours(14).AddMinutes(30));
 }
예제 #22
0
 public void SetUp()
 {
     finder = new ObjectFinder();
 }