Esempio n. 1
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates a new AddSnippet Form and precompiles this form with the selected text
        /// </summary>
        /// <param name="pluginManager"></param>
        public static IManageSnippetForm PrepareAddNewSnippetForm(IPluginManager pluginManager)
        {
            if (pluginManager == null)
                return null;

            // Manage editor selection
            string selText = pluginManager.RetrieveSelectedText();

            // Open "Add Snippet" Window
            pluginManager.ClosePublishSnippetWindow();
            IManageSnippetForm addSnipForm = pluginManager.CreateAddSnippetForm();
            if (addSnipForm != null)
                addSnipForm.PrepareAddNewSnippet(selText);

            return addSnipForm;
        }
Esempio n. 2
0
        /////////////////////////////////////////////////////////////////////////////////

        #region Logout Actions
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Performs the logout action for the current user
        /// </summary>
        /// <param name="pluginManager"></param>
        /// <param name="user"></param>
        public static void LogoutUser(IPluginManager pluginManager, UserClient user)
        {
            System.Threading.Thread th = new System.Threading.Thread(
                new System.Threading.ThreadStart(delegate { DoLogout(user); })
                );
            th.Start();

            // change the buttons
            pluginManager.DisplayLoggedOutButtons();

            // clean up previous search contents (privacy concern)
            ISearchSnippetForm searchForm = pluginManager.FindWindow <ISearchSnippetForm>();

            if (searchForm != null)
            {
                searchForm.DisplayCleanForm();
            }

            // clean up previous publish info
            IPublishSnippetForm publishForm = pluginManager.FindWindow <IPublishSnippetForm>();

            if (publishForm != null)
            {
                publishForm.ResetResults();
            }

            // close publish window
            pluginManager.ClosePublishSnippetWindow();

            // close addSnippet Window
            pluginManager.CloseAddSnippetWindow();

            // cleanup previous login from login page
            ILoginForm loginForm = pluginManager.FindWindow <ILoginForm>();

            if (loginForm != null)
            {
                loginForm.ResetFields();
            }

            // show login page
            PrepareLoginForm(pluginManager);
        }
Esempio n. 3
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Creates a new AddSnippet Form and precompiles this form with the selected text
        /// </summary>
        /// <param name="pluginManager"></param>
        public static IManageSnippetForm PrepareAddNewSnippetForm(IPluginManager pluginManager)
        {
            if (pluginManager == null)
            {
                return(null);
            }

            // Manage editor selection
            string selText = pluginManager.RetrieveSelectedText();

            // Open "Add Snippet" Window
            pluginManager.ClosePublishSnippetWindow();
            IManageSnippetForm addSnipForm = pluginManager.CreateAddSnippetForm();

            if (addSnipForm != null)
            {
                addSnipForm.PrepareAddNewSnippet(selText);
            }

            return(addSnipForm);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new ViewSnippet Form and precompiles this form with the content of the given snippet
        /// </summary>
        /// <param name="pluginManager"></param>
        /// <param name="snippetId">ID of the snppet to display</param>
        public static IManageSnippetForm PrepareViewSnippetForm(IPluginManager pluginManager, long snippetId)
        {
            if (pluginManager == null)
            {
                return(null);
            }

            if (snippetId <= 0)
            {
                return(null);
            }

            // read snippets and populate the List
            SnippetsWS snippetRepo = new SnippetsWS();

            log.DebugFormat("Reading snippet {0}", snippetId);
            Snippet snip = snippetRepo.GetSnippetByID(snippetId);

            if (snip == null)
            {
                log.WarnFormat("Snippet {0} is null", snippetId);
                return(null);
            }

            //CG: Add +1 to the view stats
            System.Threading.Tasks.Task.Factory.StartNew(() => snippetRepo.StoreHit(snip));

            // Open "Add Snippet" Window
            log.DebugFormat("Loading snippet {0}", snippetId);
            pluginManager.ClosePublishSnippetWindow();

            IManageSnippetForm viewSnipForm = pluginManager.CreateViewSnippetForm();

            viewSnipForm.PrepareViewSnippet(snip);

            return(viewSnipForm);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new ViewSnippet Form and precompiles this form with the content of the given snippet
        /// </summary>
        /// <param name="pluginManager"></param>
        /// <param name="snippetId">ID of the snppet to display</param>
        public static IManageSnippetForm PrepareViewSnippetForm(IPluginManager pluginManager, long snippetId)
        {
            if (pluginManager == null)
                return null;

            if (snippetId <= 0)
                return null;

            // read snippets and populate the List
            SnippetsWS snippetRepo = new SnippetsWS();
            log.DebugFormat("Reading snippet {0}", snippetId);
            Snippet snip = snippetRepo.GetSnippetByID(snippetId);

            if (snip == null)
            {
                log.WarnFormat("Snippet {0} is null", snippetId);
                return null;
            }

            //CG: Add +1 to the view stats
            System.Threading.Tasks.Task.Factory.StartNew(() => snippetRepo.StoreHit(snip));

            // Open "Add Snippet" Window
            log.DebugFormat("Loading snippet {0}", snippetId);
            pluginManager.ClosePublishSnippetWindow();

            IManageSnippetForm viewSnipForm = pluginManager.CreateViewSnippetForm();
            viewSnipForm.PrepareViewSnippet(snip);

            return viewSnipForm;
        }
Esempio n. 6
0
        /////////////////////////////////////////////////////////////////////////////////

        #region Logout Actions
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Performs the logout action for the current user
        /// </summary>
        /// <param name="pluginManager"></param>
        /// <param name="user"></param>
        public static void LogoutUser(IPluginManager pluginManager, UserClient user)
        {
            System.Threading.Thread th = new System.Threading.Thread(
                new System.Threading.ThreadStart(delegate { DoLogout(user); })
            );
            th.Start();

            // change the buttons 
            pluginManager.DisplayLoggedOutButtons();

            // clean up previous search contents (privacy concern)
            ISearchSnippetForm searchForm = pluginManager.FindWindow<ISearchSnippetForm>();
            if (searchForm != null)
                searchForm.DisplayCleanForm();

            // clean up previous publish info
            IPublishSnippetForm publishForm = pluginManager.FindWindow<IPublishSnippetForm>();
            if (publishForm != null)
                publishForm.ResetResults();

            // close publish window
            pluginManager.ClosePublishSnippetWindow();

            // close addSnippet Window
            pluginManager.CloseAddSnippetWindow();

            // cleanup previous login from login page
            ILoginForm loginForm = pluginManager.FindWindow<ILoginForm>();
            if (loginForm != null)
                loginForm.ResetFields();

            // show login page 
            PrepareLoginForm(pluginManager);
        }
Esempio n. 7
0
        /////////////////////////////////////////////////////////////////////////////////

        #region About Form
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Closes the obsolete forms when the server is changed in the About form
        /// </summary>
        /// <param name="pluginManager"></param>
        public static void CloseObsoleteFormsFromAbout(IPluginManager pluginManager)
        {
            SearchPageCleanup(pluginManager);
            pluginManager.ClosePublishSnippetWindow();
            pluginManager.CloseAddSnippetWindow();
        }
Esempio n. 8
0
        /////////////////////////////////////////////////////////////////////////////////

        #region About Form
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Closes the obsolete forms when the server is changed in the About form
        /// </summary>
        /// <param name="pluginManager"></param>
        public static void CloseObsoleteFormsFromAbout(IPluginManager pluginManager)
        {
            SearchPageCleanup(pluginManager);
            pluginManager.ClosePublishSnippetWindow();
            pluginManager.CloseAddSnippetWindow();
        }