示例#1
0
        private void RunCommand(string helpTopic,
                                Action <SolutionInfo> command,
                                TaskScheduler taskScheduler = null)
        {
            PaketOutputPane.OutputPane.Activate();
            taskScheduler = taskScheduler ?? TaskScheduler.Default;
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");
            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, tracker.GetSelectedFileName(), helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }, CancellationToken.None, TaskCreationOptions.None, taskScheduler);
            System.Threading.Tasks.Task.Run(() =>
            {
            });
        }
示例#2
0
        private void ApplyViewOrientationAndVisibility(UIDocument uiDocument, View3D view, Camera camera)
        {
            using var trans = new Transaction(uiDocument.Document);
            if (trans.Start($"Apply view orientation and visibility in '{view.Name}'") != TransactionStatus.Started)
            {
                return;
            }

            StatusBarService.SetStatusText("Loading view point data ...");
            Log.Information("Calculating view orientation from camera position ...");
            ProjectPosition projectPosition   = uiDocument.Document.ActiveProjectLocation.GetProjectPosition(XYZ.Zero);
            var             viewOrientation3D = RevitUtils.TransformCameraPosition(
                new ProjectPositionWrapper(projectPosition),
                camera.Position.ToInternalUnits(),
                true)
                                                .ToViewOrientation3D();

            if (camera.Type == CameraType.Perspective)
            {
                Log.Information("Setting active far viewer bound to zero ...");
                Parameter farClip = view.get_Parameter(BuiltInParameter.VIEWER_BOUND_ACTIVE_FAR);
                if (farClip.HasValue)
                {
                    farClip.Set(0);
                }
            }

            Log.Information("Applying new view orientation ...");
            view.SetOrientation(viewOrientation3D);

            Log.Information("Applying element visibility ...");
            var currentlyVisibleElements = uiDocument.Document.GetVisibleElementsOfView(view);
            var map = uiDocument.Document.GetIfcGuidElementIdMap(currentlyVisibleElements);
            var exceptionElements = GetViewpointVisibilityExceptions(map);
            var selectedElements  = GetViewpointSelection(map);

            if (exceptionElements.Any())
            {
                if (_bcfViewpoint.GetVisibilityDefault())
                {
                    view.HideElementsTemporary(exceptionElements);
                    selectedElements = selectedElements.Where(id => !exceptionElements.Contains(id)).ToList();
                }
                else
                {
                    view.IsolateElementsTemporary(exceptionElements);
                    selectedElements = selectedElements.Where(id => exceptionElements.Contains(id)).ToList();
                }
            }

            view.ConvertTemporaryHideIsolateToPermanent();

            if (selectedElements.Any())
            {
                Log.Information("Select {n} elements ...", selectedElements.Count);
                uiDocument.Selection.SetElementIds(selectedElements);
            }

            trans.Commit();
        }
示例#3
0
 /// <summary>
 /// Starts to run a build inside the SharpDevelop GUI.
 /// Only one build can run inside the GUI at one time.
 /// </summary>
 /// <param name="project">The project/solution to build.</param>
 /// <param name="options">The build options.</param>
 public static void BuildInGui(IBuildable project, BuildOptions options)
 {
     if (project == null)
     {
         throw new ArgumentNullException("project");
     }
     if (options == null)
     {
         throw new ArgumentNullException("options");
     }
     WorkbenchSingleton.AssertMainThread();
     if (guiBuildProgressMonitor != null)
     {
         BuildResults results = new BuildResults();
         results.Add(new BuildError(null, Core.ResourceService.GetString("MainWindow.CompilerMessages.MSBuildAlreadyRunning")));
         results.Result = BuildResultCode.MSBuildAlreadyRunning;
         if (options.Callback != null)
         {
             options.Callback(results);
         }
     }
     else
     {
         guiBuildProgressMonitor = new CancellableProgressMonitor(StatusBarService.CreateProgressMonitor());
         Gui.WorkbenchSingleton.Workbench.GetPad(typeof(Gui.CompilerMessageView)).BringPadToFront();
         GuiBuildStarted.RaiseEvent(null, new BuildEventArgs(project, options));
         StartBuild(project, options,
                    new MessageViewSink(TaskService.BuildMessageViewCategory),
                    guiBuildProgressMonitor);
     }
 }
示例#4
0
        private void AddPackageToProject(object sender, EventArgs e)
        {
            var helpTopic = "paket-add.html#Adding-to-a-single-project";

            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();

            var projectFileName = tracker.GetSelectedFileName();

            StatusBarService.UpdateText("Add NuGet package to " + projectFileName);

            var projectGuid = tracker.GetSelectedProjectGuid();

            SolutionExplorerExtensions.SaveSolution();

            try
            {
                AddPackageProcess.ShowAddPackageDialog(projectFileName, projectGuid.ToString());

                PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                StatusBarService.UpdateText("Ready");
            }
            catch (Exception ex)
            {
                SolutionExplorerExtensions.ReloadProject(projectGuid);
                PaketErrorPane.ShowError(ex.Message, projectFileName, helpTopic);
                PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
            }
        }
示例#5
0
        public void LoadOrCreateReport()
        {
            //string baseClassName = String.Empty;

            Application.UseWaitCursor = true;
            Application.DoEvents();
            try {
                IComponent cc = this.host.CreateComponent(typeof(ICSharpCode.Reports.Addin.RootReportModel), "RootReportModel");
                ICSharpCode.Reports.Addin.RootReportModel rootControl = cc as ICSharpCode.Reports.Addin.RootReportModel;

                string message;
                if (this.generator.ViewContent.PrimaryFile.IsDirty)
                {
                    message = String.Format("Create Report + {0} ...", Path.GetFileName(this.generator.ViewContent.PrimaryFile.FileName));
                }
                else
                {
                    message = String.Format("Load  Report + {0} ...", Path.GetFileName(this.generator.ViewContent.PrimaryFile.FileName));
                }
                StatusBarService.SetMessage(message);
                this.CreateNamedSurface();
                UnitConverter pageWidth  = new UnitConverter(iTextSharp.text.PageSize.A4.Width, XGraphicsUnit.Point);
                UnitConverter pageHeight = new UnitConverter(iTextSharp.text.PageSize.A4.Height + (this.reportModel.SectionCollection.Count + 1) * GlobalsDesigner.GabBetweenSection
                                                             , XGraphicsUnit.Point);
                rootControl.Size = new System.Drawing.Size((int)pageWidth.Pixel, (int)pageHeight.Pixel);
            } catch (Exception e) {
                System.Console.WriteLine(e.Message);
            } finally {
                StatusBarService.SetMessage(String.Empty);
                Application.UseWaitCursor = false;
            }
        }
        /// <summary>
        /// 通知当前的字符值;
        /// </summary>
        /// <param name="hexContext"></param>
        private static void ShowChar(IHexDataContext hexContext)
        {
            var curCharValueItem = StatusBarService.Current.GetOrCreateStatusBarTextItem(Constants.StatusBarItemGUID_CurCharValue, _curCharValueChildLength, 8);

            if (curCharValueItem == null)
            {
                return;
            }

            try {
                var stream = hexContext.Stream;
                if (stream == null)
                {
                    LoggerService.WriteCallerLine($"{nameof(stream)} can't be null.");
                    return;
                }

                stream.Position = hexContext.FocusPosition;
                StatusBarService.Report(
                    $"{LanguageService.FindResourceString(Constants.StatusBarItemText_CurCharValue)} {stream.ReadByte()}",
                    Constants.StatusBarItemGUID_CurCharValue);
            }
            catch (Exception ex) {
                LoggerService.WriteCallerLine(ex.Message);
            }
        }
示例#7
0
        public static void InitializeWorkbench()
        {
            LayoutConfiguration.LoadLayoutConfiguration();
            StatusBarService.Initialize();
            DomHostCallback.Register();             // must be called after StatusBarService.Initialize()
            ParserService.InitializeParserService();
            Project.CustomToolsService.Initialize();

            workbench = new DefaultWorkbench();
#endif
            MessageService.MainForm = workbench;

            PropertyService.PropertyChanged += new PropertyChangedEventHandler(TrackPropertyChanges);
            ResourceService.LanguageChanged += delegate { workbench.RedrawAllComponents(); };

            caller = new STAThreadCaller(workbench);

            workbench.InitializeWorkspace();

            workbench.SetMemento(PropertyService.Get(workbenchMemento, new Properties()));

            workbench.WorkbenchLayout = new SdiWorkbenchLayout();

            OnWorkbenchCreated();
        }
示例#8
0
        public void RedrawAllComponents()
        {
            RightToLeftConverter.ConvertRecursive(this);

            foreach (ToolStripItem item in TopMenu.Items)
            {
                if (item is IStatusUpdate)
                {
                    ((IStatusUpdate)item).UpdateText();
                }
            }

            foreach (IViewContent content in workbenchContentCollection)
            {
                content.RedrawContent();
                if (content.WorkbenchWindow != null)
                {
                    content.WorkbenchWindow.RedrawContent();
                }
            }

            foreach (PadDescriptor content in viewContentCollection)
            {
                content.RedrawContent();
            }

            if (layout != null)
            {
                layout.RedrawAllComponents();
            }

            StatusBarService.RedrawStatusbar();
        }
示例#9
0
        public override void OnPostCreate(Bundle savedInstanceState, PersistableBundle persistentState)
        {
            base.OnPostCreate(savedInstanceState, persistentState);

            var _  = new StatusBarService();
            var __ = new NotificationService();
        }
示例#10
0
            /// <summary>
            /// Find available work and run it on the specified worker.
            /// </summary>
            bool RunWorkerInternal(MSBuildEngineWorker worker)
            {
                ProjectToBuild nextFreeProject = null;

                lock (projectsToBuild) {
                    foreach (ProjectToBuild ptb in projectsToBuild)
                    {
                        if (ptb.buildStarted == false && ptb.DependenciesSatisfied())
                        {
                            if (nextFreeProject == null)
                            {
                                nextFreeProject = ptb;

                                // all workers busy, don't look if there is more work available
                                if (workerCount == maxWorkerCount)
                                {
                                    break;
                                }
                            }
                            else
                            {
                                // free workers available + additional work available:
                                // start a new worker
                                LoggingService.Debug("Starting a new worker");
                                workerCount++;
                                Thread thread = new Thread(RunWorkerBuild);
                                thread.Name = "MSBuildEngine worker " + (++lastUniqueWorkerID);
                                thread.SetApartmentState(ApartmentState.STA);
                                thread.Start();

                                // start at most one additional worker, the new worker can
                                // start more threads if desired
                                break;
                            }
                        }
                    }
                    if (nextFreeProject == null)
                    {
                        // nothing to do for this worker thread
                        return(false);
                    }
                    // now build nextFreeProject
                    nextFreeProject.buildStarted = true;
                }                 // end lock

                StatusBarService.SetMessage("${res:MainWindow.CompilerMessages.BuildVerb} " + Path.GetFileNameWithoutExtension(nextFreeProject.file) + "...");

                // run the build:
                if (worker.Build(nextFreeProject))
                {
                    // build successful: mark it as finished
                    lock (projectsToBuild) {
                        nextFreeProject.buildFinished = true;
                    }
                }
                return(true);
            }
示例#11
0
        public static void InitializeWorkbench(System.Type workbenchtype)
        {
            LayoutConfiguration.LoadLayoutConfiguration();
            StatusBarService.Initialize();
            DomHostCallback.Register();             // must be called after StatusBarService.Initialize()
            ParserService.InitializeParserService();
            Project.CustomToolsService.Initialize();

            workbench = (ICSharpCode.SharpDevelop.Gui.DefaultWorkbench)Activator.CreateInstance(workbenchtype);
        void CaretChanged(object sender, EventArgs e)
        {
            TextAreaControl activeTextAreaControl = textEditorControl.ActiveTextAreaControl;
            int             line = activeTextAreaControl.Caret.Line;
            int             col  = activeTextAreaControl.Caret.Column;

            StatusBarService.SetCaretPosition(activeTextAreaControl.TextArea.TextView.GetVisualColumn(line, col) + 1, line + 1, col + 1);
            NavigationService.Log(this.BuildNavPoint());
        }
示例#13
0
        private void OnMouseOver(object sender, HtmlElementEventArgs e)
        {
            HtmlElement link = sender as HtmlElement;

            if (link != null)
            {
                StatusBarService.SetMessage(link.GetAttribute("src"));
            }
        }
示例#14
0
        public static void SaveSolution()
        {
            if (DteUtils.DTE.Solution.IsDirty)
            {
                StatusBarService.UpdateText("Saving the current solution...");

                IVsSolution solution = _serviceProvider.GetService(typeof(Microsoft.VisualStudio.Shell.Interop.SVsSolution)) as IVsSolution;
                solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, null, 0);
            }
        }
示例#15
0
        /// <summary>
        /// Zoom the view to the correct scale, if necessary.
        /// </summary>
        /// <remarks>In Revit, orthogonal views do not change their camera positions, when zooming in or out. Hence,
        /// the values stored in the BCF viewpoint are not sufficient to restore the previously exported viewpoint.
        /// In order to get correct zooming, the scale value (view box height) is used, to calculate the correct zoom
        /// corners according to view center.
        /// See https://thebuildingcoder.typepad.com/blog/2020/10/save-and-restore-3d-view-camera-settings.html
        /// </remarks>
        private static void ZoomIfNeeded(UIApplication app, Camera camera, ElementId viewId)
        {
            if (camera.Type != CameraType.Orthogonal || camera is not OrthogonalCamera orthoCam)
            {
                return;
            }

            Log.Information("Found orthogonal camera, setting zoom callback ...");
            StatusBarService.SetStatusText("Waiting for view to render to apply zoom ...");
            AppIdlingCallbackListener.SetPendingZoomChangedCallback(app, viewId, orthoCam.ViewToWorldScale);
        }
示例#16
0
        private void RunCommandOnPackageAndReloadAllDependendProjects(string helpTopic, Action <PackageInfo> command)
        {
            var node = tracker.SelectedGraphNode;

            if (node == null || !node.HasCategory(PaketGraphSchema.PaketCategory))
            {
                return;
            }

            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new PackageInfo();

            info.DependenciesFileName = node.Id.GetFileName();
            info.PackageName          = node.GetPackageName();
            info.GroupName            = node.GetGroupName();

            var projectGuids =
                Dependencies.Locate(info.DependenciesFileName)
                .FindProjectsFor(info.GroupName, info.PackageName)
                .Select(project => project.GetProjectGuid())
                .ToArray();

            SolutionExplorerExtensions.SaveSolution();
            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.DependenciesFileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }
示例#17
0
        public void SetStatusMessage(string indexTerm)
        {
            string text = StringParser.Parse("${res:AddIns.HtmlHelp2.ResultsOfSearchResults}",
                                             new string[, ]
            {
                { "0", indexTerm },
                { "1", listView.Items.Count.ToString(CultureInfo.InvariantCulture) },
                { "2", (listView.Items.Count == 1)?"${res:AddIns.HtmlHelp2.SingleTopic}":"${res:AddIns.HtmlHelp2.MultiTopic}" }
            }
                                             );

            StatusBarService.SetMessage(text);
        }
示例#18
0
        public static void InitializeWorkbench(IWorkbench workbench, IWorkbenchLayout layout)
        {
            WorkbenchSingleton.workbench = workbench;

            //DisplayBindingService.InitializeService();
            LayoutConfiguration.LoadLayoutConfiguration();
            //FileService.InitializeService();
            StatusBarService.Initialize();
            //DomHostCallback.Register(); // must be called after StatusBarService.Initialize()
            ParserService.InitializeParserService();
            //Bookmarks.BookmarkManager.Initialize();
            //Project.CustomToolsService.Initialize();
            //Project.BuildModifiedProjectsOnlyService.Initialize();

            workbench.Initialize();
            workbench.SetMemento(PropertyService.Get(workbenchMemento, new Core.Properties()));

            caller = new STAThreadCaller(workbench.MainForm);
            WinFormsMessageService.DialogOwner             = workbench.MainForm;
            WinFormsMessageService.DialogSynchronizeInvoke = workbench.MainForm;

            //RemoveXButton(WorkbenchSingleton.MainForm.Handle.ToInt32());
            PropertyService.PropertyChanged += new PropertyChangedEventHandler(TrackPropertyChanges);
            ResourceService.LanguageChanged += delegate { workbench.RedrawAllComponents(); };

            ApplicationStateInfoService.RegisterStateGetter(activeContentState, delegate { return(WorkbenchSingleton.Workbench.ActiveContent); });

            // attach workbench layout -> load pads
            workbench.WorkbenchLayout = layout;

            OnWorkbenchCreated();

            // initialize workbench-dependent services:
//            Project.ProjectService.InitializeService();
            NavigationService.InitializeService();

            workbench.ActiveContentChanged += delegate
            {
                LoggingService.Debug("ActiveContentChanged to " + workbench.ActiveContent);
            };
            workbench.ActiveViewContentChanged += delegate
            {
                LoggingService.Debug("ActiveViewContentChanged to " + workbench.ActiveViewContent);
            };
            workbench.ActiveWorkbenchWindowChanged += delegate
            {
                LoggingService.Debug("ActiveWorkbenchWindowChanged to " + workbench.ActiveWorkbenchWindow);
            };
        }
示例#19
0
        private void RunCommandAndReloadAllProjects(string helpTopic, Action <SolutionInfo> command)
        {
            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

            SolutionExplorerExtensions.SaveSolution();

            // https://github.com/fsprojects/Paket.VisualStudio/issues/84
            // explicitly save unsaved projects
            foreach (var project in SolutionExplorerExtensions.GetAllProjects().Where(p => false == p.Saved))
            {
                project.Save();
            }

            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.FileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }
示例#20
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //对登陆界面的帐号密码进行判断并对XML 进行重新配置
            if (CheckData(this.txtUserName.Text.Trim(), this.txtPassword.Text.Trim()))
            {
                try
                {
                    CallRemotingService.SelectServerSite(site);
                    DataSet   ds        = new DataSet();
                    DataTable dataTable = CreateUserTable();//创建一张自定义结构的表
                    Dictionary <string, string> rowData = new Dictionary <string, string>()
                    {
                        { RBAC_USER_FIELDS.FIELD_USERNAME, txtUserName.Text.Trim() }
                    };
                    FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref dataTable, rowData); //把rowData中的数据添加在表dataTable中
                    ds.Tables.Add(dataTable);                                                       //把表dataTable添加到表集ds中
                    DataSet dataUser = new DataSet();

                    IServerObjFactory isof       = CallRemotingService.GetRemoteObject();//创建工厂接口对象
                    IUserEngine       userEngine = isof.CreateIUserEngine();

                    dataUser = userEngine.CheckUser(ds); //通过传入的帐号查询返回该帐号对应的信息

                    if (CheckUser(dataUser))             //数据库信息和用户信息进行对比返回bool类型
                    {
                        UpdateLanguageInfo();
                        UpdateServerSitList();
                        //对登录用户的信息进行登记
                        UpdateLoginUserInfo();

                        DialogResult = DialogResult.OK;
                        this.Close();
                        StatusBarService.SetCaretPosition(30, 70, 0);
                    }
                }
                catch (Exception ex)
                {
                    MessageService.ShowMessage(ex.Message);
                }
                finally
                {
                    CallRemotingService.UnregisterChannel();
                }
            }
            Xmlproper();
        }
示例#21
0
        /// <summary>
        /// 画布当前鼠标位置发生变化时,通知状态栏;
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CanvasDataContext_CurrentMousePositionChanged(ICanvasDataContext canvasDataContext)
        {
            var currentPosition = CanvasService.CanvasDataContext.CurrentMousePosition;

            if (currentPosition == null)
            {
                return;
            }

            StatusBarService.Report(
                LanguageService.TryGetStringWithFormat(
                    Constants.LanguageFormat_CurrentMousePosition,
                    currentPosition.X.ToString("F4"),
                    currentPosition.Y.ToString("F4")
                    )
                );
        }
        private void RefreshFilesCount(IFolderBrowserDataContext dataContext)
        {
            if (dataContext == null)
            {
                return;
            }
            var vm = dataContext.FolderBrowserViewModel;

            if (vm == null)
            {
                return;
            }

            long fileCount    = 0;
            long regFileCount = 0;
            long dirCount     = 0;

            try {
                foreach (var file in vm.FileRows)
                {
                    if (file.File is IRegularFile)
                    {
                        regFileCount++;
                    }
                    else if (file.File is IDirectory)
                    {
                        dirCount++;
                    }
                    fileCount++;
                }

                ThreadInvoker.UIInvoke(() => {
                    var fileCountItem    = StatusBarService.GetOrCreateStatusBarTextItem(Constants.StatusBarItemText_FileCount, GridChildLength.Auto, 5);
                    var regFileCountItem = StatusBarService.GetOrCreateStatusBarTextItem(Constants.StatusBarItemGUID_RegFileCount, GridChildLength.Auto, 6);
                    var dirCountItem     = StatusBarService.GetOrCreateStatusBarTextItem(Constants.StatusBarItemGUID_DirectoryCount, GridChildLength.Auto, 7);

                    fileCountItem.Text    = $"{LanguageService.FindResourceString(Constants.StatusBarItemText_FileCount)} {fileCount}";
                    regFileCountItem.Text = $"{LanguageService.FindResourceString(Constants.StatusBarItemText_RegFileCount)} {regFileCount}";
                    dirCountItem.Text     = $"{LanguageService.FindResourceString(Constants.StatusBarItemText_DirectoryCount)} {dirCount}";
                });
            }
            catch (Exception ex) {
                LoggerService.WriteCallerLine(ex.Message);
            }
        }
        /// <summary>
        /// Sets a callback that applies a zoom to the current view.
        /// </summary>
        /// <param name="app">The current UI application.</param>
        /// <param name="viewId">The view ID for the view to be zoomed.</param>
        /// <param name="zoom">The zoom in decimal precision.</param>
        public static void SetPendingZoomChangedCallback(UIApplication app, ElementId viewId, decimal zoom)
        {
            void Callback(object sender, IdlingEventArgs args)
            {
                StatusBarService.SetStatusText("Zooming to scale '" + zoom + "' ...");
                UIView currentView = app.ActiveUIDocument.GetOpenUIViews().First();

                if (currentView.ViewId != viewId)
                {
                    return;
                }

                UIDocument uiDoc      = app.ActiveUIDocument;
                View       activeView = uiDoc.ActiveView;

                var zoomCorners = currentView.GetZoomCorners();
                XYZ bottomLeft  = zoomCorners[0];
                XYZ topRight    = zoomCorners[1];

                var(currentHeight, currentWidth) =
                    RevitUtils.ConvertToViewBoxValues(topRight, bottomLeft, activeView.RightDirection);

                var zoomedViewBoxHeight = Convert.ToDouble(zoom).ToInternalRevitUnit();
                var zoomedViewBoxWidth  = zoomedViewBoxHeight * currentWidth / currentHeight;

                XYZ newTopRight = activeView.Origin
                                  .Add(activeView.UpDirection.Multiply(zoomedViewBoxHeight / 2))
                                  .Add(activeView.RightDirection.Multiply(zoomedViewBoxWidth / 2));
                XYZ newBottomLeft = activeView.Origin
                                    .Subtract(activeView.UpDirection.Multiply(zoomedViewBoxHeight / 2))
                                    .Subtract(activeView.RightDirection.Multiply(zoomedViewBoxWidth / 2));

                Log.Information("Zoom to {topRight} | {bottomLeft} ...", newTopRight.ToString(), newBottomLeft.ToString());
                currentView.ZoomAndCenterRectangle(newTopRight, newBottomLeft);

                StatusBarService.ResetStatusBarText();
                Log.Information("Finished applying zoom for orthogonal view.");
                app.Idling -= Callback;
            }

            Log.Information("Append zoom callback for orthogonal view to idle state of Revit application ...");
            app.Idling += Callback;
        }
示例#24
0
        void WebBrowserStatusTextChanged(object sender, EventArgs e)
        {
            IWorkbenchWindow workbench = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;

            if (workbench == null)
            {
                return;
            }
            BrowserPane browser = workbench.ActiveViewContent as BrowserPane;

            if (browser == null)
            {
                return;
            }
            if (browser.HtmlViewPane == this)
            {
                StatusBarService.SetMessage(webBrowser.StatusText);
            }
        }
示例#25
0
        /// <summary>
        /// Asks the user for a file name for the current project, and then saves the project under the given name.
        /// </summary>
        public void SaveProjectAs()
        {
            SaveFileDialog fdiag = new SaveFileDialog();

            fdiag.OverwritePrompt = true;
            fdiag.AddExtension    = true;


            fdiag.Filter = StringParser.Parse("${res:Altaxo.FileFilter.ProjectFiles}|*.axoprj|${res:Altaxo.FileFilter.AllFiles}|*.*");

            if (fdiag.ShowDialog() == DialogResult.OK)
            {
                string filename = fdiag.FileName;
                SaveProject(filename);
                FileService.RecentOpen.AddLastProject(filename);
                StatusBarService.SetMessage(filename + ": " + ResourceService.GetString("Altaxo.Project.ProjectSavedMessage"));
                //MessageService.ShowMessage(filename, ResourceService.GetString("Altaxo.Project.ProjectSavedMessage"));
            }
        }
        /// <summary>
        /// 通知位置;
        /// </summary>
        /// <param name="hexContext"></param>
        private static void NotifyPosition(IHexDataContext hexContext)
        {
            var positionItem = StatusBarService.Current.GetOrCreateStatusBarTextItem(Constants.StatusBarItemGUID_Position, _positionChildLength, 4);

            if (positionItem == null)
            {
                return;
            }

            try {
                StatusBarService.Report(
                    $"{LanguageService.FindResourceString(Constants.StatusBarItemText_Position)} {hexContext.FocusPosition}",
                    Constants.StatusBarItemGUID_Position
                    );
            }
            catch (Exception ex) {
                LoggerService.WriteCallerLine(ex.Message);
            }
        }
示例#27
0
        /// <summary>
        /// Opens a Altaxo project. If the current project is dirty, the user is ask for saving the current project.
        /// </summary>
        /// <param name="filename"></param>
        public void OpenProject(string filename)
        {
            if (CurrentOpenProject != null)
            {
                System.ComponentModel.CancelEventArgs e = new System.ComponentModel.CancelEventArgs();
                if (this.CurrentOpenProject.IsDirty)
                {
                    AskForSavingOfProject(e);
                }

                if (e.Cancel == true)
                {
                    return;
                }


                CloseProject();
            }

            if (!FileUtility.TestFileExists(filename))
            {
                return;
            }
            StatusBarService.SetMessage("${res:MainWindow.StatusBar.OpeningCombineMessage}");

            if (Path.GetExtension(filename).ToUpper() == ".AXOPRJ")
            {
                string validproject = Path.ChangeExtension(filename, ".axoprj");
                if (File.Exists(validproject))
                {
                    LoadProject(validproject);
                }
            }
            else
            {
                LoadProject(filename);
            }

            StatusBarService.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}");
        }
        private void RunCommandAndReloadAllProjects(string helpTopic, Action <SolutionInfo> command)
        {
            PaketOutputPane.OutputPane.Activate();
            PaketErrorPane.Clear();
            StatusBarService.UpdateText("Paket command started.");

            var info = new SolutionInfo();

            info.Directory = SolutionExplorerExtensions.GetSolutionDirectory();
            info.FileName  = SolutionExplorerExtensions.GetSolutionDirectory();
            var projectGuids = SolutionExplorerExtensions.GetAllProjectGuids();

            SolutionExplorerExtensions.SaveSolution();
            foreach (var projectGuid in projectGuids)
            {
                SolutionExplorerExtensions.UnloadProject(projectGuid);
            }

            System.Threading.Tasks.Task.Run(() =>
            {
                try
                {
                    command(info);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe("Ready\r\n");
                    StatusBarService.UpdateText("Ready");
                }
                catch (Exception ex)
                {
                    PaketErrorPane.ShowError(ex.Message, info.FileName, helpTopic);
                    PaketOutputPane.OutputPane.OutputStringThreadSafe(ex.Message + "\r\n");
                }
            }).ContinueWith(_ =>
            {
                foreach (var projectGuid in projectGuids)
                {
                    SolutionExplorerExtensions.ReloadProject(projectGuid);
                }
            });
        }
示例#29
0
        private void ShowBCfViewpointInternal(UIApplication app)
        {
            UIDocument uiDocument = app.ActiveUIDocument;
            var        hasCamera  = _bcfViewpoint.GetCamera().Match(
                camera =>
            {
                Log.Information("Found camera type {t}, opening related OpenProject view ...", camera.Type.ToString());
                View3D openProjectView = uiDocument.Document.GetOpenProjectView(camera.Type);

                ResetView(uiDocument, openProjectView);
                Log.Information("Reset view '{v}'.", openProjectView.Name);
                ApplyViewOrientationAndVisibility(uiDocument, openProjectView, camera);
                Log.Information("Applied view orientation and visibility in '{v}'.", openProjectView.Name);
                ApplyClippingPlanes(uiDocument, openProjectView);
                Log.Information("Applied view point clipping planes in '{v}'.", openProjectView.Name);

                if (!uiDocument.ActiveView.Id.Equals(openProjectView.Id))
                {
                    Log.Information("Setting view '{t}' as active view ...", openProjectView.Name);
                    uiDocument.ActiveView = openProjectView;
                }

                uiDocument.RefreshActiveView();
                Log.Information("Refreshed active view.");
                StatusBarService.ResetStatusBarText();

                ZoomIfNeeded(app, camera, uiDocument.ActiveView.Id);
                Log.Information("Finished loading BCF viewpoint.");

                return(true);
            },
                () => false);

            if (!hasCamera)
            {
                Log.Error("BCF viewpoint has no camera information. Aborting ...");
            }
        }
示例#30
0
 void Finish()
 {
     LoggingService.Debug("MSBuild finished");
     MSBuildEngine.isRunning = false;
     if (currentResults.Result == BuildResultCode.None)
     {
         currentResults.Result = BuildResultCode.Success;
     }
     if (currentResults.Result == BuildResultCode.Success)
     {
         parentEngine.MessageView.AppendLine("${res:MainWindow.CompilerMessages.BuildFinished}");
         StatusBarService.SetMessage("${res:MainWindow.CompilerMessages.BuildFinished}");
     }
     else
     {
         parentEngine.MessageView.AppendLine("${res:MainWindow.CompilerMessages.BuildFailed}");
         StatusBarService.SetMessage("${res:MainWindow.CompilerMessages.BuildFailed}");
     }
     if (options.Callback != null)
     {
         WorkbenchSingleton.MainForm.BeginInvoke(options.Callback, currentResults);
     }
 }