예제 #1
0
파일: PageView.cs 프로젝트: gopa810/Rambha
        public MNReferencedCore FindContentObject(SMContentType type, string contentId)
        {
            MNReferencedCore value = null;

            //Debugger.Log(0, "", "--FindContentObject: A\n");
            if (CurrentDocument.CurrentLanguage != null)
            {
                //Debugger.Log(0, "", "--FindContentObject: B\n");
                value = CurrentDocument.CurrentLanguage.FindObject(contentId);
            }

            if (value == null)
            {
                if (CurrentDocument.DefaultLanguage != null)
                {
                    //Debugger.Log(0, "", "--FindContentObject: DEFAULT B\n");
                    value = CurrentDocument.DefaultLanguage.FindObject(contentId);
                }
            }

            if (value == null && type == SMContentType.Text)
            {
                //Debugger.Log(0, "", "--FindContentObject: C\n");
                MNReferencedText rt = CurrentDocument.FindText(contentId);
                if (rt != null)
                {
                    //Debugger.Log(0, "", "--FindContentObject: D\n");
                    MNReferencedText str = new MNReferencedText();
                    str.Text = rt.Text;
                    value    = str;
                }
            }

            return(value);
        }
예제 #2
0
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      dte            = (DTE)VsServiceProvider.GetService(typeof(DTE));
                Document activeDocument = dte.ActiveDocument;

                if (activeDocument == null)
                {
                    return;
                }

                IItem item        = null;
                var   projectName = activeDocument.ProjectItem.ContainingProject.FullName;

                if (SolutionInfo.IsOpenFolderModeActive())
                {
                    item = new CurrentDocument(activeDocument);
                    Items.Add(item);
                }
                else if (string.IsNullOrWhiteSpace(projectName) == false)
                {
                    item = new CurrentProjectItem(activeDocument.ProjectItem);
                    Items.Add(item);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #3
0
        Result IExternalCommand.Execute(
            ExternalCommandData excmd,
            ref string mainmessage,
            ElementSet elemset)
        {
            CurrentApplication = excmd.Application;
            UiDocument         = CurrentApplication.ActiveUIDocument;
            CurrentDocument    = CurrentApplication.ActiveUIDocument.Document;

            // draw box for area or pick a named scope box
            var view = Create3DViewFromArea();

            if (view == null)
            {
                throw new CancellableException();
            }

            // create options for export
            var opts = new NavisworksExportOptions
            {
                ConvertElementProperties = true,
                Coordinates = NavisworksCoordinates.Shared,
                ExportLinks = true,
                ExportScope = NavisworksExportScope.View,
                ViewId      = CurrentDocument.ActiveView.Id
            };

            // if the export of a specific VIEW for each linked model doesn't work -
            // open other linked Revit models and create the same 3D for each

            // create folders and other variables
            var projFolder    = FindProjectFolder(CurrentDocument);
            var projNumber    = GetProjectNumber(projFolder);
            var navisFileName = $"{projNumber}_ALL";
            var fullNavPath   = Directory.GetParent(projFolder)?.Parent?.FullName + @"\NAVIS\" + navisFileName + ".nwc";
            var navisFolder   = Directory.GetParent(fullNavPath).FullName;

            // export to NWC
            const string testFolder = @"C:\_Revit\";

            CurrentDocument.Export(testFolder, navisFileName, opts);
            //CurrentDocument.Export(navisFolder, navisFileName, opts);

            // starts clash detection in separate thread
            //StartClashDetectionThread(fullNavPath);

            return(Result.Succeeded);

            // switch over to Navisworks context

            /*
             * Append all files
             * import Search Sets
             * import Clash Tests
             * Run Clash Tests
             * Split based on typical responsibility
             * Export to HTML
             * Export to Viewpoints
             */
        }
예제 #4
0
 /// <summary>
 /// Copy the text to the clipboard.
 /// </summary>
 public override void Execute()
 {
     if (CurrentDocument != null)
     {
         CurrentDocument.CopyText();
     }
 }
예제 #5
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string json = CurrentDocument.ToString();

            File.WriteAllText(CurrentFile, json);
            toolStripStatusLabel2.Text = "(saved)";
        }
예제 #6
0
 /// <summary>
 /// Bind the prograns to dropdown
 /// </summary>
 public void BindPrograms()
 {
     try
     {
         int campaignID = CurrentDocument.GetIntegerValue("CampaignID", default(int));
         if (campaignID != default(int))
         {
             var programs = ProgramProvider.GetPrograms()
                            .WhereEquals("NodeSiteID", CurrentSite.SiteID)
                            .WhereEquals("CampaignID", campaignID)
                            .Columns("ProgramID,ProgramName")
                            .ToList();
             if (programs != null)
             {
                 ddlPrograms.DataSource     = programs;
                 ddlPrograms.DataTextField  = "ProgramName";
                 ddlPrograms.DataValueField = "ProgramID";
                 ddlPrograms.DataBind();
                 string selectText = ValidationHelper.GetString(ResHelper.GetString("Kadena.CampaignProduct.SelectProgramText"), string.Empty);
                 ddlPrograms.Items.Insert(0, new ListItem(selectText, "0"));
             }
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("CMSWebParts_Kadena_Campaign_Web_Form_CampaignProductsFilter", "BindPrograms", ex, CurrentSite.SiteID, ex.Message);
     }
 }
예제 #7
0
        // TODO : Refactor this method. Generics can be a solution.
        public void CollectActiveProjectItem()
        {
            try
            {
                DTE      dte            = (DTE)VsServiceProvider.GetService(typeof(DTE));
                Document activeDocument = dte.ActiveDocument;

                if (activeDocument == null)
                {
                    return;
                }

                IItem item = null;
                if (SolutionInfo.IsOpenFolderModeActive())
                {
                    item = new CurrentDocument(activeDocument);
                }
                else
                {
                    item = new CurrentProjectItem(activeDocument.ProjectItem);
                }

                Items.Add(item);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #8
0
 /// <summary>
 /// Adds <paramref name="page"/> to the currently-opened document. This differs from <see cref="AddResource"/>
 /// in that this method also adds <paramref name="page"/> to the document page order list, too. If
 /// <paramref name="after"/> is not <c>null</c>, then <paramref name="page"/> will be added after
 /// <paramref name="after"/> in the page order list. If <paramref name="after"/> is <c>null</c>, then
 /// <paramref name="page"/> will simply be added to the end of the page order list.
 /// </summary>
 /// <param name="page">The page to add to the document.</param>
 /// <param name="after">The page to add <paramref name="page"/> after in the page order list, or <c>null</c> to
 /// add <paramref name="page"/> to the end of the page order list.</param>
 private void AddPage(Page page, Page after = null)
 {
     CurrentDocument.Add(page);
     DocumentModified = true;
     CurrentDocument.AddPageToPageOrder(page, after);
     RefreshResourceListView();
 }
예제 #9
0
파일: Pages.cs 프로젝트: stuart2w/SAW
 public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
 {
     if (CurrentDocument.AddPage(CurrentPage, transaction, true, CurrentPageIndex + Offset, Duplicate) != null)
     {
         Editor.DisplayPage(CurrentPageIndex + Offset);
     }
 }
예제 #10
0
파일: Pages.cs 프로젝트: stuart2w/SAW
        public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
        {
            if (CurrentDocument.Count < 2)
            {
                return;
            }
            // deleting the last page would bugger things up completely
            // Only confirm with user if the page is not empty
            if (!CurrentPage.IsEmpty)
            {
                if (MessageBox.Show(Strings.Item("Confirm_DeletePage"), RootApplication.AppName, MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }
            CurrentDocument.DeletePage(CurrentPageIndex, transaction);
            // Usually we will display the page following this one, which now has the same page index, unless there isn't one
            int newIndex = CurrentPageIndex;

            if (newIndex >= CurrentDocument.Count)
            {
                newIndex = CurrentDocument.Count - 1;
            }
            Editor.DisplayPage(newIndex);
        }
예제 #11
0
        /// <summary>
        /// Refreshes the list view containing the list of resources in the main editor window.
        /// This might cause some UI slowdown so try and not call it too often.
        /// </summary>
        private void RefreshResourceListView()
        {
            IEnumerable <Resource> displayedResources = CurrentDocument
                                                        .Where(IsResourceDisplayed)
                                                        .OrderBy(GetResourceOrderComparer);

            var topItemIndex = listViewResources.TopItem != null ? listViewResources.TopItem.Index : 0;

            IsRefreshingResourceListView = true;
            listViewResources.SuspendLayout();
            listViewResources.Items.Clear();

            foreach (Resource resource in displayedResources)
            {
                listViewResources.Items.Add(CreateListViewItem(resource));
            }

            listViewResources.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            listViewResources.ResumeLayout(false);

            if (topItemIndex != 0 && listViewResources.Items.Count >= topItemIndex - 1)
            {
                listViewResources.TopItem = listViewResources.Items[topItemIndex];
            }
            IsRefreshingResourceListView = false;
        }
예제 #12
0
        private void LoadDocumentDefaultFieldValues()
        {
            if (htmlDoc.DocumentNode.SelectNodes("//ngs_input") != null && htmlDoc.DocumentNode.SelectNodes("//ngs_input").Count > 0)
            {
                foreach (HtmlAgilityPack.HtmlNode node in htmlDoc.DocumentNode.SelectNodes("//ngs_input"))
                {
                    if (FieldInDocumentFields(node.Name, node.GetAttributeValue("name", "")))
                    {
                        string str = "";

                        if (CurrentDocument != null)
                        {
                            str = CurrentDocument.GetFieldValue(node.GetAttributeValue("name", ""));
                        }
                        else
                        {
                            str = GetFieldValueFromFieldValueList(node.GetAttributeValue("name", ""));
                        }

                        if (!String.IsNullOrEmpty(str))
                        {
                            node.InnerHtml = str;
                        }
                        else
                        {
                            str = GlobalVariables.CurrentCompanySettings.GetSettingValueOrDefault(node.GetAttributeValue("name", ""), "");
                            if (!String.IsNullOrEmpty(str))
                            {
                                node.InnerHtml = str;
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Adjust the draworder of a <see cref="SpriteNode"/>.
        /// </summary>
        public void MoveSpriteNodeInFrontOfTarget(ulong nodeId, int destinationIndex)
        {
            RequireMode(EditorMode.Design);

            using var uow = CurrentDocument.StartUnitOfWork("Change draworder");
            _currentDocument.MoveSpriteInDrawOrder(uow, nodeId, destinationIndex);
        }
예제 #14
0
 public void SaveDraft()
 {
     if (!We7.Framework.AppCtx.IsDemoSite)
     {
         CurrentDocument.Save(DesignFile, Encoding.UTF8);
     }
 }
예제 #15
0
 /// <summary>
 /// Save the document changes.
 /// </summary>
 public override void Execute()
 {
     if (CurrentDocument != null)
     {
         CurrentDocument.Save();
     }
 }
예제 #16
0
        void SetCurrentMaterial(string uidMaterial)
        {
            if (!_materials.ContainsKey(uidMaterial))
            {
                RMaterial material = CurrentDocument.GetElement(uidMaterial) as RMaterial;

                Color c = material.Color;

                MaterialBuilder m;
                if (material.Transparency != 0)
                {
                    m = new MaterialBuilder()
                        .WithAlpha(AlphaMode.BLEND)
                        .WithDoubleSide(true)
                        .WithMetallicRoughnessShader()
                        .WithChannelParam("BaseColor", new Vector4(c.Red / 256f, c.Green / 256f, c.Blue / 256f, 1 - (material.Transparency / 128f)));
                }
                else
                {
                    m = new MaterialBuilder()
                        .WithDoubleSide(true)
                        .WithMetallicRoughnessShader()
                        .WithChannelParam("BaseColor", new Vector4(c.Red / 256f, c.Green / 256f, c.Blue / 256f, 1));
                }
                m.UseChannel("MetallicRoughness");
                _materials.Add(uidMaterial, m);
            }
            _material = _materials[uidMaterial];
        }
예제 #17
0
 /// <summary>
 /// Open the find dialog.
 /// </summary>
 public override void Execute()
 {
     if (CurrentDocument != null)
     {
         CurrentDocument.SelectAllText();
     }
 }
예제 #18
0
 protected void ToolCopyClick(object sender, EventArgs e)
 {
     if (CurrentDocument == null)
     {
         return;
     }
     ViewDocumentsAsync(new List <Document>(new[] { (Document)CurrentDocument.Clone() }));
 }
예제 #19
0
 public Control GetView(int ControlWidth)
 {
     if (this.CurrentDocument != null)
     {
         return(this.GetControl(CurrentDocument.QuerySelector("body"), ControlWidth - 20, null));
     }
     return(null);
 }
예제 #20
0
 /// <summary>
 /// 根据ID获取节点,如果是BODY则直接获取BODY
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public HtmlNode GetElementById(string id)
 {
     if (string.Compare(id, "body", true) == 0)
     {
         return(SelectSingleNode("//body"));
     }
     return(CurrentDocument.GetElementbyId(id));
 }
예제 #21
0
        /// <summary>
        /// Moves a node to another place in the scene Hierarchy.
        /// </summary>
        public void MoveNodeInHierarchy(ulong nodeId, ulong targetNodeId, InsertPosition insertPosition)
        {
            RequireMode(EditorMode.Design);

            var node = CurrentDocument.GetNode(nodeId);

            using var uow = CurrentDocument.StartUnitOfWork($"{node} Move in scene tree");
            _currentDocument.MoveNodeInHierarchy(uow, nodeId, targetNodeId, insertPosition);
        }
예제 #22
0
파일: Pages.cs 프로젝트: stuart2w/SAW
 public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
 {
     if (CurrentPageIndex == 0)
     {
         return;
     }
     CurrentDocument.MovePage(CurrentPageIndex, CurrentPageIndex - 1, transaction);
     Editor.DisplayPage(CurrentPageIndex - 1);
 }
예제 #23
0
        /// <summary>
        /// Adds an animation key in the current animation, at the current timeline frame.
        /// </summary>
        public void RemoveKeyAtCurrentFrame(ulong nodeId, PropertyType property)
        {
            RequireMode(EditorMode.Animate);

            var node      = CurrentDocument.GetNode(nodeId);
            var animation = CurrentDocument.GetAnimation(_currentAnimationId);

            using var uow = CurrentDocument.StartUnitOfWork($"{node} Remove Key {property} @ [F:{animation.CurrentFrame}]");
            animation.RemoveKeyAtCurrentFrame(uow, nodeId, property);
        }
    /// <summary>
    /// Checks, whether current document is product type. If not, hides webpart on live site and show warning in design.
    /// </summary>
    /// <returns>True if current document is product type, false otherwise</returns>
    private bool CheckForProductPage()
    {
        if (CurrentDocument.IsProduct())
        {
            return(true);
        }

        HandleError(GetString("strands.recommendations.product.wrongdocument"));
        return(false);
    }
예제 #25
0
파일: Pages.cs 프로젝트: stuart2w/SAW
 {    // adds another page if at the end
     public override void Trigger(EditableView.ClickPosition.Sources source, EditableView pnlView, Transaction transaction)
     {
         if (CurrentPageIndex >= CurrentDocument.Count - 1)
         {
             if (CurrentDocument.AddPage(CurrentPage, transaction, true) == null)
             {
                 return;
             }
         }
         Editor.DisplayPage(CurrentPageIndex + 1);
     }
예제 #26
0
 /// <summary>
 /// Saves the document.
 /// </summary>
 /// <returns>True if saved</returns>
 public bool SaveDocument()
 {
     CurrentSheet = null;
     if (CurrentDocument != null)
     {
         CurrentDocument.Dispose();
     }
     CurrentDocument = null;
     CurrentFilename = null;
     return(true);
 }
예제 #27
0
 private void OnTimerElapsed(object sender, ElapsedEventArgs e)
 {
     Execute.OnUIThread(() => _connection.Ping());
     // if past timeout then exit and display error
     if ((utcPingStart - DateTime.UtcNow).Seconds > 30)
     {
         _startingTimer.Stop();
         _trace.Drop();
         CurrentDocument.OutputError("Timeout exceeded attempting to start Trace");
     }
 }
예제 #28
0
        public void TestCodeElementFromPoint()
        {
            var text             = CurrentDocument.GetTextAsync().Result;
            var tree             = CurrentDocument.GetSyntaxTreeAsync().Result;
            var position         = text.ToString().IndexOf("DynamicMethod", StringComparison.Ordinal);
            var virtualTreePoint = new VirtualTreePoint(tree, text, position);
            var textPoint        = new MockTextPoint(virtualTreePoint, 4);
            var scope            = vsCMElement.vsCMElementFunction;
            var element          = CodeModel.CodeElementFromPoint(textPoint, scope);

            Assert.Equal("DynamicMethod", element.Name);
        }
예제 #29
0
            /// <summary>
            /// 关闭Sdsite网站
            /// </summary>
            static public void CloseSdsite()
            {
                OnSdsiteClosing(EventArgs.Empty);

                CurrentDocument.Save();
                DesignDataDocument.Save();
                CurrentDocument.Close();
                CurrentDocument    = null;
                DesignDataDocument = null;

                OnSdsiteClosed(EventArgs.Empty);
            }
예제 #30
0
 /// <summary>
 /// Saves the current document to the given path.
 /// Uses the extension of <paramref name="path"/> to determine whether to
 /// save uncompressed (<c>.xml</c>) or not.
 /// </summary>
 /// <param name="path">The file system path to which to save the document.</param>
 public void SaveDocument(string path)
 {
     try
     {
         CurrentDocument.Save(path, path.ToLowerInvariant().EndsWith(".xml") ? false : true);
         DocumentPath     = path;
         DocumentModified = false;
     }
     catch (IOException ex)
     {
         MessageBox.Show("The document cannot be saved.\r\n" + ex.Message, "Save - " + ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }