void SetData_TV_LV(ExplorerListItem load) { if (load.addToTV && load.TV_data != null && load.TV_node != null)//add folder to tree view { ((TreeViewDataModel)load.TV_data).Childrens.Clear(); foreach (ExplorerNode n in load.node.Child) { if (n.Info.Size > 0) { continue; } TreeViewDataModel child = new TreeViewDataModel((TreeViewDataModel)load.TV_data) { DisplayData = new TreeviewDataItem(n) }; ((TreeViewDataModel)load.TV_data).Childrens.Add(child); } if (load.explandTV) { ((TreeViewItem)load.TV_node).ExpandSubtree(); } } ((tabControl.Items[load.indexLV_tab] as TabItem).Content as UC_Lv_item).ShowDataToLV(load.node); ((ComboBoxHeader)(tabControl.Items[load.indexLV_tab] as TabItem).Header).Node = load.node; }
//update TV, TB, LV item private void Ucitem_EventListViewFolderDoubleClickCallBack(ExplorerListItem load) { load.indexLV_tab = tabControl1.SelectedIndex; CMS_Tabcontrol.Enabled = false; try { ((tabControl1.Controls[tabControl1.SelectedIndex] as TabPage).Controls[0] as UC_LVitem).threxplorer.Abort(); } catch { } ((tabControl1.Controls[tabControl1.SelectedIndex] as TabPage).Controls[0] as UC_LVitem).threxplorer = new Thread(GetList_AddItemTo_LVnTV_); ((tabControl1.Controls[tabControl1.SelectedIndex] as TabPage).Controls[0] as UC_LVitem).threxplorer.Start(load); }
//Set explorer data void GetData_TV_LV(object obj) { ExplorerListItem o = (ExplorerListItem)obj; bool exception = false; bool flag_arenull = false; try { if (Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.ListIteamRequest(o.node) == null) { flag_arenull = true; } } catch (ThreadAbortException) { exception = true; } catch (IOException ex) { if (ex.Message == "The device is not ready.\r\n") { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error); exception = true; } else { Console.WriteLine("abort (IOException)"); exception = true; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "Error", MessageBoxButton.OK, MessageBoxImage.Error); exception = true; } finally { if (flag_arenull || exception) { Dispatcher.Invoke(new Action(() => { ((tabControl.Items[tabControl.SelectedIndex] as TabItem).Content as UC_Lv_item).managerexplorernodes.Back(); } )); } //Dispatcher.Invoke(new Action(() => CMS_Tabcontrol.Enabled = true)); } if (!exception & !flag_arenull) { Dispatcher.Invoke(new Action(() => SetData_TV_LV(o))); } }
private void Lvitem_EventListViewFolderDoubleClickCallBack(ExplorerListItem load) { load.indexLV_tab = tabControl.SelectedIndex; Thread thr = ((UC_Lv_item)((TabItem)tabControl.Items[tabControl.SelectedIndex]).Content).thr; try { if (thr.IsAlive) { thr.Abort(); } } catch { } thr = new Thread(GetData_TV_LV); thr.Start(load); }
public void ExplorerCurrentNode(bool explandTV = false, bool addToTV = false, TreeNode Tnode = null) { ExplorerListItem load = new ExplorerListItem(); load.node = managerhistory_itemnodes.NodeWorking(); load.explandTV = explandTV; load.addToTV = addToTV; if (Tnode != null) { load.TV_node = Tnode; } EventListViewFolderDoubleClickCallBack(load); }
public void GetList_AddItemTo_LVnTV_(object obj) { ExplorerListItem o = (ExplorerListItem)obj; bool exception = false; bool returnnull = false; try { if (Setting_UI.reflection_eventtocore.ExplorerAndManagerFile.ListIteamRequest(o.node) == null) { returnnull = true; } } catch (ThreadAbortException) { exception = true; } catch (IOException ex) { if (ex.Message == "The device is not ready.\r\n") { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); exception = true; } else { Console.WriteLine("abort (IOException)"); exception = true; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); exception = true; } finally { if (returnnull || exception) { Invoke(new Action(() => { list_UCLVitem[o.indexLV_tab].managerhistory_itemnodes.Back(); })); } Invoke(new Action(() => CMS_Tabcontrol.Enabled = true)); } if (!exception & !returnnull) { Invoke(new Action(() => SetData_GetList_AddItemTo_LVnTV_(o))); } }
public void ExplorerCurrentNode(bool explandTV = false, bool addToTV = false, TreeViewDataModel DataItem = null, TreeViewItem TV_item = null) { ExplorerListItem load = new ExplorerListItem(); load.node = managerexplorernodes.NodeWorking(); load.explandTV = explandTV; load.addToTV = addToTV; if (TV_item != null) { load.TV_node = TV_item; } if (DataItem != null) { load.TV_data = DataItem; } EventListViewFolderDoubleClickCallBack(load); }
public void SetData_GetList_AddItemTo_LVnTV_(ExplorerListItem load) { if (load.addToTV && load.TV_node != null)//add folder to tree view { ((TreeNode)load.TV_node).Nodes.Clear(); foreach (ItemNode c in load.node.Childs) { if (c.Info.Size > 0) { continue; } TreeNode_ child = new TreeNode_(c); ((TreeNode_)load.TV_node).Nodes.Add(child); } if (load.explandTV) { ((TreeNode)load.TV_node).Expand(); } } // Add LV tab index if (load.indexLV_tab != -1) { List <ItemLV> ListItem_LV = new List <ItemLV>(); DateTime temp = new DateTime(0); foreach (ItemNode c in load.node.Childs) { if (c.Info.Size > 0) { continue; } string datetime = ""; if (c.Info.DateMod != temp) { try { datetime = c.Info.DateMod.ToString(TimeFormat); } catch { } } ListItem_LV.Add(new ItemLV() { str = new string[] { c.Info.Name, "Folder", string.Empty, datetime, c.Info.MimeType, c.Info.ID }, icon = icon_folder }); } foreach (ItemNode c in load.node.Childs) { if (c.Info.Size < 1) { continue; } string extension = c.GetExtension(); ListItem_LV.Add(new ItemLV() { str = new string[] { c.Info.Name, "File", c.Info.Size.ToString(), c.Info.DateMod.ToString(TimeFormat), c.Info.MimeType, c.Info.ID }, icon = c.GetRoot.RootType.Type == CloudType.LocalDisk ? IconReader.GetFileIcon(c.GetFullPathString(), IconReader.IconSize.Small, false) : //some large file make slow. IconReader.GetFileIcon("." + extension, IconReader.IconSize.Small, false) }); } list_UCLVitem[load.indexLV_tab].AddListViewItem(ListItem_LV); } //set tab text name tabControl1.TabPages[load.indexLV_tab].Text = load.node.Info.Name; //set tooltip tab tabControl1.TabPages[load.indexLV_tab].ToolTipText = load.node.GetFullPathString(); //set PathNode list_UCLVitem[load.indexLV_tab].pathUC1.Node = load.node; //OldPathLV inpath = new OldPathLV(); //inpath.ID = list.id_folder; //inpath.Path = loaditemthread.path.TrimEnd(new char[] { '\\', '/' }); ////set old Path TextBox //list_UCLVitem[loaditemthread.indexLV_tab].oldpathlv.Add(inpath); }