Изменение размера сетки в Microsoft Visio 2013

Я добавил форму Charting shapes > Grid в документ Visio:

введите описание изображения здесь

Размер фигуры намного больше, чем фактическая сетка:

введите описание изображения здесь>> </p>

<p> Как изменить размер фигуры так, чтобы она соответствовала реальной сетке? </p>

<p> Я использую Microsoft Visio 2013 Professional для Windows 7. </p>

<p> Доступ к <a href= файлу , если вы хотите попробовать.

7 голосов | спросил Franck Dernoncourt 21 AM000000120000003331 2014, 00:56:33

2 ответа


4

Интересно, что это происходит, если вы измените значения по умолчанию для строк и столбцов формы сетки (например, в шаблонах диаграмм и графиков). Конкретные формы старые и не обновлялись в Visio 2013. Это было не намеренное поведение разработчиков. Это то, что команда Visio должна исправить, поэтому ее следует сообщать команде Visio в Microsoft.

ответил Devid 1 stEurope/Moscowp30Europe/Moscow09bEurope/MoscowMon, 01 Sep 2014 03:00:30 +0400 2014, 03:00:30
1

Существует полезная статья, обсуждающая это и почему она не работает на http://visualsignals.typepad.co.uk/vislog/2012/02/modifying-the-visio-grid-shape.html (это как-то связано с ячейки не изменяют размер правильно, когда они не видны).

Удобно, автор предоставляет аналогичную форму, которую вы можете загрузить и использовать вместо этого, которая имеет правильное поведение, плюс исходный код для ее создания в позже опубликовать .

Код VB.NET, который он использует для создания фиксированной формы, находится ниже:

 Module Module1

    Private Const User_RowHeight_Name = "RowHeight"
    Private Const User_ColumnWidth_Name = "ColumnWidth"
    Private Const User_RowIndex_Name = "RowIndex"
    Private Const User_ColumnIndex_Name = "ColumnIndex"
    Private Const User_IsVisible_Name = "IsVisible"
    Private Const User_ResizeModeIndex_Name = "ResizeModeIdx"

    Private Const Prop_Rows_Name = "Rows"
    Private Const Prop_Columns_Name = "Columns"
    Private Const Prop_ResizeMode_Name = "ResizeMode"
    Private Const Prop_RowHeight_Name = "RowHeight"
    Private Const Prop_ColumnWidth_Name = "ColumnWidth"

    Private Const Format_Cell_Delimiter = ";"


    Public Sub GridBuilder()

    If ActiveWindow.Type = VisWinTypes.visDrawing Then
        Call BuildGrid(ActiveWindow, _
                       10, 10, _
                       "100 mm", "50 mm", _
                       "25 mm", "5 mm")
    Else
        MsgBox "Please select a drawing window before running the Grid Builder code.", vbOKOnly, "Grid Builder"
    End If

    End Sub


    Private Sub BuildGrid(ByRef wdw As Window, _
                          ByVal rowCount As Integer, columnCount As Integer, _
                          strGridWidth As String, strGridHeight As String, _
                          strCellWidth As String, strCellHeight As String)

    Dim pag As Page
    Dim shpParent As Shape


    '  Create Grid parent shape
    Set pag = ActivePage
    Set shpParent = pag.DrawRectangle(3, 3, 5, 5)
    With shpParent

        '  Add new User, Shape Data and Actions sections
        .AddSection visSectionUser
        .AddSection visSectionProp
        .AddSection visSectionAction

        '  Add Row / Column count Shape Data cells
        .AddNamedRow visSectionProp, Prop_Rows_Name, visTagDefault
        .CellsSRC(visSectionProp, visRowLast, visCustPropsType).FormulaU = "1"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsFormat).FormulaU = """" & CreateNumericIndexString(1, rowCount, Format_Cell_Delimiter) & """"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsValue).FormulaU = "INDEX(" & rowCount - 1 & ",Prop." & Prop_Rows_Name & ".Format)"
        .AddNamedRow visSectionProp, Prop_Columns_Name, visTagDefault
        .CellsSRC(visSectionProp, visRowLast, visCustPropsType).FormulaU = "1"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsFormat).FormulaU = """" & CreateNumericIndexString(1, columnCount, Format_Cell_Delimiter) & """"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsValue).FormulaU = "INDEX(" & columnCount - 1 & ",Prop." & Prop_Columns_Name & ".Format)"

        '  Add resize mode cells
        .AddNamedRow visSectionProp, Prop_ResizeMode_Name, visTagDefault
        .CellsSRC(visSectionProp, visRowLast, visCustPropsType).FormulaU = "1"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsFormat).FormulaU = """Size parent to cells" & Format_Cell_Delimiter & "Size cells to parent"""
        .CellsSRC(visSectionProp, visRowLast, visCustPropsValue).FormulaU = "INDEX(0,Prop." & Prop_ResizeMode_Name & ".Format)"
        .AddNamedRow visSectionUser, User_ResizeModeIndex_Name, visTagDefault
        .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = "LOOKUP(Prop." & Prop_ResizeMode_Name & ",Prop." & Prop_ResizeMode_Name & ".Format)"

        '  Add RowHeight / ColumnWidth User cells
        .AddNamedRow visSectionProp, Prop_RowHeight_Name, visTagDefault
        .CellsSRC(visSectionProp, visRowLast, visCustPropsType).FormulaU = "2"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsValue).FormulaU = strCellHeight
        .CellsSRC(visSectionProp, visRowLast, visCustPropsInvis).FormulaU = "User." & User_ResizeModeIndex_Name & "=1"
        .AddNamedRow visSectionProp, Prop_ColumnWidth_Name, visTagDefault
        .CellsSRC(visSectionProp, visRowLast, visCustPropsType).FormulaU = "2"
        .CellsSRC(visSectionProp, visRowLast, visCustPropsValue).FormulaU = strCellWidth
        .CellsSRC(visSectionProp, visRowLast, visCustPropsInvis).FormulaU = "User." & User_ResizeModeIndex_Name & "=1"

        '  Add RowHeight / ColumnWidth Shape Data cells
        .AddNamedRow visSectionUser, User_RowHeight_Name, visTagDefault
        .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = "IF(User." & User_ResizeModeIndex_Name & "=0,Prop." & Prop_RowHeight_Name & ",Height/Prop." & Prop_Rows_Name & ")"
        .AddNamedRow visSectionUser, User_ColumnWidth_Name, visTagDefault
        .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = "IF(User." & User_ResizeModeIndex_Name & "=0,Prop." & Prop_ColumnWidth_Name & ",Width/Prop." & Prop_Columns_Name & ")"

        '  Set Width and Height cells
        .CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = "IF(User." & User_ResizeModeIndex_Name & "=0,Prop." & Prop_RowHeight_Name & "*Prop." & Prop_Rows_Name & ",SETATREFEXPR(" & strGridHeight & "))"
        .CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = "IF(User." & User_ResizeModeIndex_Name & "=0,Prop." & Prop_ColumnWidth_Name & "*Prop." & Prop_Columns_Name & ",SETATREFEXPR(" & strGridWidth & "))"


        '  Add Actions cells for context menu
        .AddNamedRow visSectionAction, "Resize0", visTagDefault
        .CellsSRC(visSectionAction, visRowLast, visActionMenu).FormulaU = "INDEX(0,Prop." & Prop_ResizeMode_Name & ".Format)"
        .CellsSRC(visSectionAction, visRowLast, visActionAction).FormulaU = "SETF(GetRef(Prop." & Prop_ResizeMode_Name & ")," & """INDEX(0""" & "&LISTSEP()&" & """Prop." & Prop_ResizeMode_Name & ".Format)""" & ")"
        .CellsSRC(visSectionAction, visRowLast, visActionChecked).FormulaU = "User." & User_ResizeModeIndex_Name & "=0"
        .AddNamedRow visSectionAction, "Resize1", visTagDefault
        .CellsSRC(visSectionAction, visRowLast, visActionMenu).FormulaU = "INDEX(1,Prop." & Prop_ResizeMode_Name & ".Format)"
        .CellsSRC(visSectionAction, visRowLast, visActionAction).FormulaU = "SETF(GetRef(Prop." & Prop_ResizeMode_Name & ")," & """INDEX(1""" & "&LISTSEP()&" & """Prop." & Prop_ResizeMode_Name & ".Format)""" & ")"
        .CellsSRC(visSectionAction, visRowLast, visActionChecked).FormulaU = "User." & User_ResizeModeIndex_Name & "=1"

        '  Set protection and behaviour cells
        .CellsSRC(visSectionObject, visRowLock, visLockCalcWH).FormulaU = "1"
        .CellsSRC(visSectionObject, visRowLock, visLockTextEdit).FormulaU = "1"
        .CellsSRC(visSectionObject, visRowLock, visLockVtxEdit).FormulaU = "1"
        .CellsSRC(visSectionObject, visRowGroup, visGroupDisplayMode).FormulaU = "1"
        .ConvertToGroup
    End With


    'Generate grid cell shapes and add them to the parent
    Dim iRow As Integer
    Dim iCol As Integer
    Dim shpTempCell As Shape

    Dim GridSelection As Selection
    wdw.DeselectAll
    Set GridSelection = wdw.Selection
    GridSelection.Select shpParent, visSelect

    For iRow = 1 To rowCount
        For iCol = 1 To columnCount
            Set shpTempCell = CreateGridCell(shpParent, iRow, iCol)
            If Not shpTempCell Is Nothing Then
                GridSelection.Select shpTempCell, visSelect
                Set shpTempCell = Nothing
            End If
        Next iCol
    Next iRow

    GridSelection.AddToGroup

    End Sub

    Private Function CreateGridCell(shpParent As Shape, rowIdx As Integer, colIdx As Integer) As Shape
    Dim shpCell As Shape

    If Not shpParent Is Nothing Then
        Dim pag As Page
        Dim parentId As Integer

        Set pag = shpParent.Parent
        parentId = shpParent.ID
        Set shpCell = pag.DrawRectangle(1, 1, 2, 2)

        With shpCell
            .AddSection visSectionUser
            .AddNamedRow visSectionUser, User_RowIndex_Name, visTagDefault
            .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = rowIdx
            .AddNamedRow visSectionUser, User_ColumnIndex_Name, visTagDefault
            .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = colIdx

            'Set shape visibility
            .AddNamedRow visSectionUser, User_IsVisible_Name, visTagDefault
            '  =IF(OR(User.RowIndex>Sheet.1!Prop.Rows,User.ColumnIndex>Sheet.1!Prop.Columns),0,1)
            .CellsSRC(visSectionUser, visRowLast, visUserValue).FormulaU = "IF(OR(User." & User_RowIndex_Name & ">Sheet." & parentId & "!Prop." & Prop_Rows_Name & ",User." & User_ColumnIndex_Name & ">Sheet." & parentId & "!Prop." & Prop_Columns_Name & "),0,1)"
            .CellsSRC(visSectionFirstComponent, visRowComponent, visCompNoShow).FormulaU = "NOT(User." & User_IsVisible_Name & ")"

            'Set width and height
            .CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaU = "GUARD(Sheet." & parentId & "!User." & User_RowHeight_Name & ")"
            .CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaU = "GUARD(Sheet." & parentId & "!User." & User_ColumnWidth_Name & ")"

            'Set position (PinX and PinY)
            '  =Sheet.1!User.ColumnWidth*IF(User.IsVisible,User.ColumnIndex,1)-Sheet.1!User.ColumnWidth/2
            '  =Sheet.1!Height-Sheet.1!User.RowHeight*IF(User.IsVisible,User.RowIndex,1)+Sheet.1!User.RowHeight/2
            .CellsSRC(visSectionObject, visRowXFormOut, visXFormPinX).FormulaU = "GUARD(Sheet." & parentId & "!User." & User_ColumnWidth_Name & "*IF(User." & User_IsVisible_Name & ",User." & User_ColumnIndex_Name & ",1)-Sheet." & parentId & "!User." & User_ColumnWidth_Name & "/2)"
            .CellsSRC(visSectionObject, visRowXFormOut, visXFormPinY).FormulaU = "GUARD(Sheet." & parentId & "!Height-Sheet." & parentId & "!User." & User_RowHeight_Name & "*IF(User." & User_IsVisible_Name & ",User." & User_RowIndex_Name & ",1)+Sheet." & parentId & "!User." & User_RowHeight_Name & "/2)"

            .CellsSRC(visSectionObject, visRowLock, visLockVtxEdit).FormulaU = "1"
            .CellsSRC(visSectionObject, visRowLock, visLockRotate).FormulaU = "1"
            .CellsSRC(visSectionObject, visRowLock, visLockDelete).FormulaU = "1"
        End With


    End If

    Set CreateGridCell = shpCell

    End Function


    Private Function CreateNumericIndexString(ByVal startInt As Integer, endInt As Integer, delimiter As String) As String
    Dim i As Integer
    Dim IdxString As String

    For i = startInt To endInt
        IdxString = IdxString & CStr(i)
        If Not i = endInt Then
            IdxString = IdxString & delimiter
        End If
    Next i

    CreateNumericIndexString = IdxString

    End Function

End Module
ответил Rhumborl 14 J000000Thursday16 2016, 15:54:23

Похожие вопросы

Популярные теги

security × 330linux × 316macos × 2827 × 268performance × 244command-line × 241sql-server × 235joomla-3.x × 222java × 189c++ × 186windows × 180cisco × 168bash × 158c# × 142gmail × 139arduino-uno × 139javascript × 134ssh × 133seo × 132mysql × 132