Esempio n. 1
0
        private void OnCommandClick(CommandSpec spec)
        {
            var cmdSpec   = (CommandItemInfoSpec)spec;
            var macroInfo = cmdSpec.Info;

            var trigger = macroInfo.Triggers.HasFlag(Triggers_e.ToggleButton) ? Triggers_e.ToggleButton : Triggers_e.Button;

            var targetDoc = m_App.Documents.Active;

            if (m_MacroRunner.TryRunMacroCommand(trigger, macroInfo, targetDoc, m_WorkDir))
            {
                if (macroInfo.Triggers.HasFlag(Triggers_e.ToggleButton))
                {
                    if (macroInfo.ResolveButtonStateCodeOnce || macroInfo.ToggleButtonStateCodeType == ToggleButtonStateCode_e.None)
                    {
                        if (m_CachedToggleStates.TryGetValue(macroInfo, out bool isChecked))
                        {
                            isChecked = !isChecked;
                            m_CachedToggleStates[macroInfo] = isChecked;
                        }
                        else
                        {
                            Debug.Assert(false, "State should have been resolved by SOLIDWORKS before this call");
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void InvokeTrigger(Triggers_e trigger, IXDocument targetDoc)
        {
            CommandMacroInfo[] cmds;

            if (m_Triggers.TryGetValue(trigger, out cmds))
            {
                cmds = cmds.Where(c => c.Scope.IsInScope(m_App)).ToArray();

                if (cmds.Any())
                {
                    m_Logger.Log($"Invoking {cmds.Length} command(s) for the trigger {trigger}", LoggerMessageSeverity_e.Debug);

                    foreach (var cmd in cmds)
                    {
                        m_MacroRunner.TryRunMacroCommand(trigger, cmd, targetDoc, m_WorkDir);
                    }
                }
            }
        }