public bool NewFile(bool bSilence = false) { TinyFS tfs = _Interop.GetTinyFS(null); tfs.New(); if (!tfs.m_bReady) { MessageBox.Show("无法创建新文件!", "CreateFileError.", MessageBoxButton.OK , MessageBoxImage.Error); return false; } UnitControl ucNew = new UnitControl(); ucNew.Margin = new System.Windows.Thickness(24, 4, 0, 0); ucNew.ControlStateChangeEvent += OnUnitControlStateChange; ucNew.GotFocus += new RoutedEventHandler(OnUnitControlGotFocus); ucNew.ControlCloseEvent += OnUnitControlClose; ucNew.ControlSavedEvent += OnUnitControlSaved; ucNew.AttachToTinyFS(tfs); ucNew.Modify = true; MainWrapPanel.Children.Add(ucNew); ucNew.Focus(); return true; }
public bool OpenFile(string strFile, bool bSilence = false) { if (!File.Exists(strFile)) { if (!bSilence) { MessageBox.Show(strFile + " not existed!", "OpenFileError.", MessageBoxButton.OK , MessageBoxImage.Error); } return false; } foreach (object obj in MainWrapPanel.Children) { if (obj is UnitControl) { UnitControl uc = obj as UnitControl; if (uc.IsEqual(strFile)) { SelectUnit(uc); return false; } } } TinyFS tfs = _Interop.GetTinyFS(strFile); if (!tfs.m_bReady) { if (!bSilence) { MessageBox.Show(strFile + " 文件损坏!", "OpenFileError.", MessageBoxButton.OK , MessageBoxImage.Error); } return false; } UnitControl ucNew = new UnitControl(); ucNew.FileName = strFile; ucNew.Margin = new System.Windows.Thickness(24,4,0,0); ucNew.ControlStateChangeEvent += OnUnitControlStateChange; ucNew.GotFocus += new RoutedEventHandler(OnUnitControlGotFocus); ucNew.ControlCloseEvent += OnUnitControlClose; ucNew.ControlSavedEvent += OnUnitControlSaved; ucNew.AttachToTinyFS(tfs); MainWrapPanel.Children.Add(ucNew); ucNew.Focus(); Config.AddOpenListItem(strFile); return true; }
private void SelectUnit(UnitControl uc) { uc.Focus(); uc.Maxi = true; }