Esempio n. 1
0
        private static DateRange GetDateRange(int period, SelectionWindow selectionWindow)
        {
            switch (selectionWindow)
            {
            case SelectionWindow.Prev:
            {
                var startDate = DateTime.Today.Subtract(TimeSpan.FromDays(period * 2)).Subtract(TimeSpan.FromDays(1));
                var endDate   = DateTime.Today.Subtract(TimeSpan.FromDays(period)).Subtract(TimeSpan.FromDays(1));
                return(new DateRange
                    {
                        StartDate = startDate,
                        EndDate = endDate
                    });
            }

            case SelectionWindow.Current:
            {
                var startDate = DateTime.Today.Subtract(TimeSpan.FromDays(period)).Subtract(TimeSpan.FromDays(1));
                var endDate   = DateTime.Today.Subtract(TimeSpan.FromDays(1));
                return(new DateRange
                    {
                        StartDate = startDate,
                        EndDate = endDate
                    });
            }

            default:
                return(null);
            }
        }
Esempio n. 2
0
        private static Bitmap CreateScreenshot()
        {
            using (var bmp = new Bitmap((int)SystemParameters.VirtualScreenWidth, (int)SystemParameters.VirtualScreenHeight))
            {
                using (var graphic = Graphics.FromImage(bmp))
                {
                    graphic.CopyFromScreen((int)SystemParameters.VirtualScreenLeft, (int)SystemParameters.VirtualScreenTop, 0, 0, bmp.Size);

                    var hBitmap = bmp.GetHbitmap();

                    var selection = new SelectionWindow(new ImageBrush(Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())));
                    if (selection.ShowDialog() != true)
                    {
                        return(default(Bitmap));
                    }

                    var result = new Bitmap(selection.Result.Width, selection.Result.Height, PixelFormat.Format24bppRgb);
                    using (var resultgraphic = Graphics.FromImage(result))
                    {
                        resultgraphic.DrawImage(bmp, new Rectangle(0, 0, selection.Result.Width, selection.Result.Height), selection.Result, GraphicsUnit.Pixel);
                    }

                    NativeMethods.DeleteObject(hBitmap);
                    return(result);
                }
            }
        }
Esempio n. 3
0
                public void OnGUI()
                {
                    string name = "None";

                    if (type != null)
                    {
                        name = type.GetNiceName();
                    }

                    float size = new GUIStyle().CalcSize(new GUIContent(name)).x + 20f;
                    var   opt  = new GUILayoutOption[] { GUILayout.Width(size) };

                    // Display the type selection menu.
                    if (EditorGUILayout.DropdownButton(new GUIContent(name), FocusType.Keyboard, opt))
                    {
                        var selectTypeTab = new Tab <Type>(

                            getValues: () => Blackboard.registerTypes,
                            getCurrent: () => type,
                            setTarget: (t) => { type = t; },
                            getValueName: (t) => t.GetNiceName(),
                            title: "Select Type"
                            );

                        SelectionWindow.Show(selectTypeTab);
                    }
                }
Esempio n. 4
0
        public override void OnMemberDrawn(Rect rect)
        {
            var drop = gui.RegisterFieldForDrop <UnityObject>(rect);

            if (drop != null)
            {
                memberValue = GetPath(drop);
            }

            var e = Event.current;

            if (e != null && rect.Contains(e.mousePosition))
            {
                if (Event.current.control && EventsHelper.IsMMBMouseDown())
                {
                    SelectionWindow.Show(new Tab <GameObject>(
                                             @getValues: Resources.FindObjectsOfTypeAll <GameObject>,
                                             @getCurrent: () => null,
                                             @setTarget: input => memberValue = GetPath(input),
                                             @getValueName: target => target.name,
                                             @title: "Objects"
                                             ));
                }
            }
        }
Esempio n. 5
0
        // Display a menu to select key codes.
        private void selectKey()
        {
            // Get all the keycodes
            var keyCodes = Enum.GetValues(typeof(KeyCode));
            var keys     = new KeyCode[keyCodes.Length];

            // Set all the keycode values in the array in order to feed it into the selection window.
            int i = 0;

            foreach (KeyCode k in keyCodes)
            {
                keys[i++] = k;
            }

            // Display the selection window to pick a keycode.
            SelectionWindow.Show(new Tab <KeyCode>(

                                     getValues: () => keys,
                                     getCurrent: () => _selectedKey,
                                     setTarget: key => { _selectedKey = key; },

                                     getValueName: key => Enum.GetName(typeof(KeyCode), key),
                                     title: "Keys"
                                     ));
        }
Esempio n. 6
0
 void Initialize()
 {
     Selected       = 0;
     PlayerObject   = GameObject.FindGameObjectWithTag("Player");
     Player         = PlayerObject.GetComponent <PlayerControl>();
     WindowSelector = new SelectionWindow(PlayerObject, new Vector3(3, 2), new Vector3(5, 3));
     NewMessage     = new MessageWindow(PlayerObject);
     Items          = new string[] { "Save", "Load", "Exit" };
 }
Esempio n. 7
0
 void Initialize()
 {
     Selected       = 0;
     PlayerObject   = GameObject.FindGameObjectWithTag("Player");
     Player         = PlayerObject.GetComponent <PlayerControl>();
     WindowSelector = new SelectionWindow(PlayerObject, new Vector3(3, 2), new Vector3(5, 3));
     NewMessage     = new MessageWindow(PlayerObject);
     Items          = new string[] { "Yes", "No" };
     NewMessage.NewMessage("Hello", false);
 }
        public void ShowContextForm(int type)
        {
            desriptor = new Intermech.Navigator.DBObjectTypes.Descriptor(type);

            DynamicSelectionEventHandler delegat = new DynamicSelectionEventHandler(ImbaseTblSelected);

            SelectionWindow.DynamicSelectObjects("Таблицы IMBASE", "Выберите таблицу в которую будет произведена запись данных", desriptor, delegat, SelectionOptions.Default);

            SelectionWindow.OnSelectionWindowAfterClose += SelectionWindow_OnSelectionWindowAfterClose;
        }
 public StoreInstance()
 {
     App             = new App();
     Audio           = new Audio();
     Display         = new Display();
     Obs             = new Obs();
     Pipe            = new Pipe();
     Record          = new Record();
     SelectionWindow = new SelectionWindow();
     Webcam          = new Webcam();
 }
Esempio n. 10
0
    void Gray()
    {
        WhiteCam.active = BlackCam.active = true;
        SelectionWindow.SetActiveRecursively(false);
        gameState          = GameState.PlayGame;
        currentPlayMode    = CurrentPlayMode.Grey;
        time               = Time.timeSinceLevelLoad;
        CharWRender.active = CharBRender.active = true;

        TutorialWindow.SetActiveRecursively(true);
    }
Esempio n. 11
0
 void White()
 {
     WhiteCam.active = BlackCam.active = false;
     MainCam.active  = true;
     ActivateBlackMode(false);
     ActivateWhiteMode(true);
     SelectionWindow.SetActiveRecursively(false);
     gameState = GameState.PlayGame;
     GameManager.currentPlayMode = CurrentPlayMode.White;
     time = Time.timeSinceLevelLoad;
     CharWRender.active = true;
     CharBRender.active = false;
     TutorialWindow.SetActiveRecursively(true);
 }
Esempio n. 12
0
        /// <summary>
        /// Exposes to the user a text-format selector for the supplied Initial Text-Format.
        /// Returns indication of success (true, false=cancelled) plus the new text-format.
        /// </summary>
        public static Tuple <bool, TextFormat> SelectFor(TextFormat InitialTextFormat)
        {
            var Selector = new TextFormatSelector(InitialTextFormat);

            Selector.SelectionAction =
                (selectedtextformat =>
            {
                Selector.SelectedTextFormat = selectedtextformat;
                SelectionWindow.Close();
            });

            var Result = Display.OpenContentDialogWindow <TextFormatSelector>(ref SelectionWindow, "Text format...", Selector).IsTrue();

            return(new Tuple <bool, TextFormat>(Result, Selector.SelectedTextFormat));
        }
Esempio n. 13
0
 public void Initialize()
 {
     Selected       = 0;
     PlayerObject   = GameObject.FindGameObjectWithTag("Player");
     Player         = PlayerObject.GetComponent <PlayerControl>();
     WindowSelector = new SelectionWindow(PlayerObject, new Vector3(3, 2));
     NewMessage     = new MessageWindow(PlayerObject);
     Items          = new string[] { "New Game", "Load Save", "Exit" };
     if (!Started)
     {
         Started = true;
         StartCoroutine(Wait());
     }
     PlayerObject.transform.position = Vector3.zero;
 }
        public void ShowSelection()
        {
            var desktop = GuiManager.Screen.Desktop;

            if (SelectionWindow.ClassList.Items.Count > 0 && SelectionWindow.ClassList.SelectedItems.Count == 0)
            {
                SelectionWindow.ClassList.SelectItem(0);
            }

            SelectionWindow.LayoutFlags = ControlLayoutFlags.Center;
            desktop.Children.Add(SelectionWindow);
            SelectionWindow.Update();

            desktop.UpdateLayout();
        }
Esempio n. 15
0
        /// <summary>
        /// Add genre to content
        /// </summary>
        private void AddGenre()
        {
            // Create array of genre string for selection
            GenreCollection allGenres;

            if (this.Content is Movie)
            {
                allGenres = Organization.AllMovieGenres;
            }
            else
            {
                allGenres = Organization.AllTvGenres;
            }

            List <string> selectableGenres = new List <string>();

            for (int i = 0; i < allGenres.Count; i++)
            {
                // Don't list genres already added
                if (content.DisplayGenres.Contains(allGenres[i]))
                {
                    continue;
                }

                // Add genre name
                selectableGenres.Add(allGenres[i]);
            }
            string[] selectableGenresArray = selectableGenres.ToArray();

            SelectionWindow selWindow = new SelectionWindow("Select Genre to Add", selectableGenresArray);

            selWindow.ShowDialog();

            // If selection is valid set sub-folder as sub-content folder
            if (!string.IsNullOrEmpty(selWindow.Results))
            {
                foreach (string genre in allGenres)
                {
                    if (genre == selWindow.Results)
                    {
                        this.content.DisplayGenres.Add(genre);
                        break;
                    }
                }
            }
        }
Esempio n. 16
0
        protected override void AcceptCoordsInput(InputArgs <Point2D, SelectionSet> args)
        {
            if (!getFirstPoint)
            {
                firstPoint          = args.Input;
                getFirstPoint       = true;
                args.InputCompleted = false;

                consLine = new SelectionWindow(firstPoint, firstPoint);
                Editor.Document.Transients.Add(consLine);
            }
            else
            {
                args.Value          = GetSelectionFromWindow();
                args.InputCompleted = true;

                Editor.Document.Transients.Remove(consLine);
            }
        }
 public override void OnRightGUI()
 {
     if (gui.SelectionButton())
     {
         string[] names        = Enum.GetNames(memberType);
         int      currentIndex = memberValue == null ? -1 : names.IndexOf(memberValue.ToString());
         SelectionWindow.Show(new Tab <string>(
                                  @getValues: () => names,
                                  @getCurrent: () => memberValue.ToString(),
                                  @setTarget: name =>
         {
             if (names[currentIndex] != name)
             {
                 memberValue = name.ParseEnum(memberType);
             }
         },
                                  @getValueName: name => name,
                                  @title: memberTypeName + "s"
                                  ));
     }
 }
Esempio n. 18
0
        private void AddChild()
        {
            if (this.SelectedRootFolder != null)
            {
                // Get list of sub-directories in content folder
                string[] subDirs = this.SelectedRootFolder.GetFolderSubDirectoryNamesThatArentChildren().ToArray();

                // open selection form to allow user to chose a sub-folder
                SelectionWindow selForm = new SelectionWindow("Select Folder", subDirs);
                selForm.ShowDialog();

                // If selection is valid set sub-folder as sub-content folder
                if (!string.IsNullOrEmpty(selForm.Results))
                {
                    ContentRootFolder newChild = new ContentRootFolder(this.ContentType, selForm.Results, System.IO.Path.Combine(this.SelectedRootFolder.FullPath, selForm.Results));
                    newChild.PropertyChanged += cloneFolder_PropertyChanged;
                    this.SelectedRootFolder.ChildFolders.Add(newChild);
                }
                UpdateAvailableFolders();
            }
        }
Esempio n. 19
0
        public WorkspaceViewModel SelectBarcodesWorkspace(IEnumerable <WorkspaceViewModel> workspaces)
        {
            var selectedWorkspace = workspaces.First();
            var input             = new SelectionInput <WorkspaceViewModel>
            {
                Title             = "Barcodes - Workspaces",
                ContentHeader     = "Select desired workspace",
                Label             = "Workspace:",
                Items             = workspaces,
                SelectedItem      = selectedWorkspace,
                DisplayMemberPath = "Name"
            };
            var dataContext = new SelectionViewModel <WorkspaceViewModel>(input);
            var window      = new SelectionWindow(dataContext)
            {
                Owner = MainWindow
            };

            window.ShowDialog();
            return(dataContext.Result);
        }
Esempio n. 20
0
        public StorageBarcodeViewModel SelectStorageBarcode(object parentViewModel, List <StorageBarcodeViewModel> barcodes)
        {
            var selectedBarcode = barcodes.First();
            var input           = new SelectionInput <StorageBarcodeViewModel>
            {
                Title             = "Barcodes - Import",
                ContentHeader     = "Select barcode",
                Label             = "Barcode:",
                Items             = barcodes,
                SelectedItem      = selectedBarcode,
                DisplayMemberPath = "Title"
            };
            var dataContext = new SelectionViewModel <StorageBarcodeViewModel>(input);
            var window      = new SelectionWindow(dataContext)
            {
                Owner = GetWindowWithDataContext(parentViewModel)
            };

            window.ShowDialog();
            return(dataContext.Result);
        }
Esempio n. 21
0
        public static void BrowseInteractions(IEnumerable <TypeInfo> types, bool drawGraph, bool passSelection)
        {
            if (WindowManager.InteractionBrowsers.Count > 0 && !passSelection)
            {
                var selectionWindow = new SelectionWindow(types, drawGraph);
#if ILSpy
                selectionWindow.Owner = MainWindow;
#elif Reflector
                System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(selectionWindow);
#endif
                selectionWindow.Show();
                return;
            }

            var window = new InteractionBrowserWindow(types, drawGraph);
#if ILSpy
            window.Owner = MainWindow;
#elif Reflector
            System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(window);
#endif
            window.Show();
        }
Esempio n. 22
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            var isValueOfTypeNode = target as IsValueOfType;

            Type typeToCheck = isValueOfTypeNode.type;

            string typename = "null";

            if (typeToCheck != null)
            {
                typename = isValueOfTypeNode.type.GetNiceName();
            }

            float size = new GUIStyle().CalcSize(new GUIContent(typename)).x + 20f;
            var   opt  = new GUILayoutOption[] { GUILayout.Width(size) };

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Type: ");

            // Display the type selection menu.
            if (EditorGUILayout.DropdownButton(new GUIContent(typename), FocusType.Keyboard, opt))
            {
                var selectTypeTab = new Tab <Type>(

                    getValues: () => Blackboard.registerTypes,
                    getCurrent: () => isValueOfTypeNode.type,
                    setTarget: (t) => { isValueOfTypeNode.type = t; },
                    getValueName: (t) => t.GetNiceName(),
                    title: "Select Type"
                    );

                SelectionWindow.Show(selectTypeTab);
            }

            EditorGUILayout.EndHorizontal();
        }
Esempio n. 23
0
        public override void OnGUI()
        {
            using (gui.Horizontal())
            {
                bool isNull        = member.IsNull();
                bool isObjectField = prefs.Bools.ValueOrDefault(id);

                gui.Text(displayText, isNull ? "null" : memberValue.name + " (" + memberTypeName + ")");

                var fieldRect = gui.LastRect;
                {
                    GUIHelper.PingField(fieldRect, memberValue, !isNull && isObjectField);
                }

                if (gui.SelectionButton("object"))
                {
                    Func <UnityObject[], string, Tab> newTab = (values, title) =>
                                                               new Tab <UnityObject>(
                        @getValues: () => values,
                        @getCurrent: member.As <UnityObject>,
                        @setTarget: member.Set,
                        @getValueName: obj => obj.name,
                        @title: title
                        );

                    bool isGo = memberType == typeof(GameObject);
                    SelectionWindow.Show("Select a " + memberTypeName,
                                         newTab(UnityObject.FindObjectsOfType(memberType), "All"),
                                         newTab(isGo ?  (UnityObject[])gameObject.GetChildren() :
                                                gameObject.GetComponentsInChildren(memberType), "Children"),
                                         newTab(isGo ?  (UnityObject[])gameObject.GetParents() :
                                                gameObject.GetComponentsInParent(memberType), "Parents"),
                                         newTab(isGo ? PrefabHelper.GetGameObjectPrefabs().ToArray() :
                                                PrefabHelper.GetComponentPrefabs(memberType).Cast <UnityObject>().ToArray(), "Prefabs")
                                         );
                }
            }
        }
Esempio n. 24
0
        protected override void AcceptTextInput(InputArgs <string, SelectionSet> args)
        {
            args.InputValid = Point2D.TryParse(args.Input, out Point2D pt);
            if (args.InputValid)
            {
                if (!getFirstPoint)
                {
                    firstPoint          = pt;
                    getFirstPoint       = true;
                    args.InputCompleted = false;

                    consLine = new SelectionWindow(firstPoint, firstPoint);
                    Editor.Document.Transients.Add(consLine);
                }
                else
                {
                    args.Value          = GetSelectionFromWindow();
                    args.InputCompleted = true;

                    Editor.Document.Transients.Remove(consLine);
                }
            }
        }
        public override void OnRightGUI()
        {
            if (gui.SelectionButton())
            {
                Func <string[]> getScenes = () =>
                                            Directory.GetFiles("Assets", "*.unity", SearchOption.AllDirectories)
                                            .Select(f => f.Substring(f.IndexOf("Assets") + 6).RemoveExtension())
                                            .ToArray();

                Func <string, string> getSceneName = path =>
                                                     path.Substring(path.Replace('\\', '/').LastIndexOf('/') + 1);

                var dictionary = new KVPList <string, string>();
                var allScenes  = getScenes();
                foreach (var s in allScenes)
                {
                    dictionary.Add(getSceneName(s), s);
                }

                Func <Func <string[]>, string, Tab <string> > sceneTab = (scenes, title) =>
                                                                         new Tab <string>(
                    @getValues: scenes,
                    @getCurrent: () => dictionary.ContainsKey(memberValue) ? dictionary[memberValue] : memberValue,
                    @setTarget: s => memberValue = getSceneName(s),
                    @getValueName: s => s,
                    @title: title
                    );

                var buildScenes = EditorBuildSettings.scenes.Select(s => s.path);

                SelectionWindow.Show("Select scene",
                                     sceneTab(getScenes, "All"),
                                     sceneTab(getScenes().Where(s => buildScenes.Any(bs => Regex.Replace(bs, "/", "\\").Contains(s))).ToArray, "Build")
                                     );
            }
        }
Esempio n. 26
0
    void Awake()
    {
        BlackMat.color = new Color(BlackMat.color.r, BlackMat.color.g, BlackMat.color.b, 1f);
        WhiteMat.color = new Color(WhiteMat.color.r, WhiteMat.color.g, WhiteMat.color.b, 1f);
        gameState      = GameState.OpeningWindow;
        OpeningWindow.SetActiveRecursively(true);
        GameOverWindow.SetActiveRecursively(false);
        SelectionWindow.SetActiveRecursively(false);
        TutorialWindow.SetActiveRecursively(false);


        BlackCam.camera.rect = new Rect(0.5f, 0, 0.5f, 1);
        WhiteCam.camera.rect = new Rect(0, 0, 0.5f, 1);

        MainCam.camera.rect = new Rect(0, 0, 1, 1);
        MainCam.active      = true;
        BlackCam.active     = WhiteCam.active = false;
        //fb = fbsuccess.GetComponent<UILabel>();

        deathLbl.text = "You died: @ time(s)!";
        timeLbl.text  = "Your max time: @";

        //White();
    }
        private void AddChild()
        {
            if (this.SelectedRootFolder != null)
            {
                // Get list of sub-directories in content folder
                string[] subDirs = this.SelectedRootFolder.GetFolderSubDirectoryNamesThatArentChildren().ToArray();

                // open selection form to allow user to chose a sub-folder
                SelectionWindow selForm = new SelectionWindow("Select Folder", subDirs);
                selForm.ShowDialog();

                // If selection is valid set sub-folder as sub-content folder
                if (!string.IsNullOrEmpty(selForm.Results))
                {
                    ContentRootFolder newChild = new ContentRootFolder(this.ContentType, selForm.Results, System.IO.Path.Combine(this.SelectedRootFolder.FullPath, selForm.Results));
                    newChild.PropertyChanged += cloneFolder_PropertyChanged;
                    this.SelectedRootFolder.ChildFolders.Add(newChild);
                }
                UpdateAvailableFolders();
            }
        }
Esempio n. 28
0
        public override void OnGUI()
        {
            if (memberValue == null)
            {
                memberValue = GetNew();
            }

            member.CollectionCount = memberValue.Count;

            if (UpdateCount && _lastUpdatedCount != memberValue.Count)
            {
                _lastUpdatedCount = memberValue.Count;
                displayText       = Regex.Replace(_originalDisplay, @"\$count", _lastUpdatedCount.ToString());
            }

            bool showAdvanced = _options.Advanced && !_options.Readonly;

            // header
            using (gui.Horizontal())
            {
                foldout = gui.Foldout(displayText, foldout, Layout.Auto);

                if (_options.Filter)
                {
                    _filter.Field(gui, 70f);
                }

                gui.FlexibleSpace();

                if (showAdvanced)
                {
                    isAdvancedChecked = gui.CheckButton(isAdvancedChecked, "advanced mode");
                }

                if (!_options.Readonly)
                {
                    using (gui.State(memberValue.Count > 0))
                    {
                        if (gui.ClearButton("elements"))
                        {
                            Clear();
                            _dirty = true;
                        }
                        if (gui.RemoveButton("last element"))
                        {
                            RemoveLast();
                            _dirty = true;
                        }
                    }
                    if (gui.AddButton("element", MiniButtonStyle.ModRight))
                    {
                        AddValue();
                        _dirty = true;
                    }
                }
            }

            if (!foldout)
            {
                return;
            }

            if (memberValue.IsEmpty())
            {
                using (gui.Indent())
                    gui.HelpBox("Sequence is empty");
                return;
            }

            _dirty = false;

            // body
            using (gui.Vertical(_options.GuiBox ? GUI.skin.box : GUIStyle.none))
            {
                // advanced area
                if (isAdvancedChecked)
                {
                    using (gui.Indent((GUI.skin.box)))
                    {
                        using (gui.Horizontal())
                        {
                            _newSize = gui.Int("New size", _newSize);
                            if (gui.MiniButton("c", "Commit", MiniButtonStyle.ModRight))
                            {
                                if (_newSize != memberValue.Count)
                                {
                                    memberValue.AdjustSize(_newSize, RemoveAt, AddValue);
                                }
                            }
                        }

                        using (gui.Horizontal())
                        {
                            gui.Label("Commands");

                            if (gui.MiniButton("Shuffle", "Shuffle list (randomize the order of the list's elements", (Layout)null))
                            {
                                Shuffle();
                            }

                            if (gui.MoveDownButton())
                            {
                                memberValue.Shift(true);
                            }

                            if (gui.MoveUpButton())
                            {
                                memberValue.Shift(false);
                            }

                            if (!_elementType.IsValueType && gui.MiniButton("N", "Filter nulls"))
                            {
                                for (int i = memberValue.Count - 1; i > -1; i--)
                                {
                                    if (memberValue[i] == null)
                                    {
                                        RemoveAt(i);
                                    }
                                }
                            }
                        }
                    }
                }

                using (gui.Indent(_options.GuiBox ? GUI.skin.box : GUIStyle.none))
                {
#if PROFILE
                    Profiler.BeginSample("Sequence Elements");
#endif
                    for (int iLoop = 0; iLoop < memberValue.Count; iLoop++)
                    {
                        var i            = iLoop;
                        var elementValue = memberValue[i];

                        if (_filter != null && elementValue != null)
                        {
                            string elemStr = elementValue.ToString();
                            if (!_filter.IsMatch(elemStr))
                            {
                                continue;
                            }
                        }

                        using (gui.Horizontal())
                        {
                            if (_options.LineNumbers)
                            {
                                gui.NumericLabel(i);
                            }

                            var previous = elementValue;

                            gui.BeginCheck();
                            {
                                using (gui.Vertical())
                                {
                                    var element = GetElement(i);
                                    gui.Member(element, @ignoreComposition: _perItemAttributes == null);
                                }
                            }

                            if (gui.HasChanged())
                            {
                                if (_options.Readonly)
                                {
                                    memberValue[i] = previous;
                                    _dirty         = true;
                                }
                                else if (_options.UniqueItems)
                                {
                                    int occurances = 0;
                                    for (int k = 0; k < memberValue.Count; k++)
                                    {
                                        if (memberValue[i].GenericEquals(memberValue[k]))
                                        {
                                            occurances++;
                                            if (occurances > 1)
                                            {
                                                memberValue[i] = previous;
                                                _dirty         = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            if (isAdvancedChecked)
                            {
                                var c  = elementValue as Component;
                                var go = c == null ? elementValue as GameObject : c.gameObject;
                                if (go != null)
                                {
                                    gui.InspectButton(go);
                                }

                                if (showAdvanced)
                                {
                                    if (gui.MoveDownButton())
                                    {
                                        MoveElementDown(i);
                                        _dirty = true;
                                    }
                                    if (gui.MoveUpButton())
                                    {
                                        MoveElementUp(i);
                                        _dirty = true;
                                    }
                                }
                            }

                            if (!_options.Readonly && _options.PerItemRemove && gui.RemoveButton("element", MiniButtonStyle.ModRight))
                            {
                                RemoveAt(i);
                                _dirty = true;
                            }
                        }
                    }
#if PROFILE
                    Profiler.EndSample();
#endif
                }
            }

            // footer
            if (_shouldDrawAddingArea)
            {
                Action <UnityObject> addOnDrop = obj =>
                {
                    var    go = obj as GameObject;
                    object value;
                    if (go != null)
                    {
                        value = _elementType == typeof(GameObject) ? (UnityObject)go : go.GetComponent(_elementType);
                    }
                    else
                    {
                        value = obj;
                    }
                    AddValue((TElement)value);
                };

                using (gui.Indent())
                {
                    gui.DragDropArea <UnityObject>(
                        @label: "+Drag-Drop+",
                        @labelSize: 14,
                        @style: EditorStyles.toolbarButton,
                        @canSetVisualModeToCopy: dragObjects => dragObjects.All(obj =>
                    {
                        var go   = obj as GameObject;
                        var isGo = go != null;
                        if (_elementType == typeof(GameObject))
                        {
                            return(isGo);
                        }
                        return(isGo ? go.GetComponent(_elementType) != null : obj.GetType().IsA(_elementType));
                    }),
                        @cursor: MouseCursor.Link,
                        @onDrop: addOnDrop,
                        @onMouseUp: () => SelectionWindow.Show(new Tab <UnityObject>(
                                                                   @getValues: () => UnityObject.FindObjectsOfType(_elementType),
                                                                   @getCurrent: () => null,
                                                                   @setTarget: item =>
                    {
                        AddValue((TElement)(object)item);
                    },
                                                                   @getValueName: value => value.name,
                                                                   @title: _elementType.Name + "s")),
                        @preSpace: 2f,
                        @postSpace: 35f,
                        @height: 15f
                        );
                }
                gui.Space(3f);
            }

            if (_dirty)
            {
                var vfw = unityTarget as IVFWObject;
                if (vfw != null)
                {
                    vfw.MarkChanged();
                }
            }
        }
Esempio n. 29
0
        public override void OnGUI()
        {
            using (gui.Horizontal())
            {
                if (_autoAlloc && memberValue == null)
                {
                    if (memberType.IsA <UnityObject>())
                    {
                        Debug.Log("Cannot automatically allocate memory for UnityObject member: " + member.NiceName);
                    }
                    else if (memberType.IsAbstract)
                    {
                        Debug.Log("Cannot automatically allocate memory for abstract member: " + member.NiceName);
                    }
                    else
                    {
                        memberValue = memberType.ActivatorInstance();
                    }
                }

                var isEmpty  = string.IsNullOrEmpty(displayText);
                var label    = isEmpty ? string.Empty : displayText + " " + (foldout ? "^" : ">");
                var value    = member.Value;
                var unityObj = value as UnityObject;

                string field;
                if (value == null)
                {
                    field = _nullString;
                }
                else
                {
                    field = (_isToStringImpl || unityObj != null) ? value.ToString() : value.GetType().GetNiceName();
                }

                if (isEmpty)
                {
                    Foldout();
                }

                var e = Event.current;

                gui.Prefix(label);

                var labelRect = gui.LastRect;

                gui.Cursor(labelRect, MouseCursor.Link);
                if (!isEmpty && e.IsMouseContained(labelRect) && e.IsLMBDown())
                {
                    foldout = !foldout;
                }

                gui.Space(2.3f);

                if (unityObj != null)
                {
                    var icon = AssetPreview.GetMiniThumbnail(unityObj);
                    gui.Label(new GUIContent(field, icon), GUIStyles.ObjectField);
                }
                else
                {
                    gui.Label(field, GUIStyles.ObjectField);
                }

                var totalRect = gui.LastRect;
                var fieldRect = totalRect;
                fieldRect.width -= 15f;

                if (unityObj != null)
                {
                    gui.Cursor(fieldRect, MouseCursor.Zoom);
                    if (fieldRect.Contains(e.mousePosition))
                    {
                        if (e.IsLMBDown())
                        {
                            EditorHelper.PingObject(unityObj);
                            if (e.IsDoubleClick())
                            {
                                EditorHelper.SelectObject(unityObj);
                            }
                            e.Use();
                        }
                        else if (e.IsRMBDown())
                        {
                            var mb = unityObj as MonoBehaviour;
                            if (mb != null)
                            {
                                var monoscript = MonoScript.FromMonoBehaviour(mb);
                                var scriptPath = AssetDatabase.GetAssetPath(monoscript);
                                UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(scriptPath, 0);
                            }
                        }
                    }
                }

                var drop = gui.RegisterFieldForDrop <UnityObject>(fieldRect, _getDraggedObject, _isDropAccepted);
                if (drop != null)
                {
                    memberValue = drop;
                    GUI.changed = true;
                }

                var thumbRect = totalRect;
                thumbRect.width -= fieldRect.width;
                thumbRect.x     += fieldRect.width;

                gui.Cursor(thumbRect, MouseCursor.Link);

                // Selection/thumb button
                {
                    if (e.IsMouseContained(thumbRect) && e.IsMouseDown())
                    {
                        if (e.IsLMB())
                        {
                            if (_disablePicker)
                            {
                                memberValue = memberType.ActivatorInstance();
                            }
                            else
                            {
                                SelectionWindow.Show("Select a `" + memberTypeName + "` object", _tabs);
                            }
                        }
                        else if (e.IsRMB())
                        {
                            try
                            {
                                memberValue = memberType.ActivatorInstance();
                            }
                            catch (Exception ex)
                            {
                                Debug.Log("Error creating new instance of type `{0}`: {1}".FormatWith(memberType.GetNiceName(), ex.Message));
                            }
                        }
                    }
                }
            }

            if (!foldout)
            {
                return;
            }

            if (member.IsNull())
            {
                gui.HelpBox("Member value is null");
                return;
            }

            if (_polymorphicType == null || _polymorphicType == memberType)
            {
                object value = member.Value;
                DrawRecursive(ref value, gui, id, unityTarget);
                member.Value = value;
            }
            else
            {
                var drawer     = MemberDrawersHandler.CachedGetObjectDrawer(_polymorphicType);
                var drawerType = drawer.GetType();
                if (drawerType == typeof(RecursiveDrawer) || drawerType == typeof(UnityObjectDrawer))
                {
                    object value = member.Value;
                    DrawRecursive(ref value, gui, id, unityTarget);
                    member.Value = value;
                }
                else
                {
                    drawer.Initialize(member, attributes, gui, prefs);
                    gui.Member(member, attributes, drawer, false);
                }
            }
        }
Esempio n. 30
0
 void Play()
 {
     OpeningWindow.SetActiveRecursively(false);
     SelectionWindow.SetActiveRecursively(true);
 }
        /// <summary>
        /// Add genre to content
        /// </summary>
        private void AddGenre()
        {
            // Create array of genre string for selection
            GenreCollection allGenres;
            if (this.Content is Movie)
                allGenres = Organization.AllMovieGenres;
            else
                allGenres = Organization.AllTvGenres;

            List<string> selectableGenres = new List<string>();
            for (int i = 0; i < allGenres.Count; i++)
            {
                // Don't list genres already added
                if (content.DisplayGenres.Contains(allGenres[i]))
                    continue;

                // Add genre name
                selectableGenres.Add(allGenres[i]);
            }
            string[] selectableGenresArray = selectableGenres.ToArray();

            SelectionWindow selWindow = new SelectionWindow("Select Genre to Add", selectableGenresArray);
            selWindow.ShowDialog();

            // If selection is valid set sub-folder as sub-content folder
            if (!string.IsNullOrEmpty(selWindow.Results))
                foreach (string genre in allGenres)
                    if (genre == selWindow.Results)
                    {
                        this.content.DisplayGenres.Add(genre);
                        break;
                    }
        }
 private void SelectionWindow_OnSelectionWindowAfterClose(object sender, EventArgs e)
 {
     SelectionWindow.CloseWindow(desriptor);
 }