private void FormMain_Load(object sender, EventArgs e) { SetCaptionText(); openFileDialog1.Filter = "Garmin-Dateien|*.img;*.typ;*.tdb;*.mdx;*.dem|Alle Dateien|*.*"; ImageList myImages = new ImageList(); myImages.ImageSize = new Size(16, 16); myImages.TransparentColor = Color.Transparent; myImages.Images.Add(new Bitmap(16, 16)); // Dummy-Image, damit der Platz im TabKopf einkalkuliert wird tabControl1.ImageList = myImages; tabControl1.TabPages[0].ImageIndex = 0; dummytabpage = tabControl1.TabPages[0]; tabControl1.TabPages.Clear(); try { for (int i = 0; i < Args.Length; i++) { NewTabPageWithFile(Args[i].Trim()); } if (Args.Length > 0 && tabControl1.TabPages.Count > 0) { TabPageData tpd = TabPageData4Page(tabControl1.TabPages[0]); tpd.Tv.Select(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void SwapTabs(int sourceIndex, int destinationIndex) { TabPageData tabData = _tabPageDataCollection.TabPageDictionary[sourceIndex]; _tabPageDataCollection.TabPageDictionary[sourceIndex] = _tabPageDataCollection.TabPageDictionary[destinationIndex]; _tabPageDataCollection.TabPageDictionary[destinationIndex] = tabData; _tabPageDataCollection.TabPageDictionary[sourceIndex].PageIndex = sourceIndex; _tabPageDataCollection.TabPageDictionary[destinationIndex].PageIndex = destinationIndex; _tabPageDataCollection.ActiveTabIndex = destinationIndex; }
private void appendNewToolStripMenuItem_Click(object sender, EventArgs e) { int tabPageIndex = _tabPageDataCollection.TabPageDictionary.Max(p => p.Key) + 1; var tabPageData = new TabPageData { PageIndex = tabPageIndex, TabPageLabel = "Page" + (tabPageIndex + 1) }; tabPageData.GenerateUniqueIdIfNoneExists(); _tabPageDataCollection.TabPageDictionary.Add(tabPageIndex, tabPageData); _applicationState.TabPageAddOrRemove = true; _tabPageDataCollection.ActiveTabIndex = tabPageData.PageIndex; InitializeTabControls(); }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { TabPage tp = (sender as TabControl).SelectedTab; string txt = null; if (tp != null) { TabPageData tpd = TabPageData4Page(tp); if (tpd != null) { txt = tpd.Path; } } SetCaptionText(txt); }
private void addNewTabToolStripMenuItem_Click(object sender, EventArgs e) { int newIndex = _listViewDataSource.Max(x => x.Index) + 1; string tabPageLabel = "Page" + (newIndex + 1); var tabPageData = new TabPageData { PageIndex = newIndex, TabPageLabel = tabPageLabel, TabPageText = "" }; tabPageData.GenerateUniqueIdIfNoneExists(); _listViewDataSource.Add(new DragableListItem { Index = newIndex, Label = tabPageLabel, PageData = tabPageData }); TabDataChanged = true; LoadTabPageCollection(); }
private void cutToolStripMenuItem_Click(object sender, EventArgs e) { if (!_tabPageDataCollection.TabPageDictionary.ContainsKey(_tabPageDataCollection.ActiveTabIndex)) { return; } TabPageData tabPageData = _tabPageDataCollection.TabPageDictionary[_tabPageDataCollection.ActiveTabIndex]; RichTextBox richTextBox = GetRichTextBoxInActiveTab(); if (!string.IsNullOrWhiteSpace(richTextBox?.SelectedText)) { richTextBox.Cut(); tabPageData.TabPageText = richTextBox.Text; } }
void NewTabPageWithFile(string newfile) { string[] files = new string[] { "" }; if (File.Exists(newfile)) { files[0] = newfile; } else if (Directory.Exists(newfile)) { files = Directory.GetFiles(newfile, "*.*", SearchOption.AllDirectories); Array.Sort(files); } else { MessageBox.Show("'" + newfile + "' not exist!", "error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } for (int i = RecentUsedPaths.Count - 1; i >= 0; i--) { if (RecentUsedPaths[i] == newfile) { RecentUsedPaths.RemoveAt(i); } } TabPageData tpd = AppendNewTabPage(Path.GetFileName(newfile), newfile); foreach (var file in files) { NodeContent.Content4PhysicalFile content4file = new NodeContent.Content4PhysicalFile(file); TreeNode tn = Data.AppendNode(tpd.Tv, NodeContent.NodeType.PhysicalFile, content4file, Path.GetFileName(content4file.Filename)); Data.AppendNode(tn); // damit der Knoten ausklappbar ist //tpd.Tv.SelectedNode = tn; } SetCaptionText(tpd.Path); tabControl1.SelectedTab = tpd.Page; // TabPage akt. tpd.Tv.Select(); // Treeview akt. if (tpd.Tv.Nodes.Count > 0) { tpd.Tv.SelectedNode = tpd.Tv.Nodes[0]; // 1. Node akt. } }
private void InitializeTabControls() { _applicationState.Initializing = true; if (!_memoStorageService.DatabaseExists()) { _applicationState.DatabaseLoaded = false; _applicationState.DatabaseExists = false; } else { _applicationState.DatabaseExists = true; } // Create tab pages tabControlNotepad.TabPages.Clear(); foreach (int tabPageIndex in _tabPageDataCollection.TabPageDictionary.Keys) { TabPageData tabPageData = _tabPageDataCollection.TabPageDictionary[tabPageIndex]; var tabPageControl = new MemoTabPageControl("MemoTabPageControl", tabPageIndex) { Dock = DockStyle.Fill }; var tabPage = new TabPage(tabPageData.TabPageLabel); tabPageControl.TabTextDataChanged += tabPageControl_TabTextDataChanged; tabPage.Controls.Add(tabPageControl); var richTextBox = ControlHelper.GetChildControlByName(tabPageControl, tabPageControl.TabPageControlTextboxName) as RichTextBox; if (richTextBox != null) { SecureMemoFontSettings fontSettings = _appSettingsService.Settings.FontSettings; richTextBox.Font = new Font(fontSettings.FontFamily, fontSettings.FontSize, fontSettings.Style); richTextBox.Text = tabPageData.TabPageText; richTextBox.ContextMenuStrip = contextMenuTextArea; richTextBox.SelectionChanged += RichTextBox_SelectionChanged; } tabControlNotepad.TabPages.Add(tabPage); } tabControlNotepad.SelectedIndex = _tabPageDataCollection.ActiveTabIndex; _applicationState.Initializing = false; UpdateApplicationState(); }
private void undoToolStripMenuItem_Click(object sender, EventArgs e) { if (!_tabPageDataCollection.TabPageDictionary.ContainsKey(_tabPageDataCollection.ActiveTabIndex)) { return; } TabPageData tabPageData = _tabPageDataCollection.TabPageDictionary[_tabPageDataCollection.ActiveTabIndex]; RichTextBox richTextBox = GetRichTextBoxInActiveTab(); if (richTextBox != null && richTextBox.CanUndo) { richTextBox.Undo(); } if (richTextBox != null) { tabPageData.TabPageText = richTextBox.Text; } }
void CloseTabPage() { if (tabControl1.TabPages.Count > 0) { if (MessageBox.Show("Would you like to Close this Tab?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { TabPage page = tabControl1.SelectedTab; tabControl1.TabPages.Remove(page); // ev. geöffnete Dateien schließen TabPageData tpd = TabPageData4Page(page); if (tpd != null) { foreach (TreeNode tn in tpd.Tv.Nodes) // alle TreeNodes der 1. Ebene untersuchen { NodeContent nc = Data.NodeContent4TreeNode(tn); GarminCore.BinaryReaderWriter br = null; switch (nc.Type) { case NodeContent.NodeType.PhysicalFile: case NodeContent.NodeType.LogicalFile: br = (nc.Data as NodeContent.Content4File).BinaryReader; break; } if (br != null) { br.Dispose(); } } for (int i = RecentUsedPaths.Count - 1; i >= 0; i--) { if (RecentUsedPaths[i] == tpd.Path) { RecentUsedPaths.RemoveAt(i); } } RecentUsedPaths.Insert(0, tpd.Path); } } } }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { if (!_tabPageDataCollection.TabPageDictionary.ContainsKey(_tabPageDataCollection.ActiveTabIndex)) { return; } if (!Clipboard.ContainsText()) { return; } TabPageData tabPageData = _tabPageDataCollection.TabPageDictionary[_tabPageDataCollection.ActiveTabIndex]; RichTextBox richTextBox = GetRichTextBoxInActiveTab(); if (richTextBox == null) { return; } richTextBox.Paste(); tabPageData.TabPageText = richTextBox.Text; }
/// <summary> /// get/set value of one page /// </summary> public TabPageData this[int nIndex] { get { if (tbl[nIndex] == null) { tbl[nIndex] = new TabPageData(); if (Count < nIndex + 1) { Count = nIndex + 1; } } return((TabPageData)tbl[nIndex]); } set { tbl[nIndex] = value; if (Count < nIndex + 1) { Count = nIndex + 1; } } }
private TextSearchResult GetTextSearchResultInActiveState(TextSearchProperties searchProperties) { var textSearchResult = new TextSearchResult(); TabPageData tabPageData = _tabPageDataCollection.TabPageDictionary[_searchState.TabIndex]; int matchPos; if (string.IsNullOrEmpty(tabPageData.TabPageText)) { SetNextTabIndex(searchProperties.SearchDirection); return(textSearchResult); } if (searchProperties.SearchDirection == TextSearchEvents.SearchDirection.Down) { if (_searchState.StartPosDown >= tabPageData.TabPageText.Length) { _searchState.StartPosDown = tabPageData.TabPageText.Length - 1; } else if (_searchState.StartPosDown < 0) { _searchState.StartPosDown = 0; } matchPos = tabPageData.TabPageText.IndexOf(searchProperties.SearchText, _searchState.StartPosDown, searchProperties.CaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); } else { if (_searchState.StartPosUp < 0 || _searchState.StartPosUp > tabPageData.TabPageText.Length) { _searchState.StartPosUp = tabPageData.TabPageText.Length; } matchPos = tabPageData.TabPageText.LastIndexOf(searchProperties.SearchText, _searchState.StartPosUp, searchProperties.CaseSensitive ? StringComparison.CurrentCulture : StringComparison.CurrentCultureIgnoreCase); } if (matchPos >= 0) { _searchState.StartPosDown = matchPos + searchProperties.SearchText.Length; _searchState.StartPosUp = matchPos - searchProperties.SearchText.Length; if (_searchState.StartPosUp < 0) { _searchState.StartPosUp = 0; } textSearchResult.StartPos = matchPos; textSearchResult.Length = searchProperties.SearchText.Length; _searchState.MatchesFound++; textSearchResult.SearchTextFound = true; } else { _searchState.StartPosDown = 0; _searchState.StartPosUp = -1; SetNextTabIndex(searchProperties.SearchDirection); textSearchResult.SearchTextFound = false; } return(textSearchResult); }
public TabEditorOriginalElementState(TabPageData pageData) { UniqueID = pageData.UniqueId; PageIndex = pageData.PageIndex; LabelText = pageData.TabPageLabel; }
/// <summary> /// Daten für den akt. Node anzeigen /// <para>aus dem akt. und ev. den darüber liegenden Nodes wird bestimmt, welche Daten anzuzeigen sind</para> /// </summary> /// <param name="tn"></param> /// <param name="tpd"></param> void ShowData4Node(TreeNode tn, TabPageData tpd) { byte[] hex = null; long firsthexadr = 0; tpd.Hexwin.ClearContent(); tpd.Info.Clear(); StringBuilder info = new StringBuilder(); NodeContent nc = Data.NodeContent4TreeNode(tn); TreeViewData tvd = TreeViewData.GetTreeViewData(tn); switch (nc.Type) { case NodeContent.NodeType.PhysicalFile: if (nc.Data is NodeContent.Content4PhysicalFile) { Data.RegisterCoreFiles(tvd, (nc.Data as NodeContent.Content4PhysicalFile).Filename); Data.ShowData4Node_PhysicalFile(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4PhysicalFile, tvd); } break; case NodeContent.NodeType.SimpleFilesystem: nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische Datei übergeordnet sein if (nc.Data is NodeContent.Content4PhysicalFile) { DataSimpleFilesystem.ShowData(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4PhysicalFile, tvd); } break; case NodeContent.NodeType.LogicalFile: if (nc.Data is NodeContent.Content4LogicalFile) { Data.RegisterCoreFiles(tvd, (nc.Data as NodeContent.Content4LogicalFile).Filename); Data.ShowData4Node_LogicalFile(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4LogicalFile, tvd); } break; case NodeContent.NodeType.GarminCommonHeader: nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische oder logische Datei übergeordnet sein if (nc.Data is NodeContent.Content4File) { Data.ShowData4Node_GarminCommonHeader(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4File, tvd); } break; case NodeContent.NodeType.GarminSpecialHeader: nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische oder logische Datei übergeordnet sein if (nc.Data is NodeContent.Content4File) { Data.ShowData4Node_GarminSpecialHeader(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4File, tvd); } break; case NodeContent.NodeType.Index: if (tn.Parent != null) { Data.ShowData4Node_GarminStdFile(info, out hex, out firsthexadr, Data.GetNextContent4File(tn), Data.NodeContent4TreeNode(tn.Parent).Type, (int)nc.Data, tvd); } break; case NodeContent.NodeType.DataRange: NodeContent.Content4DataRange c4dr = nc.Data as NodeContent.Content4DataRange; info.AppendLine(c4dr.Info); hex = c4dr.Bytes; firsthexadr = c4dr.FirstAdr; break; default: NodeContent.Content4File c4f = Data.GetNextContent4File(tn); Data.RegisterCoreFiles(tvd, c4f.Filename); Data.ShowData4Node_GarminStdFile(info, out hex, out firsthexadr, c4f, nc.Type, -1, tvd); break; } tpd.Info.AppendText(info.ToString()); tpd.Info.Select(0, 0); tpd.Info.ScrollToCaret(); if (hex != null) { tpd.Hexwin.SetContent(hex, (ulong)firsthexadr); } }