Пример #1
0
        public AutoOptionsConfigWindow(AutoOptionsSettings aOSettingsParam, ExternalCommandData cDParam) : this()
        {
            aOSettings  = aOSettingsParam;
            DataContext = aOSettings;

            ////todo: this data binding doesn't work, perhaps because of reference value levels
            //System.Windows.Data.Binding warningBinding = new System.Windows.Data.Binding();
            //warningBinding.Mode = BindingMode.OneWay;
            //warningBinding.Source = selWarnOpts;
            //WarningOptionsPanel.DataContext = warningBinding;

            //System.Windows.Data.Binding errorBinding = new System.Windows.Data.Binding();
            //errorBinding.Mode = BindingMode.OneWay;
            //errorBinding.Source = selErrorOpts;
            //ErrorOptionsPanel.DataContext = errorBinding;

            //Set DataContext to null or it will be inherited from parent (set to aOSettings) till something is selected
            WarningOptionsPanel.DataContext = null;
            ErrorOptionsPanel.DataContext   = null;

            //Center the window on the main Revit window
            Autodesk.Revit.UI.Rectangle revitWindow = cDParam.Application.MainWindowExtents;
            Double centerWindowX = (revitWindow.Left + revitWindow.Right) / 2;
            Double centerWindowY = (revitWindow.Top + revitWindow.Bottom) / 2;

            Left = centerWindowX - Width / 2;
            Top  = centerWindowY - Height / 2;

            GenerateWarningsTree();
            GenerateErrorTree();
        }
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiApp    = commandData.Application;
            Application   revitApp = uiApp.Application;
            UIDocument    uiDoc    = uiApp.ActiveUIDocument;
            Document      dbDoc    = null;

            if (uiDoc != null)
            {
                dbDoc = uiDoc.Document;
            }

            IAutoOptionsRepository settingsRepo = new AutoOptionsConfigFileRepo();
            AutoOptionsSettings    aOSettings   = settingsRepo.LoadAutoOptions();

            AutoOptionsConfigWindow configWindow = new AutoOptionsConfigWindow(aOSettings, commandData);
            Boolean?saveChanges = configWindow.ShowDialog();

            if (saveChanges.Value)
            {
                aOSettings.LastUpdate = DateTime.Now;
                settingsRepo.WriteAutoOptions(aOSettings);
                //Access the dispatcher and point it to the new settings
                AutoOptionsDispatcher dispatcher = AutoOptionsDispatcher.Instance;
                dispatcher.SetOptions(aOSettings);
            }

            return(Result.Succeeded);
        }
Пример #3
0
        public void WriteAutoOptions(AutoOptionsSettings aOListParam)
        {
            XmlSerializer xmlFormat = new XmlSerializer(typeof(AutoOptionsSettings), new Type[] { typeof(AutoOptionsResolution), typeof(RevitResolution) });

            if (!Directory.Exists(FileLocations.AddInDirectory))
            {
                Directory.CreateDirectory(FileLocations.AddInDirectory);
            }

            //todo: confirm overwrite of file
            using (Stream fstream = new FileStream(configFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                xmlFormat.Serialize(fstream, aOListParam);
            }
        }
Пример #4
0
        public FailureCatcherWindow(AutoOptionsSettings aOSettings, AutoFailureHandlingOptions caughtFailOpts, UIApplication uiApp = null) : this()
        {
            DataContext = aOSettings;
            CaughtFailurePanel.DataContext = caughtFailOpts;

            //Center the window on the main Revit window. uiApp is not guaranteed to be set
            if (uiApp != null)
            {
                var    revitWindow   = uiApp.MainWindowExtents;
                Double centerWindowX = (revitWindow.Left + revitWindow.Right) / 2;
                Double centerWindowY = (revitWindow.Top + revitWindow.Bottom) / 2;
                Left = centerWindowX - Width / 2;
                Top  = centerWindowY - Height / 2;
            }
        }
Пример #5
0
        /// <summary>
        /// Updates TreeViewWarningOptions filtered for the search string
        /// </summary>
        private void GenerateWarningsTree()
        {
            TreeViewWarningOptions.Items.Clear();

            AutoOptionsSettings subList = aOSettings.GetFilteredList();

            var warningCats = subList.WarningOptions
                              .Select(x => x.BuiltInFailuresSubCategory)
                              .Distinct();

            foreach (var cat in warningCats)
            {
                Int32 itemIndex = TreeViewWarningOptions.Items.Add(new TreeViewItem()
                {
                    Header = cat
                });
                ((TreeViewItem)TreeViewWarningOptions.Items[itemIndex]).ItemsSource = subList.WarningOptions
                                                                                      .Where(x => x.BuiltInFailuresSubCategory == cat)
                                                                                      .Select(x => x.BuiltInFailuresInternalName);
            }
        }
Пример #6
0
        /// <summary>
        /// Updates TreeViewErrorOptions filtered for the search string
        /// </summary>
        private void GenerateErrorTree()
        {
            //todo: create strongly typed TreeItems
            TreeViewErrorOptions.Items.Clear();

            AutoOptionsSettings subList = aOSettings.GetFilteredList();
            var errorCats = subList.ErrorOptions
                            .Select(x => x.BuiltInFailuresSubCategory)
                            .Distinct();

            foreach (var cat in errorCats)
            {
                Int32 itemIndex = TreeViewErrorOptions.Items.Add(new TreeViewItem()
                {
                    Header = cat
                });
                ((TreeViewItem)TreeViewErrorOptions.Items[itemIndex]).ItemsSource = subList.ErrorOptions
                                                                                    .Where(x => x.BuiltInFailuresSubCategory == cat)
                                                                                    .Select(x => x.BuiltInFailuresInternalName);
            }
        }
 /// <summary>
 /// Sets the AutoOptionsSettings currently in use. The Dispatcher won't be properly initialized till this is called
 /// </summary>
 /// <param name="aOListParam"><The Settings to use/param>
 public void SetOptions(AutoOptionsSettings aOListParam)
 {
     currentSettings = aOListParam;
 }