Beispiel #1
0
        protected override void InitVM()
        {
            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList();
            List <FrameworkModule> toremove = new List <FrameworkModule>();

            foreach (var item in m)
            {
                var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault();
                if (f?.IgnorePrivillege == true)
                {
                    toremove.Add(item);
                }
            }
            toremove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)
            {
                SelectedModule = modules.Where(x => x.IsApi == false && (x.ClassName == Entity.ClassName || x.FullName == Entity.ClassName)).SelectMany(x => x.Actions).FirstOrDefault().Module.FullName;
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions        = mm.ToListItems(y => y.ActionName, y => y.Url);
                SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
            }
        }
Beispiel #2
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.Icon))
            {
                var res = Entity.Icon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }

            SelectedRolesIds.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleCode != null && x.Allowed == true).Select(x => x.ID).ToList());

            var data    = DC.Set <FrameworkMenu>().AsNoTracking().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            foreach (var p in AllParents)
            {
                if (p.Text.StartsWith("MenuKey."))
                {
                    p.Text = Localizer[p.Text];
                }
            }

            var modules = Wtm.GlobaInfo.AllModule;

            var toRemove = new List <SimpleModule>();

            foreach (var item in modules)
            {
                if (item.IgnorePrivillege)
                {
                    toRemove.Add(item);
                }
            }
            var m = modules.ToList();

            toRemove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true))
            {
                if (string.IsNullOrEmpty(SelectedModule))
                {
                    SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName;
                }
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions = mm.ToListItems(y => y.ActionName, y => y.Url);
                if (SelectedActionIDs == null)
                {
                    SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void SaveFighterAnimationFile()
        {
            // rendering files not loaded
            if (string.IsNullOrEmpty(AJFilePath))
            {
                return;
            }

            // collect used symbols from all actions
            var usedSymbols = AllActions.Select(e => e.Symbol).ToArray();

            // generate new aj file
            var newAJFile = AJManager.RebuildAJFile(usedSymbols, false);

            // update animation offset and sizes
            foreach (var a in AllActions)
            {
                // don't write subroutines
                if (a.Subroutine)
                {
                    continue;
                }

                // update animation size and offset
                if (!string.IsNullOrEmpty(a.Symbol))
                {
                    var offsize = AJManager.GetOffsetSize(a.Symbol);
                    a.AnimOffset = offsize.Item1;
                    a.AnimSize   = offsize.Item2;
                }
            }

            // save action changes to dat file
            SaveAllActionChanges();

            // dump to file
            File.WriteAllBytes(AJFilePath, newAJFile);
        }
        /// <summary>
        ///
        /// </summary>
        private void SaveFighterAnimationFile()
        {
            // rendering files not loaded
            if (string.IsNullOrEmpty(AJFilePath))
            {
                return;
            }

            // make sure okay to overwrite
            if (MessageBox.Show($"Is it okay to overwrite {AJFilePath}?", "Save Animation File Changes?", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
            {
                return;
            }

            // collect used symbols from all actions
            var usedSymbols = AllActions.Select(e => e.Symbol);

            // generate new aj file
            Dictionary <string, Tuple <int, int> > animOffsets = new Dictionary <string, Tuple <int, int> >();

            using (MemoryStream ajBuffer = new MemoryStream())
                using (BinaryWriterExt w = new BinaryWriterExt(ajBuffer))
                {
                    // collect used symbols
                    foreach (var sym in usedSymbols)
                    {
                        if (sym != null)
                        {
                            if (SymbolToAnimation.ContainsKey(sym) && !animOffsets.ContainsKey(sym))
                            {
                                // write animation
                                var anim = SymbolToAnimation[sym];
                                animOffsets.Add(sym, new Tuple <int, int>((int)ajBuffer.Position, anim.Length));
                                w.Write(anim);
                                w.Align(0x20, 0xFF);
                            }
                            else
                            if (!animOffsets.ContainsKey(sym))
                            {
                                // animation not found
                                MessageBox.Show($"\"{sym}\" animation not found", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                animOffsets.Add(sym, new Tuple <int, int>(0, 0));
                            }
                        }
                    }

                    // dump to file
                    File.WriteAllBytes(AJFilePath, ajBuffer.ToArray());
                }


            int index = 0;

            foreach (var a in AllActions)
            {
                // don't write subroutines
                if (a.Subroutine)
                {
                    continue;
                }

                // get embedded script
                var ftcmd = new SBM_FighterCommand();
                ftcmd._s = _node.Accessor._s.GetEmbeddedStruct(0x18 * index, ftcmd.TrimmedSize);

                // update symbol name
                ftcmd.Name = a.Symbol;

                if (a.Symbol == null)
                {
                    continue;
                }

                // offset
                var ofst = animOffsets[a.Symbol];

                // update action offset and size
                a.AnimOffset = ofst.Item1;
                a.AnimSize   = ofst.Item2;

                // update file offset and size
                ftcmd.AnimationOffset = a.AnimOffset;
                ftcmd.AnimationSize   = a.AnimSize;

                // resize if needed
                if (_node.Accessor._s.Length <= 0x18 * index + 0x18)
                {
                    _node.Accessor._s.Resize(0x18 * index + 0x18);
                }

                // update script
                _node.Accessor._s.SetEmbededStruct(0x18 * index, ftcmd._s);
                index++;
            }

            MainForm.Instance.SaveDAT();
        }
Beispiel #5
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.ICon))
            {
                var res = Entity.ICon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }
            IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper
                              .IconFontDicItems
                              .ContainsKey(IconFont)
                                ? IconFontsHelper
                              .IconFontDicItems[IconFont]
                              .Select(x => new ComboSelectListItem()
            {
                Text  = x.Text,
                Value = x.Value,
                ICon  = x.ICon
            }).ToList()
                                : new List <ComboSelectListItem>();

            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().AsNoTracking().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            foreach (var p in AllParents)
            {
                if (p.Text.StartsWith("MenuKey."))
                {
                    if (Localizer[p.Text].ResourceNotFound == true)
                    {
                        p.Text = Core.Program._localizer[p.Text];
                    }
                    else
                    {
                        p.Text = Localizer[p.Text];
                    }
                }
            }

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            var toRemove = new List <FrameworkModule>();

            foreach (var item in modules)
            {
                if (item.IgnorePrivillege)
                {
                    toRemove.Add(item);
                }
                else
                {
                    if (!item.IsApi)
                    {
                        continue;
                    }
                    if (item.NameSpace == "WalkingTec.Mvvm.Admin.Api")
                    {
                        if (!item.ModuleName.EndsWith($"({Program._localizer["BuildinApi"]})"))
                        {
                            item.ModuleName += $"({Program._localizer["BuildinApi"]})";
                        }
                    }
                    else if (!item.ModuleName.EndsWith("(api)"))
                    {
                        item.ModuleName += "(api)";
                    }
                }
            }
            var m = modules.ToList();

            toRemove.ForEach(x => m.Remove(x));
            AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName);
            if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true))
            {
                if (string.IsNullOrEmpty(SelectedModule))
                {
                    SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName;
                }
                var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions = mm.ToListItems(y => y.ActionName, y => y.Url);
                if (SelectedActionIDs == null)
                {
                    SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
                }
            }
        }
Beispiel #6
0
        protected override void InitVM()
        {
            if (!string.IsNullOrEmpty(Entity.ICon))
            {
                var res = Entity.ICon.Split(' ');
                IconFont     = res[0];
                IconFontItem = res[1];
            }
            IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper
                              .IconFontDicItems
                              .ContainsKey(IconFont)
                                ? IconFontsHelper
                              .IconFontDicItems[IconFont]
                              .Select(x => new ComboSelectListItem()
            {
                Text  = x.Text,
                Value = x.Value,
                ICon  = x.ICon
            }).ToList()
                                : new List <ComboSelectListItem>();

            SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList());

            var data    = DC.Set <FrameworkMenu>().ToList();
            var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder);
            var pids    = Entity.GetAllChildrenIDs(DC);

            AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID);

            var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;

            var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList();
            List <FrameworkModule> toremove = new List <FrameworkModule>();

            foreach (var item in m)
            {
                var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault();
                if (f?.IgnorePrivillege == true)
                {
                    toremove.Add(item);
                }
            }
            toremove.ForEach(x => m.Remove(x));
            var m2 = modules.Where(x => x.NameSpace == "WalkingTec.Mvvm.Admin.Api").ToList();

            foreach (var item in m2)
            {
                if (item.ModuleName.EndsWith("(内置api)") == false)
                {
                    item.ModuleName += "(内置api)";
                }
            }
            m.AddRange(m2);
            AllModules = m.ToListItems(y => y.ModuleName, y => y.ClassName);
            if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true))
            {
                if (string.IsNullOrEmpty(SelectedModule))
                {
                    SelectedModule = modules.Where(x => (x.ClassName == Entity.ClassName)).FirstOrDefault()?.ClassName;
                }
                var mm = modules.Where(x => x.ClassName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList();
                AllActions = mm.ToListItems(y => y.ActionName, y => y.Url);
                if (SelectedActionIDs == null)
                {
                    SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList();
                }
            }
        }