Multiple menu items != multiple event handlers?

I'm developing a program whereby a user can rate how much they like certain images when displayed on screen. The bulk of the work is done, but my rating mechanism (first attempt at one) is currently a right-click pop-up menu with the values 1-10 in ten menu items - naff I know, but its early design stages ;)
This brings obvious problems, and I don't want to have to code event handlers for each and every Menu item just to set the same parameter to a different value depending on which menu item the user clicked (i.e. I don't want to have to create an event for the first menu item that simply sets and int variable to 1, and do the same for #2 through 10). What I was wondering was, is there any simpler way of implementing this? I.e. can I use the same event for the whole popup menu and detect the value of the option clicked and set the value accordingly? This would also mean, should I need to extend the rating scale above ten, say perhaps to twenty, then there would be no further coding necessary (which is nice! Lol!).
Can anyone offer any suggestions? I did search, but tbh didn't have a clue what to search for. Your advice is appreciated.

Implement the ActionListner that allows the constructor to take an argument as to the rating of the menu item, and then set the required rating variable to this when called. For example
class MyRatingSystem
    int rating = 0;
    public void createMenus()
        JMenu ratings = new JMenu("Ratings");
        for(int i = 0; i < 10; i++)
            JMenuItem rating = new JMenuItem("Vote: " + i);
            rating.addActionListener(new RatingListener(i));
            ratings.add(rating);
    class RatingListener imlpements ActionListener{
        final int rate;
        public RatingListener(int rate)
            this.rate = rate;
        public void actionPerformed(ActionEvent ae)
            rating = this.rate;
}The above code is inefficient and is only there to serve the purpose of an example(look at the loop, although I would think the compiler could do some loop unrolling?)
HTH

Similar Messages

  • Multiple event handlers registered for the same event and error when adding users to sec groups

    Project Server 2013 CU April (May) 2014
    I've created and installed two event handlers (separate dll:s) and both are triggering on Project Published - initially, both are working fine.
    After an IISReset, trying to create a new security group (or add a user to an existing group) will result in an error on the page and a corresponding error in the ULS log - the latter indicating an error in the method security.creategroups, and specifically
    a problem 'An item with the same key has already been added.'
    An SQL trace reveals a break in execution after executing the proc 'pub.MSP_ADMIN_ReadEventReceivers' which returns all registered event handlers.
    In my case, the result of that proc execution shows that there are two event handlers registered with an EVENT_ID of 53 (Project Published) and with ORDER_FIRED set to 1 and 2 respectively.
    I tried removing one of the event receivers using the Central Admin PWA interface and then everything worked just fine - I added the event receiver back again, and everything STILL worked! IISReset and I got the error back again. :-(
    Since there's obviously some problem with reading multiple entries from that table regardless of the ORDER_FIRED differentiation, I tried temporarily modifying one of the '53' entries in the table directly and then the sec group was created just fine!
    I would like to know if anyone else has seen this? I've seen this on three separate installations now after deploying a second event listener onto those systems.
    /Lars Hammarberg
    //Lars Hammarberg www.connecta.se

    Hi Lars,
    yes I have seen the same issue. It is not related to April CU. I had the error before with SP1.
    It is not only an issue with the security groups. At least in our case nothing worked at all. No custom field editing, all Queue Jobs failing.
    For your case I suggest you consolidate your code in one eventhandler.
    Theory says that you can have more than 1 (up to 999) eventhandlers for one Event (http://msdn.microsoft.com/en-us/library/ms481079(v=office.12).aspx) but that seems not to
    work. Not sure, if it worked in earlier versions.
    Kind regards
    Christoph
    Christoph Muelder | Senior Consultant, MCTS, MCSE, MCT | SOLVIN information management GmbH, Germany

  • Multiple event handlers for one button

    I'm trying to create a button with 2 event handlers, such
    that when you roll-over the button, a submenu pops up, and when you
    click the button, you go to a certain frame. I feel like this
    shouldn't be hard at all, but it's not working. Below is the
    actionscript I have tried. Both event handlers work as I want them
    to if alone, but the on(release) functionality does not work when I
    try to put them together.(I have Flash 8). Thanks for your help!
    on (release) {
    _root.gotoAndStop("one1");
    tellTarget (_root.navigation) {
    gotoAndStop (1);
    on (rollOver) {
    this.gotoAndPlay("links");
    tellTarget (_root.navigation.introduction) {
    gotoAndStop (1);
    tellTarget (_root.navigation.overview) {
    gotoAndStop (16);
    tellTarget (_root.navigation.coronary) {
    gotoAndStop (1);

    this code is ok, it seems that when u rollover on the button,
    the event is fired and it keeps on running the time u r on it. i
    think just add
    delete this.onRollOver inside rollOver event.

  • Multiple Listeners - Multiple Event Handlers

    According to the tutorial, event handling code executes in a single event dispatching thread to ensure that each event handler finishes execution before the next executes. I'm also aware that I can add multiple action listeners to a single component, like JButton. But if I add mutliple listeners to a component, is there any way to determine in what order the event handling code will execute? Is there an order to which the listeners listen..
    Thanks in advance.

    Thanks to both of you for your responses and suggestions.
    camickr...
    I don't think its good style to add multiple listeners
    and write code dependent on the order of execution.I appreciate your candor here and I'm inclined to agree. So I've reorganized things a bit and I don't need to have the listeners in any particular order. But thank you for taking a look at the source code. It didn't occur to me to do that. That is interesting.
    Deudeu..
    If you require a specific sequential order you should create cascading eventsThis would be a way to resolve the issue of sequential response. When I changed my design a bit however, I didn't need to perform anything sequentially.

  • Can I programmatically trigger a menu item tag selected event?

    I am trying to trigger a menu item selected event using built-in vi's. I want my Handle Menu vi to handle the case where the user checks on a boolean control as well as slected the menu option. I don't want to use POSTMESSAGE with acceleration key combination. Are there any built-in vi's which can "post" such a message?

    I have a similar situation and understand why adding a message to the menu queue would be an elegant solution to the problem.
    I have lots of menu bar selections in my program, and I would like to set up a button bar like most applications now have. To do this using the "in parallel" way becomes a ratsnets of wires and would take up a lot of window space.
    I have attached a file that is a good example of how to solve this problem with Event Structures in LabVIEW 6.1. It doesn't take up much additional diagram space and it can be quickly and easily reconfigured.
    It would be nice if future versions of LabVIEW had a more integrated button bar.
    Matt
    Attachments:
    Menu_and_button_bars.vi ‏68 KB

  • Parallel event handlers disabling events while handling

    Hi, I have an application where there are multiple event handlers in multiple while loops that are driven from the same front panel.  The front panel controls are designed to provide diferent motion control moves for different axes under control.  All events that trigger these moves are fired by the same event handler for the same axes of motion. Hence, for safety reasons, I do not want some of these controls to be executable while certain other move profiles are executing. Sounds simple to implement right?
    When I use traditional prop nodes like disable to disable the front panel controls, the event queue still acquires the event and then subsequently executes it.   I want to be able to clear this event queue so that no other events from a certain group of my front panel controls can be executed simultaneousy.  However, I do not want to disable all front panel controls since I have other buttons that are capable of controlling other indepenedent things and safety functions like stopping.
    It is like I need a disable events property or soemthing that can be done programmatically. Can someone please advise me on what makes sense to do here?
    Attachments:
    evntdisable.vi ‏119 KB

    There is no way to interact directly with the event queue that LV maintains. If you need to do that you need to utilize the queue functions that LV provides and create your own event queue. However, if all you need is prevent interactions while an event in being processed, value change events have a setting that is (set by default) called: Lock Panel Until Handler Completes. And for other kinds of events, there's an option in the event structure's event-definition dialog box that perhorms the same action.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Some Doubts about Event Handlers

    Hi,
    I had some doubts on Event handlers in OIM 11.1.1.5 ........
    1) I want to use the same event handler for both Post Insert and Post update task.... Can I use the same event handler for that... If yes then how can I do that....
    2) Can I create the single Plugin.xml class and add the all jar files in single say lib folder and zip them all together.. if yes then What changes I need to do?? Need to add only the plugin tags for different class files in plugin.xml file? OR need to do some thing extra also...?
    3) If i need to change any thing in any class of event handler.. Is there need to unregister the plugin and again register...??
    If yes.... Is there need to delete the event handler using the weblogicDeleteMetadata command???
    4) As we Import the event handler from path like event handler/db/... If we add all the evetn handler.xml files in that folder..... As During Import weblogicImportMetadata recursively call all the files in that folder.... Now if i need to change anything in any one of event handler class... then if we import from the same folder event handler/db/... What will it do............Create the duplicate copy of all the eventhandlers????? OR i need to add only those Eventhandler.xml files for those class files i made the changes.....
    5) As I need to create email on user creation during recon and also email id get updated as first name or last name updates..... What I had to use in Event handler.xml (entity-type="User" operation="CREATE") or Some thing else....
    Help me clarify my doubts...

    Anil Bansal wrote:
    Hi,
    I had some doubts on Event handlers in OIM 11.1.1.5 ........
    1) I want to use the same event handler for both Post Insert and Post update task.... Can I use the same event handler for that... If yes then how can I do that....Yes, you can have the same. Just have two event handlers in the same MDS file and the operation should be CREATE for one while MODIFY for another. The class and version and name remains the same.
    2) Can I create the single Plugin.xml class and add the all jar files in single say lib folder and zip them all together.. if yes then What changes I need to do?? Need to add only the plugin tags for different class files in plugin.xml file? OR need to do some thing extra also...?Yes, in the single plugin xml you can define multiple eventhandlers and the jar will contain multiple event handlers class.
    3) If i need to change any thing in any class of event handler.. Is there need to unregister the plugin and again register...??
    If yes.... Is there need to delete the event handler using the weblogicDeleteMetadata command???No, if you are just changing the class, then you need to update the class only in the plugin. For this, first delete plugin and then update plugin and then purgecache.
    4) As we Import the event handler from path like event handler/db/... If we add all the evetn handler.xml files in that folder..... As During Import weblogicImportMetadata recursively call all the files in that folder.... Now if i need to change anything in any one of event handler class... then if we import from the same folder event handler/db/... What will it do............Create the duplicate copy of all the eventhandlers????? OR i need to add only those Eventhandler.xml files for those class files i made the changes.....If won't create duplicate copies but would overwrite the ones which are there in MDS at the same location. So effectively, if the xml is not changing you should not be worried about overwritting.
    5) As I need to create email on user creation during recon and also email id get updated as first name or last name updates..... What I had to use in Event handler.xml (entity-type="User" operation="CREATE") or Some thing else....For recon and event handler, you will need to have post process event handler on User CREATE and UPDATE. On Create construct the email address and populate it in the email field. For update check if the firstname/lastname are changing and if yes, then update the email id on the profile.
    >
    Help me clarify my doubts...

  • Menu item appears multiple items

    I've created a menu item for the extension I'm working on; however, it is showing up 4 times in the Tools menu instead of just once. I've looked at various tutorials on the subject,but I can't seem to find what I've done incorrectly.
    VSCT File
    <?xml version="1.0" encoding="utf-8"?>
    <CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <Extern href="stdidcmd.h"/>
    <Extern href="vsshlids.h"/>
    <Commands package="guidTemplatePackPkg">
    <Groups>
    <Group guid="guidTemplatePackCmdSet" id="MyMenuGroup" priority="0x0600">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
    </Group>
    </Groups>
    <Buttons>
    <Button guid="guidTemplatePackCmdSet" id="cmdidMyCommand" priority="0x2000" type="Button">
    <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_REFERENCES" />
    <CommandFlag>DynamicVisibility</CommandFlag>
    <CommandFlag>DefaultInvisible</CommandFlag>
    <Strings>
    <CommandName>AddSideWaffleProject</CommandName>
    <ButtonText>Add Template Reference (SideWaffle project)</ButtonText>
    </Strings>
    </Button>
    </Buttons>
    </Commands>
    <!-- SideWaffle Menu Options -->
    <Commands package="guidMenuOptionsPkg">
    <Groups>
    <Group guid="guidMenuOptionsCmdSet" id="SWMenuGroup" priority="0x0600">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
    </Group>
    </Groups>
    <Buttons>
    <Button guid="guidMenuOptionsCmdSet" id="cmdidOpenSWMenu" priority="0x0100" type="Button">
    <Parent guid="guidMenuOptionsCmdSet" id="SWMenuGroup" />
    <Icon guid="guidImages" id="bmpPic1" />
    <Strings>
    <ButtonText>SideWaffle Settings</ButtonText>
    </Strings>
    </Button>
    </Buttons>
    <Bitmaps>
    <Bitmap guid="guidImages" href="Resources\Images.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
    </Bitmaps>
    </Commands>
    <!-- End SideWaffle Menu Options -->
    <Symbols>
    <GuidSymbol name="guidTemplatePackPkg" value="{e6e2a48e-387d-4af2-9072-86a5276da6d4}" />
    <GuidSymbol name="guidTemplatePackCmdSet" value="{a94bef1a-053e-4066-a851-16e5f6c915f1}">
    <IDSymbol name="MyMenuGroup" value="0x1020" />
    <IDSymbol name="cmdidMyCommand" value="0x0100" />
    </GuidSymbol>
    <!-- SideWaffle Menu Options -->
    <GuidSymbol name="guidMenuOptionsPkg" value="{796B8CBC-3010-4A76-872B-56775129765F}" />
    <GuidSymbol name="guidMenuOptionsCmdSet" value="{13EE92AE-B8B5-4728-8AF6-F53D8DD9C391}">
    <IDSymbol name="SWMenuGroup" value="0x1020" />
    <IDSymbol name="cmdidOpenSWMenu" value="0x0100" />
    </GuidSymbol>
    <GuidSymbol name="guidImages" value="{900524C9-8677-4F84-AF97-3A1B5B45E3B2}" >
    <IDSymbol name="bmpPic1" value="1" />
    <IDSymbol name="bmpPic2" value="2" />
    <IDSymbol name="bmpPicSearch" value="3" />
    <IDSymbol name="bmpPicX" value="4" />
    <IDSymbol name="bmpPicArrows" value="5" />
    <IDSymbol name="bmpPicStrikethrough" value="6" />
    </GuidSymbol>
    <!-- End SideWaffle Menu Options -->
    </Symbols>
    </CommandTable>
    TemplatePackage.cs
    using EnvDTE;
    using EnvDTE80;
    using Microsoft.VisualStudio.Shell;
    using Microsoft.VisualStudio.Shell.Interop;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.Design;
    using System.Linq;
    using System.Runtime.InteropServices;
    using TemplatePack.Tooling;
    namespace TemplatePack
    [PackageRegistration(UseManagedResourcesOnly = true)]
    [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
    [ProvideMenuResource("Menus.ctmenu", 1)]
    [Guid(GuidList.guidTemplatePackPkgString)]
    [ProvideAutoLoad(UIContextGuids80.SolutionExists)]
    public sealed class TemplatePackPackage : Package
    private DTE2 _dte;
    protected override void Initialize()
    base.Initialize();
    _dte = GetService(typeof(DTE)) as DTE2;
    OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
    if (null != mcs)
    CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
    OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId);
    button.BeforeQueryStatus += button_BeforeQueryStatus;
    mcs.AddCommand(button);
    /*if(Environment.GetEnvironmentVariable("SideWaffleEnableDynamicTemplates") != null)*/{
    try {
    new DynamicTemplateBuilder().ProcessTemplates();
    catch (Exception ex) {
    // todo: replace with logging or something
    System.Windows.MessageBox.Show(ex.ToString());
    void button_BeforeQueryStatus(object sender, EventArgs e)
    var button = (OleMenuCommand)sender;
    var project = GetSelectedProjects().ElementAt(0);
    // TODO: We should only show this if the target project has the TemplateBuilder NuGet pkg installed
    // or something similar to that.
    button.Visible = true;
    // button.Visible = project.IsWebProject();
    private void ButtonClicked(object sender, EventArgs e)
    Project currentProject = GetSelectedProjects().ElementAt(0);
    var projects = _dte.Solution.GetAllProjects();
    var names = from p in projects
    where p != currentProject
    select p.Name;
    ProjectSelector selector = new ProjectSelector(names);
    bool? isSelected = selector.ShowDialog();
    if (isSelected.HasValue && isSelected.Value)
    // need to save everything because we will directly write to the project file in the creator
    _dte.ExecuteCommand("File.SaveAll");
    TemplateReferenceCreator creator = new TemplateReferenceCreator();
    var selectedProject = projects.First(p => p.Name == selector.SelectedProjectName);
    creator.AddTemplateReference(currentProject, selectedProject);
    public IEnumerable<Project> GetSelectedProjects()
    var items = (Array)_dte.ToolWindows.SolutionExplorer.SelectedItems;
    foreach (UIHierarchyItem selItem in items)
    var item = selItem.Object as Project;
    if (item != null)
    yield return item;
    [PackageRegistration(UseManagedResourcesOnly = true)]
    [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
    [ProvideMenuResource("Menus.ctmenu", 1)]
    [Guid(GuidList.guidMenuOptionsPkgString)]
    [ProvideAutoLoad(UIContextGuids80.SolutionExists)]
    public sealed class MenuOptionsPackage : Package
    // Overridden Package Implementation
    #region Package Members
    protected override void Initialize()
    base.Initialize();
    // Add our command handlers for menu (commands must exist in the .vsct file)
    OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
    if ( null != mcs )
    // Create the command for the menu item.
    CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.SWMenuGroup);
    OleMenuCommand menuItem = new OleMenuCommand(MenuItemCallback, menuCommandID );
    mcs.AddCommand( menuItem );
    #endregion
    private void MenuItemCallback(object sender, EventArgs e)
    // Here is where our UI (i.e. user control) will go to do all the settings.
    var window = new SettingsForm();
    window.Show();
    PackageConstants.cs
    // PkgCmdID.cs
    // MUST match PkgCmdID.h
    using System;
    namespace TemplatePack
    static class GuidList
    public const string guidTemplatePackPkgString = "e6e2a48e-387d-4af2-9072-86a5276da6d4";
    public const string guidTemplatePackCmdSetString = "a94bef1a-053e-4066-a851-16e5f6c915f1";
    public static readonly Guid guidTemplatePackCmdSet = new Guid(guidTemplatePackCmdSetString);
    // SideWaffle Remote Source Settings
    public const string guidMenuOptionsPkgString = "796B8CBC-3010-4A76-872B-56775129765F";
    public const string guidMenuOptionsCmdSetString = "13EE92AE-B8B5-4728-8AF6-F53D8DD9C391";
    public static readonly Guid guidMenuOptionsCmdSet = new Guid(guidMenuOptionsCmdSetString);
    static class PkgCmdIDList
    public const uint cmdidMyCommand = 0x100;
    public const uint SWMenuGroup = 0x100;
    I just can't seem to figure out what I might be doing wrong. Any suggestions?

    Already ahead of you on that one. Here's where I'm at
    VSCT File
    <?xml version="1.0" encoding="utf-8"?>
    <CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <Extern href="stdidcmd.h"/>
    <Extern href="vsshlids.h"/>
    <Commands package="guidTemplatePackPkg">
    <Groups>
    <Group guid="guidTemplatePackCmdSet" id="MyMenuGroup" priority="0x0600">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
    </Group>
    <Group guid="guidMenuOptionsCmdSet" id="SWMenuGroup" priority="0x0500">
    <Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
    </Group>
    </Groups>
    <Buttons>
    <Button guid="guidMenuOptionsCmdSet" id="cmdiSWCommand" priority="0x1000" type="Button">
    <Parent guid="guidMenuOptionsCmdSet" id="SWMenuGroup" />
    <Icon guid="guidImages" id="bmpPic1" />
    <Strings>
    <CommandName>cmdidSWCommand</CommandName>
    <ButtonText>SideWaffle Settings</ButtonText>
    </Strings>
    </Button>
    <Button guid="guidTemplatePackCmdSet" id="cmdidMyCommand" priority="0x2000" type="Button">
    <Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_REFERENCES" />
    <CommandFlag>DynamicVisibility</CommandFlag>
    <CommandFlag>DefaultInvisible</CommandFlag>
    <Strings>
    <CommandName>AddSideWaffleProject</CommandName>
    <ButtonText>Add Template Reference (SideWaffle project)</ButtonText>
    </Strings>
    </Button>
    </Buttons>
    <Bitmaps>
    <Bitmap guid="guidImages" href="Resources\Images.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows"/>
    </Bitmaps>
    </Commands>
    <Symbols>
    <GuidSymbol name="guidTemplatePackPkg" value="{e6e2a48e-387d-4af2-9072-86a5276da6d4}" />
    <GuidSymbol name="guidTemplatePackCmdSet" value="{a94bef1a-053e-4066-a851-16e5f6c915f1}">
    <IDSymbol name="MyMenuGroup" value="0x1020" />
    <IDSymbol name="cmdidMyCommand" value="0x0100" />
    </GuidSymbol>
    <GuidSymbol name="guidMenuOptionsCmdSet" value="{13EE92AE-B8B5-4728-8AF6-F53D8DD9C391}">
    <IDSymbol name="SWMenuGroup" value="0x1010" />
    <IDSymbol name="cmdidSWCommand" value="0x0090" />
    </GuidSymbol>
    <GuidSymbol name="guidImages" value="{900524C9-8677-4F84-AF97-3A1B5B45E3B2}" >
    <IDSymbol name="bmpPic1" value="1" />
    <IDSymbol name="bmpPic2" value="2" />
    <IDSymbol name="bmpPicSearch" value="3" />
    <IDSymbol name="bmpPicX" value="4" />
    <IDSymbol name="bmpPicArrows" value="5" />
    <IDSymbol name="bmpPicStrikethrough" value="6" />
    </GuidSymbol>
    </Symbols>
    </CommandTable>
    PackageConstants.cs
    // PkgCmdID.cs
    // MUST match PkgCmdID.h
    using System;
    namespace TemplatePack
    static class GuidList
    public const string guidTemplatePackPkgString = "e6e2a48e-387d-4af2-9072-86a5276da6d4";
    public const string guidTemplatePackCmdSetString = "a94bef1a-053e-4066-a851-16e5f6c915f1";
    public static readonly Guid guidTemplatePackCmdSet = new Guid(guidTemplatePackCmdSetString);
    // SideWaffle Remote Source Settings
    public const string guidMenuOptionsPkgString = "796B8CBC-3010-4A76-872B-56775129765F";
    public const string guidMenuOptionsCmdSetString = "13EE92AE-B8B5-4728-8AF6-F53D8DD9C391";
    public static readonly Guid guidMenuOptionsCmdSet = new Guid(guidMenuOptionsCmdSetString);
    static class PkgCmdIDList
    public const uint cmdidMyCommand = 0x100;
    public const uint cmdidSWCommand = 0x101;
    TemplatePackPackage.cs
    using System;
    using System.Linq;
    using System.Diagnostics;
    using System.Globalization;
    using System.Runtime.InteropServices;
    using System.ComponentModel.Design;
    using Microsoft.Win32;
    using Microsoft.VisualStudio;
    using Microsoft.VisualStudio.Shell.Interop;
    using Microsoft.VisualStudio.OLE.Interop;
    using Microsoft.VisualStudio.Shell;
    using System.Collections.Generic;
    using EnvDTE;
    using EnvDTE80;
    using LigerShark.Templates.DynamicBuilder;
    using TemplatePack.Tooling;
    namespace TemplatePack
    [PackageRegistration(UseManagedResourcesOnly = true)]
    [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
    [ProvideMenuResource("Menus.ctmenu", 1)]
    [Guid(GuidList.guidTemplatePackPkgString)]
    [ProvideAutoLoad(UIContextGuids80.SolutionExists)]
    public sealed class TemplatePackPackage : Package
    private DTE2 _dte;
    protected override void Initialize()
    base.Initialize();
    _dte = GetService(typeof(DTE)) as DTE2;
    OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
    if (null != mcs)
    CommandID cmdId = new CommandID(GuidList.guidTemplatePackCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
    OleMenuCommand button = new OleMenuCommand(ButtonClicked, cmdId);
    button.BeforeQueryStatus += button_BeforeQueryStatus;
    mcs.AddCommand(button);
    CommandID menuCommandID = new CommandID(GuidList.guidMenuOptionsCmdSet, (int)PkgCmdIDList.cmdidSWCommand);
    MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
    mcs.AddCommand(menuItem);
    /*if(Environment.GetEnvironmentVariable("SideWaffleEnableDynamicTemplates") != null)*/{
    try {
    new DynamicTemplateBuilder().ProcessTemplates();
    catch (Exception ex) {
    // todo: replace with logging or something
    System.Windows.MessageBox.Show(ex.ToString());
    void button_BeforeQueryStatus(object sender, EventArgs e)
    var button = (OleMenuCommand)sender;
    var project = GetSelectedProjects().ElementAt(0);
    // TODO: We should only show this if the target project has the TemplateBuilder NuGet pkg installed
    // or something similar to that.
    button.Visible = true;
    // button.Visible = project.IsWebProject();
    private void ButtonClicked(object sender, EventArgs e)
    Project currentProject = GetSelectedProjects().ElementAt(0);
    var projects = _dte.Solution.GetAllProjects();
    var names = from p in projects
    where p != currentProject
    select p.Name;
    ProjectSelector selector = new ProjectSelector(names);
    bool? isSelected = selector.ShowDialog();
    if (isSelected.HasValue && isSelected.Value)
    // need to save everything because we will directly write to the project file in the creator
    _dte.ExecuteCommand("File.SaveAll");
    TemplateReferenceCreator creator = new TemplateReferenceCreator();
    var selectedProject = projects.First(p => p.Name == selector.SelectedProjectName);
    creator.AddTemplateReference(currentProject, selectedProject);
    public IEnumerable<Project> GetSelectedProjects()
    var items = (Array)_dte.ToolWindows.SolutionExplorer.SelectedItems;
    foreach (UIHierarchyItem selItem in items)
    var item = selItem.Object as Project;
    if (item != null)
    yield return item;
    private void MenuItemCallback(object sender, EventArgs e)
    // Here is where our UI (i.e. user control) will go to do all the settings.
    var window = new SettingsForm();
    window.Show();
    Once I removed the second package it no longer appeared multiple times in the Tools menu; however, when I click the button the SettingsForm is not being opened.

  • Multiple drop down menu items to populate the a separate text box...more help please

    Thanks to Gilad D67 for showing me how to have multiple drop down menu items appear in a separate text box. This stuff blows my mind. Is there any script I can use to make a new drop down menu item appear in the same text box, but on a new line below a previous entry. For example. I select 'cat' from my drop down menu and it appears in my text box. Now I choose 'dog' from my menu and it appears in my text box like so  'cat dog.' Is there any way I can make 'dog' go straight to a new line automatically without having to manually go into the text box and change it?
    cat
    dog (new selection goes straight to a new line)
    Now, I don't have a clue if this is also possible, but imagine, I don't like my drop down menu selection of 'dog' and I go back into the menu and I change to 'rat' but in the text box, 'dog' still appears and 'rat' is added. Do I have to manually delete 'dog' from the text box or is there script that can do this for me.
    Any assistance would be incredible. It amazes me how people know this stuff.
    This is the script I have so far
    (function () {
        // Do nothing if not committed
        if (event.willCommit) return;
        // Set up an array to hold the individual paragraphs of text
        var aQuotes = [3];
        // Populate the array with the paragraph text
        aQuotes[0] = "Use common singular nouns, plural nouns [plural ‘s’] and proper names to say what things are"
        aQuotes[1] = "Use numbers 1–10 to count"
        aQuotes[2] = "Use basic adjectives and colours to say what someone/something is or has"
        // Get the selected item, which is the export value of the selected combo box item
        var item = event.changeEx
        // Display the text corresponding to the selected item in the text field
        getField("Text30").value += " " + aQuotes[item];

    You have to set the option for the text field to be multiline and then change the last line of the script to:
    getField("Text30").value += "\r" + aQuotes[item];
    To reset the field you can use a separate button with a Clear Form command, and then you just select this one field from the list.

  • Multiple drop down menu items to populate the same separate text box. How can I do it?

    In Acrobat Pro X, I've figured out how to create a drop down menu with items that will populate a separate text box, but how can I get multiple menu items to populate the same text box. For example. My drop down menu has three items  cat, dog, mouse. I choose cat and it appears in my separate text box (hooray). Next, I choose 'dog' from the same menu. I would like it to appear in the same text box along with my previous selection 'cat.' Is this possible? I'm very new to Java Script, any assistance would be greatly appreciated! Thank you

    She is the script I'm using
    (function () {
        // Do nothing if not committed
        if (event.willCommit) return;
        // Set up an array to hold the individual paragraphs of text
        var aQuotes = [3];
        // Populate the array with the paragraph text
        aQuotes[0] = "cat"
        aQuotes[1] = "dog"
        aQuotes[2] = "mouse"
        // Get the selected item, which is the export value of the selected combo box item
        var item = event.changeEx
        // Display the text corresponding to the selected item in the text field
        getField("Text field 1").value = aQuotes[item];

  • Event Handlers which trigger functions with multiple arguments

    I am playing two video clips back to back. I have a few
    things which I need to do in between clips, so what I am doing for
    each is adding a handler for VideoEvent.COMPLETE, at which time i
    want to call a function which takes multiple arguments, like this:
    video.addEventListener(VideoEvent.COMPLETE,
    myFunction("1","2","3"));
    private function myFunction(var1:String, var2:String,
    var3:String):void
    video.removeEventListeners(VideoEvent.COMPLETE, myFunction);
    I've already figured out that getting rid of event handlers
    that trigger anonymous functions is impossible. Please don't tell
    me that it's impossible to remove them if functions require more
    than 0 arguments...

    "muskiemania" <[email protected]> wrote in
    message
    news:gc0pk0$jfb$[email protected]..
    >I am playing two video clips back to back. I have a few
    things which I need
    >to
    > do in between clips, so what I am doing for each is
    adding a handler for
    > VideoEvent.COMPLETE, at which time i want to call a
    function which takes
    > multiple arguments, like this:
    >
    > video.addEventListener(VideoEvent.COMPLETE,
    myFunction("1","2","3"));
    >
    > private function myFunction(var1:String, var2:String,
    var3:String):void
    > {
    > video.removeEventListeners(VideoEvent.COMPLETE,
    myFunction);
    > }
    >
    > I've already figured out that getting rid of event
    handlers that trigger
    > anonymous functions is impossible. Please don't tell me
    that it's
    > impossible to
    > remove them if functions require more than 0
    arguments...
    Any function that you add via addEventListener should expect
    exactly ONE
    argument, the event. And 99.958% of the time, you can take
    that event
    object and figure out exactly what you need to know.
    HTH;
    Amy

  • Start Menu items/shotcuts and Start Menu search ability on multiple workstations

    2/13/2014 our IT department began to receive complaints of missing programs. After investigation of a few users we were able to determine that the programs existed but all shortcuts and items from the start menu had been completely removed. In addition the
    searching feature of the start menu was not functional. This happened to about 90% of our environment and the catalyst seemed to be Windows updates or at least occurred after the auto reboot initiated by Windows Updates.  The only items visible in start
    menu were items added after the fact, internet explorer, magnifier, command prompt, and notepad. All other items, folders, and the ability to search installed programs or folders were completely removed. However all programs are present in the program files
    folders. THe start menu folder in program data was empty except for the aforementioned items. Additionally properties of start menu had all necessary checks in boxes such as search program files and folders etc. Also show hidden items and folders is enabled
    for many users so the items were not hidden but gone. And the biggest kicker of all was after a full domain investigation into the issues we found that the majority of our windows server platforms, primarily 2008, were also affected and system restore is unavailable.
    This conflicts with our idea that Windows Updates caused this since our servers get their updates on a manual initiated basis by their admins which we have not performed as of yet for this month. This caused me to begin looking at SCCM SCEP as all systems
    have System Center Endpoint Protection and received definition updates. Also accessing different user profiles or even a new profile did not make a difference, issue still present.
    Due to the enormous inconvenience we sent out a company wide email asking users to perform system restores to get us in a stable state. A system restore to the day before Windows updates (second Wednesday of every month configured by SCCM SCUP) restored
    the start menu items.
    On a multitude of machines IT performed troubleshooting and system restores recording the changes removed and added. We then, on a healthy machine, started to apply the windows updates and SCEP (antivirus) definitions 1 by 1 with out success of replicating
    the issue. Next we performed a system wide antivirus full scan and did not find any viruses. This is obviously not a system criticle issue bringing us down but is a huge concern for us in IT as it happened company wide and caused a large flux of tickets and
    some down time for non-technical users. We most definitely want to know the cause and after several days of investigation and troubleshooting Im turning to the Microsoft community for help.
    I know I categorized this as a Windows 7 issue and its affecting windows server 2008, 2003, and 7, but I did not see a forum for all windows platforms. Since the majority of affected users are Windows 7 I opened it here.
    So to summarize in a bulleted format:
    Issue: Wide spread issue affecting around 60-70 users and servers, all profiles, were all start menu items save one or two system defaults were removed. Additionally the searching feature for the start menu looks to be broken as programs
    exist in program files and are unsearchable from start menu. IT was also affected and I remain affected until I find the cause.
    Investigation and Troubleshooting:
    Start menu properties: nothing has changed and search options are enabled.
    Missing items are not hidden, hiding and unhiding does nothing and folder options show hidden files is checked.
    Program data start menu location is indeed empty as well as user app data start menu location
    No group policy's are in place altering start menu items and no group policy changes were made as of recent
    No SCCM packages pushed company wide in last month or pushed individually
    Windows Updates occurred on windows 7 machines only before the issue occurred and computers restarted and the issue surfaced
    System Center Endpoint Protection Antivirus updates and definitions deployed just before the occurrence with windows updates. SCEP def updates happen on all windows boxes to include servers
    Paint.exe was completely missing from system32 folder for some users machines to include my own
    System restore to that morning before restarts or previous day fixes the issue for windows 7 users
    No windows updates were initiated on any servers
    Servers were also affected with windows 7 machines
    About half the users affected had corrupt Microsoft Office 2013 Pro Plus Click to Run installations and for some the system restore did not fix this and we had to re-install office for around 10 users
    SCEP antivirus did not catch any viruses that could cause this, I performed MBAM scans on a handful of machines and didn't find anything either.
    Re-creating start menu shortcuts works
    Happened to two of our companies locations NH and MA, all part of the same domain but different LANS of course. Companies are interconnected by MPLS connection.
    I combed through SCCM to see if anything deployed and found nothing. Currently I have SCUP updates and SCEP updates disabled. I will post a list of Windows Updates that occurred when the issue occurred as well as the SCEP updates. I have read all the threads
    about this types of issues and tried all steps without success. Googling the issue also did not rear results.
    MichaelSpaulding

    Hi,
    I would like to suggest you try these steps to figure out what could be causing this problem.
    1. Run Troubleshooter
    Open the Search and Indexing troubleshooter
    http://windows.microsoft.com/en-US/windows7/Open-the-Search-and-Indexing-troubleshooter
    2. Create a new library and include fewer folders for test purpose. Now search for a file from that folder. See if it works.
    Create a new library
    http://windows.microsoft.com/en-US/windows7/Create-a-new-library
    3. Try to rebuild search indexing. Refer the steps from the following article.
    http://windows.microsoft.com/en-US/windows7/Change-advanced-indexing-options
    Also you may use the System File Checker tool (SFC.exe) to check the issue. The sfc /scannow command scans all protected system files and replaces incorrect versions with correct Microsoft versions.
    How to use the System File Checker tool to troubleshoot missing or corrupted system files on Windows Vista or on Windows 7
    http://support.microsoft.com/kb/929833
    In addition, you may refer to the following Microsoft TechNet article for the Windows Search related Group Policies.
    Group Policy for Windows Search
    http://technet.microsoft.com/en-us/library/cc732491(WS.10).aspx
    Hope it helps.
    Regards,
    Blair Deng
    Blair Deng
    TechNet Community Support

  • How do I select multiple events in iCal 8.0?

    In OSX Mavericks, I used to be able to select multiple events in iCal in the event list view. I could select the initial event in the span of events to be selected. Then hold Shift while selecting the final even in the span of events. As a result, all of the events in that span would be selected.
    in OSX Yosemite, this is no longer possible. There appears to be no list view, and holding the Shift button does not allow me to select a span of events.
    What is the best way to select a span of events, say as much as 30 events?
    Thank you.

    Empty Caches
    1. Safari > Preference > Advanced
        Checkmark the box for "Show Develop menu in menu bar".
        "Develop" menu will appear in the Safari menu bar.
        Click Develop and select "Empty Caches" from the dropdown.
    2. Quit Safari if open.
        Option click the "Go" menu in the Finder menu bar.
        Select "Library" and then "Caches".
        Look for the folder 'com.apple.Safari"
        Right click "com.apple.Safari" and select "Move to Trash"
        Relaunch Safari.

  • Is it possible to handle multiple events using Jscript for a button in Apex

    Hi,
    I've application wherein in one of the pages for a button, I need to trigger 2 events as: 1. redirect to a new page upon 'click' of the button
    2. display a set of values on 'mouse over' that button.
    I'm able to handle both separately, but not in one button. I would like to know if there is any limitation in Apex that we cant handle multiple events? Currently I've put a text item near the button, and called the Jscript for mouse over event in that as a temporary workaround. Can someone let me know if this is feasible? If not any other alternative to handle this?
    Thanks in advance,
    gsachidh

    Hi Gsachidh,
    well interesting problem you're facinng. Indeed, it can't be specified using the 'Button Attributes' So we have to come up with an workaround.
    A quick en dirty solution would be to specify it with the 'Optional URL Redirect options'. In a normal button, with processing on same page, this would be 'no target'. but in case of additional things to be done this can be used, using an target URL. I used this many times, in example with popUp windows for refreshing the caller object when changes are made. In your case we have to add next to the href an onmouseover event. this can be done with;
    Target set to => URL
    URL - target => javascript:doSubmit('<button_name>');" onMouseOver="javascript:showTooltip('tooltip');"
    Here the " is the key, letting ApEx know the target (href) is doSubmit('<button_name>'), just like when no target would be specified and adding a new javascript event; onMouseOver.
    Although this is a dirty solution in my opinion, it is the best i could come up with. I have another idea in how to do this, that is by adding this event dynamically with javascript with an addEvent. But i don't have an example at the moment for this scenario.
    Simon
    Message was edited by:
    S1M0N

  • Is it possible to show multiple events in the Events window of IMovie ?

    we have recently made a video of a play,  where we filmed from different angles each day  over 7 nights using a selection of long and mid-shots.  So we now have multiple Events ( one from each day).  In order to now edit all the events into a single project it would be helpful if  I could display all the events underneith each other in the Events window to make shot selection and editing easier.
    Can this be done in I Movie,  Thanks

    In the View menu do you have, Group Events by Disk, Grou Events by Month and Show Separate Dates in Events all checked?
    That should allow you the broadest way to view all your Events.
    Matt

Maybe you are looking for

  • Status bar with opera style page loading statistics?

    Anyone ever seen an app or terminal code or something that allows us to see page loading stats (seconds taken, # images loaded, speed, etc) like the status bar in Opera or one you can load in FF? I would love to have this ability in Safari. I found o

  • Acrobat 9 Installation

    Hi, suddenly my laptop crashed and I lost my Acrobat Professional 9 and Framemaker 8 with it. I have the serial numbers for these two with me. Can anyone tell me if I can download the software installers, install them on my laptop and activate the li

  • HT201077 full resolution is not loading, just getting a smaller version, has this policy changed?

    The FAQs says that full resolution will load to the icloud photo stream from my macbookpro, but that's not the case, it's a smaller version.  Has this changed? It used to work at full resolution.

  • Apache and postgresql boot script

    Hi fellas, I do the apache and pgsql installation by tarball, but i dont have the boot script of these services. Anyone have it?

  • SharedObject.flush / Security.showSettings issue

    First time poster, so hopefully I'm following all the appropriate protocols... Hi!  I'm having a weird problem, and I'm sure the fix is easy, but it's not easy till I know it... I'm compiling in CS4, testing in IE (and stand-alone).  The code I have