Exemple #1
0
        public void Execute(UIApplication uiapp)
        {
            Document    doc   = uiapp.ActiveUIDocument.Document;
            Application app   = uiapp.Application;
            UIDocument  uidoc = uiapp.ActiveUIDocument;

            Selection choices = uidoc.Selection;

            IList <Element> pickedElements = uidoc.Selection.PickElementsByRectangle("Select by rectangle");

            if (pickedElements.Count > 0)
            {
                // Collect Ids of all picked elements
                IList <ElementId> idsToSelect = new List <ElementId>(pickedElements.Count);
                foreach (Element element in pickedElements)
                {
                    idsToSelect.Add(element.Id);
                }

                // Update the current selection
                uidoc.Selection.SetElementIds(idsToSelect);
                TaskDialog.Show("Revit", string.Format("{0} elements added to Selection.", idsToSelect.Count));
                ModelessForm ModelessForm = new ModelessForm();
                ModelessForm.Show();
            }
        }
Exemple #2
0
        /// <summary>
        ///   Riempie le ComboBoxes
        /// </summary>
        ///
        public void FillTheComboBoxes(List <string> stringList)
        {
            foreach (string item in stringList)
            {
                typologieCodeComboBox.Items.Add(item);
                cellCodeComboBox.Items.Add(item);
                positionalCodeComboBox.Items.Add(item);
            }

            // Assegna al Text delle ComboBox il valore attivo, se presente
            _modelessForm   = App.thisApp.RetriveForm();
            _typologieCode  = _modelessForm.TypologieCode;
            _cellCode       = _modelessForm.CellCode;
            _positionalCode = _modelessForm.PositionalCode;

            // Verifica che il valore contenuto nei codici sia uno dei parametri
            foreach (string param in stringList)
            {
                if (_typologieCode == param)
                {
                    typologieCodeComboBox.Text = _typologieCode;
                }
                if (_cellCode == param)
                {
                    cellCodeComboBox.Text = _cellCode;
                }
                if (_positionalCode == param)
                {
                    positionalCodeComboBox.Text = _positionalCode;
                }
            }
        }
Exemple #3
0
        public void taskDialog(UIDocument uidoc)
        {
            ModelessForm ModelessForm = new ModelessForm();

            ModelessForm.Show();

            return;
        }
        /// <summary>
        ///   Salva il nuovo valore nel progetto
        /// </summary>
        ///
        private void saveButton_Click(object sender, EventArgs e)
        {
            _newProjectName = insertNameProjectTextBox.Text;

            // Chiama il metodo che imposta il nuovo nome del Progetto
            _modelessForm = App.thisApp.RetriveForm();
            _modelessForm.MakeRequest(RequestId.SetProjectName);
        }
Exemple #5
0
        /// <summary>
        ///   Salva le modifiche effettuate
        /// </summary>
        ///
        private void saveButton_Click(object sender, EventArgs e)
        {
            _typologieCode  = typologieCodeComboBox.SelectedItem as string;
            _cellCode       = cellCodeComboBox.SelectedItem as string;
            _positionalCode = positionalCodeComboBox.SelectedItem as string;

            // Chiama il metodo che implementa i cambiamenti
            _modelessForm = App.thisApp.RetriveForm();
            _modelessForm.GoToChanges();

            // Salva i cambiamenti nel File di configurazione
            SavesCodesInJson();
        }
Exemple #6
0
        /// <summary>
        ///   Salva i nuovi codici nel file .json di Configurazione
        /// </summary>
        ///
        private void SavesCodesInJson()
        {
            _modelessForm = App.thisApp.RetriveForm();
            string pathExcel = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
                               _modelessForm.PathFileConfig;

            if (File.Exists(pathExcel))
            {
                // Scrive i codici in un file esterno Json di Configurazione
                Json fileJson = new Json();
                fileJson.UpdateJson(5, 4, "TypologieCode", _typologieCode);
                fileJson.UpdateJson(6, 5, "CellCode", _cellCode);
                fileJson.UpdateJson(7, 6, "PositionalCode", _positionalCode);

                // Ottiene il _pathconfig del foglio Excel
                string       jsonText        = File.ReadAllText(ModelessForm.thisModForm.PathFileTxt);
                IList <Data> traduction      = JsonConvert.DeserializeObject <IList <Data> >(jsonText);
                Data         singleItem      = traduction.FirstOrDefault(x => x.Id == 1);
                string       pathExcelConfig = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + singleItem.Value;

                // Esporta le modifiche su foglio Excel, del pathDataCell, di AbacoCells.xlsm e di Images
                exportValueToExcel.KillExcel();
                _colValue = 6;
                exportValueToExcel.ExportExcelAndChangeValue(pathExcelConfig, _typologieCode, _cellCode, _positionalCode, _rawCommessa, _colValue);

                // Chiude la Form
                this.Close();

                // Avvisa che per far funziona reil DataCell bisogna riaccenderlo
                MessageBox.Show("Hai concluso correttamente la Configurazione. " +
                                "\nRientra cliccando nuovamente sul Plugin DataQuery che trovi nel Pannello BOLD");

                // Chiude il DataCell
                ModelessForm.thisModForm.Close();
            }
        }
 /// <summary>
 ///   Cancella le modifiche
 /// </summary>
 ///
 private void cancelButton_Click(object sender, EventArgs e)
 {
     // Chiama il metodo che chiude questa Form e riattiva la Form
     _modelessForm = App.thisApp.RetriveForm();
     _modelessForm.CloseSetProjectName();
 }
 /// <summary>
 ///   Ottiene il valore salvato nel nome del Progetto
 /// </summary>
 ///
 private void GetProjectName()
 {
     // Chiama il metodo che ottine il nome salvato nel Progetto
     _modelessForm = App.thisApp.RetriveForm();
     _modelessForm.MakeRequest(RequestId.ProjectName);
 }
        /// <summary>
        ///   Pulsante di modifica del Path di configurazione
        /// </summary>
        ///
        private void configInitialButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Ottiene il nuovo Path del File di configurazione
                    _pathConfig = openFileDialog1.FileName;

                    if (!_pathConfig.Contains("BOLD Software\\Config\\Config.xlsx"))
                    {
                        MessageBox.Show("Non hai scelto il file corretto.\n" +
                                        "Inserisci nuovamente il nome del file, ricordandoti che abbia questo percorso: \"...BOLD Software\\Config.xlsx\"");
                    }
                    else
                    {
                        // Lo scrive in un file esterno
                        //System.IO.File.WriteAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\BOLD Software\Config\ConfigPath.txt", _pathConfig);

                        // Lo scrive in un file esterno Json
                        Json   fileJson     = new Json();
                        string pathReplaced = _pathConfig.Replace(Environment.GetFolderPath(
                                                                      Environment.SpecialFolder.MyDocuments), "");
                        fileJson.UpdateJson(1, 0, "ConfigPath", pathReplaced);

                        // Chiude questo pannello
                        modelessForm = App.thisApp.RetriveForm();
                        modelessForm.CloseConfigPanel();

                        // legge il file .json
                        string pathFileTxt = ModelessForm.thisModForm.PathFileTxt;
                        string jsonText    = File.ReadAllText(pathFileTxt);
                        var    traduction  = JsonConvert.DeserializeObject <IList <Data> >(jsonText);

                        if (traduction.Any(x => x.Id == 2))
                        {
                            Data singleItem = traduction.FirstOrDefault(x => x.Id == 2);
                            if (!Directory.Exists(singleItem.Value))
                            {
                                // Apre il pannello DataCellPaths
                                ShowDataCellPaths();
                            }
                            else
                            {
                                // Ottiene il path di DataCell
                                Data itemDataCell = traduction.FirstOrDefault(x => x.Id == 2);
                                _pathDataCell = itemDataCell.Value;

                                // Ottiene il path di AbacoCells
                                Data itemAbacoCells = traduction.FirstOrDefault(x => x.Id == 3);
                                _pathConfig = itemAbacoCells.Value;

                                // Ottiene i path di AbacoCells.xlsm e di Images
                                exportValueToExcel.ExportExcelAndChangeValue(_pathConfig, _pathDataCell, "", "", _rawCommessa, _colDataCell);

                                // Chiude la Form
                                this.Close();

                                // Avvisa che per far funziona reil DataCell bisogna riaccenderlo
                                MessageBox.Show("Hai concluso correttamente la Configurazione. " +
                                                "\nRientra cliccando nuovamente sul Plugin DataQuery che trovi nel Pannello BOLD");

                                // Chiude il DataCell
                                ModelessForm.thisModForm.Close();
                            }
                        }
                        else
                        {
                            // Apre il pannello DataCellPaths
                            ShowDataCellPaths();
                        }
                    }
                }
                catch (SecurityException ex)
                {
                    MessageBox.Show($"Security error.\n\nError message: {ex.Message}\n\n" +
                                    $"Details:\n\n{ex.StackTrace}");
                }
            }
        }