Example #1
0
        public IActionResult AddComment(MixModel model)
        {
            if (ModelState.IsValid)
            {
                if (!ReCaptchaPassed(Request.Form["g-recaptcha-response"], _configuration.GetSection("GoogleReCaptcha:secret").Value))
                {
                    ModelState.AddModelError(string.Empty, "You failed the CAPTCHA, stupid robot.  Go play some 1x1 on SFs instead.");

                    return(View("~/Views/Home/Blog.cshtml", model));
                }

                var comment = new Comments();
                comment.ParentID           = model.Comments.ParentID;
                comment.CommentContent     = model.Comments.CommentContent;
                comment.CommentAuthor      = model.Comments.CommentAuthor;
                comment.CommentAuthorEmail = model.Comments.CommentAuthorEmail;
                comment.CommentAuthorUrl   = model.Comments.CommentAuthorUrl;
                comment.CommentAuthorIP    = HttpContext.Connection.RemoteIpAddress.ToString();
                comment.CommentDate        = DateTime.Now;
                comment.CommentType        = "Comment";
                _db.Add(comment);
                _db.SaveChanges();
                if (model.Comments.CommentType == "post")
                {
                    return(RedirectToAction("Blog", new { q = model.Comments.ParentID }));
                }
                else
                {
                    return(RedirectToAction("Gallery", new { q = model.Comments.PhotoID }));
                }
            }

            return(View("~/Views/Home/Index.cshtml?q=" + HttpContext.Request.Query["q"], model));
        }
Example #2
0
        public ActionResult OtvoriPitanje(int?id)
        {
            if (id == null || id == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (HttpContext.Request.UrlReferrer != null)
            {
                ViewBag.Return = HttpContext.Request.UrlReferrer.ToString();
            }
            var model = new MixModel();

            model.Pitanja   = bazaPodataka.PopisPitanja.ToList().Where(x => x.id == id);
            model.Odgovori  = bazaPodataka.PopisOdgovora.ToList().OrderByDescending(x => x.najdraze).ThenByDescending(x => x.datumObjave);
            model.Korisnici = bazaPodataka.PopisKorisnika.ToList();

            model.Korisnici.Where(x => x.PutanjaSlike == null || x.PutanjaSlike.Length == 0).ForEach(x => x.PutanjaSlike = "~/img/user.png");

            if (model.Pitanja == null)
            {
                return(HttpNotFound());
            }
            var odgovori = bazaPodataka.PopisOdgovora.Where(x => x.pitanje_id == id).ToList();
            int c        = odgovori.Count();

            ViewBag.Broj = c;
            ViewBag.Id   = id;

            return(PartialView("_PartialPitanje", model));
        }
Example #3
0
        /// <summary>
        /// Called when a mix is selected.
        /// Launches the mix through Nokia Music API.
        /// </summary>
        /// <param name="sender">MixesList (LongListSelector).</param>
        /// <param name="e">Event arguments.</param>
        void OnMixSelected(Object sender, SelectionChangedEventArgs e)
        {
            MixModel selectedMix = (MixModel)MixesList.SelectedItem;

            if (selectedMix != null)
            {
                App.MusicApi.LaunchMix(selectedMix.Id);
            }
        }
Example #4
0
        public ActionResult Index()
        {
            var model = new MixModel();

            model.Kategorije = bazaPodataka.PopisKategorija.ToList().OrderBy(x => x.kategorija);
            model.Pitanja    = bazaPodataka.PopisPitanja.ToList().OrderByDescending(x => x.datumObjave);
            model.Odgovori   = bazaPodataka.PopisOdgovora.ToList();

            return(View(model));
        }
        public IActionResult MixView()
        {
            MixModel model = new MixModel()
            {
                DbWorkers = Repository.GetWorkers(),
                Titles    = Repository.GetTitles()
            };


            return(View(model));
        }
Example #6
0
 public static MixHessInfo GetHessMixSbNMA(Universe univ, IList <Vector> coords, ILinAlg la
                                           , IList <ResInfo> lstResAllAtom, double nbondMaxDist, out string errmsg
                                           , bool bGetIntmInfo, string strBkbnReso
                                           )
 {
     // nbondMaxDist = double.PositiveInfinity
     MixModel.FnGetHess GetHess = delegate(Universe luniv, IList <Vector> lcoords, int[] idxAll, int[] idxBuffer, int[] idxCoarse, int[] idxBackbone)
     {
         var hessinfo = Hess.GetHessSbNMA(luniv, lcoords, nbondMaxDist);
         return(hessinfo);
     };
     return(MixModel.GetHessMixModel(univ, coords, la, lstResAllAtom, GetHess, out errmsg, bGetIntmInfo, strBkbnReso));
 }
Example #7
0
        public ActionResult OtvoriKategoriju(int?id)
        {
            var kategorija = bazaPodataka.PopisKategorija.Find(id);
            var naziv      = kategorija.kategorija;

            ViewBag.Kategorija = naziv;
            var model = new MixModel();

            model.Pitanja  = bazaPodataka.PopisPitanja.Where(x => x.id_kategorija == kategorija.id).OrderByDescending(p => p.datumObjave).ToList();
            model.Odgovori = bazaPodataka.PopisOdgovora.ToList();
            ViewBag.Id     = id;

            return(PartialView("_PartialKategorija", model));
        }
Example #8
0
        public MixViewModel LookupMix(MixModel mix)
        {
            if (MixLookupMap.ContainsKey(mix.MixId))
            {
                return(MixLookupMap[mix.MixId]);
            }
            else
            {
                MixViewModel newViewModel = new MixViewModel(mix);

                MixLookupMap.Add(newViewModel.MixId, newViewModel);
                MixCollection.Add(newViewModel);
                return(newViewModel);
            }
        }
Example #9
0
        public MainForm()
        {
            InitializeComponent();

            _InventoryManager = new InventoryManager();
            _MixModel         = new MixModel();

            var handlebarsConfig = new HandlebarsConfiguration();

            handlebarsConfig.Helpers.Add("percent", (output, context, arguments) => output.Write(string.Format("{0:P}", arguments)));
            handlebarsConfig.Helpers.Add("unit", (output, context, arguments) => output.Write(string.Format("{0} {1}", arguments)));
            _Handlebars = Handlebars.Create(handlebarsConfig);

            tabPageEntryBindingSource.DataSource = new List <TabPageEntry>
            {
                new TabPageEntry(R.mix, R.TabMix),
                new TabPageEntry(R.recipes, R.TabRecipes),
                new TabPageEntry(R.ingredients, R.TabIngredients)
            };

            _InventoryManager.PropertyChanged += OnInventoryManagerPropertyChanged;

            if (!string.IsNullOrEmpty(Settings.Default.LastInventoryFile))
            {
                _InventoryManager.Load(Settings.Default.LastInventoryFile);
            }
            else
            {
                _InventoryManager.New("new_inventory.xml");
            }

            numMixVolume.DataBindings.Add(nameof(NumericUpDown.Value), _MixModel, nameof(MixModel.Volume), false, DataSourceUpdateMode.OnPropertyChanged);
            numMixNicotine.DataBindings.Add(nameof(NumericUpDown.Value), _MixModel, nameof(MixModel.NicotineDose), false, DataSourceUpdateMode.OnPropertyChanged);
            numMixVg.DataBindings.Add(nameof(NumericUpDown.Value), _MixModel, nameof(MixModel.VgPercentage), false, DataSourceUpdateMode.OnPropertyChanged);
            numMixPg.DataBindings.Add(nameof(NumericUpDown.Value), _MixModel, nameof(MixModel.PgPercentage), false, DataSourceUpdateMode.OnPropertyChanged);
            _MixModel.PropertyChanged += OnMixModelPropertyChanged;
            mixIngredientModelBindingSource.DataSource = _MixModel.Ingredients;
            SetErrors();

            cmbRecipeIngredientAdd.ComboBox.DataSource = ingredientBindingSource;

            SetTitle();
            saveInventoryToolStripMenuItem.Enabled = _InventoryManager.IsDirty;
        }
Example #10
0
        public ActionResult Pretrazivanje(string pitanjeTekst, string kategorija)
        {
            if (!String.IsNullOrWhiteSpace(pitanjeTekst))
            {
                ViewBag.Pojam = pitanjeTekst;
            }
            if (!String.IsNullOrWhiteSpace(kategorija))
            {
                ViewBag.Kategorija = kategorija;
                TempData["kat"]    = kategorija;
            }

            var model = new MixModel();

            model.Kategorije = bazaPodataka.PopisKategorija.ToList().OrderBy(x => x.kategorija);
            model.Pitanja    = bazaPodataka.PopisPitanja.ToList().OrderByDescending(x => x.datumObjave);
            model.Odgovori   = bazaPodataka.PopisOdgovora.ToList();

            if (!String.IsNullOrWhiteSpace(pitanjeTekst))
            {
                model.Pitanja = model.Pitanja.Where(x => x.pitanjeTekst.ToUpper().Contains(pitanjeTekst.ToUpper())).ToList();
                if (!String.IsNullOrWhiteSpace(kategorija))
                {
                    model.Pitanja = model.Pitanja.Where(x => x.pitanjeTekst.ToUpper().Contains(pitanjeTekst.ToUpper()) && x.kategorijaId.kategorija == kategorija).ToList();
                }
            }
            else if ((String.IsNullOrWhiteSpace(pitanjeTekst)) && (!String.IsNullOrWhiteSpace(kategorija)))
            {
                model.Pitanja = model.Pitanja.Where(x => x.kategorijaId.kategorija == kategorija).ToList();
            }
            foreach (var kat in model.Kategorije)
            {
                if (kat.kategorija == kategorija)
                {
                    ViewBag.Id = kat.id;
                }
            }


            return(PartialView("_PartialKategorija", model));
        }
Example #11
0
        public ActionResult IspisPitanja()
        {
            MixModel model = new MixModel();

            model.Pitanja  = bazaPodataka.PopisPitanja.ToList().OrderByDescending(x => x.datumObjave).ThenBy(x => x.kategorijaId.kategorija);
            model.Odgovori = bazaPodataka.PopisOdgovora.ToList().OrderByDescending(x => x.datumObjave).ThenBy(x => x.Pit.pitanjeTekst);

            if (TempData["kat"] != null)
            {
                var kat = TempData["kat"].ToString();
                model.Pitanja = bazaPodataka.PopisPitanja.ToList().Where(x => x.kategorijaId.kategorija == kat).OrderByDescending(x => x.datumObjave).ThenBy(x => x.kategorijaId.kategorija);
            }


            System.Threading.Thread.Sleep(1000);

            AppReport appReport = new AppReport();

            appReport.pdfSvaPitanja(model);

            return(File(appReport.Podatci, System.Net.Mime.MediaTypeNames.Application.Pdf, "PopisSvihPitanja.pdf"));
        }
Example #12
0
        public ActionResult Main(string user)
        {
            IEnumerable <Resumes> resume;

            if (c.Students.Where(e => e.Email == user).FirstOrDefault() != null)
            {
                Student s      = c.Students.Where(e => e.Email == user).FirstOrDefault();
                var     result = from deger in c.Resumes
                                 where deger.Sid == s.Id
                                 select deger;
                resume          = result;
                ViewBag.message = s.Ad;
            }
            else

            {
                Mentor mentr  = c.Mentors.Where(a => a.Email == user).FirstOrDefault();
                var    result = from deger in c.Resumes
                                where deger.Mid == mentr.Id
                                select deger;
                resume          = result;
                ViewBag.message = mentr.Ad;
            }



            //TempData["email"] = s.Email;



            var model = new MixModel {
                mentors = c.Mentors.ToList(), students = c.Students.ToList(), resumes = resume.ToList()
            };

            return(View(model));
        }
Example #13
0
        public void AddMix(string name)
        {
            MixTable table = new MixTable(name, false, 0, MixSortOrder.None, false);

            DatabaseManager.Current.AddMix(table);

            MixModel mixModel = new MixModel(table);
            Mixes.Add(mixModel);
            mixLookupDictionary.Add(mixModel.MixId, mixModel);

            MixEntryTable entryTable = new MixEntryTable(mixModel.MixId, string.Empty, true, MixType.None);
            DatabaseManager.Current.AddMixEntry(entryTable);

            mixModel.AddEntry(entryTable);
        }
Example #14
0
        private void LoadCollection()
        {
            PerfTracer perfTracer = new PerfTracer("LibraryModel Loading");

            IEnumerable<SongTable> allSongs = DatabaseManager.Current.FetchSongs();
            foreach (SongTable songEntry in allSongs)
            {
                SongModel songModel = new SongModel(songEntry);
                _allSongs.Add(songModel);
                songLookupDictionary.Add(songModel.SongId, songModel);                
            }

            perfTracer.Trace("Songs Added");

            IEnumerable<AlbumTable> allAlbums = DatabaseManager.Current.FetchAlbums();
            foreach (AlbumTable albumEntry in allAlbums)
            {
                AlbumModel albumModel = new AlbumModel(albumEntry);
                _allAlbums.Add(albumModel);
                albumLookupDictionary.Add(albumModel.AlbumId, albumModel);
            }

            perfTracer.Trace("Albums Added");

            IEnumerable<ArtistTable> allArtists = DatabaseManager.Current.FetchArtists();
            foreach (ArtistTable artistEntry in allArtists)
            {
                ArtistModel artistModel = new ArtistModel(artistEntry);
                _allArtists.Add(artistModel);
                artistLookupDictionary.Add(artistModel.ArtistId, artistModel);
            }

            perfTracer.Trace("Artists Added");

            IEnumerable<PlaylistTable> allPlaylists = DatabaseManager.Current.FetchPlaylists();
            foreach (PlaylistTable playlistEntry in allPlaylists)
            {
                PlaylistModel playlistModel = new PlaylistModel(playlistEntry);
                Playlists.Add(playlistModel);
                playlistLookupDictionary.Add(playlistModel.PlaylistId, playlistModel);

                playlistModel.Populate();
            }

            perfTracer.Trace("Playlists Added");

            IEnumerable<MixTable> allMixes = DatabaseManager.Current.FetchMixes();
            foreach (MixTable mixEntry in allMixes)
            {
                MixModel mixModel = new MixModel(mixEntry);
                Mixes.Add(mixModel);
                mixLookupDictionary.Add(mixModel.MixId, mixModel);

                mixModel.Populate();
            }

            perfTracer.Trace("Mixes Added");
        }
Example #15
0
        public void pdfSvaPitanja(MixModel podaci)
        {
            BaseFont bfontHeader = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, false);
            BaseFont bfontText   = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, true);
            BaseFont bfontFooter = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, BaseFont.CP1250, false);

            Font headerBold = new Font(bfontText, 16, Font.BOLD, BaseColor.DARK_GRAY);
            Font naslov     = new Font(bfontText, 12, Font.BOLDITALIC, BaseColor.DARK_GRAY);
            Font tekst      = new Font(bfontText, 12, Font.NORMAL, BaseColor.BLACK);

            using (MemoryStream memo = new MemoryStream())
            {
                using (Document pdfDokument = new Document(PageSize.A4, 50, 50, 20, 50))
                {
                    PdfWriter.GetInstance(pdfDokument, memo).CloseStream = false;
                    pdfDokument.Open();

                    Paragraph q = new Paragraph("QBox", headerBold);
                    q.Alignment     = Element.ALIGN_CENTER;
                    q.SpacingBefore = 10;
                    q.SpacingAfter  = 10;
                    pdfDokument.Add(q);

                    Paragraph p = new Paragraph("Popis pitanja", naslov);
                    p.Alignment     = Element.ALIGN_CENTER;
                    p.SpacingBefore = 20;
                    p.SpacingAfter  = 20;
                    pdfDokument.Add(p);


                    BaseColor colorheader = BaseColor.PINK;

                    PdfPTable t = new PdfPTable(6);
                    t.WidthPercentage = 100;
                    t.SetWidths(new float[] { 1, 4, 3, 2, 3, 1 });

                    t.AddCell(vratiCeliju("R.br", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Pitanje", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Korisničko ime", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Objavljeno", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Kategorija", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Odg.", tekst, colorheader, true));

                    int i = 1;
                    foreach (var pit in podaci.Pitanja.ToList())
                    {
                        t.AddCell(vratiCeliju(i.ToString() + ".", tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(pit.pitanjeTekst, tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(pit.korisnickoIme.korisnicko_ime, tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(pit.datumObjave.Day.ToString() + "." + pit.datumObjave.Month.ToString() + "." + pit.datumObjave.Year.ToString(), tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(pit.kategorijaId.kategorija, tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(podaci.Odgovori.Where(x => x.pitanje_id == pit.id).Count().ToString(), tekst, BaseColor.WHITE, false));
                        i++;
                    }

                    pdfDokument.Add(t);


                    p               = new Paragraph("Čakovec, " + DateTime.Now.ToString("dd.MM.yyyy"), tekst);
                    p.Alignment     = Element.ALIGN_RIGHT;
                    p.SpacingBefore = 30;

                    pdfDokument.Add(p);
                }

                Podatci = memo.ToArray();

                using (var reader = new PdfReader(Podatci))
                {
                    using (var ms = new MemoryStream())
                    {
                        using (var stamper = new PdfStamper(reader, ms))
                        {
                            int pageCount = reader.NumberOfPages;
                            for (int i = 1; i <= pageCount; i++)
                            {
                                Rectangle      pageSize = reader.GetPageSize(i);
                                PdfContentByte canvas   = stamper.GetOverContent(i);

                                canvas.BeginText();
                                canvas.SetFontAndSize(bfontFooter, 10);

                                canvas.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, $"Stranica {i} / {pageCount}", pageSize.Right - 50, 30, 0);
                                canvas.EndText();
                            }
                        }
                        Podatci = ms.ToArray();
                    }
                }
            }
        }
Example #16
0
        public void pdfKorisnikOdgovori(Korisnik korisnik)
        {
            BaseFont bfontHeader = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, false);
            BaseFont bfontText   = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, true);
            BaseFont bfontFooter = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, BaseFont.CP1250, false);

            Font headerBold = new Font(bfontText, 16, Font.BOLD, BaseColor.DARK_GRAY);
            Font naslov     = new Font(bfontText, 12, Font.BOLDITALIC, BaseColor.DARK_GRAY);
            Font tekst      = new Font(bfontText, 12, Font.NORMAL, BaseColor.BLACK);

            MixModel model = new MixModel();

            model.Pitanja  = bazaPodataka.PopisPitanja.ToList();
            model.Odgovori = bazaPodataka.PopisOdgovora.Where(x => x.korisnicko_ime == korisnik.id).ToList().OrderByDescending(x => x.datumObjave).ThenBy(x => x.najdraze);

            using (MemoryStream memo = new MemoryStream())
            {
                using (Document pdfDokument = new Document(PageSize.A4, 50, 50, 20, 50))
                {
                    PdfWriter.GetInstance(pdfDokument, memo).CloseStream = false;
                    pdfDokument.Open();

                    Paragraph q = new Paragraph("QBox", headerBold);
                    q.Alignment     = Element.ALIGN_CENTER;
                    q.SpacingBefore = 10;
                    q.SpacingAfter  = 10;
                    pdfDokument.Add(q);

                    Paragraph p = new Paragraph("Popis odgovora korisnika '" + korisnik.korisnicko_ime + "'", naslov);
                    p.Alignment     = Element.ALIGN_CENTER;
                    p.SpacingBefore = 20;
                    p.SpacingAfter  = 20;
                    pdfDokument.Add(p);

                    BaseColor colorheader = BaseColor.PINK;

                    PdfPTable t = new PdfPTable(5);
                    t.WidthPercentage = 100;
                    t.SetWidths(new float[] { 2, 4, 4, 2, 2 });

                    t.AddCell(vratiCeliju("R.br", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Pitanje", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Odgovor", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Objavljeno", tekst, colorheader, true));
                    t.AddCell(vratiCeliju("Najdraži", tekst, colorheader, true));

                    int i = 1;
                    foreach (var odg in model.Odgovori)
                    {
                        t.AddCell(vratiCeliju(i.ToString() + ".", tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(odg.Pit.pitanjeTekst, tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(odg.odgovor, tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(odg.datumObjave.Day.ToString() + "." + odg.datumObjave.Month.ToString() + "." + odg.datumObjave.Year.ToString(), tekst, BaseColor.WHITE, false));
                        t.AddCell(vratiCeliju(odg.najdraze ? "DA" : "NE", tekst, BaseColor.WHITE, false));
                        i++;
                    }

                    pdfDokument.Add(t);


                    p               = new Paragraph("Čakovec, " + DateTime.Now.ToString("dd.MM.yyyy"), tekst);
                    p.Alignment     = Element.ALIGN_RIGHT;
                    p.SpacingBefore = 30;

                    pdfDokument.Add(p);
                }

                Podatci = memo.ToArray();

                using (var reader = new PdfReader(Podatci))
                {
                    using (var ms = new MemoryStream())
                    {
                        using (var stamper = new PdfStamper(reader, ms))
                        {
                            int pageCount = reader.NumberOfPages;
                            for (int i = 1; i <= pageCount; i++)
                            {
                                Rectangle      pageSize = reader.GetPageSize(i);
                                PdfContentByte canvas   = stamper.GetOverContent(i);

                                canvas.BeginText();
                                canvas.SetFontAndSize(bfontFooter, 10);

                                canvas.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, $"Stranica {i} / {pageCount}", pageSize.Right - 50, 30, 0);
                                canvas.EndText();
                            }
                        }
                        Podatci = ms.ToArray();
                    }
                }
            }
        }
        public MixViewModel LookupMix(MixModel mix)
        {
            if (MixLookupMap.ContainsKey(mix.MixId))
            {
                return MixLookupMap[mix.MixId];
            }
            else
            {
                MixViewModel newViewModel = new MixViewModel(mix);

                MixLookupMap.Add(newViewModel.MixId, newViewModel);
                MixCollection.Add(newViewModel);
                return newViewModel;
            }
        }
Example #18
0
        public static MixHessInfo GetHessMixEAnm(Universe univ, IList <Vector> coords, ILinAlg la, IList <ResInfo> lstResAllAtom
                                                 , bool bAllowAllToCoarse, bool bOnlyCoarseConnBackbone
                                                 , Tuple <double, double> anmSprcstCutoffAll    // all-all
                                                 , Tuple <double, double> anmSprcstCutoffMix    // all/buffer-coarse
                                                 , Tuple <double, double> anmSprcstCutoffCoarse // coarse-coarse
                                                 , out string errmsg
                                                 , bool bGetIntmInfo, string strBkbnReso
                                                 )
        {
            double anmSprcstAll    = anmSprcstCutoffAll.Item1;
            double anmSprcstMix    = anmSprcstCutoffMix.Item1;
            double anmSprcstCoarse = anmSprcstCutoffCoarse.Item1;
            double anmCutoffAll    = anmSprcstCutoffAll.Item2;
            double anmCutoffMix    = anmSprcstCutoffMix.Item2;
            double anmCutoffCoarse = anmSprcstCutoffCoarse.Item2;

            HDebug.Assert(anmCutoffAll >= 0);
            HDebug.Assert(anmCutoffCoarse >= 0);
            MixModel.FnGetHess GetHess = delegate(Universe luniv, IList <Vector> lcoords, int[] idxAll, int[] idxBuffer, int[] idxCoarse, int[] idxBackbone)
            {
                int size = coords.Count;

                HashSet <int> setIdxAll      = idxAll.HToHashSet();
                HashSet <int> setIdxBuffer   = idxBuffer.HToHashSet();
                HashSet <int> setIdxCoarse   = idxCoarse.HToHashSet();
                HashSet <int> setIdxBackbone = idxBackbone.HToHashSet();

                Matrix anmKij = Matrix.Zeros(size, size);
                for (int c = 0; c < size; c++)
                {
                    if (lcoords[c] == null)
                    {
                        continue;
                    }
                    int typec = 0;
                    if (setIdxAll.Contains(c))
                    {
                        HDebug.Assert(typec == 0); typec = 1;
                    }
                    if (setIdxBuffer.Contains(c))
                    {
                        HDebug.Assert(typec == 0); typec = 2;
                    }
                    if (setIdxCoarse.Contains(c))
                    {
                        HDebug.Assert(typec == 0); typec = 3;
                    }
                    HDebug.Assert(typec != 0);

                    for (int r = c + 1; r < size; r++)
                    {
                        if (lcoords[r] == null)
                        {
                            continue;
                        }
                        int typer = 0;
                        if (setIdxAll.Contains(r))
                        {
                            HDebug.Assert(typer == 0); typer = 1;
                        }
                        if (setIdxBuffer.Contains(r))
                        {
                            HDebug.Assert(typer == 0); typer = 2;
                        }
                        if (setIdxCoarse.Contains(r))
                        {
                            HDebug.Assert(typer == 0); typer = 3;
                        }
                        HDebug.Assert(typer != 0);

                        double sprcst;
                        double cutoff;
                        int    type0  = Math.Min(typec, typer);
                        int    type1  = Math.Max(typec, typer);
                        int    type01 = type0 * 10 + type1;
                        switch (type01)
                        {
                        case 11: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break;             // All    - All

                        case 12: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break;             // All    - Buffer

                        case 22: sprcst = anmSprcstAll; cutoff = anmCutoffAll; break;             // Buffer - Buffer

                        case 33: sprcst = anmSprcstCoarse; cutoff = anmCutoffCoarse; break;       // Coarse - Coarse

                        case 23: sprcst = anmSprcstMix; cutoff = anmCutoffMix; break;             // Buffer - Coarse

                        case 13:                                                                  // All    - Buffer
                            if (bAllowAllToCoarse == false)
                            {
                                continue;
                            }
                            sprcst = anmSprcstMix;
                            cutoff = anmCutoffMix;
                            break;

                        default: throw new Exception();
                        }

                        HDebug.Assert(bOnlyCoarseConnBackbone == false); // "true" makes the result bad
                        if (bOnlyCoarseConnBackbone)
                        {
                            bool c_bkbn = setIdxBackbone.Contains(c);
                            bool r_bkbn = setIdxBackbone.Contains(r);
                            if (c_bkbn && r_bkbn)
                            {
                                // special treatment that in-between backbones use only coarse grained onnections.
                                sprcst = anmSprcstCoarse;
                                cutoff = anmCutoffCoarse;
                            }
                            else if ((type01 == 11) || (type01 == 12) || (type01 == 22))
                            {
                                // do nothing. use the above setting.
                            }
                            else
                            {
                                // all-to-coarse
                                HDebug.AssertOr(type01 == 13, type01 == 23);
                                if (type01 == 33)
                                {
                                    HDebug.Assert(type01 != 33); // should be treated by (c_bkbn && r_bkbn)
                                    throw new Exception("HDebug.Assert(type01 != 33)");
                                }
                                continue;
                            }
                        }
                        double cutoff2 = cutoff * cutoff;

                        double dist2 = (coords[c] - coords[r]).Dist2;
                        if (dist2 <= cutoff2)
                        {
                            anmKij[c, r] = sprcst;
                            anmKij[r, c] = sprcst;
                        }
                    }
                }

                var hessinfo = Hess.GetHessEAnm(luniv, lcoords, anmKij);
                return(hessinfo);
            };
            return(MixModel.GetHessMixModel(univ, coords, la, lstResAllAtom, GetHess, out errmsg, bGetIntmInfo, strBkbnReso));
        }