パタン編集フォーム

Namespace: FVIL.Forms
Assembly: FVILforms (in FVILforms.dll) Version: 3.1.0.0 (3.1.0.9)

Syntax

C#
public class PatternModifyForm : Form
Visual Basic
Public Class PatternModifyForm
	Inherits Form

Remarks

パタン画像(CFviPattern)のマスク情報を編集するフォームです。

Examples

このフォームの使用方法については、ソースコード中の buttonModify_Click、 を参考にしてください。

1) パタン登録ツールボックスの起動:


2) パタン登録ツールボックスの操作:


3) パタン編集フォームの起動:


4) パタン編集フォームの操作:


5) パタン表示:


ソースコード:
C# Copy imageCopy
// $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace User.SampleCode.Forms
{
    public partial class PatternForm : Form
    {
        public PatternForm()
        {
            InitializeComponent();
        }

        private void PatternForm_Load(object sender, EventArgs e)
        {
            // 画像ビューの設定.
            this.ImageView.Image = new FVIL.Data.CFviImage(
                System.IO.Path.Combine(Program.DataDir, "key_UC8_M.png")
                );

            // パタンビューの設定.
            this.PatternView.Display.MaskEnable = true;
            this.PatternView.Display.EssentialMaskEnable = true;
        }

        /// <summary>
        /// [Register] ボタンが押下されたとき
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRegist_Click(object sender, EventArgs e)
        {
            if (PatternRegistForm == null)
            {
                // ツールボックス表示.(モードレス表示)
                this.PatternRegistForm = new FVIL.Forms.PatternRegistForm(this.ImageView);
                this.PatternRegistForm.Show(this);
                this.PatternRegistForm.FormClosed += PatternRegistForm_FormClosed;
                this.PatternRegistForm.Location = this.PointToScreen(new Point(7, 7));
            }
        }

        /// <summary>
        /// ツールボックスが閉じたとき
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PatternRegistForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                // 前回分解放.
                if (this.Pattern != null)
                    this.Pattern.Dispose();
                this.Pattern = null;
                this.PatternView.Image = null;

                // パタン生成.
                if (this.PatternRegistForm.DialogResult == DialogResult.OK)
                {
                    // パタン登録位置の情報.
                    FVIL.GDI.CFviDrawPatternRegist overlay = this.ImageView.Display.OverlayPatternRegist;
                    FVIL.Data.CFviImage image = this.ImageView.Image;                        // 原画像.
                    FVIL.Data.CFviRectangle rect = overlay.RegistRect.ToCFviRectangle();    // 登録位置の矩形.
                    FVIL.Data.CFviPoint mark = overlay.CenterMark.ToCFviPoint();            // 基準点.

                    // パタン生成.
                    this.Pattern = new FVIL.Data.CFviPattern(image, rect, mark);
                    this.Pattern.Caption = PatternRegistForm.Caption;    // パタン名称.
                    if (this.Pattern.Caption.Trim() == "")
                        this.Pattern.Caption = DateTime.Now.ToString();

                    // パタンビューに表示する.
                    this.PatternView.Image = Pattern;
                    this.PatternView.FitImageSize();
                    this.PatternView.Refresh();
                }
            }
            finally
            {
                this.PatternRegistForm = null;
            }
        }
        FVIL.Forms.PatternRegistForm PatternRegistForm = null;
        FVIL.Data.CFviPattern Pattern = null;

        /// <summary>
        /// [Modify] ボタンが押下されたとき
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonModify_Click(object sender, EventArgs e)
        {
            if (this.Pattern != null)
            {
                FVIL.Forms.PatternModifyForm form = new FVIL.Forms.PatternModifyForm();
                form.Pattern = this.Pattern;

                form.StartPosition = FormStartPosition.CenterParent;
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                }

                this.PatternView.Refresh();
            }
        }
    }
}


Visual Basic Copy imageCopy
' $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Namespace SampleCode.Forms
    Public Partial Class PatternForm
        Inherits Form
        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub PatternForm_Load(sender As Object, e As EventArgs)
            ' 画像ビューの設定.
            Me.ImageView.Image = New FVIL.Data.CFviImage(System.IO.Path.Combine(Program.DataDir, "key_UC8_M.png"))

            ' パタンビューの設定.
            Me.PatternView.Display.MaskEnable = True
            Me.PatternView.Display.EssentialMaskEnable = True
        End Sub

        ''' <summary>
        ''' [Register] ボタンが押下されたとき
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        Private Sub buttonRegist_Click(sender As Object, e As EventArgs)
            If PatternRegistForm Is Nothing Then
                ' ツールボックス表示.(モードレス表示)
                Me.PatternRegistForm = New FVIL.Forms.PatternRegistForm(Me.ImageView)
                Me.PatternRegistForm.Show(Me)
                AddHandler Me.PatternRegistForm.FormClosed, AddressOf PatternRegistForm_FormClosed
                Me.PatternRegistForm.Location = Me.PointToScreen(New Point(7, 7))
            End If
        End Sub

        ''' <summary>
        ''' ツールボックスが閉じたとき
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        Private Sub PatternRegistForm_FormClosed(sender As Object, e As FormClosedEventArgs)
            Try
                ' 前回分解放.
                If Me.Pattern IsNot Nothing Then
                    Me.Pattern.Dispose()
                End If
                Me.Pattern = Nothing
                Me.PatternView.Image = Nothing

                ' パタン生成.
                If Me.PatternRegistForm.DialogResult = DialogResult.OK Then
                    ' パタン登録位置の情報.
                    Dim overlay As FVIL.GDI.CFviDrawPatternRegist = Me.ImageView.Display.OverlayPatternRegist
                    Dim image As FVIL.Data.CFviImage = Me.ImageView.Image
                    ' 原画像.
                    Dim rect As FVIL.Data.CFviRectangle = overlay.RegistRect.ToCFviRectangle()
                    ' 登録位置の矩形.
                    Dim mark As FVIL.Data.CFviPoint = overlay.CenterMark.ToCFviPoint()
                    ' 基準点.
                    ' パタン生成.
                    Me.Pattern = New FVIL.Data.CFviPattern(image, rect, mark)
                    Me.Pattern.Caption = PatternRegistForm.Caption
                    ' パタン名称.
                    If Me.Pattern.Caption.Trim() = "" Then
                        Me.Pattern.Caption = DateTime.Now.ToString()
                    End If

                    ' パタンビューに表示する.
                    Me.PatternView.Image = Pattern
                    Me.PatternView.FitImageSize()
                    Me.PatternView.Refresh()
                End If
            Finally
                Me.PatternRegistForm = Nothing
            End Try
        End Sub
        Private PatternRegistForm As FVIL.Forms.PatternRegistForm = Nothing
        Private Pattern As FVIL.Data.CFviPattern = Nothing

        ''' <summary>
        ''' [Modify] ボタンが押下されたとき
        ''' </summary>
        ''' <param name="sender"></param>
        ''' <param name="e"></param>
        Private Sub buttonModify_Click(sender As Object, e As EventArgs)
            If Me.Pattern IsNot Nothing Then
                Dim form As New FVIL.Forms.PatternModifyForm()
                form.Pattern = Me.Pattern

                form.StartPosition = FormStartPosition.CenterParent
                If form.ShowDialog(Me) = DialogResult.OK Then
                End If

                Me.PatternView.Refresh()
            End If
        End Sub
    End Class
End Namespace

Inheritance Hierarchy

System..::..Object
System..::..MarshalByRefObject
System.ComponentModel..::..Component
System.Windows.Forms..::..Control
System.Windows.Forms..::..ScrollableControl
System.Windows.Forms..::..ContainerControl
System.Windows.Forms..::..Form
FVIL.Forms..::..PatternModifyForm

See Also