Пример #1
0
 private void AddToolTip(PythonCommandSetting commandSetting, PushButtonData pushButtonData)
 {
     if (!string.IsNullOrEmpty(commandSetting.ToolTip))
     {
         pushButtonData.ToolTip = commandSetting.ToolTip;
     }
 }
Пример #2
0
 private void AssignPythonCommandSettingsToCollection(XmlDocument xml)
 {
     foreach (XmlNode node in xml.DocumentElement)
     {
         PythonCommandSetting scriptCommandSetting = GetSettingFromXmlNode(node);
         if (scriptCommandSetting.HasRequiredItems())
         {
             _pythonCommandSettings.Add(scriptCommandSetting);
         }
     }
 }
Пример #3
0
        private PushButtonData CreatePythonPushButtonDataFromSetting
            (PythonCommandSetting commandSetting)
        {
            PushButtonData pushButton = new PushButtonData(
                commandSetting.CommandName, commandSetting.NameOnRibbon,
                _emitter.AssemblyLocation, commandSetting.CommandName);

            if (!string.IsNullOrEmpty(commandSetting.ImageUri))
            {
                AddPngImage(commandSetting, pushButton);
            }
            AddToolTip(commandSetting, pushButton);
            return(pushButton);
        }
Пример #4
0
        private void AddPngImage(PythonCommandSetting commandSetting, PushButtonData pbd)
        {
            if (Path.GetExtension(commandSetting.ImageUri) == ".png")
            {
                ResourceManager resourceManager = new ResourceManager(
                    "RevitDKTools.Properties.Resources",
                    Assembly.GetExecutingAssembly());
                string imagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace(@"file:\", string.Empty) +
                                   resourceManager.GetString("SCRIPTS_FOLDER_LOCATION") + commandSetting.ImageUri;
                imagePath = Path.GetFullPath(imagePath);
                BitmapImage bitmapImage = new BitmapImage(new Uri(imagePath));
                pbd.LargeImage = bitmapImage;

                if (bitmapImage.PixelHeight == 16 && bitmapImage.PixelWidth == 16)
                {
                    pbd.Image = bitmapImage;
                }
            }
        }
Пример #5
0
        private PythonCommandSetting GetSettingFromXmlNode(XmlNode node)
        {
            PythonCommandSetting scriptCommandSetting = new PythonCommandSetting();

            foreach (XmlNode child in node)
            {
                switch (child.Name)
                {
                case "CommandName":
                    scriptCommandSetting.CommandName = child.InnerText;
                    break;

                case "NameOnRibbon":
                    scriptCommandSetting.NameOnRibbon = child.InnerText;
                    break;

                case "ScriptPath":
                    scriptCommandSetting.ScriptRelativePath = child.InnerText;
                    break;

                case "ParentButton":
                    scriptCommandSetting.ParentButton = child.InnerText;
                    break;

                case "ToolTip":
                    scriptCommandSetting.ToolTip = child.InnerText;
                    break;

                case "ImageUri":
                    scriptCommandSetting.ImageUri = child.InnerText;
                    break;
                }
            }

            return(scriptCommandSetting);
        }