示例#1
0
        /// <summary>
        /// Проверка введенных данных по базе
        /// </summary>
        /// <returns>True - есть такие данные, false - нет таких данных</returns>
        private bool CheckInteredItemData()
        {
            var hasSame = false;

            #region Проверяем по базе плагина

            if (DwgBaseHelpers.DeseializeFromXml(_mpDwgBaseFile, out var mpDwgBaseItems))
            {
                foreach (var mpDwgBaseItem in mpDwgBaseItems)
                {
                    if (mpDwgBaseItem.IsBlock)
                    {
                        if (mpDwgBaseItem.Name.Equals(Item.Name))
                        {
                            ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg35") + ": " + Item.Name);
                            hasSame = true;
                        }
                    }
                }
            }
            else
            {
                ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg36"));
                return(false);
            }
            #endregion

            #region Проверяем по базе пользователя

            if (DwgBaseHelpers.DeseializeFromXml(_userDwgBaseFile, out var userDwgBaseItems))
            {
                foreach (var userDwgBaseItem in userDwgBaseItems)
                {
                    if (userDwgBaseItem.IsBlock)
                    {
                        if (userDwgBaseItem.Name.Equals(Item.Name))
                        {
                            ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg37") + ": " + Item.Name);
                            hasSame = true;
                        }
                    }
                }
            }
            else
            {
                ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg38"));
                return(false);
            }
            #endregion

            return(hasSame);
        }
示例#2
0
        private void MultiChangePath_Accept_OnClick(object sender, RoutedEventArgs e)
        {
            if (MultiChangePath_Path.Text.Equals("Блоки/") | MultiChangePath_Path.Text.Equals("Чертежи/"))
            {
                ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u25"));
                MultiChangePath_Path.Focus();
                return;
            }

            var selectedItems = new List <DwgBaseItem>();

            foreach (DwgBaseItemWithSelector item in MultiChangePath_LvItems.Items)
            {
                if (item.Selected)
                {
                    selectedItems.Add(item.Item);
                }
            }

            if (!selectedItems.Any())
            {
                ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u26"));
                return;
            }

            if (!ModPlusAPI.Windows.MessageBox.ShowYesNo(
                    ModPlusAPI.Language.GetItem(LangItem, "u27"),
                    MessageBoxIcon.Question))
            {
                return;
            }

            var updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar.SetValue);
            var updatePtDelegate = new UpdateProgressTextDelegate(ProgressText.SetValue);

            ProgressBar.Minimum = 0;
            ProgressBar.Maximum = _dwgBaseItems.Count;
            ProgressBar.Value   = 0;
            var index = 1;

            foreach (var dwgBaseItem in _dwgBaseItems)
            {
                foreach (var selectedItem in selectedItems)
                {
                    if (dwgBaseItem.Equals(selectedItem))
                    {
                        dwgBaseItem.Path = MultiChangePath_Path.Text;
                    }
                }

                Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty,
                                   ModPlusAPI.Language.GetItem(LangItem, "u24") + ": " + index + "/" + _dwgBaseItems.Count);
                Dispatcher?.Invoke(updatePbDelegate, DispatcherPriority.Background,
                                   System.Windows.Controls.Primitives.RangeBase.ValueProperty, (double)index);
                index++;
            }

            // was changed
            UserBaseChanged = true;

            // save
            DwgBaseHelpers.SerializerToXml(_dwgBaseItems, _userDwgBaseFile);
            DwgBaseHelpers.DeseializeFromXml(_userDwgBaseFile, out _dwgBaseItems);
            Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, ModPlusAPI.Language.GetItem(LangItem, "u28"));
            ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u28"));

            ClearProgress();

            // refill
            MultiChangePath_FillData();
        }