Example #1
0
        // Загрузка функций
        private void LoadFunctions()
        {
            try
            {
                var functionsKey = Registry.CurrentUser.OpenSubKey("ModPlus\\Functions");
                if (functionsKey == null)
                {
                    return;
                }
                using (functionsKey)
                {
                    foreach (var functionKeyName in functionsKey.GetSubKeyNames())
                    {
                        var functionKey = functionsKey.OpenSubKey(functionKeyName);
                        var prForValue  = functionKey?.GetValue("ProductFor");
                        if (prForValue != null && prForValue.Equals("Renga"))
                        {
                            // беру свойства функции из реестра
                            var file  = functionKey.GetValue("File") as string;
                            var onOff = functionKey.GetValue("OnOff") as string;
                            if (string.IsNullOrEmpty(onOff))
                            {
                                continue;
                            }
                            var isOn = !bool.TryParse(onOff, out var b) || b; // default - true

                            // Если "Продукт для" подходит, файл существует и функция включена - гружу
                            if (isOn)
                            {
                                if (!string.IsNullOrEmpty(file) && File.Exists(file))
                                {
                                    // load
                                    var localFuncAssembly = Assembly.LoadFrom(file);
                                    LoadFunctionsHelper.GetDataFromFunctionInterface(localFuncAssembly, file);
                                }
                                else
                                {
                                    var foundedFile = LoadFunctionsHelper.FindFile(functionKeyName);
                                    if (!string.IsNullOrEmpty(foundedFile) && File.Exists(foundedFile))
                                    {
                                        var localFuncAssembly = Assembly.LoadFrom(foundedFile);
                                        LoadFunctionsHelper.GetDataFromFunctionInterface(localFuncAssembly, foundedFile);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                RengaApplication.UI.ShowMessageBox(Renga.MessageIcon.MessageIcon_Error, "ModPlus", exception.Message);
            }
        }
Example #2
0
        private static void LoadFunctions(Editor ed)
        {
            try
            {
                var functionsKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("ModPlus\\Functions");
                if (functionsKey == null)
                {
                    return;
                }
                using (functionsKey)
                {
                    foreach (var functionKeyName in functionsKey.GetSubKeyNames())
                    {
                        var functionKey = functionsKey.OpenSubKey(functionKeyName);
                        if (functionKey == null)
                        {
                            continue;
                        }
                        foreach (var availPrVersKeyName in functionKey.GetSubKeyNames())
                        {
                            // Если версия продукта не совпадает, то пропускаю
                            if (!availPrVersKeyName.Equals(VersionData.CurrentCadVersion))
                            {
                                continue;
                            }
                            var availProductVersionKey = functionKey.OpenSubKey(availPrVersKeyName);
                            if (availProductVersionKey == null)
                            {
                                continue;
                            }

                            // беру свойства функции из реестра
                            var file       = availProductVersionKey.GetValue("File") as string;
                            var onOff      = availProductVersionKey.GetValue("OnOff") as string;
                            var productFor = availProductVersionKey.GetValue("ProductFor") as string;
                            if (string.IsNullOrEmpty(onOff) || string.IsNullOrEmpty(productFor))
                            {
                                continue;
                            }
                            if (!productFor.Equals("AutoCAD"))
                            {
                                continue;
                            }
                            var isOn = !bool.TryParse(onOff, out var b) || b; // default - true

                            // Если "Продукт для" подходит, файл существует и функция включена - гружу
                            if (isOn)
                            {
                                if (!string.IsNullOrEmpty(file) && File.Exists(file))
                                {
                                    // load
                                    if (!_quiteLoad)
                                    {
                                        ed.WriteMessage($"\n* {Language.GetItem(LangItem, "p15")} {functionKeyName}");
                                    }
                                    var localFuncAssembly = Assembly.LoadFrom(file);
                                    LoadFunctionsHelper.GetDataFromFunctionInterface(localFuncAssembly);
                                }
                                else
                                {
                                    var foundedFile = LoadFunctionsHelper.FindFile(functionKeyName);
                                    if (!string.IsNullOrEmpty(foundedFile) && File.Exists(foundedFile))
                                    {
                                        if (!_quiteLoad)
                                        {
                                            ed.WriteMessage($"\n* {Language.GetItem(LangItem, "p15")} {functionKeyName}");
                                        }
                                        var localFuncAssembly = Assembly.LoadFrom(foundedFile);
                                        LoadFunctionsHelper.GetDataFromFunctionInterface(localFuncAssembly);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }
Example #3
0
 private void FillFieldsFunction()
 {
     _hasFieldsFunction  = LoadFunctionsHelper.HasStampsPlugin();
     BtFields.Visibility = _hasFieldsFunction ? Visibility.Visible : Visibility.Collapsed;
 }
        private static void AddHelpPanel(RibbonTab ribTab)
        {
            // create the panel source
            var ribSourcePanel = new RibbonPanelSource
            {
                Title = "ModPlus"
            };

            // now the panel
            var ribPanel = new RibbonPanel
            {
                Source = ribSourcePanel
            };

            ribTab.Panels.Add(ribPanel);

            var ribRowPanel = new RibbonRowPanel();

            ribRowPanel.Items.Add(
                RibbonHelpers.AddBigButton(
                    "mpUserInfo",
                    Language.GetItem(LangItem, "h56"),
                    _colorTheme == 1
                        ? "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/UserInfo_32x32.png"
                        : "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/UserInfo_32x32_dark.png",
                    Language.GetItem(LangItem, "h56"),
                    Orientation.Vertical,
                    string.Empty,
                    string.Empty,
                    "help/userinfo"));

            ribRowPanel.Items.Add(
                RibbonHelpers.AddBigButton(
                    "mpSettings",
                    Language.GetItem(LangItem, "h12"),
                    _colorTheme == 1
                    ? "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/HelpBt.png"
                    : "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/HelpBt_dark.png",
                    Language.GetItem(LangItem, "h41"),
                    Orientation.Vertical,
                    Language.GetItem(LangItem, "h42"),
                    string.Empty,
                    "help/mpsettings"));
            ribSourcePanel.Items.Add(ribRowPanel);

            ribRowPanel = new RibbonRowPanel();
            if (LoadFunctionsHelper.HasStampsPlugin(_colorTheme, out var icon))
            {
                ribRowPanel.Items.Add(
                    RibbonHelpers.AddSmallButton(
                        "mpStampFields",
                        Language.GetItem(LangItem, "h43"),
                        icon,
                        Language.GetItem(LangItem, "h44"),
                        Language.GetItem(LangItem, "h45"),
                        string.Empty,
                        "autocadplugins/mpstamps"));
                ribRowPanel.Items.Add(new RibbonRowBreak());
            }

            ribRowPanel.Items.Add(
                RibbonHelpers.AddSmallButton(
                    "mpShowProductIcons",
                    Language.GetItem(LangItem, "h46"),
                    _colorTheme == 1
                        ? "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/mpShowProductIcons_16x16.png"
                        : "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/mpShowProductIcons_16x16_dark.png",
                    Language.GetItem(LangItem, "h37"),
                    Language.GetItem(LangItem, "h38"),
                    "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/mpShowProductIcon.png", "help/mpsettings"));
            ribRowPanel.Items.Add(new RibbonRowBreak());

            ribRowPanel.Items.Add(
                RibbonHelpers.AddSmallButton(
                    "mpHideProductIcons",
                    Language.GetItem(LangItem, "h47"),
                    _colorTheme == 1
                        ? "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/mpHideProductIcons_16x16.png"
                        : "pack://application:,,,/Modplus_" + VersionData.CurrentCadVersion + ";component/Resources/mpHideProductIcons_16x16_dark.png",
                    Language.GetItem(LangItem, "h39"),
                    string.Empty,
                    string.Empty,
                    "help/mpsettings"));
            ribSourcePanel.Items.Add(ribRowPanel);
        }
 private void FillFieldsFunction()
 {
     BtFields.Visibility = LoadFunctionsHelper.HasStampsPlugin(1, out _) ? Visibility.Visible : Visibility.Collapsed;
 }