Page 1 of 2

View Manager v1.5 (08-10-08) [MM3]

Posted: Tue Aug 26, 2008 2:59 am
by MoDementia
No Longer Available

Re: View Manager v1.2 (26-08-08) [MM3]

Posted: Wed Aug 27, 2008 9:17 am
by Deadman36g
Is it possible you could add a way to select None (Show all tracks) from the button as well (So i don't have to go through the options each time).

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Wed Aug 27, 2008 4:33 pm
by MoDementia
New Version

' 26-08-08 Version 1.3
' Added None (Show All Tracks)

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Wed Aug 27, 2008 5:04 pm
by nynaevelan
What are the numbers in the parentheses??

Nyn

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Wed Aug 27, 2008 5:26 pm
by MoDementia
Filter IDs (Too lazy to store it somewhere else) :P

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Wed Aug 27, 2008 6:17 pm
by nynaevelan
Thank you, that helps. :D

Nyn

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Wed Aug 27, 2008 7:14 pm
by Deadman36g
MoDementia wrote:New Version

' 26-08-08 Version 1.3
' Added None (Show All Tracks)
Thank you :)

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 5:37 am
by nynaevelan
Is there a way to refresh the filter list without having to restart MM??

Nyn

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 6:35 am
by MoDementia
Not without consequences.
There is no trigger for when filters are added or deleted.
The table would have to be interrogated every 30secs-1min to see if it had changed or on every play/selection which would be a waste of processing time given how rarely these are added / deleted.

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 7:35 am
by nynaevelan
Ok, I can live with a refresh when I remember to open/close MM. I do not want performance degraded because as you stated the filters are not changed that often, at least not in my db. Although now that I have a much better source to manage them, I am tempted to create some more.

Nyn

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 1:45 pm
by Bex
I like this script! :D
MoDementia wrote:Not without consequences.
There is no trigger for when filters are added or deleted.
The table would have to be interrogated every 30secs-1min to see if it had changed or on every play/selection which would be a waste of processing time given how rarely these are added / deleted.
Actually, I think you can solve this by using the OnClickFunc on the Filters-menu, like this:

Code: Select all

  Set FilterMnu = SDB.UI.AddMenuItemSub(SubMnu,1,-1)
  FilterMnu.Caption = "Filters"
  FilterMnu.UseScript = Script.ScriptPath
  FilterMnu.OnClickFunc = "CreateFilterMenus"
And then create a sub which creates the menus:

Code: Select all

Sub CreateFilterMenus(OnMnu)
  Set iter = SDB.Database.OpenSQL("SELECT ID, Name FROM Filters ORDER BY Name")
  Do While NOT iter.EOF
    Set Mnu = SDB.UI.AddMenuItem(OnMnu,2,-1)
    Mnu.Caption = iter.StringByIndex(1) & " (" & iter.StringByIndex(0) & ")"
    Mnu.UseScript = Script.ScriptPath
    Mnu.IconIndex = SDB.RegisterIcon("Scripts\View Manager\Icons\table_refresh.ico",0)
    Script.RegisterEvent Mnu, "OnClick", "btnClickFilter"
  iter.Next
  Loop
  Set iter = Nothing
End sub
But it doesn't work correctly. You need to find a way to remove the old menus, you'll understand what I mean when you test it.

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 5:27 pm
by MoDementia
Thanks Bex,

I refresh the saved views by creating individual SDB.Objects for them and calling DestroyMenus before adding the menus. It would work for the code you suggested too.
However, I think that having to click "Filters" each time to get the sub menus and waiting for them to be rebuilt would be more annoying than restarting MM once in a while?

Code: Select all

    Sub CreateFilterMenus(OnMnu)
      Call DestroyFilterMenus
      Set StringList = SDB.NewStringList
      Set iter = SDB.Database.OpenSQL("SELECT ID, Name FROM Filters ORDER BY Name")
      Do While NOT iter.EOF
        Set Mnu = SDB.UI.AddMenuItem(OnMnu,2,-1)
        Mnu.Caption = iter.StringByIndex(1) & " (" & iter.StringByIndex(0) & ")"
        Mnu.UseScript = Script.ScriptPath
        Mnu.IconIndex = SDB.RegisterIcon("Scripts\View Manager\Icons\table_refresh.ico",0)
        Script.RegisterEvent Mnu, "OnClick", "btnClickFilter"
        Set SDB.Objects("Filter" & iter.StringByIndex(0)) = Mnu
        StringList.Add "Filter" & iter.StringByIndex(0)
      iter.Next
      Loop
      Set iter = Nothing
      Set SDB.Objects("VMFilterList") = StringList
    End sub

Sub DestroyFilterMenus
  Set StringList = SDB.Objects("VMFilterList")
  If NOT StringList Is Nothing Then
    For xCounter = 0 to StringList.Count - 1
      ThisObjectText = StringList.Item(xCounter)
      Set Mnu = SDB.Objects(ThisObjectText)
      Mnu.Checked = False
      Mnu.Visible = False
      Script.UnRegisterEvents Mnu
      Set Mnu = Nothing
      Set SDB.Objects(ThisObjectText) = Nothing
    Next
  End If
End Sub

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 6:10 pm
by Bex
Yes, it takes annoyingly long time to create the menus but you could add a simple check and only recreate them if some have been added/deleted.

Add this to the OnStartup Sub:

Code: Select all

SDB.IniFile.IntValue("ViewManager","FilterCount")=SDB.Database.OpenSQL("SELECT Count(*) FROM Filters").valuebyindex(0)
And here's the new CreateFilterMenus sub:

Code: Select all

Sub CreateFilterMenus(OnMnu)
   FilterCount=SDB.Database.OpenSQL("SELECT Count(*) FROM Filters").valuebyindex(0)
   If Not SDB.IniFile.IntValue("ViewManager","FilterCount")=FilterCount Then Exit Sub
   Call DestroyFilterMenus
   Set StringList = SDB.NewStringList
   Set iter = SDB.Database.OpenSQL("SELECT ID, Name FROM Filters ORDER BY Name")
   Do While NOT iter.EOF
     Set Mnu = SDB.UI.AddMenuItem(OnMnu,2,-1)
     Mnu.Caption = iter.StringByIndex(1) & " (" & iter.StringByIndex(0) & ")"
     Mnu.UseScript = Script.ScriptPath
     Mnu.IconIndex = SDB.RegisterIcon("Scripts\View Manager\Icons\table_refresh.ico",0)
     Script.RegisterEvent Mnu, "OnClick", "btnClickFilter"
     Set SDB.Objects("Filter" & iter.StringByIndex(0)) = Mnu
     StringList.Add "Filter" & iter.StringByIndex(0)
   iter.Next
   Loop
   Set iter = Nothing
   Set SDB.Objects("VMFilterList") = StringList
   SDB.IniFile.IntValue("ViewManager","FilterCount")=FilterCount
End sub
You also need to add the create menu statement to the OnStartup sub.

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 6:16 pm
by Bex
I just tested it and it needs some more work but I'm sure you get the picture and sort it out! :D

Re: View Manager v1.3 (28-08-08) [MM3]

Posted: Thu Aug 28, 2008 6:18 pm
by MoDementia
Hehehe I also thought about that , it doesn't work if you add and delete the same amount of filters i.e. you add 1 and delete 1 :(

I will try and do another version with an option to use either method.