private void ExpandItemIfChildrenIsExpanded(ObjectViewItem item)
 {
     foreach (var subitem in item.Children)
     {
         if (subitem.IsExpanded)
         {
             item.IsExpanded = true;
             return;
         }
     }
 }
 private void ExpandItemIfHasNewChildern(ObjectViewItem item, IList <ObjectViewItem> newSubItem)
 {
     foreach (var subitem  in newSubItem)
     {
         if (item.Children.FirstOrDefault(p => p.Header.Equals(subitem.Header)) == null)
         {
             item.IsExpanded = true;
             return;
         }
     }
 }
Exemple #3
0
        private void TreeViewItem_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            ObjectViewItem item = ObjectView.SelectedItem as ObjectViewItem;

            e.Handled = true;

            if (item != null && item.Tag != null)
            {
                e.Handled = false;
            }
        }
            public void UpdateObjectViewItem(DBConnection conn, IList <ObjectViewItem> items)
            {
                IList <DbObjectInfo> dbObjs = null;

                try
                {
                    dbObjs = AddinBackend.TryToGetObjsInfo(conn);
                }
                catch (Exception)
                {
                    return;
                }

                if (dbObjs == null)
                {
                    return;
                }

                ObjectViewItem localVarItems = items.FirstOrDefault(
                    p => p.Header.Equals(LocalVariablesHeader));
                ObjectViewItem sharedTableItems = items.FirstOrDefault(
                    p => p.Header.Equals(SharedTableHeader));

                if (localVarItems == null)
                {
                    localVarItems = new ObjectViewItem
                    {
                        Header        = LocalVariablesHeader,
                        IsExpanded    = false,
                        IconImage     = folderBitSource,
                        ExpandImage   = openedFolderBitSource,
                        UnExpandImage = folderBitSource
                    };
                    items.Insert(0, localVarItems);
                }

                if (sharedTableItems == null)
                {
                    sharedTableItems = new ObjectViewItem
                    {
                        Header        = SharedTableHeader,
                        IsExpanded    = false,
                        IconImage     = folderBitSource,
                        ExpandImage   = openedFolderBitSource,
                        UnExpandImage = folderBitSource
                    };
                    items.Insert(1, sharedTableItems);
                }

                UpdateLocalVariables(dbObjs, localVarItems);
                UpdateSharesTable(dbObjs, sharedTableItems);
            }
            private void UpdateLocalVariables(IList <DbObjectInfo> dbObjs, ObjectViewItem localVarItems)
            {
                List <ObjectViewItem> newItems = new List <ObjectViewItem>();

                foreach (var objWithSameForm in dbObjs.Where(p => !p.shared).GroupBy(p => p.forms))
                {
                    string form       = objWithSameForm.Key;
                    string formHeader = DDBString.FirstLetterToUpper(form.ToLower());

                    ObjectViewItem formItem = localVarItems.Children.FirstOrDefault(
                        p => p.Header.Equals(formHeader));

                    if (formItem == null)
                    {
                        formItem = new ObjectViewItem
                        {
                            Header        = formHeader,
                            IsExpanded    = false,
                            IconImage     = folderBitSource,
                            ExpandImage   = openedFolderBitSource,
                            UnExpandImage = folderBitSource
                        }
                    }
                    ;

                    var newVariableItem = new ObservableCollection <ObjectViewItem>();
                    foreach (var obj in objWithSameForm)
                    {
                        newVariableItem.Add(new ObjectViewItem
                        {
                            Header        = FormatDbObjectStr(obj),
                            Tag           = obj,
                            IconImage     = docBitSource,
                            ExpandImage   = docBitSource,
                            UnExpandImage = docBitSource
                        });
                    }

                    ExpandItemIfHasNewChildern(formItem, newVariableItem);
                    formItem.Children = newVariableItem;
                    newItems.Add(formItem);
                }

                localVarItems.Children.Clear();
                foreach (var obj in newItems)
                {
                    localVarItems.Children.Add(obj);
                }

                ExpandItemIfChildrenIsExpanded(localVarItems);
            }
Exemple #6
0
        private DbObjectInfo CheckObjectSelectedItemVariable()
        {
            ObjectViewItem item = ObjectView.SelectedItem as ObjectViewItem;

            if (item == null)
            {
                throw new ArgumentNullException("Invalid Variable");
            }
            DbObjectInfo info = item.Tag as DbObjectInfo;

            if (info == null)
            {
                throw new ArgumentException("Invalid Variable");
            }
            return(info);
        }
            private void UpdateSharesTable(IList <DbObjectInfo> dbObjs, ObjectViewItem tables)
            {
                var newSharedTables = new ObservableCollection <ObjectViewItem>();

                foreach (var st in dbObjs.Where(p => p.shared))
                {
                    newSharedTables.Add(new ObjectViewItem
                    {
                        Header        = FormatDbObjectStr(st),
                        Tag           = st,
                        IconImage     = docBitSource,
                        ExpandImage   = docBitSource,
                        UnExpandImage = docBitSource
                    });
                }

                ExpandItemIfHasNewChildern(tables, newSharedTables);
                tables.Children = newSharedTables;
            }
        private ObjectViewItem GenerateListEntry(string name, int index, IOrderedEnumerable <string> sceneObjects, IOrderedEnumerable <string> gameConfigObjects, IOrderedEnumerable <string> stageConfigObjects)
        {
            bool _isScene       = sceneObjects.Contains(name);
            bool _isGameConfig  = gameConfigObjects.Contains(name);
            bool _isStageConfig = stageConfigObjects.Contains(name);
            var  lvc            = new ObjectViewItem()
            {
                Content           = name,
                ObjectName        = name,
                IsChecked         = false,
                Tag               = index.ToString(),
                Obj_IsScene       = _isScene,
                Obj_IsGameConfig  = _isGameConfig,
                Obj_IsStageConfig = _isStageConfig
            };

            lvc.Checked += ObjectsList_ItemChecked;

            //if (!lvc.Obj_IsStageConfig) lvc.Foreground = Methods.Internal.Theming.GetSCBResource("Maniac_ObjectManager_RedTextColor");
            //else if (lvc.Obj_IsScene) lvc.Foreground = Methods.Internal.Theming.GetSCBResource("Maniac_ObjectManager_GreenTextColor");
            //else lvc.Foreground = Methods.Internal.Theming.GetSCBResource("NormalText");

            return(lvc);
        }