예제 #1
0
        private Panel CreatePanel(PanelProfile panelProfile)
        {
            var panel = new TableLayoutPanelExtension(panelProfile);

            return(panel);
        }
예제 #2
0
        public TableLayoutPanelExtension(PanelProfile panelProfile)
        {
            PanelProfile = panelProfile;

            SuspendLayout();

            textBox = new TextBox
            {
                Anchor      = AnchorStyles.Top | AnchorStyles.Left,
                Dock        = DockStyle.Top,
                BorderStyle = BorderStyle.FixedSingle,
            };
            listView = new ListView
            {
                Anchor             = AnchorStyles.Top | AnchorStyles.Left,
                Dock               = DockStyle.Fill,
                BorderStyle        = BorderStyle.FixedSingle,
                HeaderStyle        = ColumnHeaderStyle.Clickable,
                LabelEdit          = false,
                AllowColumnReorder = true,
                FullRowSelect      = true,
                GridLines          = true,
            };

            Dock = DockStyle.Fill;
            Controls.Add(listView);
            Controls.Add(textBox);

            textBox.Text     = panelProfile.Location;
            textBox.KeyDown += (object sender, KeyEventArgs e) =>
            {
                if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
                {
                    DeferSwitchLocation(textBox.Text);
                }
            };

            ColumnHeader nameHeader = new ColumnHeader {
                Width = 200, Text = "Name"
            };
            ColumnHeader sizeHeader = new ColumnHeader {
                Width = 50, Text = "Size"
            };
            ColumnHeader dateHeader = new ColumnHeader {
                Width = 50, Text = "Date"
            };

            listView.View = (View)Enum.Parse(typeof(View), panelProfile.View);
            listView.Columns.AddRange(new ColumnHeader[]
            {
                nameHeader,
                sizeHeader,
                dateHeader,
            });
            listView.SmallImageList = new ImageList();
            //listView.SmallImageList.ImageSize = new Size( 50, 50 );

            ResumeLayout();
            PerformLayout();

            DeferSwitchLocation(panelProfile.Location);
        }
예제 #3
0
        public static void SaveTo(PanelProfile profile, string fileName)
        {
            var jsonString = JsonSerializer.Serialize(profile);

            File.WriteAllText(fileName, jsonString);
        }