Ejemplo n.º 1
0
 public virtual void OnNavigatedFrom(NavigationContext navigationContext)
 {
     if (RegionManager != null)
     {
         IRegion tabRegion = RegionManager.Regions[RegionNames.RibbonTabRegion];
         RibbonTabs.ToList().ForEach(tabRegion.Remove);
     }
 }
Ejemplo n.º 2
0
        public static IEnumerable <IRibbonTab> AsEnumerable(this RibbonTabs source)
        {
            IEnumerator enumerator = source.GetEnumerator();

            while (enumerator.MoveNext())
            {
                yield return(enumerator.Current as IRibbonTab);
            }
        }
Ejemplo n.º 3
0
 public virtual void OnNavigatedTo(NavigationContext navigationContext)
 {
     //добавляем RibbonTabs
     if (RegionManager != null)
     {
         IRegion tabRegion = RegionManager.Regions[RegionNames.RibbonTabRegion];
         RibbonTabs.ToList().ForEach(tab => tabRegion.Add(tab));
     }
 }
Ejemplo n.º 4
0
        public ITab GetTab(string typeName, string tabName)
        {
            List <ITab> tabs;

            if (RibbonTabs.TryGetValue(typeName, out tabs))
            {
                return(tabs?.Where(a => a.TabName == tabName).Select(a => a).FirstOrDefault());
            }
            return(null);
        }
Ejemplo n.º 5
0
 public static RibbonTab GetOrCreate(this RibbonTabs tabs, string TabDisplayName, string TabInternalName, string ClientId)
 {
     if (tabs[TabInternalName] != null)
     {
         return(tabs[TabInternalName]);
     }
     else
     {
         return(tabs.Add(TabDisplayName, TabInternalName, ClientId));
     }
 }
Ejemplo n.º 6
0
        public ITab CreateNewTab(string typename, string name)
        {
            var tab = new RTab(name);

            List <ITab> tabs;

            if (RibbonTabs.TryGetValue(typename, out tabs))
            {
                tabs.Add(tab);
            }
            else
            {
                RibbonTabs.Add(typename, new List <ITab>()
                {
                    tab
                });
            }
            return(tab);
        }
Ejemplo n.º 7
0
        private void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            // prepare ribbon
            foreach (var ribbonId in Workspace.SettingsService.GetValue <string[]>(WpfSettingsProvider.RibbonOrder))
            {
                var rib = RibbonTabs.FirstOrDefault(t => t.Metadata.Id == ribbonId);
                if (rib != null)
                {
                    this.ribbon.Items.Add(rib.Value);
                }
            }

            // prepare user console
            CompositionContainer.Container.SatisfyImports(inputPanel);
            TakeFocus();
            Workspace.InputService.Reset();

            Workspace.Update(isDirty: false);

            var args = Environment.GetCommandLineArgs().Skip(1); // trim off executable

            args = args.Where(a => !a.StartsWith("/"));          // remove options
            if (args.Count() == 1)
            {
                var fileName = args.First();
                if (File.Exists(fileName))
                {
                    Workspace.Update(isDirty: false);
                    Workspace.ExecuteCommand("File.Open", fileName);
                }
                else
                {
                    Workspace.OutputService.WriteLine("Unable to open file: ", fileName);
                }
            }
            else
            {
                SetTitle(Workspace.Drawing);
            }
        }
Ejemplo n.º 8
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                SetupDynamoPaths();
                inventorApplication = addInSiteObject.Application;
                PersistenceManager.InventorApplication = inventorApplication;
                userInterfaceManager = inventorApplication.UserInterfaceManager;

                //initialize event delegates
                userInterfaceEvents = inventorApplication.UserInterfaceManager.UserInterfaceEvents;

                UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars);
                userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;

                UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments);
                userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;

                UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface);
                userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate;

                appEvents = inventorApplication.ApplicationEvents;
                appEvents.OnActivateDocument   += appEvents_OnActivateDocument;
                appEvents.OnDeactivateDocument += appEvents_OnDeactivateDocument;

                Icon dynamoIcon = Resources.logo_square_32x32;

                //retrieve the GUID for this class
                GuidAttribute addInCLSID;
                addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(this.GetType(), typeof(GuidAttribute));
                string addInCLSIDString;
                addInCLSIDString = "{" + addInCLSID.Value + "}";

                dynamoAddinButton = new DynamoInventorAddinButton(
                    buttonDisplayName, buttonInternalName, CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Initialize Dynamo.",
                    "Dynamo is a visual programming environment for Inventor.", dynamoIcon, dynamoIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory assemblyUtilitiesCategory = inventorApplication.CommandManager.CommandCategories.Add(commandCategoryDisplayName, commandCategoryInternalName, addInCLSID);
                assemblyUtilitiesCategory.Add(dynamoAddinButton.ButtonDefinition);

                if (firstTime == true)
                {
                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        CommandBar assemblyUtilityCommandBar;

                        assemblyUtilityCommandBar = userInterfaceManager.CommandBars.Add(commandBarDisplayName,
                                                                                         commandBarInternalName,
                                                                                         CommandBarTypeEnum.kRegularCommandBar,
                                                                                         addInCLSID);
                    }

                    else
                    {
                        Inventor.Ribbons ribbons           = userInterfaceManager.Ribbons;
                        Inventor.Ribbon  assemblyRibbon    = ribbons["Assembly"];
                        RibbonTabs       ribbonTabs        = assemblyRibbon.RibbonTabs;
                        RibbonTab        assemblyRibbonTab = ribbonTabs["id_AddInsTab"];
                        RibbonPanels     ribbonPanels      = assemblyRibbonTab.RibbonPanels;
                        assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls;
                        CommandControl  assemblyCmdBtnCmdCtrl    = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);

                        Inventor.Ribbon partRibbon       = ribbons["Part"];
                        RibbonTabs      partRibbonTabs   = partRibbon.RibbonTabs;
                        RibbonTab       modelRibbonTab   = partRibbonTabs["id_AddInsTab"];
                        RibbonPanels    partRibbonPanels = modelRibbonTab.RibbonPanels;
                        partRibbonPanel = partRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls partRibbonPanelCtrls = partRibbonPanel.CommandControls;
                        CommandControl  partCmdBtnCmdCtrl    = partRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);

                        Inventor.Ribbon drawingRibbon       = ribbons["Drawing"];
                        RibbonTabs      drawingRibbonTabs   = drawingRibbon.RibbonTabs;
                        RibbonTab       drawingRibbonTab    = drawingRibbonTabs["id_AddInsTab"];
                        RibbonPanels    drawingRibbonPanels = drawingRibbonTab.RibbonPanels;
                        drawingRibbonPanel = drawingRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls drawingRibbonPanelCtrls = drawingRibbonPanel.CommandControls;
                        CommandControl  drawingCmdBtnCmdCtrl    = drawingRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 9
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.
            AddinGlobal.InventorApp = addInSiteObject.Application;

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;
            try
            {
                AddinGlobal.GetAddinClassId(this.GetType());
                Icon icon1 = Properties.Resources.button_turn_on;
                Icon icon2 = Properties.Resources.log_door;
                Icon icon3 = Properties.Resources.chat_31;
                Icon icon4 = Properties.Resources.off_on_power_energy_1_;
                Icon icon5 = null;

                //Icon icon1 = new Icon(this.GetType(), "InventorAddIn1.Properties.AddSlotOption.ico"); //Change it if necessary but make sure it's embedded.
                //Button1
                InventorButton button1 = new InventorButton(
                    "Session erstellen", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Erstellen Sie eine neue Session",
                    icon1, icon1,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button1.SetBehavior(true, true, true);
                button1.Execute = ButtonAction.Button1_Execute;
                //Button2
                InventorButton button2 = new InventorButton(
                    "Beitreten", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Eine Session beitreten",
                    icon2, icon2,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button2.SetBehavior(true, true, true);
                button2.Execute = ButtonAction.Button2_Execute;
                //Button3
                InventorButton button3 = new InventorButton(
                    "Messages", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "See your Messages",
                    icon3, icon3,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button3.SetBehavior(true, true, true);
                button3.Execute = ButtonAction.Button3_Execute;
                //Button4
                InventorButton button4 = new InventorButton(
                    "Beenden", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Beenden Sie die Session",
                    icon4, icon4,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button4.SetBehavior(true, true, true);
                button4.Execute = ButtonAction.Button4_Execute;
                //Button5
                InventorButton button5 = new InventorButton(
                    "Username: \n Meeting-ID: ", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Info",
                    icon5, icon5,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button5.SetBehavior(true, true, true);
                button5.Execute          = ButtonAction.Button5_Execute;
                ButtonAction.InventorApp = m_inventorApplication;

                if (firstTime == true)
                {
                    UserInterfaceManager uiMan = AddinGlobal.InventorApp.UserInterfaceManager;
                    if (uiMan.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface) //kClassicInterface support can be added if necessary.
                    {
                        /*Inventor.Ribbon ribbon = uiMan.Ribbons["Assem"];//["Part"];
                         * RibbonTab tab = ribbon.RibbonTabs["id_TabTools"]; //Change it if necessary.*/

                        //Assembly
                        Inventor.Ribbons ribbon         = uiMan.Ribbons;
                        Inventor.Ribbon  assemblyRibbon = ribbon["Assembly"];
                        RibbonTabs       ribbonTabs     = assemblyRibbon.RibbonTabs;
                        RibbonTab        tab            = ribbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId       = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.assemblyRibbonPanel = tab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.assemblyRibbonPanel);
                        CommandControls cmdCtrls = AddinGlobal.assemblyRibbonPanel.CommandControls;
                        cmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        cmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        cmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        cmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        //Part
                        Inventor.Ribbon partRibbon     = ribbon["Part"];
                        RibbonTabs      partRibbonTabs = partRibbon.RibbonTabs;
                        RibbonTab       modelRibbonTab = partRibbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId   = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.partRibbonPanel = modelRibbonTab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.partRibbonPanel);

                        CommandControls pcmdCtrls = AddinGlobal.partRibbonPanel.CommandControls;
                        pcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        //Drawing
                        Inventor.Ribbon drawingRibbon     = ribbon["Drawing"];
                        RibbonTabs      drawingRibbonTabs = drawingRibbon.RibbonTabs;
                        RibbonTab       drawingRibbonTab  = drawingRibbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId      = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.drawingRibbonPanel = drawingRibbonTab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.drawingRibbonPanel);


                        CommandControls dcmdCtrls = AddinGlobal.drawingRibbonPanel.CommandControls;
                        dcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        /* Get the 2d sketch environment base object
                         * Inventor.Environment partSketchEnvironment;
                         * partSketchEnvironment = userInterfaceManager.Environments["PMxPartSketchEnvironment"];
                         *
                         * //make this command bar accessible in the panel menu for the 2d sketch environment.
                         * partSketchEnvironment.PanelBar.CommandBarList.Add(slotCommandBar);*/
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
        }
    void DrawSpellbook(Event curEvent)
    {
        //Draw the spellbook background
        GUI.DrawTexture(spellBookRect, spellBookBackground);

        for (int i = 0; i < ribbons.Length; i++)
        {
            //Calculate the size and position for the ribbons
            Rect currentRect = new Rect(spellBookRect.xMax - Screen.width * 0.023f + i * Screen.width * 0.001f, spellBookRect.y + Screen.height * 0.05f + i * tabSpaceAmount, Screen.width * 0.06f, Screen.height * 0.05f);
            //If the mouse is hovering over the ribbon
            if (currentRect.Contains(curEvent.mousePosition))
            {
                //Draw the ribbon hover texture
                GUI.DrawTexture(currentRect, ribbons[i].hover);
                //If the player clicks on a ribbon with the left mouse button set the selected tab to the one pressed
                if (curEvent.button == 0 && curEvent.type == EventType.mouseDown)
                {
                    selectedTab = ribbons[i].tab;
                }
            }
            //If the mouse isn't hovering over the ribbon then draw the normal ribbon texture
            else
            {
                GUI.DrawTexture(currentRect, ribbons[i].normal);
            }
            //Make a label containing the name of the tab over the ribbon
            GUI.Label(new Rect(currentRect.x + currentRect.width * 0.1f, currentRect.y, currentRect.width, currentRect.height), ribbons[i].tab.ToString(), "RibbonLabel");
        }

        int j;
        int k;

        GUILayout.BeginArea(spellIconArea);
        for (int i = 0; i < spellBookCapacity; i++)
        {
            j = i / spellBookPageWidth;
            k = i % spellBookPageWidth;
            Rect  currentRect;
            Spell spell = null;

            //If the code has runned through less than half of the spells in the spellbook draw it on the first page of the book
            if (i < spellBookCapacity * 0.5f)
            {
                currentRect = new Rect(k * (spellIconSize + spellSpaceAmount), j * (spellIconSize + spellSpaceAmount), spellIconSize, spellIconSize);
            }
            //Else if it has runned through over half draw the spells on the second page
            else
            {
                currentRect = new Rect(spellBookRect.width * 0.45f + k * (spellIconSize + spellSpaceAmount), j * (spellIconSize + spellSpaceAmount) - spellBookCapacity * 0.25f * spellIconSize - (spellSpaceAmount * spellBookCapacity * 0.25f), spellIconSize, spellIconSize);
            }

            if (selectedTab == RibbonTabs.Nature)
            {
                spells = nature;
            }
            else if (selectedTab == RibbonTabs.Arcane)
            {
                spells = arcane;
            }
            else if (selectedTab == RibbonTabs.Fire)
            {
                spells = fire;
            }
            else if (selectedTab == RibbonTabs.Frost)
            {
                spells = frost;
            }

            if (spells.Count > i)
            {
                spell = spells[i];
                //If there's a spell and the spell has a icon applied then draw the icon
                if (spell && spell.icon)
                {
                    GUI.DrawTexture(currentRect, spell.icon);
                }
                //If the mouse is hovering over the spell
                if (currentRect.Contains(curEvent.mousePosition))
                {
                    //Set the name of the hovered spell
                    hoveredSpellName = spells[i].spellName;
                    //If the player drags a spell and there's no spell currently being dragged
                    //Then set it as the dragged spell
                    if (curEvent.type == EventType.MouseDrag && !dragging)
                    {
                        dragging     = true;
                        draggedSpell = spell;
                    }
                    //If the player presses on the spell while not dragging and the spell isn't on cooldown
                    //Then cast the spell
                    else if (curEvent.type == EventType.MouseUp && !dragging && !spell.onCooldown)
                    {
                        spell.Use();
                    }
                }
                //If the spell is on cooldown
                if (spell.onCooldown)
                {
                    if (Event.current.type.Equals(EventType.Repaint))
                    {
                        //Set the cutoff of the cooldown material to match the state of the cooldown
                        cooldownMaterial.SetFloat("_Cutoff", spell.cooldownTimer / spell.cooldown);
                        //Draw the cooldown texture over the item
                        Graphics.DrawTexture(currentRect, cooldownTexture, cooldownMaterial);
                    }
                }
            }
            //The slot are empty
            //Draw the texture for the empty slots with a opacity of 70%
            else
            {
                GUI.color = new Color(0.4f, 0.4f, 0.4f, 0.7f);
                GUI.DrawTexture(currentRect, spellEmpty);
                GUI.color = new Color(1f, 1f, 1f, 1f);
            }
        }
        GUILayout.EndArea();
    }