Interaction logic for DataUiGrid.xaml
Inheritance: System.Windows.Controls.UserControl
示例#1
0
        public void Initialize(DataUiGrid dataUiGrid, TreeView treeView)
        {
            mDataUiGrid = dataUiGrid;
            mTreeView = treeView;

            FillTreeView();
        }
示例#2
0
        private void AddOrShowGrid()
        {
            if(variableGrid == null)
            {
                variableGrid = new DataUiGrid();

                var tabControl = PluginManager.CenterTab;

                variableTab = this.AddToTab(tabControl, variableGrid, "Variables");
                variableTab.DrawX = false;

                // let's make this the first item and have it be focused:
                tabControl.SelectedTab = variableTab;
                // This makes it the last tab clicked, which gives it priority:
                variableTab.LastTimeClicked = DateTime.Now;

                if (showSettings)
                {
                    settingsGrid = new DataUiGrid();
                    settingsTab = this.AddToTab(PluginManager.CenterTab, settingsGrid, "Settings");
                    settingsTab.DrawX = false;
                }
            }
            else
            {
                this.ShowTab(variableTab);
                if (showSettings)
                {
                    this.ShowTab(settingsTab);
                }
            }
        }
示例#3
0
        public void Initialize(TestWpfControl variablesDataUiGrid)
        {
            mVariablesDataGrid = variablesDataUiGrid.DataGrid;
            variableViewModel  = new Plugins.VariableGrid.MainControlViewModel();
            variablesDataUiGrid.DataContext = variableViewModel;
            variablesDataUiGrid.SelectedBehaviorVariableChanged += HandleBehaviorVariableSelected;
            variablesDataUiGrid.AddVariableClicked += HandleAddVariable;

            InitializeRightClickMenu();
        }
示例#4
0
        public void Initialize(PropertyGrid propertyGrid, DataUiGrid variablesDataUiGrid, DataUiGrid eventsDataUiGrid)
        {
            mVariablesDataGrid = variablesDataUiGrid;

            InitializeEvents(eventsDataUiGrid);

            mPropertyGrid = propertyGrid;
            mPropertyGrid.PropertySort = PropertySort.Categorized;

            InitializeRightClickMenu();
        }
示例#5
0
        public void Initialize(PropertyGrid propertyGrid, DataUiGrid variablesDataUiGrid, DataUiGrid eventsDataUiGrid)
        {
            mVariablesDataGrid = variablesDataUiGrid;

            InitializeEvents(eventsDataUiGrid);

            mPropertyGrid = propertyGrid;
            mPropertyGrid.PropertySort = PropertySort.Categorized;

            InitializeRightClickMenu();
        }
 private static void SetAlternatingColors(DataUiGrid grid, List<MemberCategory> categories)
 {
     // skip the first category in putting the alternating colors:
     for (int i = 0; i < categories.Count; i++)
     {
         var category = categories[i];
         if (i != 0)
         {
             const byte brightness = 227;
             category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);
         }
     }
 }
示例#7
0
        public void Initialize()
        {
            mainControl = new Gum.TestWpfControl();

            GumCommands.Self.GuiCommands.AddControl(mainControl, "Variables", TabLocation.CenterBottom);

            mVariablesDataGrid      = mainControl.DataGrid;
            variableViewModel       = new Plugins.VariableGrid.MainControlViewModel();
            mainControl.DataContext = variableViewModel;
            mainControl.SelectedBehaviorVariableChanged += HandleBehaviorVariableSelected;
            mainControl.AddVariableClicked += HandleAddVariable;

            InitializeRightClickMenu();
        }
        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            CreateCategoriesAndVariables(instance, container, categories, ati);

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }


            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if (categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" should be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                categories.Insert(0, nameCategory);
            }

            SetAlternatingColors(grid, categories);

            foreach(var category in categories)
            {
                grid.Categories.Add(category);
            }

            grid.Refresh();
        }
示例#9
0
        internal static void RefreshGrid(DataUiGrid grid)
        {
            if (RefreshesToSkip > 0)
            {
                RefreshesToSkip--;
            }
            else
            {
                grid.Refresh();
            }

            foreach (var category in grid.Categories)
            {
                List<InstanceMember> membersToRefresh = new List<InstanceMember>();

                foreach (DataGridItem instanceMember in category.Members)
                {
                    // Not sure why we check if the instanceMember has non-0 count for options.
                    // It could have had 0 before, but after a refresh, it may now have options.
                    bool shouldRefresh = //instanceMember.CustomOptions.Count != 0 &&
                        instanceMember.TypeConverter != null;

                    if (shouldRefresh)
                    {
                        instanceMember.RefreshOptions();
                        membersToRefresh.Add(instanceMember);
                    }
                }

                bool shouldSort = membersToRefresh.Count != 0;

                foreach (var item in membersToRefresh)
                {
                    var index = category.Members.IndexOf(item);
                    category.Members.Remove(item);
                    category.Members.Insert(index, item);
                }
            }
        }
        public static void UpdateShownVariables(DataUiGrid grid, IElement element)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            CreateInstanceMembersForVariables(element, defaultCategory);

            foreach (var category in categories)
            {
                const byte brightness = 227;
                category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);

                grid.Categories.Add(category);
            }

            grid.Refresh();

        }
示例#11
0
        internal static void RefreshGrid(DataUiGrid grid)
        {
            if (RefreshesToSkip > 0)
            {
                RefreshesToSkip--;
            }
            else
            {
                grid.Refresh();
            }

            foreach (var category in grid.Categories)
            {
                List<InstanceMember> membersToRefresh = new List<InstanceMember>();

                foreach (DataGridItem instanceMember in category.Members)
                {
                    bool shouldRefresh = instanceMember.CustomOptions.Count != 0 &&
                        instanceMember.TypeConverter != null;

                    if (shouldRefresh)
                    {
                        instanceMember.RefreshOptions();
                        membersToRefresh.Add(instanceMember);
                    }
                }

                bool shouldSort = membersToRefresh.Count != 0;

                foreach (var item in membersToRefresh)
                {
                    var index = category.Members.IndexOf(item);
                    category.Members.Remove(item);
                    category.Members.Insert(index, item);
                }
            }
        }
        public static void UpdateShownVariables(DataUiGrid grid, NamedObjectSave instance, IElement container)
        {
            grid.Categories.Clear();

            List<MemberCategory> categories = new List<MemberCategory>();
            var defaultCategory = new MemberCategory("Variables");
            defaultCategory.FontSize = 14;
            categories.Add(defaultCategory);

            AssetTypeInfo ati = instance.GetAssetTypeInfo();

            // not sure if this is needed:
            if (instance.TypedMembers.Count == 0)
            {
                instance.UpdateCustomProperties();
            }

            for (int i = 0; i < instance.TypedMembers.Count; i++)
            {

                TypedMemberBase typedMember = instance.TypedMembers[i];
                InstanceMember instanceMember = CreateInstanceMember(instance, container, typedMember, ati);

                var categoryToAddTo = GetOrCreateCategoryToAddTo(categories, ati, typedMember);

                if (instanceMember != null)
                {
                    categoryToAddTo.Members.Add(instanceMember);
                }
            }

            if (ati != null)
            {
                SortCategoriesAndMembers(ref categories, ati);
            }

            if (defaultCategory.Members.Count == 0)
            {
                categories.Remove(defaultCategory);
            }
            else if(categories.Count != 1)
            {
                defaultCategory.Name = "Other Variables";
            }

            if (categories.Count != 0)
            {
                // "Name" shoul be the very first property:
                var nameCategory = CreateNameInstanceMember(instance);
                //categories.Add(nameCategory);
                categories.Insert(0, nameCategory);
                //categories.First().Members.Insert(0, nameInstanceMember);
            }

            // skip the first category in putting the alternating colors:
            for (int i = 0; i < categories.Count; i++)
            {
                var category = categories[i];
                if (i != 0)
                {
                    const byte brightness = 227;
                    category.SetAlternatingColors(new SolidColorBrush(Color.FromRgb(brightness, brightness, brightness)), Brushes.Transparent);
                }
                grid.Categories.Add(category);
            }
            grid.Refresh();
        }
 public void InitializeEvents(DataUiGrid eventsDataUiGrid)
 {
     mEventsDataGrid = eventsDataUiGrid;
 }