Exemplo n.º 1
0
        public ParamsView AddTool()
        {
            var toolProp      = _type.GetProperty("Tool");
            var machineProp   = _type.GetProperty("MachineType");
            var materialProp  = _type.GetProperty("Material");
            var frequencyProp = _type.GetProperty("Frequency");

            var selector = CreateSelector("Инструмент", "Ξ");

            var textBox = selector.Controls[0];

            BindingSource.DataSourceChanged += (s, e) => textBox.Text = toolProp.GetValue(ParamsObject)?.ToString();

            var button = selector.Controls[1];

            button.Click += (s, e) =>
            {
                var machine  = (MachineType?)machineProp.GetValue(ParamsObject);
                var material = (Material?)materialProp.GetValue(ParamsObject);
                if (!machine.CheckNotNull("Станок") || !material.CheckNotNull("Материал"))
                {
                    return;
                }
                if (ToolService.SelectTool(machine.Value) is Tool tool)
                {
                    toolProp.SetValue(ParamsObject, tool);
                    textBox.Text = tool.ToString();
                    frequencyProp.SetValue(ParamsObject, ToolService.CalcFrequency(tool, machine.Value, material.Value));

                    BindingSource.ResetBindings(false);
                }
            };
            return(this);
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            Acad.Write($"Инициализация плагина. Версия сборки от {File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location)}");

            _settings = Settings.Load();

            _machineSettings    = _settings.MachineSettings.ToDictionary(p => p.MachineType);
            _techProcessFactory = new TechProcessFactory(_settings);

            ToolService.SetMachineSettings(_machineSettings);
            ToolService.AddMachineTools(MachineType.ScemaLogic, _settings.ToolsScemaLogic);
            ToolService.AddMachineTools(MachineType.Donatoni, _settings.ToolsDonatoni);
            ToolService.AddMachineTools(MachineType.Krea, _settings.ToolsKrea);

            _camPaletteSet = new CamPaletteSet();

            //var manager = new CamManager();

            //PaletteSet paletteSet = new PaletteSet("Технология")
            //{
            //    Style = PaletteSetStyles.NameEditable | PaletteSetStyles.ShowPropertiesMenu | PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton,
            //    MinimumSize = new Size(300, 200),
            //    KeepFocus = true,
            //    Visible = true
            //};
            //paletteSet.Add("Объекты", new TechProcessView(manager));
            //var programView = new ProgramView(manager);
            //var programmPalette = paletteSet.Add("Программа", programView);
            //paletteSet.PaletteActivated += (sender, args) =>
            //{
            //    if (args.Activated.Name == "Программа")
            //        programView.SetProgram(manager.GetProgramm());
            //};

            Application.DocumentManager.DocumentActivated += (sender, args) => SetActiveDocument(args.Document);

            SetActiveDocument(Acad.ActiveDocument);

            //PaletteSet focus use Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
            //AutocadUtils.AddPaletteSet("Настройки", SettingForm);
            //machine.ChangeActionsCount += (sender, args) => ObjectForm.ShowProgress(String.Format("Генерация обработки... {0} строк", args.Data));
        }