コード例 #1
0
ファイル: MainWindow.cs プロジェクト: mstone121/FileTag
        private void InitializeComponent()
        {
            //this.components = new System.ComponentModel.Container();
            this.SuspendLayout();

            #region Bars
            // Component init for various toolbars

            // Status Bar
            // Bottom bar of application
            statusBar = new StatusStrip();
            statusBar.Name = "statusBar";
            statusBar.Location = new Point(0, 590);

            // Tool Bar
            // Main toolbar
            toolStrip = new ToolStrip();
            toolStrip.Location = new Point(0, 24);
            toolStrip.Name = "toolStrip";
            toolStrip.Items.Add("Write Tag", null, click_write_tag);
            toolStrip.Items.Add("Tag from File", null, click_tag_from_file);
            toolStrip.Items.Add("Tag from Filename", null, click_tag_from_filename);

            // Menu Bar
            // Top bar of application
            menuBar = new MenuStrip();
            menuBar.SuspendLayout();
            menuBar.Name = "menuBar";
            menuBar.Location = new Point(0, 0);

            #region Menu Bar Items

            //  File
            mb_file = new ToolStripMenuItem();
            mb_file.Name = "mb_file";
            mb_file.Text = "File";

            //      Open
            mb_file_open = new ToolStripMenuItem();
            mb_file_open.Name = "mb_file_open";
            mb_file_open.Text = "Open File(s)";
            mb_file_open.Click += new EventHandler(mb_file_open_Click);

            //      Exit
            mb_file_exit = new ToolStripMenuItem();
            mb_file_exit.Name = "mb_file_exit";
            mb_file_exit.Text = "Exit";
            mb_file_exit.Click += new EventHandler(mb_file_exit_Click);

            mb_file.DropDownItems.AddRange(new ToolStripItem[] {
                mb_file_open,
                mb_file_exit});

            // View
            mb_view = new ToolStripMenuItem();
            mb_view.Name = "mb_view";
            mb_view.Text = "View";

            //      Columns
            mb_view_columns = new ToolStripMenuItem();
            mb_view_columns.Name = "mb_view_columns";
            mb_view_columns.Text = "Columns...";
            mb_view_columns.Click += new EventHandler(mb_view_columns_Click);

            mb_view.DropDownItems.AddRange(new ToolStripItem[] {
                mb_view_columns});

            //  Help
            mb_help = new ToolStripMenuItem();
            mb_help.Name = "mb_help";
            mb_help.Text = "Help";

            //      About
            mb_help_about = new ToolStripMenuItem();
            mb_help_about.Name = "mb_help";
            mb_help_about.Text = "About";

            mb_help.DropDownItems.AddRange(new ToolStripItem[] {
                mb_help_about});

            menuBar.Items.AddRange(new ToolStripItem[] {
                mb_file,
                mb_view,
                mb_help});

            #endregion

            #endregion

            #region Main Interface
            // Main window components

            // Main window splitter
            mainSplit = new SplitContainer();
            ((System.ComponentModel.ISupportInitialize)(mainSplit)).BeginInit();
            mainSplit.Panel1.SuspendLayout();
            mainSplit.Panel2.SuspendLayout();
            mainSplit.SuspendLayout();

            mainSplit.BorderStyle = BorderStyle.Fixed3D;
            mainSplit.Dock = DockStyle.Fill;
            mainSplit.FixedPanel = FixedPanel.Panel1;
            mainSplit.Location = new Point(0, 49);
            mainSplit.Name = "mainSplit";

            // Control Side
            mainSplit.Panel1MinSize = 300;

            // File Side
            mainSplit.Panel2.Controls.Add(fileList);
            mainSplit.Size = new Size(984, 541);
            mainSplit.SplitterDistance = 300;
            mainSplit.TabIndex = 3;

            // File tag controls
            controlGrid = new DataGridView();
            controlGrid.Dock = DockStyle.Fill;
            controlGrid.AllowUserToAddRows = false;
            controlGrid.CellValueChanged += new DataGridViewCellEventHandler(control_grid_value_change);
            controlGrid.RowHeadersVisible = false;

            DataGridViewColumn cg_property = new DataGridViewTextBoxColumn();
            cg_property.HeaderText = "Property";
            cg_property.ReadOnly = true;
            cg_property.SortMode = DataGridViewColumnSortMode.NotSortable;

            DataGridViewColumn cg_value = new DataGridViewTextBoxColumn();
            cg_value.HeaderText = "Value";
            cg_value.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            cg_value.SortMode = DataGridViewColumnSortMode.NotSortable;

            controlGrid.Columns.AddRange(new DataGridViewColumn[] {cg_property, cg_value});

            foreach (String property in properties)
                controlGrid.Rows.Add(new String[] { property, "" });

            // File list view
            fileList = new RightClickableListView();

            fileList.Name = "fileList";
            fileList.AllowColumnReorder = true;
            fileList.AllowDrop = true; // Drag-n-Drop
            fileList.Dock = DockStyle.Fill;
            fileList.Location = new Point(0, 0);
            fileList.View = View.Details; // Details View
            fileList.FullRowSelect = true;
            fileList.MultiSelect = true;
            fileList.HideSelection = false;
            fileList.KeyDown += new KeyEventHandler(fileList_key_press);
            fileList.ColumnContextMenuClicked += new RightClickableListView.ColumnContextMenuHandler(fileList_right_click);
            fileList.ItemSelectionChanged += new ListViewItemSelectionChangedEventHandler(fileList_selection);

            #endregion

            #region Dialogs
            // Dialog components

            openFileDialog = new OpenFileDialog();
            openFileDialog.FileName = "openFileDialog";

            #endregion

            #region Menus
            headerContext = new ContextMenu();

            foreach (String header in MainWindow.headers)
            {
                MenuItem item = new MenuItem(header);
                item.Click += new EventHandler(header_menu_item_click);
                headerContext.MenuItems.Add(item);
            }

            #endregion

            #region Main Window
            // Settings for main window

            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode = AutoScaleMode.Font;
            ClientSize = new Size(984, 612);
            MinimumSize = new Size(700, 500);

            Name = "MainWindow";
            Text = "File Tag";

            #endregion

            #region Add Controls

            Controls.Add(mainSplit);
            Controls.Add(toolStrip);
            Controls.Add(statusBar);
            Controls.Add(menuBar);
            MainMenuStrip = menuBar;

            mainSplit.Panel1.Controls.Add(controlGrid);
            mainSplit.Panel2.Controls.Add(fileList);

            #endregion

            #region Resume Layouts

            menuBar.ResumeLayout(false);
            menuBar.PerformLayout();

            mainSplit.Panel1.ResumeLayout(false);
            mainSplit.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(mainSplit)).EndInit();
            mainSplit.ResumeLayout(false);

            ResumeLayout(false);
            PerformLayout();

            #endregion
        }
コード例 #2
0
        private void InitializeComponent()
        {
            //this.components = new System.ComponentModel.Container();
            this.SuspendLayout();

            #region Bars
            // Component init for various toolbars

            // Status Bar
            // Bottom bar of application
            statusBar          = new StatusStrip();
            statusBar.Name     = "statusBar";
            statusBar.Location = new Point(0, 590);

            // Tool Bar
            // Main toolbar
            toolStrip          = new ToolStrip();
            toolStrip.Location = new Point(0, 24);
            toolStrip.Name     = "toolStrip";
            toolStrip.Items.Add("Write Tag", null, click_write_tag);
            toolStrip.Items.Add("Tag from File", null, click_tag_from_file);
            toolStrip.Items.Add("Tag from Filename", null, click_tag_from_filename);


            // Menu Bar
            // Top bar of application
            menuBar = new MenuStrip();
            menuBar.SuspendLayout();
            menuBar.Name     = "menuBar";
            menuBar.Location = new Point(0, 0);

            #region Menu Bar Items

            //  File
            mb_file      = new ToolStripMenuItem();
            mb_file.Name = "mb_file";
            mb_file.Text = "File";

            //      Open
            mb_file_open        = new ToolStripMenuItem();
            mb_file_open.Name   = "mb_file_open";
            mb_file_open.Text   = "Open File(s)";
            mb_file_open.Click += new EventHandler(mb_file_open_Click);

            //      Exit
            mb_file_exit        = new ToolStripMenuItem();
            mb_file_exit.Name   = "mb_file_exit";
            mb_file_exit.Text   = "Exit";
            mb_file_exit.Click += new EventHandler(mb_file_exit_Click);

            mb_file.DropDownItems.AddRange(new ToolStripItem[] {
                mb_file_open,
                mb_file_exit
            });

            // View
            mb_view      = new ToolStripMenuItem();
            mb_view.Name = "mb_view";
            mb_view.Text = "View";

            //      Columns
            mb_view_columns        = new ToolStripMenuItem();
            mb_view_columns.Name   = "mb_view_columns";
            mb_view_columns.Text   = "Columns...";
            mb_view_columns.Click += new EventHandler(mb_view_columns_Click);

            mb_view.DropDownItems.AddRange(new ToolStripItem[] {
                mb_view_columns
            });

            //  Help
            mb_help      = new ToolStripMenuItem();
            mb_help.Name = "mb_help";
            mb_help.Text = "Help";

            //      About
            mb_help_about      = new ToolStripMenuItem();
            mb_help_about.Name = "mb_help";
            mb_help_about.Text = "About";

            mb_help.DropDownItems.AddRange(new ToolStripItem[] {
                mb_help_about
            });


            menuBar.Items.AddRange(new ToolStripItem[] {
                mb_file,
                mb_view,
                mb_help
            });

            #endregion

            #endregion

            #region Main Interface
            // Main window components

            // Main window splitter
            mainSplit = new SplitContainer();
            ((System.ComponentModel.ISupportInitialize)(mainSplit)).BeginInit();
            mainSplit.Panel1.SuspendLayout();
            mainSplit.Panel2.SuspendLayout();
            mainSplit.SuspendLayout();

            mainSplit.BorderStyle = BorderStyle.Fixed3D;
            mainSplit.Dock        = DockStyle.Fill;
            mainSplit.FixedPanel  = FixedPanel.Panel1;
            mainSplit.Location    = new Point(0, 49);
            mainSplit.Name        = "mainSplit";

            // Control Side
            mainSplit.Panel1MinSize = 300;

            // File Side
            mainSplit.Panel2.Controls.Add(fileList);
            mainSplit.Size             = new Size(984, 541);
            mainSplit.SplitterDistance = 300;
            mainSplit.TabIndex         = 3;

            // File tag controls
            controlGrid      = new DataGridView();
            controlGrid.Dock = DockStyle.Fill;
            controlGrid.AllowUserToAddRows = false;
            controlGrid.CellValueChanged  += new DataGridViewCellEventHandler(control_grid_value_change);
            controlGrid.RowHeadersVisible  = false;

            DataGridViewColumn cg_property = new DataGridViewTextBoxColumn();
            cg_property.HeaderText = "Property";
            cg_property.ReadOnly   = true;
            cg_property.SortMode   = DataGridViewColumnSortMode.NotSortable;

            DataGridViewColumn cg_value = new DataGridViewTextBoxColumn();
            cg_value.HeaderText   = "Value";
            cg_value.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            cg_value.SortMode     = DataGridViewColumnSortMode.NotSortable;

            controlGrid.Columns.AddRange(new DataGridViewColumn[] { cg_property, cg_value });

            foreach (String property in properties)
            {
                controlGrid.Rows.Add(new String[] { property, "" });
            }



            // File list view
            fileList = new RightClickableListView();

            fileList.Name = "fileList";
            fileList.AllowColumnReorder = true;
            fileList.AllowDrop          = true; // Drag-n-Drop
            fileList.Dock                      = DockStyle.Fill;
            fileList.Location                  = new Point(0, 0);
            fileList.View                      = View.Details; // Details View
            fileList.FullRowSelect             = true;
            fileList.MultiSelect               = true;
            fileList.HideSelection             = false;
            fileList.KeyDown                  += new KeyEventHandler(fileList_key_press);
            fileList.ColumnContextMenuClicked += new RightClickableListView.ColumnContextMenuHandler(fileList_right_click);
            fileList.ItemSelectionChanged     += new ListViewItemSelectionChangedEventHandler(fileList_selection);

            #endregion

            #region Dialogs
            // Dialog components

            openFileDialog          = new OpenFileDialog();
            openFileDialog.FileName = "openFileDialog";

            #endregion

            #region Menus
            headerContext = new ContextMenu();

            foreach (String header in MainWindow.headers)
            {
                MenuItem item = new MenuItem(header);
                item.Click += new EventHandler(header_menu_item_click);
                headerContext.MenuItems.Add(item);
            }


            #endregion

            #region Main Window
            // Settings for main window

            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode       = AutoScaleMode.Font;
            ClientSize          = new Size(984, 612);
            MinimumSize         = new Size(700, 500);

            Name = "MainWindow";
            Text = "File Tag";

            #endregion

            #region Add Controls

            Controls.Add(mainSplit);
            Controls.Add(toolStrip);
            Controls.Add(statusBar);
            Controls.Add(menuBar);
            MainMenuStrip = menuBar;

            mainSplit.Panel1.Controls.Add(controlGrid);
            mainSplit.Panel2.Controls.Add(fileList);

            #endregion

            #region Resume Layouts

            menuBar.ResumeLayout(false);
            menuBar.PerformLayout();

            mainSplit.Panel1.ResumeLayout(false);
            mainSplit.Panel2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(mainSplit)).EndInit();
            mainSplit.ResumeLayout(false);

            ResumeLayout(false);
            PerformLayout();

            #endregion
        }