コード例 #1
0
ファイル: Merged.cs プロジェクト: jonishzx/Clover
        private bool ValidIdentity(int fromRow, int fromColumn, int toRow, int toColumn)
        {
            bool isIdentyty = true;

            for (int loopIndex = fromRow; loopIndex <= toRow; loopIndex++)
            {
                IRow   hssRow          = CurrentSheet.GetRow(loopIndex);
                string fromColumnValue = GetCellValue(hssRow.GetCell(fromColumn));

                for (int columnIndex = fromColumn + 1; columnIndex <= toColumn; columnIndex++)
                {
                    string currentColumnValue = GetCellValue(hssRow.GetCell(columnIndex));
                    isIdentyty = isIdentyty && string.Compare(fromColumnValue, currentColumnValue) == 0;
                    if (!isIdentyty)
                    {
                        break;
                    }
                }
                if (!isIdentyty)
                {
                    break;
                }
            }
            return(isIdentyty);
        }
コード例 #2
0
ファイル: Merged.cs プロジェクト: jonishzx/Clover
        private void RecursivelyMerged(int fromRow, int fromColumn, int toRow, int toColumn, MergedConfig orgianConfig)
        {
            bool isIndentity    = false;
            int  endMergedIndex = fromColumn;

            for (int loopIndex = toColumn; loopIndex >= fromColumn; loopIndex--)
            {
                isIndentity = ValidIdentity(fromRow, fromColumn, toRow, loopIndex);
                if (isIndentity)
                {
                    endMergedIndex = loopIndex;
                    break;
                }
            }

            CurrentSheet.AddMergedRegion(new CellRangeAddress(fromRow, fromColumn, toRow, endMergedIndex));

            if (toColumn - endMergedIndex > 0)
            {
                MergedConfig config = new MergedConfig();
                config.MergedType         = orgianConfig.MergedType;
                config.MergedTypePriority = orgianConfig.MergedTypePriority;
                config.IgnoreEmpty        = orgianConfig.IgnoreEmpty;
                config.NeedValid          = orgianConfig.NeedValid;
                config.FromRow            = fromRow + "";
                config.FromColumn         = (endMergedIndex + 1).ToString();
                config.ToRow    = toRow + "";
                config.ToColumn = toColumn + "";
                DoAllSingleMerged(config);
            }
        }
コード例 #3
0
ファイル: Commands.cs プロジェクト: RandyLyne/SwRI_Tools
    //Autogenerated code. End of implementation [GetState_OpenSchematics]

    //Autogenerated code. Begin of implementation [Command_OpenSchematics]
    public void Command_OpenSchematics(IServerDocumentView view, ref string parameters)
    {
        IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
        IDXPProject   CurrentProject;
        int           LogicalDocumentCount;
        int           LoopIterator;
        IDXPDocument  CurrentSheet;

        CurrentProject       = CurrentWorkspace.DM_FocusedProject();
        LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
        ISch_Document SchDoc;
        IClient       Client = DXP.GlobalVars.Client;

        for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
        {
            CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
            if (CurrentSheet.DM_DocumentKind() == "SCH")
            {
                SchDoc = CurrentSheet as ISch_Document;
                //Open document if not already open.
                if (!Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                {
                    Client.ShowDocument(Client.OpenDocument("SCH", CurrentSheet.DM_FullPath()));
                }
            }
        }
    }
コード例 #4
0
ファイル: SheetEditor.cs プロジェクト: slagusev/Gridden
        /// <summary>
        /// Removes the given Sprite from the current sheet.
        /// </summary>
        public void RemoveSpriteFromCurrentSheet(int index)
        {
            // remove from sheet and save.
            CurrentSheet.RemoveSprite(index);
            SaveSheetToFile();

            SelectedSpriteIndex = 0;
        }
コード例 #5
0
ファイル: MsExcel.cs プロジェクト: lusionx/lusionkit
        public void InsertPicture(string RangeName, string PicturePath)
        {
            Range rg = GetRange(RangeName);

            rg.Select();
            Pictures pics = (Pictures)CurrentSheet.Pictures(miss);//m_objSheet.Pictures(m_objOpt);

            pics.Insert(PicturePath, miss);
        }
コード例 #6
0
    /// <summary>
    /// Get paths of all outjobs in the project.
    /// </summary>
    /// <returns>List of outjobs in project.</returns>
    public List <string> GetOutputJobPath()
    {
        try
        {
            List <string> DirList          = new List <string>();
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();

            int          BoardCount = 0;
            string       BoardName  = "";
            DialogResult dlgResult;

            //Loop through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Trying to determine if there are multiple PCB files. Give warning if multiple PCBs.
                if (CurrentSheet.DM_DocumentKind() == "PCB")
                {
                    if (BoardCount == 0)
                    {
                        BoardCount += 1;
                        BoardName   = CurrentSheet.DM_FileName();
                    }
                    else
                    {
                        dlgResult = MessageBox.Show("There are multiple boards in this project. PCB outjobs will only run on the first board :" + BoardName + "\nDo you wish to continue?", "Multiple PCBs", MessageBoxButtons.YesNo);
                        if (dlgResult == DialogResult.No)
                        {
                            return(null);
                        }
                    }
                }
                //Add outjob path to list.
                if (CurrentSheet.DM_DocumentKind() == "OUTPUTJOB")
                {
                    DirList.Add(CurrentSheet.DM_FullPath());
                }
            }
            return(DirList);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }
コード例 #7
0
        public bool MoveToNextSheet()
        {
            if (!_sheetEnumerator.MoveNext())
            {
                return(false);
            }

            CurrentSheet = _sheetEnumerator.Current;

            _rowEnumerator = CurrentSheet?.GetEnumerator();
            determineFirstColumn();

            return(true);
        }
コード例 #8
0
ファイル: SheetEditor.cs プロジェクト: slagusev/Gridden
        /// <summary>
        /// Creates a new sprite from the given file and assigns it the given character for the map.
        /// This will throw an exception if there is already a Sprite in the collection assigned to the given character.
        /// </summary>
        public void AddSpriteToSheet(char c, string sourceFileName)
        {
            // create the sheet folder if it doesn't exist yet.
            string sheetDir = Path.Combine(Environment.CurrentDirectory, SheetEditor.SheetFolderName);

            if (!Directory.Exists(sheetDir))
            {
                Directory.CreateDirectory(sheetDir);
            }

            // build the new file name and copy the file to the local folder.
            int    newIndex    = CurrentSheet.Sprites.Count;
            string newFileName = Path.Combine(sheetDir, newIndex + Path.GetExtension(sourceFileName));

            File.Copy(sourceFileName, newFileName);

            // add the Sprite to the Sheet, then save it.
            CurrentSheet.AddNewSprite(c, newFileName);
            SaveSheetToFile();
        }
コード例 #9
0
        private void determineFirstColumn()
        {
            if (!_columnOffsetOn)
            {
                _columnOffset = 0;
                return;
            }

            var excelRows = CurrentSheet.GetRowEnumerator();

            if (!excelRows.MoveNext())
            {
                _columnOffset = 0;
                return;
            }

            var currentExcelRow = getCurrentExcelRow(excelRows);

            var tableStart = 0;

            for (var i = 0; i < currentExcelRow.LastCellNum; i++)
            {
                var cell = currentExcelRow.GetCell(i);

                if (cell == null)
                {
                    tableStart++;
                }
                else
                {
                    break;
                }
            }

            _columnOffset = tableStart;
        }
コード例 #10
0
ファイル: Merged.cs プロジェクト: jonishzx/Clover
        private void DoColumnSingleMerged(MergedConfig config, int indexColumn)
        {
            int fromRow = -1;

            if (!int.TryParse(config.FromRow, out fromRow))
            {
                fromRow = StartRow;
            }
            int loopIndex = fromRow;

            while (loopIndex <= EndRow)
            {
                int    startRowIndex     = loopIndex;
                IRow   hssRow            = CurrentSheet.GetRow(loopIndex);
                string standCurrentValue = GetCellValue(hssRow.GetCell(indexColumn));
                for (++loopIndex; loopIndex <= EndRow; loopIndex++)
                {
                    IRow   loopHssRow = CurrentSheet.GetRow(loopIndex);
                    string loopValue  = GetCellValue(loopHssRow.GetCell(indexColumn));

                    if (string.Compare(standCurrentValue, loopValue) != 0)
                    {
                        if (loopIndex - fromRow > 2)
                        {
                            CurrentSheet.AddMergedRegion(new CellRangeAddress(startRowIndex, indexColumn, loopIndex - 1, indexColumn));
                        }
                        break;
                    }

                    else if (loopIndex == EndRow)
                    {
                        CurrentSheet.AddMergedRegion(new CellRangeAddress(startRowIndex, indexColumn, loopIndex, indexColumn));
                    }
                }
            }
        }
コード例 #11
0
 public void Play()
 {
     CurrentSheet?.Play();
 }
コード例 #12
0
 public void Stop()
 {
     CurrentSheet?.Stop();
 }
コード例 #13
0
 protected override void UpdateCore(UpdateContext context)
 {
     CurrentSheet?.Update(context);
 }
コード例 #14
0
 public NPOI.SS.UserModel.Row CreateRow(int rownum)
 {
     _row = CurrentSheet.CreateRow(rownum);
     return(_row);
 }
コード例 #15
0
ファイル: Util.cs プロジェクト: RandyLyne/SwRI_Tools
    /// <summary>
    /// Retrieve the current open PCB.
    /// </summary>
    /// <returns>Returns IPCB_Board if PCB file is active. Returns null if no PCB file is active.</returns>
    public static IPCB_Board GetCurrentPCB(bool OpenPCB = false)
    {
        try
        {
            PCBServer = PCB.GlobalVars.PCBServer;
            if (OpenPCB)
            {
                IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace; //Get workspace
                IDXPProject   CurrentProject;
                int           LogicalDocumentCount;
                int           LoopIterator;
                IDXPDocument  CurrentSheet;
                CurrentProject       = CurrentWorkspace.DM_FocusedProject();     //Get current project.
                LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount(); //Get count of documents in the selected project.

                IClient         Client = DXP.GlobalVars.Client;
                IServerDocument ServerDoc;
                IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

                //Loop through all project documents.
                for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
                {
                    CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);

                    //Find the first PCB in the project.
                    if (CurrentSheet.DM_DocumentKind() == "PCB")
                    {
                        IPCB_Board PCBDoc = CurrentSheet as IPCB_Board;
                        //Open PCB file if not already open.
                        if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                        {
                            ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        }
                        else
                        {
                            ServerDoc = Client.OpenDocument("PCB", CurrentSheet.DM_FullPath());
                        }

                        Client.ShowDocument(ServerDoc);
                        break;
                    }
                }
            }


            IPCB_Board Board;
            if (PCBServer == null)
            {
                return(null);
            }

            Board = PCBServer.GetCurrentPCBBoard(); //Get current board
            if (Board == null)
            {
                return(null);
            }
            return(Board);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }
コード例 #16
0
ファイル: Merged.cs プロジェクト: jonishzx/Clover
        private bool DoRowSingleMerged(MergedConfig config)
        {
            bool mergedResult = true;
            int  fromColumn   = -1;
            int  toClumn      = -1;

            if (!int.TryParse(config.FromColumn, out fromColumn))
            {
                throw new ArgumentException("Merged配置项中fromColumn参数无效");
            }

            if (!int.TryParse(config.ToColumn, out toClumn))
            {
                throw new ArgumentException("Merged配置项中toColumn参数无效");
            }
            if (fromColumn > toClumn)
            {
                throw new ArgumentException("Merged配置中from参数不能大于toColumn参数");
            }
            if (fromColumn == toClumn)
            {
                return(true);
            }

            for (int index = StartRow; index <= EndRow; index++)
            {
                IRow   hssRow       = CurrentSheet.GetRow(index);
                bool   identityFlag = true;
                string lastRowValue = string.Empty;

                for (int columnIndex = fromColumn; columnIndex <= toClumn; columnIndex++)
                {
                    string currentRowValue = string.Empty;
                    ICell  currentCell     = hssRow.GetCell(columnIndex);
                    currentRowValue = GetCellValue(currentCell);

                    if (config.IgnoreEmpty)
                    {
                        if (string.IsNullOrEmpty(currentRowValue))
                        {
                            identityFlag = false;
                            break;
                        }
                    }

                    if (columnIndex > fromColumn)
                    {
                        identityFlag = string.Compare(currentRowValue, lastRowValue) == 0;
                        if (!identityFlag)
                        {
                            break;
                        }
                    }
                    lastRowValue = currentRowValue;
                }

                if (identityFlag)
                {
                    CurrentSheet.AddMergedRegion(new CellRangeAddress(index, fromColumn, index, toClumn));
                }
            }
            return(mergedResult);
        }
コード例 #17
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    bool GetBaseVariants()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer;
            IClient         Client         = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.
            string          RefDes;
            CompData        NewComp;

            bool DocOpened = false;
            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    //Client.ShowDocument(ServerDoc);

                    ISch_Lib SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Lib;

                    ISch_Iterator  LibraryIterator, PIterator;
                    ISch_Component Component;
                    ISch_Parameter Param;
                    if (SchDoc == null)
                    {
                        return(false);
                    }
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SchDoc.SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;

                    while (Component != null)
                    {
                        NewComp = new CompData("");
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            return(false);
                        }
                        RefDes              = Component.GetState_SchDesignator().GetState_Text();
                        NewComp.RefDes      = RefDes;
                        NewComp.Base_LibRef = Component.GetState_DesignItemId();
                        NewComp.UniqueID    = Component.GetState_UniqueId();
                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                        Param = PIterator.FirstSchObject() as ISch_Parameter;
                        while (Param != null)
                        {
                            if (Param.GetState_Name() != null)
                            {
                                //Store specific parameter data.
                                if ("PARTNUMBER" == Param.GetState_Name().ToUpper())
                                {
                                    NewComp.Base_Partnumber = Param.GetState_CalculatedValueString();
                                }
                            }

                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }


                        AddPart(NewComp);

                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return(true);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(false);
        }
    }
コード例 #18
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    public void GetBaseVariants()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            Dictionary <string, IComponentVariation> FltCompVar, EngCompVar;
            IDXPDocument CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer   = SCH.GlobalVars.SchServer;
            IClient                   Client = DXP.GlobalVars.Client;
            IServerDocument           ServerDoc;
            IDXPDocument              ActiveDoc  = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.
            VarParam <string, string> Parameters = new VarParam <string, string>();
            string RefDes;

            IParameterVariation TempVar;
            int  Matches;
            bool DocOpened = false;

            FltCompVar = Get_Variants("VAR_FLT");
            EngCompVar = Get_Variants("VAR_ENG");

            if (FltCompVar == null || EngCompVar == null)
            {
                return;
            }

            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    //Client.ShowDocument(ServerDoc);

                    ISch_Lib SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Lib;

                    ISch_Iterator       SchIterator, PIterator;
                    ISch_Component      Component;
                    ISch_Implementation Footprint;
                    ISch_Parameter      Param;
                    if (SchDoc == null)
                    {
                        return;
                    }
                    //Iterate theough all components on the schematic.
                    SchIterator = SchDoc.SchIterator_Create();
                    SchIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = SchIterator.FirstSchObject() as ISch_Component;



                    while (Component != null)
                    {
                        Matches = 0;
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            return;
                        }
                        RefDes = Component.GetState_SchDesignator().GetState_Text();



                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eImplementation));

                        Footprint = PIterator.FirstSchObject() as ISch_Implementation;
                        if (FltCompVar.ContainsKey(RefDes))
                        {
                            if (FltCompVar[RefDes].DM_AlternateLibraryLink().DM_Footprint() != Footprint.GetState_ModelName())
                            {
                                TempVar = FltCompVar[RefDes].DM_FindParameterVariation("ClassName");
                                if (TempVar != null)
                                {
                                    TempVar.DM_SetVariedValue("Stencil_Flt");
                                }
                                Matches++;
                            }
                        }

                        if (EngCompVar.ContainsKey(RefDes))
                        {
                            if (EngCompVar[RefDes].DM_AlternateLibraryLink().DM_Footprint() != Footprint.GetState_ModelName())
                            {
                                TempVar = EngCompVar[RefDes].DM_FindParameterVariation("ClassName");
                                if (TempVar != null)
                                {
                                    TempVar.DM_SetVariedValue("Stencil_Eng");
                                }
                                Matches++;
                            }
                        }

                        //?Param.GetState_ModelName()
                        //"FIDUCIAL_SMD"

                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                        Param = PIterator.FirstSchObject() as ISch_Parameter;
                        while (Param != null)
                        {
                            if (Param.GetState_Name() == "ClassName")
                            {
                                if (Matches == 2)
                                {
                                    Param.SetState_Text("Stencil_Base");
                                }
                                else
                                {
                                    Param.SetState_Text("");
                                }

                                Component.UpdatePart_PostProcess();
                                break;
                            }
                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }

                        Component = SchIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #19
0
ファイル: MsExcel.cs プロジェクト: lusionx/lusionkit
 private Range GetRange(string A1, string C3)
 {
     return(CurrentSheet.get_Range(A1, C3));
 }
コード例 #20
0
    public void CheckRefDes()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_Lib        SchDoc;
            IClient         Client = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            List <string> lstRefDes = new List <string>();
            List <string> Output    = new List <string>();
            string        RefDes;

            Output.Add(DateTime.Now + "," + System.IO.Path.GetFileName(CurrentProject.DM_ProjectFullPath()));
            Output.Add("");
            Output.Add("Compare,Ref1,Ref2");

            DXP.Utils.PercentInit("Collecting Refdes Values", LogicalDocumentCount);

            bool DocOpened = false;

            //Loop through each SCH document in project.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    SchDoc    = CurrentSheet as ISch_Lib;
                    //Open document if not already open.
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }


                    Client.ShowDocument(ServerDoc);

                    if (ServerDoc == null)
                    {
                        return;
                    }

                    ISch_Iterator  LibraryIterator;
                    ISch_Component Component;
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SCH.GlobalVars.SchServer.GetCurrentSchDocument().SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;

                    while (Component != null)
                    {
                        RefDes = Component.GetState_SchDesignator().GetState_Text();
                        if (Component.GetState_CurrentPartID() == 1)
                        {
                            lstRefDes.Add(RefDes);
                        }

                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }
                    ServerDoc = null;
                }
                DXP.Utils.PercentUpdate();
            }
            DXP.Utils.PercentFinish();
            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));

            lstRefDes.Sort();

            DXP.Utils.PercentInit("Checking for Dupes", lstRefDes.Count);
            for (int i = 1; i < lstRefDes.Count; i++)
            {
                if (lstRefDes[i - 1] == lstRefDes[i])
                {
                    Output.Add("Duplicate, " + lstRefDes[i]);
                }
                DXP.Utils.PercentUpdate();
            }
            DXP.Utils.PercentFinish();

            DXP.Utils.PercentInit("Checking for Similar", lstRefDes.Count);
            string[] First, Second;
            for (int i = 1; i < lstRefDes.Count; i++)
            {
                First = SplitString(lstRefDes[i]);

                if (First.Length >= 2)
                {
                    for (int j = 1; j < lstRefDes.Count; j++)
                    {
                        Second = SplitString(lstRefDes[j]);
                        if (First.Length != Second.Length)
                        {
                            if (First.Length != 3 || Second.Length != 3)
                            {
                                if (Second.Length > 2)
                                {
                                    if (First[0] == Second[0] && First[1] == Second[1] && i != j)
                                    {
                                        Output.Add("Similar, " + lstRefDes[i] + ", " + lstRefDes[j]);
                                    }
                                }
                            }
                        }
                    }
                }

                DXP.Utils.PercentUpdate();
            }
            //Output.Add("");
            DXP.Utils.PercentFinish();

            bool match = false;
            DXP.Utils.PercentInit("Checking EM/FM Parts", lstRefDes.Count);
            for (int i = 0; i < lstRefDes.Count; i++)
            {
                if (lstRefDes[i].Length > 3)
                {
                    if (lstRefDes[i].Contains("EM") || lstRefDes[i].Contains("FM"))
                    {
                        match  = false;
                        RefDes = lstRefDes[i].Remove(lstRefDes[i].Length - 2);
                        for (int j = 1; j < lstRefDes.Count; j++)
                        {
                            if (lstRefDes[j].Contains("EM") || lstRefDes[j].Contains("FM"))
                            {
                                if (RefDes == lstRefDes[j].Remove(lstRefDes[j].Length - 2) && i != j)
                                {
                                    Output.Add("Matched EM/FM, " + lstRefDes[i] + ", " + lstRefDes[j]);
                                    match = true;
                                    i    += 1;
                                    break;
                                }
                            }
                        }
                        if (match == false)
                        {
                            Output.Add("Unmatched EM/FM, " + lstRefDes[i]);
                        }
                    }
                }

                DXP.Utils.PercentUpdate();
            }
            DXP.Utils.PercentFinish();

            Util.Log(Output, Util.ProjPath() + "Refdes Report.csv");
            ServerDoc = Client.OpenDocument("Text", Util.ProjPath() + "Refdes Report.csv");
            Client.ShowDocument(ServerDoc);
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #21
0
ファイル: TestClass.cs プロジェクト: RandyLyne/SwRI_Tools
    public void ScanDocuments()//ref Dictionary<string, Heights> report)
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();


            ISch_Document   SchDoc;
            IClient         Client = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            DXP.Utils.PercentInit("Scanning Documents", LogicalDocumentCount);

            bool DocOpened = false;
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //if (CurrentSheet.DM_DocumentKind() == "PCB")
                //    if (BoardCount == 0)
                //    {
                //        BoardCount += 1;
                //        BoardName = CurrentSheet.DM_FileName();
                //    }
                //    else
                //    {

                //        dlgResult = MessageBox.Show("There are multiple boards in this project. PCB outjobs will only run on the first board :" + BoardName + "\n Do you wish to continue?", "Multiple PCBs", MessageBoxButtons.YesNo);
                //        if (dlgResult == DialogResult.No)
                //        {
                //            report = null;
                //            return;
                //        }
                //    }
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    SchDoc    = CurrentSheet as ISch_Document;
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    Client.ShowDocument(ServerDoc);
                    //GetParamHeights(ref report);

                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;

                    //if (report == null) return;
                }
                DocOpened = false;


                DXP.Utils.PercentUpdate();
            }

            DXP.Utils.PercentFinish();
            return;
            //DXP.Utils.PercentInit("Scanning Documents", LogicalDocumentCount);

            //for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            //{
            //    CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
            //    if (CurrentSheet.DM_DocumentKind() == "PCB")
            //    {
            //        if (BoardName == CurrentSheet.DM_FileName())
            //        {
            //            DocOpened = false;
            //            IPCB_Board PCBDoc = CurrentSheet as IPCB_Board;
            //            if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
            //            {
            //                ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
            //                DocOpened = true;
            //            }
            //            else
            //                ServerDoc = Client.OpenDocument("PCB", CurrentSheet.DM_FullPath());

            //            Client.ShowDocument(ServerDoc);
            //            GetBodyHeights(ref report);

            //            if (!DocOpened)
            //                Client.CloseDocument(ServerDoc);

            //            ServerDoc = null;
            //        }
            //    }
            //    DXP.Utils.PercentUpdate();
            //}
            //Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));

            //DXP.Utils.PercentFinish();

            //return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #22
0
    /// <summary>
    /// Get component list with library IDs.
    /// </summary>
    /// <returns></returns>
    public void CheckParams()
    {
        try
        {
            ComponentList <string, string> Output = new ComponentList <string, string>();
            IDXPWorkSpace CurrentWorkspace        = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer;
            IClient         Client         = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            pbProgress.Maximum = LogicalDocumentCount;
            pbProgress.Value   = 0;
            UpdateLabel("Checking Parameters");

            bool DocOpened = false;
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    ISch_Document SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Document;

                    ISch_Iterator             LibraryIterator, PIterator;
                    ISch_Component            Component;
                    VarParam <string, string> CompVars = new VarParam <string, string>();
                    ISch_Parameter            Param;
                    bool Flt = false, Eng = false;
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SchDoc.SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;
                    while (Component != null)
                    {
                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                        Param = PIterator.FirstSchObject() as ISch_Parameter;
                        while (Param != null)
                        {
                            if (Param.GetState_Name() != null)
                            {
                                if ("PE_ENG" == Param.GetState_Name().ToUpper())
                                {
                                    Eng = true;
                                }
                                else if (Param.GetState_Name().ToUpper() == "PE_FLT")
                                {
                                    Flt = true;
                                }
                            }

                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }

                        if (!Flt)
                        {
                            Param = Component.AddSchParameter();
                            Param.SetState_Name("PE_FLT");
                            Param.SetState_Text("x");
                        }

                        if (!Eng)
                        {
                            Param = Component.AddSchParameter();
                            Param.SetState_Name("PE_ENG");
                            Param.SetState_Text("x");
                        }
                        Flt       = false;
                        Eng       = false;
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
                pbProgress.Value++;
                UpdateLabel("Checking Parameters");
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));

            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #23
0
 protected override void DrawCore(DrawContext context)
 {
     CurrentSheet?.Draw(context);
 }
コード例 #24
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    public void GetBaseVariants(ref Var_Type VarList)
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer   = SCH.GlobalVars.SchServer;
            IClient                   Client = DXP.GlobalVars.Client;
            IServerDocument           ServerDoc;
            IDXPDocument              ActiveDoc  = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.
            VarParam <string, string> Parameters = new VarParam <string, string>();
            string RefDes;

            bool DocOpened = false;
            Progress.Value   = 0;
            Progress.Maximum = LogicalDocumentCount;
            UpdateLabel("Loading Variants");
            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    //Client.ShowDocument(ServerDoc);

                    ISch_Lib SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Lib;

                    ISch_Iterator  LibraryIterator, PIterator;
                    ISch_Component Component;
                    ISch_Parameter Param;
                    if (SchDoc == null)
                    {
                        return;
                    }
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SchDoc.SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;

                    while (Component != null)
                    {
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            VarList = null;
                            return;
                        }
                        RefDes     = Component.GetState_SchDesignator().GetState_Text();
                        Parameters = new VarParam <string, string>();

                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                        Param = PIterator.FirstSchObject() as ISch_Parameter;
                        while (Param != null)
                        {
                            if (Param.GetState_Name() != null)
                            {
                                //Store specific parameter data.
                                if ("PE_ENG" == Param.GetState_Name().ToUpper() || Param.GetState_Name().ToUpper() == "PE_FLT")
                                {
                                    if (Param.GetState_Text() != "x")
                                    {
                                        Parameters.Add(Param.GetState_Name().ToUpper(), Param.GetState_CalculatedValueString());
                                    }
                                }
                            }
                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }
                        //Add stored parameter data to VarList.
                        if (Parameters.Count > 0)
                        {
                            if (!VarList.Components.ContainsKey(RefDes))
                            {
                                VarList.Components.Add(RefDes, Parameters);
                            }
                        }
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
                Progress.Value += 1;
                UpdateLabel("Loading Variants");
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #25
0
 public void Pause()
 {
     CurrentSheet?.Pause();
 }
コード例 #26
0
    /// <summary>
    /// Updates base design parameters based on provided data.
    /// </summary>
    /// <param name="VarList">Parameter data</param>
    void SetBaseDesign(Var_Type VarList)
    {
        try
        {
            string        RefDes;
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer;
            IClient         Client         = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            Progress.Maximum = LogicalDocumentCount;
            Progress.Value   = 0;
            UpdateLabel("Updating Variants");
            bool DocOpened = false;
            //Iterate through all documents looking for scheatic docs.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    //Open document if not already open.
                    DocOpened = false;
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    //Client.ShowDocument(ServerDoc);

                    ISch_Lib SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Lib;

                    ISch_Iterator             LibraryIterator, PIterator;
                    ISch_Component            Component;
                    ISch_Parameter            Param;
                    VarParam <string, string> CompVars = new VarParam <string, string>();
                    if (SchDoc == null)
                    {
                        return;
                    }
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SchDoc.SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;
                    while (Component != null)
                    {
                        RefDes = Component.GetState_SchDesignator().GetState_Text();
                        if (VarList.Components.ContainsKey(Component.GetState_SchDesignator().GetState_Text()))
                        {
                            if (VarList.Components[Component.GetState_SchDesignator().GetState_Text()].Saved == false)
                            {
                                Component.UpdatePart_PreProcess();
                                CompVars = VarList.Components[Component.GetState_SchDesignator().GetState_Text()];
                                //Iterate theough all parameters in the component.
                                PIterator = Component.SchIterator_Create();
                                PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                                Param = PIterator.FirstSchObject() as ISch_Parameter;
                                while (Param != null)
                                {
                                    if (Param.GetState_Name() != null)
                                    {
                                        if (Param.GetState_Name().ToUpper() != null)
                                        {
                                            //Set parameter data in component if it is in the provided parameter data.
                                            //Param = null;
                                            if (CompVars.ContainsKey(Param.GetState_Name().ToUpper()))
                                            {
                                                if (Param.GetState_Text() == "x")
                                                {
                                                    Param.SetState_Text(CompVars[Param.GetState_Name().ToUpper()]);
                                                }
                                                else if (OverwriteValue(Param.GetState_Text().ToUpper(), CompVars[Param.GetState_Name().ToUpper()], Component.GetState_SchDesignator().GetState_Text(), Param.GetState_Name().ToUpper()))
                                                {
                                                    Param.SetState_Text(CompVars[Param.GetState_Name().ToUpper()]);
                                                }
                                            }
                                        }
                                    }
                                    Param = PIterator.NextSchObject() as ISch_Parameter;
                                }
                                Component.UpdatePart_PostProcess();
                                VarList.Components[Component.GetState_SchDesignator().GetState_Text()].Saved = true;
                            }
                        }
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    if (ServerDoc.GetModified())
                    {
                        ServerDoc.DoFileSave("");
                    }

                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
                Progress.Value += 1;
                UpdateLabel("Updating Variants");
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #27
0
    /// <summary>
    /// Iterates through all schematic docs of the active project and
    /// changes the grid snap and aligns components based on parameters.
    /// </summary>
    /// <param name="SizeInMils">Desired grid size in mils.</param>
    /// <param name="AlignToGrid">True/False if components should be aligned to the new grid.</param>
    void ChangeGridSize(int SizeInMils, bool AlignToGrid = false)
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_Document   SchDoc;
            IClient         Client = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            DXP.Utils.PercentInit("Updating Grid", LogicalDocumentCount);

            bool DocOpened = false;

            //Loop through each SCH document in project.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    SchDoc    = CurrentSheet as ISch_Document;
                    //Open document if not already open.
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }
                    Client.ShowDocument(ServerDoc);
                    SetGrid(SizeInMils);      //Set document grid size.
                    ServerDoc.DoFileSave(""); //Save file.

                    //Align parts to grid of active document.
                    if (AlignToGrid)
                    {
                        this.AlignToGrid();
                    }
                    if (!DocOpened & !AlignToGrid)
                    {
                        Client.CloseDocument(ServerDoc);
                    }
                    ServerDoc = null;
                }
                DXP.Utils.PercentUpdate();
            }
            DXP.Utils.PercentFinish();
            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
コード例 #28
0
ファイル: Merged.cs プロジェクト: jonishzx/Clover
        private bool DoAllSingleMerged(MergedConfig config)
        {
            bool mergedResult = true;
            int  fromColumn   = -1;
            int  fromRow      = -1;
            int  toClumn      = -1;
            int  toRow        = -1;

            if (!int.TryParse(config.FromColumn, out fromColumn))
            {
                throw new ArgumentException("Merge配置中fromColumn参数不能为空或者只能为数字");
            }
            if (!int.TryParse(config.ToColumn, out toClumn))
            {
                throw new ArgumentException("Merge配置中ToColumn参数不能为空或者只能为数字");
            }
            if (fromColumn > toClumn)
            {
                throw new ArgumentException("Merge配置中fromColumn参数不能大于ToColumn");
            }

            if (!int.TryParse(config.FromRow, out fromRow))
            {
                fromRow = StartRow;
            }


            if (!int.TryParse(config.ToRow, out toRow))
            {
                toRow = EndRow;
            }
            int loopIndex = fromRow;

            while (loopIndex <= toRow)
            {
                int    startRowIndex     = loopIndex;
                IRow   hssRow            = CurrentSheet.GetRow(loopIndex);
                string standCurrentValue = GetCellValue(hssRow.GetCell(fromColumn));

                for (++loopIndex; loopIndex <= toRow; loopIndex++)
                {
                    IRow   loopHssRow = CurrentSheet.GetRow(loopIndex);
                    string loopValue  = GetCellValue(loopHssRow.GetCell(fromColumn));

                    if (string.Compare(standCurrentValue, loopValue) != 0)
                    {
                        if (loopIndex - startRowIndex > 2)
                        {
                            RecursivelyMerged(startRowIndex, fromColumn, loopIndex - 1, toClumn, config);
                        }
                        break;
                    }
                    else if (loopIndex == toRow)
                    {
                        RecursivelyMerged(startRowIndex, fromColumn, loopIndex, toClumn, config);
                    }
                }
            }

            return(mergedResult);
        }