Exemplo n.º 1
0
 public NavigationViewModel()
 {
     ManagerPage.AddFrame("Work", ChangePage);
     CurrentPage = new Theory {
         DataContext = new TheoryViewModel()
     };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Provide program for the next procedure (for the global declarations).
        /// </summary>
        public static void Program(Program p)
        {
            if (boogieGlobalData == null)
            {
                boogieGlobalData = new BoogieGlobalData(p.Functions, p.Axioms, p.GlobalVariables, p.Constants);

                var methodData            = BoogieMethodData.CreateOnlyGlobal(boogieGlobalData);
                var fixedVarTranslation   = new DeBruijnFixedVarTranslation(methodData);
                var fixedTyVarTranslation = new DeBruijnFixedTVarTranslation(methodData);
                var factory =
                    new DeBruijnVarFactory(fixedVarTranslation, fixedTyVarTranslation, boogieGlobalData);
                var globalDataTheoryName = "global_data";
                var globalDataConfig     = new IsaProgramGeneratorConfig(null, true, true, true, false, SpecsConfig.None, false);
                globalDataProgAccess = new IsaProgramGenerator().GetIsaProgram(
                    globalDataTheoryName,
                    "proc",
                    methodData, globalDataConfig, factory,
                    null,
                    out var declsGlobalData,
                    !CommandLineOptions.Clo.GenerateIsaProgNoProofs,
                    true
                    );

                var globalDataTheory = new Theory(globalDataTheoryName,
                                                  new List <string> {
                    "Boogie_Lang.Semantics", "Boogie_Lang.TypeSafety", "Boogie_Lang.Util"
                },
                                                  declsGlobalData);
                ProofGenerationOutput.StoreTheoriesTopLevel(new List <Theory> {
                    globalDataTheory
                });
            }
        }
Exemplo n.º 3
0
    public void PositionNotes()
    {
        var   trk = player.loadedBeatmap.GetTrack(trackNum);
        float t   = 0;
        int   i   = 0;

        var   rtf = (RectTransform)transform;
        float h   = rtf.rect.height;
        float w   = rtf.rect.width;

        foreach (Note n in trk.notes)
        {
            MidiNoteImage im;

            if (i < _notes.Count)
            {
                im = _notes[i].GetComponent <MidiNoteImage>();
            }
            else
            {
                im = Instantiate(noteImagePrefab, transform).GetComponent <MidiNoteImage>();
                _notes.Add(im);
            }
            i++;

            t += n.deltaTime;
            //float y = t * noteScale;
            float y = (float)n.absoluteTime * noteScale;
            float x = (w / 88.0f) * (Theory.HertzToNote(n.frequency) - 21);

            im.rt.anchoredPosition = new Vector2(x, y);
            im.rt.sizeDelta        = new Vector2(w / 88.0f, n.duration * noteScale);
        }
    }
Exemplo n.º 4
0
        public async static Task <Theory> GetChords(string url)
        {
            string URL = url;

            Theory chords = new Theory();

            //HttpClient
            using (HttpClient client = new HttpClient())
                using (HttpResponseMessage response = await client.GetAsync(URL))
                    using (HttpContent content = response.Content)
                    {
                        string JSONtext = await response.Content.ReadAsStringAsync();

                        try
                        {
                            var settings = new JsonSerializerSettings
                            {
                                DefaultValueHandling = DefaultValueHandling.Include
                            };

                            //Convert JSON into object chords
                            chords = JsonConvert.DeserializeObject <Theory>(JSONtext, settings);
                        }

                        catch
                        {
                            Console.WriteLine(Environment.NewLine + "Couldn't convert the results into text.");
                        }
                    }
            return(chords);
        }
Exemplo n.º 5
0
 public void AddTheory(Theory Theory)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Theories.Add(Theory);
         db.SaveChanges();
     }
 }
Exemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Theory theory = db.TheoriesList.Find(id);

            db.TheoriesList.Remove(theory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            SolveInfo info;

            string res;
            //carico il file di test
            InputStream stream = new FileInputStream("../../../prolog/tictac.pl");
            Theory      t      = new Theory(stream);
            //preparo il motore prolog
            Prolog engine = new Prolog();

            //OOLibrary.OOLibrary lib = new OOLibrary.OOLibrary();
            //engine.unloadLibrary("alice.tuprolog.lib.JavaLibrary");
            //engine.loadLibrary(lib);
            engine.setTheory(t);



            //Listener per output e spy
            engine.addOutputListener(new MyOutputListener());
            engine.addSpyListener(new MySpyListener());
            //engine.setSpy(true);

            do
            {
                System.Console.Write("Select the version to be loaded (cs, vb, fs, java. default: cs)");
                res = System.Console.ReadLine();

                switch (res)
                {
                case "cs":
                    info = engine.solve("loadgameCS.");
                    break;

                case "vb":
                    info = engine.solve("loadgameVB.");
                    break;

                case "fs":
                    info = engine.solve("loadgameFS.");
                    break;

                case "java":
                    info = engine.solve("loadgameJava.");
                    break;

                default:
                    info = engine.solve("loadgameCS.");
                    break;
                }

                System.Console.Write("Play again? (y/n):");
                res = System.Console.ReadLine();
            } while (res.StartsWith("y"));

            System.Console.WriteLine(info.toString());
        }
Exemplo n.º 8
0
 public void DeleteTheory(int id)
 {
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         Theory newTheory = db.Theories.Find(id);
         db.Theories.Remove(newTheory);
         db.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public NavigationViewModel(string role)
 {
     ManagerPage.AddFrame("Work", ChangePage);
     IsVisibilityTeacher = Visibility.Collapsed;
     IsVisibilityStudent = Visibility.Visible;
     CurrentPage         = new Theory {
         DataContext = new TheoryViewModel()
     };
 }
Exemplo n.º 10
0
    public void SetFrequency(float note)
    {
        frequency = note;
        string name   = Theory.NoteLetter(note);
        string number = Theory.NoteNumber(note).ToString();

        noteLetter.text = name;
        noteNumber.text = number;
    }
Exemplo n.º 11
0
        private static void StoreTheory(string dirName, Theory theory)
        {
            var path         = Path.Combine(dirName, theory.TheoryName + ".thy");
            var sw           = new StreamWriter(path);
            var theoryString = IsaPrettyPrinter.PrintTheory(theory);

            sw.WriteLine(theoryString);
            sw.Close();
        }
Exemplo n.º 12
0
    public void UpdateTrackInfo()
    {
        SongPlayer player = SongPlayer.instance;
        var        bm     = player.loadedBeatmap;

        float diff = 0;

        for (int i = 0; i < bm.numTracks; i++)
        {
            if (!player.IsTrackEnabled(i))
            {
                continue;
            }

            float res = bm.GetTrack(i).Difficulty();

            if (res < 0)
            {
                diff = res;
                break;
            }
            else
            {
                diff += res;
            }
        }

        if (diff < 0)
        {
            diffText.text  = "impossible, need more keys";
            diffText.color = Color.red;
        }
        else
        {
            diffText.text  = diff.ToString("0.0") + " difficulty";
            diffText.color = Color.white;
        }

        float nps = 0;

        for (int i = 0; i < bm.numTracks; i++)
        {
            if (!player.IsTrackEnabled(i))
            {
                continue;
            }

            nps += (float)bm.GetTrack(i).Speed();
        }

        npmText.text = (nps * 60f).ToString("0.0") + "notes/mim";

        durText.text = Theory.DurationToString(player.selectedDuration);
    }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Id,Text")] Theory theory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(theory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Id = new SelectList(db.StepsList, "Id", "Name", theory.Id);
     return(View(theory));
 }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            //Inizializza interprete e imposta la teoria
            SolveInfo   si;
            InputStream ins    = new FileInputStream("../../../prolog/adapterTheory.pl");
            Theory      t      = new Theory(ins);
            Prolog      engine = new Prolog();

            engine.setTheory(t);
            engine.addExceptionListener(new MyExcptioListener());
            engine.addOutputListener(new MyOutputListener());
            engine.addSpyListener(new MySpyListener());
            //Richiede all'utente quale azioni analizzare
            List <String> stocks = new List <string>();
            String        str;

            System.Console.WriteLine("The program downloads the history of prices of a bunch of stocks, then upload an analysis on a MySQL database");//TODO
            do
            {
                System.Console.WriteLine("Write a stock name(e.g. msft, goog) to add a stock to analyze or return to finish");
                str = System.Console.ReadLine();
                if (str.Length != 0)
                {
                    stocks.Add(str);
                }
            } while (str.Length != 0);
            //Richoede il periodo d'analisi
            System.Console.WriteLine("Insert Days of the Analysis");
            str = System.Console.ReadLine();
            int days = Int32.Parse(str);

            System.Console.WriteLine("Wait please...");
            //Usa il metodo factory (F#) per ottenere gli StockAnalyzer
            var analyzers = StockAnalyzer.GetAnalyzers(stocks, days);
            IEnumerator <StockAnalyzer> ie = analyzers.GetEnumerator();

            //Inserisce nel database gli StockAnalyzer usando l'inteprete tuProlog.NET
            for (int i = 0; i < stocks.Count; i++)
            {
                ie.MoveNext();
                str = stocks[i] + ";" + ie.Current.ToString;
                System.Console.WriteLine(str);
                si = engine.solve("addStockAnalysis('" + str + "',RS).");
                if (("" + si.getVarValue("RS")) == "0")
                {
                    System.Console.WriteLine("Tuple added");
                }
                else if (("" + si.getVarValue("RS")) == "1")
                {
                    System.Console.WriteLine("Tuple already presents");
                }
            }
        }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "Id,Text")] Theory theory)
        {
            if (ModelState.IsValid)
            {
                db.TheoriesList.Add(theory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Id = new SelectList(db.StepsList, "Id", "Name", theory.Id);
            return(View(theory));
        }
Exemplo n.º 16
0
        public ClientAdapter(String theoryPath)
        {
            _engine = new Prolog();
            FileInputStream fis = new FileInputStream(new File(theoryPath));
            Theory          t   = new Theory(fis);

            _engine.setTheory(t);
            Listener ls = new Listener();

            _engine.addExceptionListener(ls);
            _engine.addOutputListener(ls);
            _engine.addSpyListener(ls);
        }
Exemplo n.º 17
0
    public virtual void SetText(float value)
    {
        var textob = GetComponent <Text>();

        if (asInt)
        {
            textob.text = (Theory.RoundFloat(value)).ToString();
        }
        else
        {
            textob.text = value.ToString();
        }
    }
Exemplo n.º 18
0
 private void ButtonAdd_Click()
 {
     if (!String.IsNullOrWhiteSpace(TextBoxTheory.Text))
     {
         var newtheory = new Theory()
         {
             Text    = TextBoxTheory.Text,
             TopicId = edcl.SelectedTopic.Id
         };
         edcl.AddTheory(newtheory);
         Clear();
     }
 }
Exemplo n.º 19
0
    void OnEnable()
    {
        touchCircleToggle.val = keyboard.touchCircles;
        rowsUpDown.val        = keyboard.numRows;
        colsUpDown.val        = keyboard.numCols;
        rootNoteLetter.val    = Theory.RoundFloat(keyboard.rootNoteLetter);
        rootNoteNumber.val    = Theory.RoundFloat(keyboard.rootNoteNumber);
        negateUpwards.val     = keyboard.upwardsNegate;
        upwardsInc.val        = Theory.RoundFloat(keyboard.upwardsDelta);
        negateDownwards.val   = keyboard.downwardsNegate;
        downwardsInc.val      = Theory.RoundFloat(keyboard.downwardsDelta);

        diagram.Invalidate();
    }
Exemplo n.º 20
0
        // GET: Theories/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Theory theory = db.TheoriesList.Find(id);

            if (theory == null)
            {
                return(HttpNotFound());
            }
            return(View(theory));
        }
Exemplo n.º 21
0
    //will round to the nearest integer
    public override void SetText(float value)
    {
        var textob = GetComponent <Text>();

        int i = Theory.RoundFloat(value);

        if ((i < 0) || (i >= options.Length))
        {
            textob.text = "???";
        }
        else
        {
            textob.text = options[i];
        }
    }
Exemplo n.º 22
0
        // GET: Theories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Theory theory = db.TheoriesList.Find(id);

            if (theory == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Id = new SelectList(db.StepsList, "Id", "Name", theory.Id);
            return(View(theory));
        }
Exemplo n.º 23
0
        public bool CreateTheory(TheoryCreate model)
        {
            var entity =
                new Theory()
            {
                OwnerId     = _userId,
                Subject     = model.Subject,
                Content     = model.Content,
                DateCreated = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Theories.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 24
0
        public IActionResult UpdateTheory([FromBody] Theory uTheory)
        {
            var oTheory = context.Theories.Find(uTheory.Id);

            if (oTheory == null)
            {
                return(NotFound());
            }

            oTheory.ImdbID      = uTheory.ImdbID;
            oTheory.Writer      = uTheory.Writer;
            oTheory.Title       = uTheory.Title;
            oTheory.Description = uTheory.Description;
            oTheory.Comments    = uTheory.Comments;

            context.SaveChanges();
            return(Ok(oTheory));
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            Subjects subjects = new Subjects();

            try
            {
                Theory t1 = new Theory();
                t1.ID    = 1;
                t1.Name  = "Theory subject1";
                t1.Marks = 150;

                Lab l1 = new Lab();
                Console.WriteLine("Enter subject id");
                l1.ID        = Convert.ToInt32(Console.ReadLine());
                l1.Name      = "Lab1";
                l1.Internals = 30;

                subjects.Add(t1);
                subjects.Add(l1);

                foreach (Subject item in subjects.GetAllSubjets())
                {
                    Console.WriteLine(item.Name);
                }

                MyGenericClass <int, Subject> myGenericClass = new MyGenericClass <int, Subject>();
            }
            catch (DuplicateKeyException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (FormatException ex)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }finally
            {
                Console.WriteLine("Always executed");
                Console.ReadLine();
            }
        }
Exemplo n.º 26
0
        public IActionResult CreateTheory([FromBody] Theory newTheory)
        {
            if (string.IsNullOrWhiteSpace(newTheory.ImdbID))
            {
                return(BadRequest("imdbId is not allowed to be null or empty."));
            }
            if (string.IsNullOrWhiteSpace(newTheory.Title))
            {
                return(BadRequest("title is not allowed to be null or empty"));
            }
            if (string.IsNullOrWhiteSpace(newTheory.Writer))
            {
                newTheory.Writer = "anonymous";
            }

            context.Theories.Add(newTheory);
            context.SaveChanges();
            return(Created("", newTheory));
        }
Exemplo n.º 27
0
    private void UpdatePanels()
    {
        SongPlayer player = SongPlayer.instance;

        float padding    = 5;
        float y          = padding;
        float lastHeight = 0;

        for (int i = 0; i < player.loadedBeatmap.numTracks; i++)
        {
            var        trk = player.loadedBeatmap.GetTrack(i);
            GameObject ob;
            if (i < panels.Count)
            {
                ob = panels[i];
                ob.SetActive(true);
            }
            else
            {
                ob = Instantiate(trackPreviewPanel, transform);
                panels.Add(ob);
            }

            var panel = ob.GetComponent <TrackPreviewPanel>();
            panel.trackIndex     = i;
            panel.trackListGet   = this;
            panel.isEnabled      = false || panel.isEnabled;
            panel.trackName      = trk.trackName;
            panel.instrumentName = trk.instrumentName;
            panel.speed          = (60 * trk.Speed()).ToString("0.00") + "npm";
            double dur = trk.duration;
            panel.time = Theory.DurationToString(dur);

            var rtf = panel.transform as RectTransform;
            rtf.anchoredPosition = new Vector2(0, -y);
            lastHeight           = rtf.rect.height;
            y += lastHeight + padding;
        }

        (transform as RectTransform).sizeDelta = new Vector2(0, y + lastHeight + padding);
    }
Exemplo n.º 28
0
        public Form1()
        {
            InitializeComponent();

            engine = new Prolog();
            try
            {
                Theory t = new Theory(new java.io.FileInputStream(@"..\..\..\der.pl"));
                engine.setTheory(t);
            }
            catch (InvalidTheoryException e1)
            {
                Console.WriteLine("Theory not valid.");
                Application.Exit();
            }
            catch (java.io.IOException e2)
            {
                Console.WriteLine("Errors in reading from file.");
                Application.Exit();
            }
        }
Exemplo n.º 29
0
        private void Element2_Click(object sender, EventArgs e)
        {
            if (StatusElement == null)
            {
                MessageBox.Show("Вы не выбрали урок!");
                return;
            }

            Color myRgbColor = new Color();

            myRgbColor = Color.FromArgb(255, 255, 255, 0);
            LessonConentLayoutPanel.BackColor = myRgbColor;
            t1.Tick    += new EventHandler(fadeOutAddTheory);
            t1.Interval = 100;
            t1.Start();

            Theory theory = new Theory();

            StatusElement.AddTheory(theory);

            LessonConentLayoutPanel.Controls.Add(theory);
        }
Exemplo n.º 30
0
        public static void Main(string[] args)
        {
            //OpenFileDialog dialog = new OpenFileDialog();
            //dialog.ShowDialog();

            OOLibrary   lib    = new OOLibrary();
            InputStream stream = new FileInputStream(@"Test.pl");
            // InputStream stream = new FileInputStream("C:\\Users\\Administrator\\Desktop\\Test.pl");


            Prolog engine = new Prolog();
            //engine.unloadLibrary("alice.tuprolog.lib.JavaLibrary");
            //engine.loadLibrary(lib);

            Theory th = new Theory(stream);

            engine.addTheory(th);
            SolveInfo info = engine.solve("testInteroperation(X).");

            System.Console.WriteLine(info.isSuccess());
            System.Console.WriteLine(info.isHalted());

            //info = engine.solve("testBasicsWithJava.");
            //System.Console.WriteLine(info.isSuccess());
            //System.Console.WriteLine(info.isHalted());


            //java.util.List[] primitives = lib.getPrimitives();

            //for (int i = 0; i < primitives.Length; i++)
            //{
            //    PrimitiveInfo p = (PrimitiveInfo)primitives[i];
            //}



            System.Console.ReadLine();
        }
Exemplo n.º 31
0
        public void Run()
        {
            engine = new Prolog();
              try
              {
            var library = new PrologLibrary();
            engine.loadLibrary(library);
              }
              catch (Exception e)
              {
            var s = string.Format(
              "*****\n{0}: {1}\n-----\n{2}\n",
              e.GetType().Name, e.Message, e.StackTrace);
            System.Console.Out.Write(s);
              }
              engine.addOutputListener(this);

              try
              {
            TheoryLoader loader = new TheoryLoader();
            String theoryText = loader.load();

            Theory theory = new Theory(theoryText);
            engine.setTheory(theory);

            if (testing)
            {
              SolveInfo testInfo = engine.solve("test.");
              if (testInfo.isSuccess())
              {
            System.Console.Out.WriteLine("Test run succeeded.");
              }
              else
              {
            System.Console.Out.WriteLine("Test run did not succeed.");
              }
            }
            else
            {
              SolveInfo info = engine
              .solve("all_subscriber_feeds(ResultList).");

              if (info.isSuccess())
              {
            System.Console.Out.WriteLine("Success.");
            var bindings = info.getBindingVars();

            if (PrologLibrary.traceEnabled)
            {
              System.Console.Out.WriteLine("Bindings:");
              System.Console.Out.WriteLine(bindings.ToString());
            }

            Var resultList = (Var)bindings.get(0);
            showSubscriberFeedsResultList(resultList);

            System.Console.Out.WriteLine("Done.");
              }
              else
              {
            System.Console.Out.WriteLine("Failure.");
              }
            }
              }
              catch (Exception e)
              {
            var s = string.Format(
              "*****\n{0}: {1}\n-----\n{2}\n",
              e.GetType().Name, e.Message, e.StackTrace);
            System.Console.Out.Write(s);
              }
        }
Exemplo n.º 32
0
        public HurricanePoker(string[] args)
        {
            System.Console.Out.WriteLine(
              "Rick Rutt's Hurricane Poker - Using the tuProlog system "
              + Prolog.getVersion()
              );

              bool enablePeeking = false;
              bool enableSpying = false;
              bool enableTrace = false;

              foreach (var arg in args)
              {
            if ((arg.Length > 1) && (arg[0] == '-'))
            {
              if (arg.Equals("-peek", StringComparison.CurrentCultureIgnoreCase))
              {
            enablePeeking = true;
            System.Console.Out.WriteLine("Peek output enabled.");
              }
              else if (arg.Equals("-spy", StringComparison.CurrentCultureIgnoreCase))
              {
            enableSpying = true;
            System.Console.Out.WriteLine("Spy output enabled.");
              }
              else if (arg.Equals("-trace", StringComparison.CurrentCultureIgnoreCase))
              {
            enableTrace = true;
            System.Console.Out.WriteLine("Trace output enabled.");
              }
              else
              {
            System.Console.Out.WriteLine("Unknown command argument ignored: " + arg);
              }
            }
            else
            {
              theoryFilePath = arg;
              System.Console.Out.WriteLine("Processing theory file: " + arg);
            }
              }

              InitializeComponent();

              this.Visible = true;

              Application.DoEvents();

              engine = new Prolog();
              try
              {
            library = new PrologPredicatesAndFunctors(this);
            library.enablePeeking = enablePeeking;
            library.enableSpying = enableSpying;
            library.enableTrace = enableTrace;

            engine.loadLibrary(library);
              }
              catch (Exception e)
              {
            var s = string.Format(
              "*****\n{0}: {1}\n-----\n{2}\n",
              e.GetType().Name, e.Message, e.StackTrace);
            System.Console.Out.Write(s);
              }
              engine.addOutputListener(this);
              engine.addSpyListener(this);
              engine.setSpy(enableSpying);

              try
              {
            TheoryLoader loader = new TheoryLoader();
            String theoryText = loader.Load(theoryFilePath);
            var t = new Theory(theoryText);
            //				t = new Theory(theoryInputStream);
            engine.setTheory(t);

            Application.DoEvents();

            SolveInfo info = engine.solve("x.");
            //			System.Console.Out.Write(info);
              }
              catch (Exception e)
              {
            var s = string.Format(
              "*****\n{0}: {1}\n-----\n{2}\n",
              e.GetType().Name, e.Message, e.StackTrace);
            System.Console.Out.Write(s);
              }

              System.Environment.Exit(0);
        }