private void panel_MouseDoubleClick(object sender, MouseEventArgs e) { //isReadyPanel = false; MyPanel doubleClickMyPanel = findsender(sender); string dive = doubleClickMyPanel.view2.GetControlFromPosition(0, 0).Text; if (Directory.Exists(File.currentpath + "/" + dive)) { Console.Write(dive); String[] look = File.LookFile(dive); currentPath_TextChanged(); Console.WriteLine(File.currentpath); //FileInfo f = new FileInfo(@"C: \Users\turtle\Desktop\Documents\Resume and Cover Letter\Hao Luo.docx"); //if (f.Exists) //{ // Console.WriteLine("check12"); // using (FileStream c = f.Open(FileMode.Open)) // { // byte[] b = new byte[1024]; // UTF8Encoding temp = new UTF8Encoding(true); // } //} if (look != null) { this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.Controls.Clear(); this.tableLayoutPanel1.RowStyles.Clear(); this.tableLayoutPanel1.RowCount = 0; numPanel = 0; foreach (var check in look) { if (check.Length > check.LastIndexOf(@"\") + 1) { createcheckbox(check); } } this.tableLayoutPanel1.AutoScroll = true; this.tableLayoutPanel1.VerticalScroll.Value = 0; this.tableLayoutPanel1.ResumeLayout(); } } else { Console.WriteLine(File.currentpath); dive = File.currentpath + "/" + dive; if ((System.IO.File.Exists(dive))) { System.Diagnostics.Process.Start(dive); } } }
private void tableRow_Hover(object sender, EventArgs e) { if (isReadyPanel == true) { tableLayoutPanel1.SuspendLayout(); int Rownum = 0; MyPanel sub = findsender(sender); Rownum = tableLayoutPanel1.GetRow(sub); tableLayoutPanel1.RowStyles[Rownum] = new RowStyle(SizeType.Absolute, 100F); isReadyPanel = false; tableLayoutPanel1.ResumeLayout(); } }
private void tableRow_Leave(object sender, EventArgs args) { if (isReadyPanel == false) { canbeUpdate = true; tableLayoutPanel1.SuspendLayout(); int Rownum = 0; Point rec = new Point(0, 0); MyPanel sub = findsender(sender); Rownum = tableLayoutPanel1.GetRow(sub); if (sub != null) { int Top = sub.PointToScreen(Point.Empty).Y; int Bottom = sub.PointToScreen(Point.Empty).Y + sub.Size.Height; int left = sub.PointToScreen(Point.Empty).X; int right = sub.PointToScreen(Point.Empty).X + sub.Size.Width; //for (int i = 0; i < 10000; i++) //{ System.Threading.Thread.Sleep(100); if ((right) <= MousePosition.X || left >= MousePosition.X || Top >= MousePosition.Y || Bottom <= MousePosition.Y) { //Console.WriteLine("\n" + Top + ", " + Bottom + ", " + left + ", " + right + ", " + // Form1.MousePosition.Y + // ", " + Form1.MousePosition.X); //Console.WriteLine(tableLayoutPanel1.RowStyles.Count); if (tableLayoutPanel1.RowStyles.Count > Rownum) { tableLayoutPanel1.RowStyles[Rownum] = new RowStyle(SizeType.Absolute, 60F); } // break; } //Console.WriteLine(tableLayoutPanel1.RowCount + ", " + Rownum); isReadyPanel = true; tableLayoutPanel1.ResumeLayout(); // } } } }
private MyPanel findsender(object sender) { MyPanel sub = null; if (sender is TableLayoutPanel) { TableLayoutPanel clicked = (TableLayoutPanel)sender; if (clicked.Parent.Parent is MyPanel) { sub = (MyPanel)clicked.Parent.Parent; } } else if (sender is CheckBox) { CheckBox clicked = (CheckBox)sender; if (clicked.Parent.Parent is MyPanel) { sub = (MyPanel)clicked.Parent.Parent; } } else if (sender is MyPanel) { MyPanel clicked = (MyPanel)sender; sub = clicked; } else { Label clicked = (Label)sender; if (clicked.Parent.Parent is MyPanel) { sub = (MyPanel)clicked.Parent.Parent; } } return(sub); }
private void panel_Click(object sender, EventArgs e) { MyPanel currentPanel = findsender(sender); currentPanel.temp.Checked = !currentPanel.temp.Checked; }
/* private void treeEstablish() * { * Boolean finished = false; * }*/ private void createcheckbox(string name) { this.tableLayoutPanel1.SuspendLayout(); //TableLayoutPanel view2 = new TableLayoutPanel(); // view2.SuspendLayout(); // DirectoryInfo d = new DirectoryInfo(name); // System.Windows.Forms.CheckBox temp = new System.Windows.Forms.CheckBox(); // temp.CheckAlign = ContentAlignment.MiddleCenter; // temp.Name = d.Name.ToString(); // temp.Size = new System.Drawing.Size(87, 37); // temp.TabIndex = 0; // view2.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 100F)); // view2.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F)); // //view2.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble; //view2.Controls.Add(new Label() {Text = d.Name.ToString(), AutoSize = true, /*Font = new Font(FontFamily.GenericSansSerif, 16, FontStyle.Bold)*/ }, 0, 0); // view2.RowStyles.Add(new RowStyle(SizeType.Absolute, 15F)); // view2.RowStyles.Add(new RowStyle(SizeType.Absolute, 15F)); // view2.Controls.Add(new Label() {Text= d.LastAccessTime.ToString(), AutoSize =true}, 0 ,1); // if (d.Attributes.Equals(File)) // { // FileInfo info = new FileInfo(name); // view2.Controls.Add(new Label() {Text = info.Length.ToString(), AutoSize = true}, 0 ,2); // } // Image folder = // Image.FromFile(@"C: \Users\turtle\Desktop\Documents\Software Projects\Progress\Faith\Images\folder\folder.png"); // Label label = new Label(); // label.Image = folder; // //label.Padding = new Padding(30); // label.AutoSize = false; // label.Dock = DockStyle.Fill; // label.ImageAlign = ContentAlignment.MiddleCenter; // temp.Dock = DockStyle.Fill; MyPanel panel = new MyPanel(name); panellist.Add(panel); panel.Dock = DockStyle.Fill; tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); tableLayoutPanel1.Controls.Add(panel, 0, tableLayoutPanel1.RowCount); // Panel front = new Panel(); // tableLayoutPanel1.Controls.Add(front, 0, tableLayoutPanel1.RowCount); // this.tableLayoutPanel1.SetColumnSpan(front, 3); // front.Location = temp.Location; // front.Size = new Size(tableLayoutPanel1.Width, 60); //front.Visible = false; //front.BackColor = Color.Black; tableLayoutPanel1.RowCount++; Label black = new Label(); black.BackColor = Color.Black; this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 5)); // this.tableLayoutPanel1.SetColumnSpan(black, 3); this.tableLayoutPanel1.Controls.Add(black); black.Dock = DockStyle.Top; this.tableLayoutPanel1.RowCount++; //panel.front.MouseEnter += new EventHandler(tableRow_Hover); //front.MouseLeave +=new EventHandler(tableRow_Leave); //view2.Dock = DockStyle.Fill; panel.view2.MouseEnter += new EventHandler(tableRow_Hover); panel.view2.MouseLeave += new EventHandler(tableRow_Leave); panel.view2.Click += new EventHandler(panel_Click); panel.view2.MouseDoubleClick += new MouseEventHandler(panel_MouseDoubleClick); panel.label.MouseEnter += new EventHandler(tableRow_Hover); panel.label.MouseLeave += new EventHandler(tableRow_Leave); panel.label.Click += new EventHandler(panel_Click); panel.label.MouseDoubleClick += new MouseEventHandler(panel_MouseDoubleClick); panel.temp.MouseEnter += new EventHandler(tableRow_Hover); panel.temp.MouseLeave += new EventHandler(tableRow_Leave); panel.temp.MouseDoubleClick += new MouseEventHandler(panel_MouseDoubleClick); panel.MouseEnter += new EventHandler(tableRow_Hover); panel.MouseLeave += new EventHandler(tableRow_Leave); panel.Click += new EventHandler(panel_Click); panel.MouseDoubleClick += new MouseEventHandler(panel_MouseDoubleClick); this.tableLayoutPanel1.ResumeLayout(); }