Ejemplo n.º 1
0
        private static IAction CreateAction(
            string actionID,
            string path,
            WebBrowserComponent webBrowser)
        {
            string url      = ExtractUrlFromFavourite(path);
            string menuPath = CreateMenuPath(path);

            // Create the menu action
            ActionPath actionPath = new ActionPath(menuPath, null);
            MenuAction action     = new MenuAction(actionID, actionPath, ClickActionFlags.None, null);

            action.Label = actionPath.LastSegment.LocalizedText;

            // Set what we're supposed to do when the menu item is clicked
            action.SetClickHandler(
                delegate
            {
                // Navigate to the URL
                webBrowser.Url = url;
                webBrowser.Go();
            });

            return(action);
        }
Ejemplo n.º 2
0
        public static ActionSet Build(WebBrowserComponent webBrowser)
        {
            List <IAction> actions = new List <IAction>();

            string favouritesFolder = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            string[] favourites = Directory.GetFiles(favouritesFolder, "*.*", SearchOption.AllDirectories);

            // The action ID is arbitrary--it's just an identifier--as long as all the
            // action IDs of all the actions in a given ActionModel are unqiue.
            // So, we'll just generate a new action ID for each action here
            // simply by incrementing an integer.
            int actionID = 0;

            foreach (string favouritePath in favourites)
            {
                IAction action = CreateAction(
                    actionID.ToString(),
                    favouritePath,
                    webBrowser);

                actions.Add(action);
                actionID++;
            }

            return(new ActionSet(actions));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called by the framework when the user clicks the "apply" menu item or toolbar button.
        /// </summary>
        public void Apply()
        {
            // TODO
            // Add code here to implement the functionality of the tool
            // If this tool is associated with a workspace, you can access the workspace
            // using the Workspace property

            WebBrowserComponent component = new WebBrowserComponent();

            ApplicationComponent.LaunchAsWorkspace(this.Context.DesktopWindow, component, SR.WorkspaceName);
        }
Ejemplo n.º 4
0
 public WebBrowserToolContext(WebBrowserComponent component)
 {
     Platform.CheckForNullReference(component, "component");
     _component = component;
 }