public MSATabPageClosingEventArgs(CloseReason closeReason, bool cancel, MSATabPage ctrl) : base(closeReason, cancel) { Control = ctrl; }
public void RemovePage(MSATabPage removedPage) { if (removedPage.ClosePage()) { Controls.Remove(removedPage); int currentIndex = 0; for (int i = 0; i < PageButtons.Count(); i++) { if (PageButtons[i].Tag.ToString() == removedPage.Name) { Controls.Remove(PageButtons[i]); currentIndex = i; if (currentIndex == PageButtons.Count()) currentIndex--; PageButtonLineUp.Remove(removedPage.ButtonName); refreshButtons(); break; } } if (Pages.Count() == 1) { SelectedPage = Pages[0] as MSATabPage; } else { if (SelectedPage == removedPage && currentIndex != -1) SelectedPage = Pages[currentIndex] as MSATabPage; } if (MSATabPageClosed != null) MSATabPageClosed.Invoke(this, new ControlEventArgs(removedPage)); } else { (removedPage as MSATabPage).OnMSATabPageClosing(new FormClosingEventArgs(CloseReason.UserClosing, false)); } }
private bool Save(MSATabPage tab) { var tb = (tab.Controls[0] as FastColoredTextBox); if (tab.Tag == null) { if (sfdMain.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; tab.PageTitle = Path.GetFileName(sfdMain.FileName); tab.Tag = sfdMain.FileName; } try { File.WriteAllText(tab.Tag as string, tb.Text); tb.IsChanged = false; } catch (Exception ex) { if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == DialogResult.Retry) return Save(tab); else return false; } tb.Invalidate(); return true; }
public void AddPage(MSATabPage newPage)//you mustn't use like "Control.Add(MSATablePage)" { ContextMenuStrip menuStrip = new ContextMenuStrip(); menuStrip.Name = "cntMSATabPage" + _Pagecounter; menuStrip.Items.Add(new ToolStripMenuItem() { Name = "kapatToolStripMenuItem" + _Pagecounter, Text = "Kapat" }); newPage.Name = ("MSATPage" + _Pagecounter);//unique ID Controls.Add(newPage); AddPageTitleButton(newPage, menuStrip); _Pagecounter++; }
private void CreateTab(string fileName) { if (ScriptCommunityPack.keywordsInformation.Count == 0) { MessageBox.Show("primarily load keywords"); return; } try { FastColoredTextBox tb = new FastColoredTextBox(); tb.AutoScroll = true; tb.BorderStyle = BorderStyle.None; tb.Font = new Font("Consolas", 9.75f); tb.BackgroundImage = Properties.Resources.bg1; tb.ForeColor = Color.White; tb.LineNumberColor = Color.White; tb.IndentBackColor = Color.FromArgb(80, Color.Gray); tb.ContextMenuStrip = cmMain; tb.Dock = DockStyle.Fill; tb.LeftPadding = 5; tb.Language = Language.Scp; tb.AddStyle(new MarkerStyle(new SolidBrush(Color.FromArgb(50, Color.Gray))));//same words style if (fileName != null) tb.OpenFile(fileName); tb.Name = Path.GetFileName(fileName); tb.ClearUndo(); tb.Tag = new PopupMenu(); tb.Focus(); tb.DelayedTextChangedInterval = 1; tb.DelayedEventsInterval = 500; tb.TextChangedDelayed += new EventHandler<TextChangedEventArgs>(tb_TextChangedDelayed); tb.SelectionChangedDelayed += new EventHandler(tb_SelectionChangedDelayed); tb.ToolTipNeeded += tb_ToolTipNeeded; tb.KeyDown += new KeyEventHandler(tb_KeyDown); tb.MouseMove += new MouseEventHandler(tb_MouseMove); tb.ChangedLineColor = changedLineColor; if (btHighlightCurrentLine.Checked) tb.CurrentLineColor = currentLineColor; tb.ShowFoldingLines = btShowFoldingLines.Checked; tb.HighlightingRangeType = HighlightingRangeType.VisibleRange; AutocompleteMenu popupMenu = new AutocompleteMenu(tb); popupMenu.Items.ImageList = ilAutocomplete; popupMenu.Opening += new EventHandler<CancelEventArgs>(popupMenu_Opening); BuildAutocompleteMenu(popupMenu); (tb.Tag as PopupMenu).popupMenu = popupMenu; tb.ToolTip.OwnerDraw = true; tb.ToolTip.Draw += ToolTip_Draw; tb.ToolTip.Popup += ToolTip_Popup; MSATabPage newPagem = new MSATabPage(tb, fileName != null ? Path.GetFileName(fileName) : "[new]"); newPagem.Tag = fileName; newPagem.MSATabPageClosing += NewPagem_MSATabPageClosing; msaTabControl1.MSATabPageClosed += msaTabControl1_MSATabPageClosed; msaTabControl1.SelectedPageChanged += MsaTabControl1_SelectedPageChanged; msaTabControl1.AddPage(newPagem); documentMap1.BackgroundImage = tb.BackgroundImage; documentMap1.Target = tb; } catch (Exception ex) { if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Retry) CreateTab(fileName); return; } msaTabControl1.SelectedPage.Tag = fileName; }