Messages - joshuawood [ switch to compact view ]

Pages: prev1 2 [3] 4 5next
11
Still no luck. I understand what you're saying, it makes sense to have the results on the this Object, but I don't see why I should also need to populate SourceList. Anyways, whether I do or don't, it still doesn't work; again, this.Count returns the correct number of items, so it is populated correctly (I had a msgbox in there):

        public override int GetActionsCount(string KeyKeywords)
        {           
            string[] Files = Directory.GetFiles(m_TempPath);     // remove temp icon files       
            foreach (string FileName in Files)                       
                File.Delete(FileName);           

            SourceList.Clear();
            EnumTray.GetTrayData(out buttonData);       // populate tray data
            if (buttonData != null)
            {
                foreach (TrayIconData trayData in buttonData)   // fill SourceList
                {

                    if (trayData.button.fsState != 8)   // only add if button is not invisible
                        SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                    if (SourceList.Count > 10)
                        break;
                }
                this.ClearTemporaryItems();
                foreach (Actions.FARRTrayAction item in SourceList)     // Copy SourceList to thisList
                    this.Add(item);               
                return this.Count;
            }
            else return 0;           
        }

It seems the same as your code, except I do nothing with the search keywords as I don't need to (I think). I also need to reset the SL using SourceList.Clear()

12
Ok, still don't get why it doesn't work for me. Here is what I have:
    class FARRTrayList : ActionsList
    {
        private TrayIconData[] buttonData = null;
        static string m_TempPath = null;

        public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {
            m_TempPath = Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Temp");
            Directory.CreateDirectory(m_TempPath);

            //SourceList.Add(new Actions.FARRTrayAction(null, m_TempPath));
            //SourceList.Add(new Actions.FARRTrayAction(this.PluginBase));
        }

        public override int GetActionsCount(string KeyKeywords)
        {
            MessageBox.Show("In GAC, m_TempPath = " + m_TempPath);
            string[] Files = Directory.GetFiles(m_TempPath);
            MessageBox.Show(Files.Length.ToString());
            foreach (string FileName in Files)
            {
                MessageBox.Show("Deleting file: " + FileName.ToString());
                File.Delete(FileName);
            }

            EnumTray.GetTrayData(out buttonData);       // populate tray data

            if (buttonData != null)
            {
                foreach (TrayIconData trayData in buttonData)
                {
                    if (trayData.button.fsState != 8)
                    {    // only add if button is not invisible
                        MessageBox.Show("Found tray app: " + trayData.Text);
                        SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                    }
                    if (SourceList.Count > 10)
                        break;
                }
                MessageBox.Show("IN GAC, with data count: " + SourceList.Count);
                return SourceList.Count;
            }

            else
            {
                MessageBox.Show("IN GAC, with no data count");
                return 0;
            }
        }
    }

It appears to work ok, but something is still not quite right. The msgboxes get called correctly. Each time the msgbox will display each tray icon's name, and count them correctly (ie, they've been added to the SourceList). If I re-execute my plugin again after loading a new tray app, it is correctly enumerated, so it is now dynamic as desired. However, still no results show, even though it is getting the data correctly. It correctly deletes any existing icons.

Edit: I should mention that this section of code:
            EnumTray.GetTrayData(out buttonData);       // populate tray data

            if (buttonData != null)
            {
                foreach (TrayIconData trayData in buttonData)
                {
                    if (trayData.button.fsState != 8)
                    {    // only add if button is not invisible
                        MessageBox.Show("Found tray app: " + trayData.Text);
                        SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                    }
                    if (SourceList.Count > 10)
                        break;
                }
                MessageBox.Show("IN GAC, with data count: " + SourceList.Count);
                return SourceList.Count;
            }
without the msgboxes of course, does work as expect when placed in the constructor, except then it is not dynamic. The results will show however, unlike when in GAC. Hopefully I'm just missing something very simple.

13
That's what I think GetActionsCount does also - gets called everytime; but it doesn't appear to work for me. I will investigate further.

14
Thanks skajfes, you're right about the PathItem needing to be set. It also appears that it needs to be unique. I just it to the same fixed string for each result, and it would only display 1 result. Change it to a result unique string and it lists all results.

Could you please explain what GetActionsCount does more? Do I need to use it? I currently do nothing with it, and don't appear to need to.

Further, I'm trying to remove all files in a set folder when my plugin is called. I have this code in a few places, but it only appears to be called when FARR is first loaded (and hence the plugin). I would have thought having it in the ActionList constructor would mean it got called everytime to the plugin got called, but doesn't appear to do so:

static string m_TempPath = null;

        public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {
            m_TempPath = Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), "Temp");
            Directory.CreateDirectory(m_TempPath);
            string[] Files = Directory.GetFiles(m_TempPath);
            foreach (string FileName in Files)
            {
                File.Delete(FileName);
            }
           
            EnumTray.GetTrayData(out buttonData);       // populate tray data

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }
        }

Edit: On further testing, it appears that FARR creates an instance of this plugin at runtime only. So using the above code, it is only called once, and hence my results list is not dynamic. How do I make the results list update each time the plugin is executed by it's regex? Is that what I need to use GetActionsCount for?

Edit again: I'm not sure if the above edit comment is actually correct. In some strange cases my first plugin call will not pickup the FARR tray icon, but sometimes after a while it does. But not another program loaded after FARR has started. It's a bit strange.

What I want to do is call
EnumTray.GetTrayData(out buttonData);

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }
each time I execute the plugin by typing in it's regex.

15
Thanks for the help skajfes. I've got a better idea now after look at the iTunes code some more.

I seem to need to put my code in the constructor:

public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {            EnumTray.GetTrayData(out buttonData);       // populate tray data

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }
}

If I put it in GetActionsCount it doesn't work. That's ok though. However, on executing a result, it does nothing except hide FARR. I have a simple MessageBox.Show() string printed at the moment (in Execute()), but the MessageBox doesn't show?

Pages: prev1 2 [3] 4 5next
Go to full version