Странное Наследие
сами кнопки появляются автоматически
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MyHandLib.Controls
{
/// <summary>
/// Interaction logic for Nav_InDirButtom.xaml
/// </summary>
public partial class Nav_InDirButton : UserControl
{
private Frame frame;
public string Dir_Path { get; set; }
public string Dir_Name { get; set; }
public Nav_InDirButton(string Dir_Path)
{
InitializeComponent();
DataContext = this;
this.frame = (Frame)Application.Current.Resources["MainFrame"];
this.Dir_Path = Dir_Path;
Dir_Name = System.IO.Path.GetFileNameWithoutExtension(Dir_Path);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
(((this.Parent as StackPanel).Parent as Grid).Parent as Nav_Bar).GoLevelDown(Dir_Path);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MyHandLib.Controls
{
/// <summary>
/// Interaction logic for Nav_InDirButtom.xaml
/// </summary>
public partial class Nav_InDirButton : UserControl
{
private Frame frame;
public string Dir_Path { get; set; }
public string Dir_Name { get; set; }
public Nav_InDirButton(string Dir_Path)
{
InitializeComponent();
DataContext = this;
this.frame = (Frame)Application.Current.Resources["MainFrame"];
this.Dir_Path = Dir_Path;
Dir_Name = System.IO.Path.GetFileNameWithoutExtension(Dir_Path);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
(((this.Parent as StackPanel).Parent as Grid).Parent as Nav_Bar).GoLevelDown(Dir_Path);
}
}
}
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.IO;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using MyHandLib.Controls;
namespace MyHandLib.Pages
{
/// <summary>
/// Interaction logic for Dir_Content.xaml
/// </summary>
public partial class Dir_Content : UserControl
{
public DirectoryInfo Dir_info;
string datapath = @"C:SharePointsystemDataTable.xlsx";
string[][] filesdata;
string
//fills the files data from excel
public Dir_Content(string Dir_Path)
{
this.Dir_info = new DirectoryInfo(Dir_Path);
InitializeComponent();
Update(Dir_Path);
}
//Updates the Control-Shows current files if the current folder doesn't contain ant sub-folders
public void Update(string Dir_Path)
{
Dir_info = new DirectoryInfo(Dir_Path);
if (Dir_info.GetDirectories().Length == 0 && Dir_info.GetFiles().Length > 0)
{
// UI_Items.Background.Opacity = 0;
filesdata = GetData();
string[] arr = new string[6];
arr[0] = "Ч¤ЧўЧ•ЧњЧЄ ЧђЧ—Ч–Ч§Ч”";
arr[1] = "Ч©Чќ ЧЎЧ¤ЧЁ";
arr[2] = "ЧЄЧ™ЧђЧ•ЧЁ";
arr[3] = "ЧћЧЎ' ЧўЧ“Ч›Ч•Чџ";
arr[4] = "ЧЄЧђЧЁЧ™Чљ ЧЎЧ*Ч›ЧЁЧ•Чџ";
arr[5] = "Ч™Ч©Ч™ЧћЧ™Ч•ЧЄ";
UI_Items.Children.Add(new Item(arr));
//adds files by filters(Folder or Name)
foreach (FileInfo Dir_file in Dir_info.GetFiles())
foreach (string[] file in filesdata)
if (file[0] == Dir_info.Name && (file[1]+".pdf") == Dir_file.Name)
UI_Items.Children.Add(new Item(file, Dir_file.FullName,(this.Parent as System.Windows.Controls.Border)));
}
else
{
UI_Items.Children.Clear();
// UI_Items.Background.Opacity = 1;
}
}
//gets all written cells
public string[][] GetData()
{
var excel = new Excel.Application();
string Name = Path.GetDirectoryName(Dir_info.FullName);
Workbook DataTable = (excel.Workbooks.Open(datapath) as Workbook);
Worksheet ws = (DataTable.Worksheets[1] as Worksheet);
string[][] files = new string[GetLastPos(ws) - 1][];
for (int i = 0; i < files.Length; i++)
{
files[i] = new string[]{ ws.Cells[1][i + 1].Value2.ToString() , ws.Cells[2][i + 1].Value2.ToString(), ws.Cells[3][i + 1].Value2.ToString(), ws.Cells[4][i + 1].Value2.ToString(),
ws.Cells[5][i + 1].Value2.ToString(), ws.Cells[6][i + 1].Value2.ToString()};
}
DataTable.Close(0);
excel.Quit();
return files;
}
//get the last cell written cell in the current worksheet
public int GetLastPos(Worksheet ws)
{
int i = 1;
while (true)
{
if (ws.Cells[i, 1].Value == null)
return i;
else
i++;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.IO;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using MyHandLib.Controls;
namespace MyHandLib.Pages
{
/// <summary>
/// Interaction logic for Dir_Content.xaml
/// </summary>
public partial class Dir_Content : UserControl
{
public DirectoryInfo Dir_info;
string datapath = @"C:SharePointsystemDataTable.xlsx";
string[][] filesdata;
string
//fills the files data from excel
public Dir_Content(string Dir_Path)
{
this.Dir_info = new DirectoryInfo(Dir_Path);
InitializeComponent();
Update(Dir_Path);
}
//Updates the Control-Shows current files if the current folder doesn't contain ant sub-folders
public void Update(string Dir_Path)
{
Dir_info = new DirectoryInfo(Dir_Path);
if (Dir_info.GetDirectories().Length == 0 && Dir_info.GetFiles().Length > 0)
{
// UI_Items.Background.Opacity = 0;
filesdata = GetData();
string[] arr = new string[6];
arr[0] = "Ч¤ЧўЧ•ЧњЧЄ ЧђЧ—Ч–Ч§Ч”";
arr[1] = "Ч©Чќ ЧЎЧ¤ЧЁ";
arr[2] = "ЧЄЧ™ЧђЧ•ЧЁ";
arr[3] = "ЧћЧЎ' ЧўЧ“Ч›Ч•Чџ";
arr[4] = "ЧЄЧђЧЁЧ™Чљ ЧЎЧ*Ч›ЧЁЧ•Чџ";
arr[5] = "Ч™Ч©Ч™ЧћЧ™Ч•ЧЄ";
UI_Items.Children.Add(new Item(arr));
//adds files by filters(Folder or Name)
foreach (FileInfo Dir_file in Dir_info.GetFiles())
foreach (string[] file in filesdata)
if (file[0] == Dir_info.Name && (file[1]+".pdf") == Dir_file.Name)
UI_Items.Children.Add(new Item(file, Dir_file.FullName,(this.Parent as System.Windows.Controls.Border)));
}
else
{
UI_Items.Children.Clear();
// UI_Items.Background.Opacity = 1;
}
}
//gets all written cells
public string[][] GetData()
{
var excel = new Excel.Application();
string Name = Path.GetDirectoryName(Dir_info.FullName);
Workbook DataTable = (excel.Workbooks.Open(datapath) as Workbook);
Worksheet ws = (DataTable.Worksheets[1] as Worksheet);
string[][] files = new string[GetLastPos(ws) - 1][];
for (int i = 0; i < files.Length; i++)
{
files[i] = new string[]{ ws.Cells[1][i + 1].Value2.ToString() , ws.Cells[2][i + 1].Value2.ToString(), ws.Cells[3][i + 1].Value2.ToString(), ws.Cells[4][i + 1].Value2.ToString(),
ws.Cells[5][i + 1].Value2.ToString(), ws.Cells[6][i + 1].Value2.ToString()};
}
DataTable.Close(0);
excel.Quit();
return files;
}
//get the last cell written cell in the current worksheet
public int GetLastPos(Worksheet ws)
{
int i = 1;
while (true)
{
if (ws.Cells[i, 1].Value == null)
return i;
else
i++;
}
}
}
}
Код:
public void GoLevelUp(string Dir_path, int Dir_Level)
{
Current_DirPath = Dir_path;
Current_DirLevel = Dir_Level;
this.UI_PreDir.Children.RemoveRange(Dir_Level, 20);
this.UI_InDir.Children.RemoveRange(0, 50);
foreach (string dir in Directory.GetDirectories(Dir_path))
{
if (Current_DirLevel <= 1 && dir.Split('\')[2].Equals("system"))
continue;
UI_InDir.Children.Add(new Nav_InDirButton(dir));
}
ContentBorder.Child = content;
content.Update(Dir_path);
}
//add an element to a dockpanel
public void addToDock(DockPanel dockPanel, UIElement control, Dock dock)
{
DockPanel.SetDock(control, dock);
dockPanel.Children.Add(control);
}
{
Current_DirPath = Dir_path;
Current_DirLevel = Dir_Level;
this.UI_PreDir.Children.RemoveRange(Dir_Level, 20);
this.UI_InDir.Children.RemoveRange(0, 50);
foreach (string dir in Directory.GetDirectories(Dir_path))
{
if (Current_DirLevel <= 1 && dir.Split('\')[2].Equals("system"))
continue;
UI_InDir.Children.Add(new Nav_InDirButton(dir));
}
ContentBorder.Child = content;
content.Update(Dir_path);
}
//add an element to a dockpanel
public void addToDock(DockPanel dockPanel, UIElement control, Dock dock)
{
DockPanel.SetDock(control, dock);
dockPanel.Children.Add(control);
}