Example #1
0
        public void RemoveStaticPage(StaticPage pageToRemove)
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            repo.DeleteTagStaticBridgeTable(pageToRemove);
            repo.RemoveStaticPage(pageToRemove);
        }
Example #2
0
        public List <StaticPage> GetAllPages()
        {
            var repo = StaticFactory.CreateStaticPageRepository();
            var page = repo.GetAllPages();

            return(page);
        }
Example #3
0
        public void addStaticPageCheckTheDelete()
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            StaticPage page = new StaticPage();

            page.Name        = "Anime";
            page.Body        = "Anime stuff";
            page.Category    = Category.Anime;
            page.Approved    = Approved.Yes;
            page.DateCreated = DateTime.Today;

            repo.AddStaticPage(page);
            List <StaticPage> pages = repo.GetAllPages();
            StaticPage        check = pages.Last();

            Assert.AreEqual("Anime", check.Name);
            Assert.AreEqual("Anime stuff", check.Body);
            //Assert.AreEqual(Anime, check.Category);
            //Assert.AreEqual("Yes", check.Approved);

            repo.RemoveStaticPage(page);

            Assert.IsNull(repo.GetPageByID(page.Id));
        }
Example #4
0
 /// <summary>
 /// Deletes selected set folder physically and rerenders the set list
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void OnBtnDelMainClickEventRaised(object sender, EventArgs e)
 {
     if (SetModel.SelectedSet != null)
     {
         DeleteSet.Delete(SetModel.SelectedSet);
         _setModels = StaticFactory.CreateAllSets(); //Renew all set list
         SetListboxInit();
     }
 }
Example #5
0
        public void TestMethod3()
        {
            _blackPerson = StaticFactory <IPerson> .CreateObject(typeof(BlackPerson));

            _whitePerson = StaticFactory <IPerson> .CreateObject(typeof(BlackPerson));

            _blackPerson.Move();
            _whitePerson.Move();
        }
Example #6
0
        static void Main()
        {
            MainViewPresenter mainPresenter = (MainViewPresenter)StaticFactory.CreateMainViewPresenter();

            mainPresenter.ShowMain();

            Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            Application.Run();
        }
Example #7
0
        public void AddStaticPage(StaticPage pageToAdd)
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            repo.AddStaticPage(pageToAdd);

            foreach (var tag in pageToAdd.Tag)
            {
                InsertTagStaticBridgeTable(tag.Id, pageToAdd.Id);
            }
        }
Example #8
0
 /// <summary>
 /// Open 'AddSetView' within MainView when clicking on MainView's 'btnAdd'
 /// </summary>
 private void AddSetPresenterInit(object sender, EventArgs e)
 {
     _addSetPresenter = (AddSetPresenter)StaticFactory.CreateAddSetPresenter(_mainView);
     _addSetPresenter.OnSubmitClicked += OnAddSetViewSubmitClicked;
     _mainView.btnBack.Visible         = true;
     _mainView.btnAdd.Visible          = false;
     _mainView.btnDel.Visible          = false;
     _mainView.btnRename.Visible       = false;
     _setlistboxPresenter.CloseSetlistbox(); //Close setlistbox
     _addSetPresenter.ShowAddSetView();
 }
Example #9
0
        private void PlayVideo(int index)
        {
            string videoPath = Path.Combine(Base._setsFolder, SetModel.SelectedSet, SetModel.SelectedTopic, "Videos");

            string[] videos = Directory.GetFiles(videoPath);

            //Open on click
            FileInfo           file = new FileInfo(videos[index]);
            VideoViewPresenter _vwp = StaticFactory.CreateVideoViewPresenter(_mainView, file);

            _vwp.ShowVideoView();
        }
Example #10
0
        public void EditStaticPage(StaticPage pageToEdit)
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            repo.DeleteTagStaticBridgeTable(pageToEdit);

            foreach (var tag in pageToEdit.Tag)
            {
                repo.InsertTagStaticBridgeTable(tag.Id, pageToEdit.Id);
            }

            repo.EditStaticPage(pageToEdit);
        }
Example #11
0
        /// <summary>
        /// Initialize SetListbox in MainView.MainPanel control list
        /// </summary>
        private void SetListboxInit()
        {
            if (_setlistboxPresenter != null)
            {
                _setlistboxPresenter.CloseSetlistbox(); //Dispose of setlistboxPresenter
            }
            _mainView.btnBack.Visible = false;
            _mainView.btnAdd.Visible  = true;
            _mainView.btnDel.Visible  = true;
            _setlistboxPresenter      = (SetlistboxPresenter)StaticFactory.CreateSetlistboxPresenter(_mainView, _setModels); //Create and load setlist presenter

            //Set double click @ main view
            _setlistboxPresenter.OnSetDoubleClicked += OnOnSetDoubleClickedEventRaised;
        }
Example #12
0
        /// <summary>
        /// Open set rename dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnRenameBtnClickEventRaised(object sender, EventArgs e)
        {
            //TODO: Check why SetListbox doesn't update after renaming set
            if (SetModel.SelectedSet != null)
            {
                //Check for illegal characters
                SetNameUpdater _setNameUpdater = StaticFactory.CreateSetNameUpdater();

                _setNameUpdater.inputNewSetTitle.TextChanged += (o, a) =>
                {
                    string illegalChars = "^[\\w ]+$";
                    Regex  regex        = new Regex(illegalChars);

                    if (_setNameUpdater.inputNewSetTitle.Text == "" || !regex.IsMatch(_setNameUpdater.inputNewSetTitle.Text))
                    {
                        _setNameUpdater.SetNameUpdaterBtnSubmit.Visible = false;
                        _setNameUpdater.WarningLabel.Visible            = true;
                    }
                    else
                    {
                        _setNameUpdater.SetNameUpdaterBtnSubmit.Visible = true;
                        _setNameUpdater.WarningLabel.Visible            = false;
                    }
                };


                //Create setNameUpdater window &
                _setNameUpdater.StartPosition = FormStartPosition.Manual;
                _setNameUpdater.Location      = new System.Drawing.Point(this._mainView.Location.X + 430, this._mainView.Location.Y + 400);

                DialogResult updateDialog = _setNameUpdater.ShowDialog(_mainView);


                //If submit btn = pressed, rename set folder name
                if (updateDialog == DialogResult.OK)
                {
                    if (_setlistboxPresenter._setlistboxView.HomeSetList.SelectedItem != null)
                    {
                        //Rename set folder name
                        UpdateSet.Update(_setlistboxPresenter._setlistboxView.HomeSetList.SelectedItem.Text, _setNameUpdater.inputNewSetTitle.Text);

                        //Rebuild setlistbox item list
                        _setlistboxPresenter._setlistboxView.HomeSetList.Items.Clear();
                        _setModels = StaticFactory.CreateAllSets();
                        SetListboxInit();
                        _setlistboxPresenter._setlistboxView.HomeSetList.SelectedIndex = 0;
                    }
                }
            }
        }
Example #13
0
 public void OnOnSetDoubleClickedEventRaised(object sender, EventArgs e)
 {
     if (SetModel.SelectedSet != null)
     {
         SetModel.SelectedSet = _setlistboxPresenter._setlistboxView.HomeSetList.SelectedItem.Text;
         _setlistboxPresenter.CloseSetlistbox();
         _setViewPresenter = StaticFactory.CreateSetViewPresenter(_mainView); //New SetViewPresenter on DCLICK
         _setViewPresenter.ShowSetView();
         _mainView.btnRename.Visible = false;
         _mainView.btnAdd.Visible    = false;
         _mainView.btnDel.Click     -= OnBtnDelMainClickEventRaised;
         _mainView.btnBack.Visible   = true;
     }
 }
Example #14
0
        public void TestUser()
        {
            User alex = StaticFactory.CreateDefaultUser();

            Console.WriteLine(alex.ToString());

            User anton = StaticFactory.CreateUserByBirthYear(1983);

            Console.WriteLine(anton.ToString());
            anton.AddFirstName("anton");
            Console.WriteLine(anton.ToString());

            User ivan = StaticFactory.CreateDefaultUser().AddFirstName("ivan");

            Console.WriteLine(ivan.ToString());
        }
Example #15
0
        public CodeGenerator() {
            varTable = new Stack<Dictionary<string, ZOperand>>();
            typeTable = new Dictionary<string, Type>();
            typeStack = new Stack<TypeGen>();
            funcStack = new Stack<CodeGen>();

            name = "ZodiacConsole";
            var exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            if (exeDir == null) return;
            var exeFilePath = Path.Combine(exeDir, name + ".exe");
            Directory.CreateDirectory(exeDir);
            ag = new AssemblyGen(name, new CompilerOptions() { OutputPath = exeFilePath });
            st = ag.StaticFactory;
            exp = ag.ExpressionFactory;
            tm = ag.TypeMapper;
        }
        /// <summary>
        /// Creates a unique instance of the plugin type, with new
        /// instances of all native-code instances needed to access
        /// the entire hardware API.
        /// </summary>
        public ImplantJSInstance CreateInstance(JavascriptImplant parent)
        {
            var implant = ImplantFactory.Construct(parent);

            implant.osc      = OscFactory.Construct(parent);
            implant.pads     = PadFactory.Construct(parent);
            implant.knobs    = KnobFactory.Construct(parent);
            implant.keys     = KeysFactory.Construct(parent);
            implant.gui      = GuiFactory.Construct(parent);
            implant.time     = TimeFactory.Construct(parent);
            implant.settings = SettingsFactory.Construct(parent);
            implant.shared   = StaticFactory.Construct(parent);
            implant.session  = SessionFactory.Construct(parent);
            implant.mode     = ModesFactory.Construct(parent);

            return(implant);
        }
Example #17
0
 public MethodContext(MethodGenInfo method, ILGenerator il, ITypeMapper typeMapper)
 {
     if (il == null)
     {
         throw new ArgumentNullException(nameof(il));
     }
     if (typeMapper == null)
     {
         throw new ArgumentNullException(nameof(typeMapper));
     }
     _method           = method;
     _il               = il;
     TypeMapper        = typeMapper;
     ExpressionFactory = new ExpressionFactory(typeMapper);
     StaticFactory     = new StaticFactory(TypeMapper);
     SupportsScopes    = !method.IsDynamicGen;
     ParameterTypes    = method.Parameters.Select(p => p.Type).ToArray();
     IsParameterArray  = method.Parameters.LastOrDefault().IsParameterArray;
 }
Example #18
0
        public StaticPage GetPostByID(int id)
        {
            StaticResponse response = new StaticResponse();
            var            repo     = StaticFactory.CreateStaticPageRepository();
            var            page     = repo.GetPageByID(id);

            if (page != null)
            {
                response.Success    = true;
                response.Message    = "It worked!";
                response.StaticPage = page;
            }
            else
            {
                response.Success = false;
                response.Message = "Post not found!";
            }
            return(page);
        }
Example #19
0
        /// <summary>
        /// Creates new topic folder, it's subdir's and <SetModel.SelectedTopic>.rtf
        /// </summary>
        private void CreateTopic()
        {
            string newTopicName = _setView.InputNewTopicName.Text;

            SetModel.SelectedTopic = newTopicName; //Update selectedTopic to newly created

            //Prep folders for the new topic
            CreateTopicFolderStructure(SetModel.SelectedSet, newTopicName);

            string path = SaveTopic.Save(SetModel.SelectedSet, _setView.InputNewTopicName.Text); //Save file

            //TODO: Implement "Update videoListView.Items ON _setView.BtnNewOldTopicSave.Click
            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.Write(_setView.MainContent.Rtf);
            }
            _setView.TopicListbox.Items.Clear();
            _setModel = StaticFactory.GetSelectedSetModel(SetModel.SelectedSet);
        }
Example #20
0
 public SetViewPresenter(MainView mainView, SetView setView)
 {
     _setView  = setView;
     _mainView = mainView;
     _mainView.btnDel.Click                 += BtnDelDeleteTopic_Click;
     _setView.btnCode.Click                 += BtnCode_Click;
     _setView.btnBold.Click                 += BtnBold_Click;
     _setView.btnUnderline.Click            += BtnUnderline_Click;
     _setView.btnItalic.Click               += BtnItalic_Click;
     _setView.MainContent.SelectionChanged  += MainContent_SelectionChanged;
     _setView.MainContent.KeyDown           += MainContent_KeyDown;
     _setView.btnClear.Click                += BtnClear_Click;
     _setView.InputNewTopicName.TextChanged += InputNewTopicName_TextChanged;
     _setView.btnNewOldTopicSave.Click      += OnBtnNewOldTopicSave_Click;
     _setModel = StaticFactory.GetSelectedSetModel(SetModel.SelectedSet);
     _setView.TopicListbox.MouseClick   += TopicListbox_MouseClicked;
     _setView.btnAddVideos.MouseClick   += BtnAddVideos_MouseClick;
     _setView.TopicListbox.SelectedIndex = 0;
     PopulateTopicListbox();
 }
Example #21
0
        /// <summary>
        /// BtnBack click logic
        /// </summary>
        public void OnBtnBackClickEventRaised(object sender, EventArgs e)
        {
            if (_mainView.MainPanel.Controls[0].Name == "AddSetViewOuterPanel")
            {
                _addSetPresenter.Dispose();
                _mainView.MainPanel.Controls.Clear();
                SetListboxInit(); //Init new SetListbox

                _mainView.btnBack.Visible   = false;
                _mainView.btnAdd.Visible    = true;
                _mainView.btnDel.Visible    = true;
                _mainView.btnRename.Visible = true;
            }

            if (_mainView.MainPanel.Controls[0].Name == "SetViewMainPanel")
            {
                _setViewPresenter.Dispose();
                _mainView.MainPanel.Controls[0].Dispose();
                _mainView.MainPanel.Controls.Clear();
                SetListboxInit();

                _mainView.btnBack.Visible   = false;
                _mainView.btnAdd.Visible    = true;
                _mainView.btnDel.Visible    = true;
                _mainView.btnDel.Click     -= _setViewPresenter.BtnDelDeleteTopic_Click;
                _mainView.btnDel.Click     += OnBtnDelMainClickEventRaised;
                _mainView.btnRename.Visible = true;
            }

            if (_mainView.MainPanel.Controls[0].Name == "videoPanel")
            {
                _mainView.MainPanel.Controls[0].Dispose();
                _mainView.MainPanel.Controls.Clear();
                _setViewPresenter = StaticFactory.CreateSetViewPresenter(_mainView); //New SetViewPresenter on DCLICK
                _setViewPresenter.ShowSetView();
            }
        }
Example #22
0
        void Initialize(Universe universe, string assemblyName, AssemblyBuilderAccess access, CompilerOptions options, ITypeMapper typeMapper = null)
        {
            if (universe == null) throw new ArgumentNullException(nameof(universe));
            if (options == null) throw new ArgumentNullException(nameof(options));
            _compilerOptions = options;
            if (typeMapper == null)
#if FEAT_IKVM
                typeMapper = new TypeMapper(universe);
#else
                typeMapper = new TypeMapper();
#endif
            ExpressionFactory = new ExpressionFactory(typeMapper);
            StaticFactory = new StaticFactory(typeMapper);

#if SILVERLIGHT
            bool save = false;
#else
            bool save = (access & AssemblyBuilderAccess.Save) != 0;
#endif
            string path = options.OutputPath;
            if (path == null && save) throw new ArgumentNullException("options.OutputPath");

            Universe = universe;

            TypeMapper = typeMapper;
            _access = access;

            if (Helpers.IsNullOrEmpty(assemblyName))
            {
                if (save) throw new ArgumentNullException(nameof(assemblyName));
                assemblyName = Guid.NewGuid().ToString();
            }
            
            string moduleName = path == null ? assemblyName : assemblyName + Path.GetExtension(path);

            _fileName = path;

            AssemblyName an = new AssemblyName();
            an.Name = assemblyName;

            AssemblyBuilder =
#if !SILVERLIGHT
                path != null ? Universe.DefineDynamicAssembly(an, access, Path.GetDirectoryName(path)) :
#endif
                    Universe.DefineDynamicAssembly(an, access);
#if FEAT_IKVM
            if (!Helpers.IsNullOrEmpty(options.KeyFile))
            {
               AssemblyBuilder.__SetAssemblyKeyPair(new StrongNameKeyPair(File.OpenRead(options.KeyFile)));
            }
            else if (!Helpers.IsNullOrEmpty(options.KeyContainer))
            {
                AssemblyBuilder.__SetAssemblyKeyPair(new StrongNameKeyPair(options.KeyContainer));
            }
            else if (!Helpers.IsNullOrEmpty(options.PublicKey))
            {
                AssemblyBuilder.__SetAssemblyPublicKey(FromHex(options.PublicKey));
            }
            if (!Helpers.IsNullOrEmpty(options.ImageRuntimeVersion) && options.MetaDataVersion != 0)
            {
                AssemblyBuilder.__SetImageRuntimeVersion(options.ImageRuntimeVersion, options.MetaDataVersion);
            }
            ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, path, options.SymbolInfo);
#else
            if (save)
            {
#if !SILVERLIGHT
                ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName, Path.GetFileName(path));
#else
                throw new NotSupportedException("Can't save on this platform");
#endif
            }
            else
                ModuleBuilder = AssemblyBuilder.DefineDynamicModule(moduleName);
#endif
        }
Example #23
0
 /// <summary>
 /// Reinitialize SetListbox
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnAddSetViewSubmitClicked(object sender, EventArgs e)
 {
     _setModels = StaticFactory.CreateAllSets(); //Renew all set list
     SetListboxInit();
 }
Example #24
0
        public void InsertTagStaticBridgeTable(int tagId, int pageId)
        {
            var repo = StaticFactory.CreateStaticPageRepository();

            repo.InsertTagStaticBridgeTable(tagId, pageId);
        }
Example #25
0
        public StaticOBJ BulidEntity(OxyzPointF start, OxyzPointF end, EntityType et)
        {
            IStaticFactory IFacotry = new StaticFactory();

            return(IFacotry.Build(start, end, et));
        }
Example #26
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;

            // Si le fichier de config contient
            if (Configuration["DataSource"] == "factory")
            {
                // StaticFactory
                StaticFactory.UpdateBinavigabilite();
            }

            else if (Configuration["DataSource"] == "local")
            {
                using (var client = new WebzineDbContext())
                {
                    if (Configuration["ResetDb"] == "true")
                    {
                        client.Database.EnsureDeleted();
                        client.Database.EnsureCreated();

                        // Load data in database
                        LocalSeeder seeder = new LocalSeeder(client, StaticFactory.Styles, StaticFactory.Titres, StaticFactory.Artistes, StaticFactory.Commentaires, StaticFactory.LienStyles, StaticFactory.Pays);
                        seeder.LoadData();
                        client.SaveChanges();
                    }

                    else
                    {
                        client.Database.EnsureCreated();
                    }
                }
            }

            else if (Configuration["DataSource"] == "spotify")
            {
                // sqlite
                using (var client = new WebzineDbContext())
                {
                    client.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
                    if (Configuration["ResetDb"] == "true")
                    {
                        client.Database.EnsureDeleted();
                        client.Database.EnsureCreated();

                        SpotifySeeder spotify = new SpotifySeeder("1a3478c9f18842bc9fee8692aa574973", "943d3a231566443ba543d0e20a673d44");

                        var    playlist = spotify.GetPlaylist(Configuration["SpotifyPlaylistId"]);
                        Seeder seed     = spotify.SeedFromPlaylist(client, playlist);

                        client.SaveChanges();

                        var spotifyStyle    = client.Styles.FirstOrDefault();
                        List <LienStyle> ls = new List <LienStyle>();
                        client.Titres.ToList().ForEach(t => ls.Add(new LienStyle {
                            IdStyle = spotifyStyle.IdStyle, IdTitre = t.IdTitre
                        }));

                        ls.ForEach(l => client.LienStyles.Add(l));

                        client.SaveChanges();
                    }

                    else
                    {
                        client.Database.EnsureCreated();
                    }
                }
            }
            else
            {
                // erreur mise de factory par default
                StaticFactory.UpdateBinavigabilite();
            }
        }