小区物业管理系统-通知发布

Posted CaoPengCheng&

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了小区物业管理系统-通知发布相关的知识,希望对你有一定的参考价值。

小区物业管理系统-通知发布

在这里插入图片描述

Imports System.Drawing.Printing
Imports System.IO

Public Class JiShiBeng
    Dim a, aa As Integer
    Dim s As String
    Dim row As Single
    Dim i, j As Single
    Dim p As Single
    Dim count As Single
    Dim count1 As Single
    Dim fnames As String
    Dim fnamed As String
    Dim printFont As Font
    Dim streamToPrint As StreamReader
    Dim x, y As Single
    Dim storedPageSettings As PageSettings

    Public Sub New(s As String)
        InitializeComponent()
    End Sub

    Private Sub 状态栏ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 状态栏ToolStripMenuItem.Click
        If 状态栏ToolStripMenuItem.Checked = False Then
            状态栏ToolStripMenuItem.Checked = True
            StatusStrip1.Visible = True
        Else
            状态栏ToolStripMenuItem.Checked = False
            StatusStrip1.Visible = False
        End If
    End Sub

    Private Sub 字体ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 字体ToolStripMenuItem.Click
        FontDialog1.Font = RichTextBox1.SelectionFont
        If (FontDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            RichTextBox1.SelectionFont = FontDialog1.Font
        End If
    End Sub

    Private Sub 自动换行ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 自动换行ToolStripMenuItem.Click
        If 自动换行ToolStripMenuItem.Checked = False Then
            RichTextBox1.WordWrap = True
            自动换行ToolStripMenuItem.Checked = True
        Else
            RichTextBox1.WordWrap = False
            自动换行ToolStripMenuItem.Checked = False
        End If
    End Sub




    Private Sub 颜色ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 颜色ToolStripMenuItem.Click
        ColorDialog1.Color = RichTextBox1.SelectionColor
        If (ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            RichTextBox1.SelectionColor = ColorDialog1.Color
        End If
    End Sub



    Private Sub 退出ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem1.Click
        Dim n As Integer
        If Len(Trim(RichTextBox1.Text)) <> 0 And a = 1 Then
            n = MsgBox("是否发布?", MsgBoxStyle.YesNoCancel, "提示")

            If n = 6 And a = 1 Then
                FileOpen(1, "通知.txt", OpenMode.Output)
                PrintLine(1, RichTextBox1.Text)
                FileClose(1)
                MsgBox("发布成功!")
                Me.Close()
            End If
            If n = 7 Then
                Me.Close()
            End If
        Else
            Me.Close()
        End If
    End Sub

    Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
        Dim linesPerPage As Single = 0
        Dim yPos As Single = 0
        Dim count As Integer = 0
        Dim leftMargin As Single = ev.MarginBounds.Left
        Dim topMargin As Single = ev.MarginBounds.Top
        Dim line As String = Nothing

        ' Calculate the number of lines per page.
        linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)

        ' Print each line of the file.
        While count < linesPerPage
            line = streamToPrint.ReadLine()
            If line Is Nothing Then
                Exit While
            End If
            yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
            ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
            count += 1
        End While

        ' If more lines exist, print another page.
        If Not (line Is Nothing) Then
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
        End If
    End Sub


    Private Sub 全选ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 全选ToolStripMenuItem.Click
        RichTextBox1.SelectAll()
    End Sub




    

    Private Sub RichTextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyUp
        If e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Or e.KeyCode = Keys.Left Or e.KeyCode = Keys.Right Then
            row = RichTextBox1.SelectionStart
            count = 0
            count1 = 0
            For j = 0 To RichTextBox1.Lines.GetUpperBound(0)
                count += RichTextBox1.Lines(j).Length + 1 ' 一个回车相当于1个
                If row < count Then
                    If j = 0 Then
                        p = row
                    Else
                        p = row - count1
                    End If
                    If count1 > row Then
                        Exit For
                    End If
                    ToolStripStatusLabel1.Text = "ln:" & CStr(j + 1) & ",col:" & CStr(p)
                End If
                count1 += RichTextBox1.Lines(j).Length + 1
            Next
        End If
    End Sub

    Private Sub RichTextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles RichTextBox1.MouseClick
        row = RichTextBox1.SelectionStart
        count = 0
        count1 = 0
        For j = 0 To RichTextBox1.Lines.GetUpperBound(0)
            count += RichTextBox1.Lines(j).Length + 1 ' 一个回车相当于1个
            If row < count Then
                If j = 0 Then
                    p = row
                Else
                    p = row - count1
                End If
                If count1 > row Then
                    Exit For
                End If
                ToolStripStatusLabel1.Text = "ln:" & CStr(j + 1) & ",col:" & CStr(p)
            End If
            count1 += RichTextBox1.Lines(j).Length + 1
        Next
    End Sub



    Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged
        row = RichTextBox1.SelectionStart
        count = 0
        count1 = 0
        For i = 0 To RichTextBox1.Lines.GetUpperBound(0)
            count += RichTextBox1.Lines(i).Length + 1 ' 一个回车相当于1个
            If row <= count Then
                If i = 0 Then
                    p = row
                Else
                    p = row - count1
                End If
                ToolStripStatusLabel1.Text = "ln:" & CStr(i + 1) & ",col:" & CStr(p)
            End If
            count1 += RichTextBox1.Lines(i).Length + 1
        Next
        If a = 1 Then
            a = 0
        Else
            a = 1
        End If
    End Sub

    Private Sub 剪切ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 剪切ToolStripMenuItem.Click
        s = RichTextBox1.SelectedText
        RichTextBox1.SelectedText = ""
    End Sub

    Private Sub 复制ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 复制ToolStripMenuItem.Click
        s = RichTextBox1.SelectedText
    End Sub

    Private Sub 粘贴ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 粘贴ToolStripMenuItem.Click
        If Len(s) <> 0 Then
            RichTextBox1.SelectedText = s
        End If
    End Sub

    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem3.Click
        RichTextBox1.SelectedText = ""
    End Sub


    Private Sub 撤消ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 撤消ToolStripMenuItem.Click
        RichTextBox1.Undo()
    End Sub


    Public Class TextFilePrintDocument
        Inherits PrintDocument
        Private printFont As Font
        Private streamToPrint As StreamReader
        Public Sub New(ByVal streamToPrint As StreamReader)
            MyBase.New()
            Me.streamToPrint = streamToPrint
        End Sub
        'Override OnBeginPrint to set up the font we are going to use
        Protected Overrides Sub OnBeginPrint(ByVal ev As PrintEventArgs)
            MyBase.OnBeginPrint(ev)
            printFont = New Font("宋体", 12)
        End Sub
        'Override the OnPrintPage to provide the printing logic for the document
        Protected Overrides Sub OnPrintPage(ByVal ev As PrintPageEventArgs)
            MyBase.OnPrintPage(ev)
            Dim lpp As Single = 0
            Dim yPos As Single = 0
            Dim count As Integer = 0
            Dim leftMargin As Single = ev.MarginBounds.Left
            Dim topMargin As Single = ev.MarginBounds.Top
            Dim line As String
            'Work out the number of lines per page
            'Use the MarginBounds on the event to do this
            lpp = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
            'Check count first so that we don't read line that we won't print
            line = streamToPrint.ReadLine()
            While ((count < lpp) And Not (line Is Nothing))
                yPos = topMargin + (count * printFont.GetHeight(ev.Graphics))
                ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
                count = count + 1
                If (count < lpp) Then
                    line = streamToPrint.ReadLine()
                End If
            End While
            If (line <> Nothing) Then
                ev.HasMorePages = True
            Else
                ev.HasMorePages = False
            End If
        End Sub
    End Class

    Private Sub JiShiBeng_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        aa = 0
        ' dk = 0
        StatusStrip1.Visible = True
        ToolStripStatusLabel1.Text = "ln:0,col:0"
    End Sub

    Private Sub 保存ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles 保存ToolStripMenuItem.Click
        '  MsgBox(RichTextBox1.Text)
        FileOpen(1, "通知.txt", OpenMode.Output)
        PrintLine(1, RichTextBox1.Text)
        FileClose(1)
        MsgBox("发布成功!")
        Me.Close()
    End Sub
End Class

以上是关于小区物业管理系统-通知发布的主要内容,如果未能解决你的问题,请参考以下文章

计算机毕业设计-物业管理系统代码-基于SSM的智能小区物业系统代码-java社区物业水电缴费系统代码

计算机毕业设计-社区疫情防控管理系统springboot-小区疫情管理系统java代码

小区物业管理系统的设计与实现 文献收集

小区物业管理系统-总结-需求分析

基于java的小区物业管理系统

小区物业管理系统-系统管理员页面