예제 #1
0
 private void MailToClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     // Todo : Move strings to assembly attributes like version.
     try
     {
         Process.Start(string.Format("mailto:{0}", lbMailTo.Text));
     }
     catch (Exception exception)
     {
         log.LogError(exception);
         UserNotifier.ShowError(exception.Message);
     }
 }
예제 #2
0
 private void WebSiteClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     // Todo : Move strings to assembly attributes like version.
     try
     {
         Process.Start(lbWebSite.Text);
     }
     catch (Exception exception)
     {
         log.LogError(exception);
         UserNotifier.ShowError(exception.Message);
     }
 }
예제 #3
0
        public void ViewResultInSmokeView()
        {
            try
            {
                var fdsConfig = new DefaultFactory(Log).CreateFdsConfig();


                if (fdsConfig == null)
                {
                    UserNotifier.ShowWarning(Constants.PluginWasNotConfigured);
                    return;
                }

                if (string.IsNullOrEmpty(fdsConfig.PathToSmokeView))
                {
                    UserNotifier.ShowWarning(Constants.SmokeViewPathIsnotConfigured);
                    return;
                }

                var openFileDialog = new OpenFileDialog
                {
                    Multiselect = false,
                    Filter      = @"SmokeView files|*.smv",
                };

                var dialogResult = openFileDialog.ShowDialog();

                if (DialogResult.OK != dialogResult)
                {
                    return;
                }

                var smokeViewHandle = CommonHelper.StartSmokeViewProcess(fdsConfig.PathToSmokeView, openFileDialog.FileName);
                var mdiHostHandle   = NativeMethods.GetParent(new DefaultFactory(Log).GetAcadActiveWindow().Handle);

                NativeMethods.SetParent(smokeViewHandle, mdiHostHandle);
                NativeMethods.ShowWindow(smokeViewHandle, NativeMethods.SW_SHOWMAXIMIZED);
            }
            catch (System.Exception exception)
            {
                Log.LogError(exception);
                UserNotifier.ShowError(exception.Message);
            }
        }
예제 #4
0
        public void BuildFdsMenu()
        {
            try
            {
                var app       = new DefaultFactory(Log).CreateAcadApplication();
                var menuBar   = app.MenuBar;
                var menuGroup = app.MenuGroups.Item(1);
                var menus     = menuGroup.Menus;

                for (var i = 0; i < menuBar.Count; i++)
                {
                    var existingMenu = menuBar.Item(i);
                    if (existingMenu.Name == Constants.FdsMenuName)
                    {
                        return;
                    }
                }

                var fdsMenu = menus.Add(Constants.FdsMenuName);

                fdsMenu.AddMenuItem(0, Constants.RunFdsMenuItem, Constants.RunFdsCommandName);
                fdsMenu.AddMenuItem(1, Constants.RunSmokeViewMenuItem, Constants.RunSmokeViewCommandName);
                fdsMenu.AddMenuItem(2, Constants.ConvertTo3dSolidsMenuItem, Constants.ConvertTo3dSolidsCommandName);
                fdsMenu.AddMenuItem(3, Constants.OpenMaterialManagerMenuItem, Constants.OpenMaterialManagerCommandName);
                fdsMenu.AddMenuItem(4, Constants.EditMaterialsMappingsMenuItem, Constants.EditMaterialsMappingsCommandName);
                fdsMenu.AddMenuItem(5, Constants.OptionsMenuItem, Constants.OptionsCommandName);
                fdsMenu.AddMenuItem(6, Constants.AboutMenuItem, Constants.AboutCommandName);
                fdsMenu.InsertInMenuBar(menuBar.Count);
                menuGroup.Save(AcMenuFileType.acMenuFileCompiled);

                Log.LogInfo("Plugin's menu was successfully built.");
            }
            catch (COMException ex)
            {
                Log.LogError(ex);
                UserNotifier.ShowError(string.Format(Constants.MenuBuildErrorMessagePattern, ex.Message));
            }
            catch (System.Exception ex)
            {
                Log.LogError(ex);
                UserNotifier.ShowError(string.Format(Constants.MenuBuildErrorMessagePattern, ex.Message));
            }
        }
예제 #5
0
        public void RunCalculationInFds()
        {
            // Todo : Bad practice to use such kind of exception handling.
            try
            {
                #region Check if config exists

                var pluginConfig = new DefaultFactory(Log).CreateFdsConfig();

                if (pluginConfig == null)
                {
                    var fdsConfig = new PluginOptions(Log);
                    fdsConfig.ShowDialog();
                    pluginConfig = fdsConfig.PluginConfig;
                    fdsConfig.Dispose();
                    fdsConfig = null;
                }

                #endregion

                #region Collect information

                // Ask user to configure calculation
                var calculationInfo = new CalculationInfo();
                var dialogResult    = calculationInfo.ShowDialog();

                var calcTime   = calculationInfo.CalculationTime;
                var workingDir = calculationInfo.OutputPath;

                calculationInfo.Dispose();
                calculationInfo = null;

                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }

                EditMaterialsMappings();

                // get solids
                var selectedSolids = AcadInfoProvider.AskUserToSelectSolids();

                if (selectedSolids.Count < 1)
                {
                    return;
                }

                #endregion

                #region Start Calculations

                var fdsStartInfo = new FdsStartInfo
                {
                    // Arguments = string.Concat("\"", pathToFile, "\""),
                    CalculationTime  = calcTime,
                    DocumentName     = AcadInfoProvider.GetDocumentName(),
                    PathToFds        = pluginConfig.PathToFds,
                    SelectedSolids   = selectedSolids,
                    UsedSurfaces     = CommonHelper.GetAllUsedSurfaces(Log),
                    WorkingDirectory = workingDir
                };

                var progressWindow     = new ConversionProgress(fdsStartInfo.SelectedSolids.Count);
                var calculationManager = new ThreadedCalculationManager(fdsStartInfo, Log, progressWindow);
                progressWindow.Shown += (s, e) => calculationManager.WaitEvent.Set();
                calculationManager.StartCalculation();

                progressWindow.ShowDialog();
                progressWindow.Dispose();
                progressWindow = null;

                #endregion
            }
            catch (System.Exception exception)
            {
                Log.LogError(exception);
                UserNotifier.ShowError(exception.Message);
            }
        }