Esempio n. 1
0
 private void Effacer(LTG_Entity.Environment e)
 {
     LTG_Entity.Environment envToRemove = ListEnvironments.FirstOrDefault(a => a.Nom == e.Name);
     ListEnvironments.Remove(envToRemove);
     ManagedList.Remove(envToRemove);
     App.Entities.Environments.Remove(e);
 }
Esempio n. 2
0
 public VMDependencyManagment(DBItemType type_available, LTG_Entity.Environment current)
 {
     ManagedEnvironment = current;
     ManagedItemType    = DBItemType.Environment;
     ListDependencies   = Linq.DependenciesList(current, type_available);
     Init(type_available);
 }
Esempio n. 3
0
        static public List <Package> ListPackages(LTG_Entity.Environment x)
        {
            var query = from package in App.Entities.Packages
                        where package.Environments.Any(elem => elem.Id == x.Id)
                        select package;

            return(new List <Package>(query));
        }
Esempio n. 4
0
        static public ObservableCollection <DBItem> DependenciesList(LTG_Entity.Environment e, DBItemType type)
        {
            ObservableCollection <DBItem> list = new ObservableCollection <DBItem>();


            foreach (Package p in e.Packages)
            {
                list.Add(p);
            }
            return(list);
        }
Esempio n. 5
0
        private string ToLatex(LTG_Entity.Environment e)
        {
            string output = "\\newenvironment\\" + e.Nom + "{";

            if (!String.IsNullOrEmpty(e.Desc))
            {
                output += " %% " + e.Desc;
            }
            output += "\n";
            output += "  " + e.CodeBefore.Replace("\n", "\n" + "  ");
            output += "\n}\n{\n";
            output += "  " + e.CodeAfter.Replace("\n", "\n" + "  ");
            output += "\n}\n";
            return(output);
        }
Esempio n. 6
0
        static public void RemoveJoin(Template t, LTG_Entity.Environment e)
        {
            foreach (TemplateEnvironment te in App.Entities.TemplateEnvironments)
            {
                if (te.Template == t)
                {
                    if (te.Environment == e)
                    {
                        App.Entities.TemplateEnvironments.Remove(te);
                    }
                }
            }

            App.Entities.SaveChanges();
        }
Esempio n. 7
0
        public void Add(LTG_Entity.Environment e)
        {
            bool add = true;

            foreach (LTG_Entity.Environment env in AddedEnv)
            {
                if (env.Nom == e.Nom)
                {
                    add = false;
                }
            }

            if (add)
            {
                // Add the environment
                AddedEnv.Add(e);
                // Add the packages dependencies
                foreach (Package p in Linq.ListPackages(e))
                {
                    Add(p);
                }
            }
        }
Esempio n. 8
0
        public void btn_Retirer()
        {
            if (CurrentDep != null)
            {
                ListDependencies.Remove(CurrentDep);
                Package currentPackage            = null;
                Macro   currentMacro              = null;
                LTG_Entity.Environment currentEnv = null;
                Meta currentMeta = null;
                switch (ManagedItemType)
                {
                case DBItemType.Template:
                    switch (DependencyType)
                    {
                    case DBItemType.Macro:
                        currentMacro = (Macro)ListAvailables.FirstOrDefault(p => ((Macro)p).Name == DepName);
                        Linq.RemoveJoin(ManagedTemplate, currentMacro);
                        break;

                    case DBItemType.Package:
                        currentPackage = (Package)ListAvailables.FirstOrDefault(p => ((Package)p).Name == DepName);
                        Linq.RemoveJoin(ManagedTemplate, currentPackage);
                        break;

                    case DBItemType.Meta:
                        currentMeta = (Meta)ListAvailables.FirstOrDefault(p => ((Meta)p).Name == DepName);
                        Linq.RemoveJoin(ManagedTemplate, currentMeta);
                        break;

                    case DBItemType.Environment:
                        currentEnv = (LTG_Entity.Environment)ListAvailables.FirstOrDefault(p => ((LTG_Entity.Environment)p).Name == DepName);
                        Linq.RemoveJoin(ManagedTemplate, currentEnv);
                        break;

                    default:
                        break;
                    }
                    break;

                case DBItemType.Macro:
                    currentPackage = (Package)ListAvailables.FirstOrDefault(p => ((Package)p).Name == DepName);
                    ManagedMacro.Packages.Remove(currentPackage);
                    break;

                case DBItemType.Meta:
                    switch (DependencyType)
                    {
                    case DBItemType.Macro:
                        currentMacro = (Macro)ListAvailables.FirstOrDefault(p => ((Macro)p).Name == DepName);
                        ManagedMeta.Macroes.Remove(currentMacro);
                        break;

                    case DBItemType.Package:
                        currentPackage = (Package)ListAvailables.FirstOrDefault(p => ((Package)p).Name == DepName);
                        ManagedMeta.Packages.Remove(currentPackage);
                        break;

                    case DBItemType.Meta:
                        currentMeta = (Meta)ListAvailables.FirstOrDefault(p => ((Meta)p).Name == DepName);
                        ManagedMeta.Metas.Remove(currentMeta);
                        break;

                    case DBItemType.Environment:
                        currentEnv = (LTG_Entity.Environment)ListAvailables.FirstOrDefault(p => ((LTG_Entity.Environment)p).Name == DepName);
                        ManagedMeta.Environments.Remove(currentEnv);
                        break;

                    default:
                        break;
                    }

                    break;

                case DBItemType.Environment:
                    currentPackage = (Package)ListAvailables.FirstOrDefault(p => ((Package)p).Name == DepName);
                    ManagedEnvironment.Packages.Remove(currentPackage);
                    break;

                default:
                    break;
                }
            }

            App.Entities.SaveChanges();
        }