/// <summary> /// Initialize a new instance of the ViewDrawRibbonAppMenuRecentDec class. /// </summary> /// <param name="ribbon">Reference to owning ribbon instance.</param> /// <param name="provider">Provider of context menu information.</param> /// <param name="recentDoc">Source rencent document instance.</param> /// <param name="maxWidth">Maximum width allowed for the item.</param> /// <param name="needPaintDelegate">Delegate for requesting paint updates.</param> /// <param name="index">Recent documet index.</param> public ViewDrawRibbonAppMenuRecentDec(KryptonRibbon ribbon, IContextMenuProvider provider, KryptonRibbonRecentDoc recentDoc, int maxWidth, NeedPaintHandler needPaintDelegate, int index) : base(provider.ProviderStateNormal.ItemHighlight.Back, provider.ProviderStateNormal.ItemHighlight.Border, provider.ProviderStateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { _maxWidth = maxWidth; Provider = provider; RecentDoc = recentDoc; ShortcutText = (index < 10 ? @"&" + index.ToString() : "A"); // Use docker to organize horizontal items ViewLayoutDocker docker = new ViewLayoutDocker { // End of line gap { new ViewLayoutSeparator(5), ViewDockStyle.Right } }; // Add the text/extraText/Image entry FixedContentValue entryContent = new FixedContentValue(recentDoc.Text, recentDoc.ExtraText, recentDoc.Image, recentDoc.ImageTransparentColor); RibbonRecentDocsEntryToContent entryPalette = new RibbonRecentDocsEntryToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry); ViewDrawContent entryDraw = new ViewDrawContent(entryPalette, entryContent, VisualOrientation.Top); docker.Add(entryDraw, ViewDockStyle.Fill); // Shortcut to Content gap docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Left); // Add the shortcut column FixedContentValue shortcutContent = new FixedContentValue(ShortcutText, null, null, Color.Empty); RibbonRecentDocsShortcutToContent shortcutPalette = new RibbonRecentDocsShortcutToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry); ViewDrawRibbonRecentShortcut shortcutDraw = new ViewDrawRibbonRecentShortcut(shortcutPalette, shortcutContent); docker.Add(shortcutDraw, ViewDockStyle.Left); // Start of line gap docker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left); // Attach a controller so menu item can be tracked and pressed RecentDocController controller = new RecentDocController(Provider.ProviderViewManager, this, needPaintDelegate); MouseController = controller; KeyController = controller; SourceController = controller; Add(docker); }
private void AsyncCallback(ESGI.Entity.Interfaces.IContainer container) { KryptonRibbonRecentDoc rDoc = new KryptonRibbonRecentDoc() { Text = container.Property("c_id").Get<String>(), Tag = container }; rDoc.Click += new EventHandler(ClickWork); kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Add(rDoc); }
/// <summary> /// Initialize a new instance of the ViewDrawRibbonAppMenuRecentDec class. /// </summary> /// <param name="ribbon">Reference to owning ribbon instance.</param> /// <param name="provider">Provider of context menu information.</param> /// <param name="recentDoc">Source rencent document instance.</param> /// <param name="maxWidth">Maximum width allowed for the item.</param> /// <param name="needPaintDelegate">Delegate for requesting paint updates.</param> /// <param name="index">Recent documet index.</param> public ViewDrawRibbonAppMenuRecentDec(KryptonRibbon ribbon, IContextMenuProvider provider, KryptonRibbonRecentDoc recentDoc, int maxWidth, NeedPaintHandler needPaintDelegate, int index) : base(provider.ProviderStateNormal.ItemHighlight.Back, provider.ProviderStateNormal.ItemHighlight.Border, provider.ProviderStateNormal.ItemHighlight, PaletteMetricPadding.ContextMenuItemHighlight, VisualOrientation.Top) { _maxWidth = maxWidth; _provider = provider; _recentDoc = recentDoc; _shortcutText = (index < 10 ? @"&" + index.ToString() : "A"); // Use docker to organize horizontal items ViewLayoutDocker docker = new ViewLayoutDocker(); // End of line gap docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Right); // Add the text/extraText/Image entry FixedContentValue entryContent = new FixedContentValue(recentDoc.Text, recentDoc.ExtraText, recentDoc.Image, recentDoc.ImageTransparentColor); RibbonRecentDocsEntryToContent entryPalette = new RibbonRecentDocsEntryToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry); ViewDrawContent entryDraw = new ViewDrawContent(entryPalette, entryContent, VisualOrientation.Top); docker.Add(entryDraw, ViewDockStyle.Fill); // Shortcut to Content gap docker.Add(new ViewLayoutSeparator(5), ViewDockStyle.Left); // Add the shortcut column FixedContentValue shortcutContent = new FixedContentValue(_shortcutText, null, null, Color.Empty); RibbonRecentDocsShortcutToContent shortcutPalette = new RibbonRecentDocsShortcutToContent(ribbon.StateCommon.RibbonGeneral, ribbon.StateCommon.RibbonAppMenuDocsEntry); ViewDrawRibbonRecentShortcut shortcutDraw = new ViewDrawRibbonRecentShortcut(shortcutPalette, shortcutContent); docker.Add(shortcutDraw, ViewDockStyle.Left); // Start of line gap docker.Add(new ViewLayoutSeparator(3), ViewDockStyle.Left); // Attach a controller so menu item can be tracked and pressed RecentDocController controller = new RecentDocController(_provider.ProviderViewManager, this, needPaintDelegate); MouseController = controller; KeyController = controller; SourceController = controller; Add(docker); }
private void MemoEditorForm1_Load(object sender, EventArgs e) { // Try and open the saved settings for memo editor RegistryKey memoEditorSettings = Registry.CurrentUser.OpenSubKey(_memoEditorPath); if (memoEditorSettings != null) { try { // Look for each of the maximum number of entries for (int i = 1; i <= _maxRecentDocs; i++) { // If we managed to get an entry string filename = memoEditorSettings.GetValue(i.ToString()) as string; if (!string.IsNullOrEmpty(filename)) { KryptonRibbonRecentDoc recentDoc = new KryptonRibbonRecentDoc(); recentDoc.Click += new EventHandler(buttonRecentFile_Clicked); recentDoc.Text = filename; // Add to end of the recent docs collection kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Add(recentDoc); } } } catch { }; try { // Restore the global palette selected previously string globalPalette = memoEditorSettings.GetValue("GlobalPalette") as string; if (!string.IsNullOrEmpty(globalPalette)) kryptonManager.GlobalPaletteMode = (PaletteModeManager)Enum.Parse(typeof(PaletteModeManager), globalPalette); // Restore the cell mode selected previously string cellMode = memoEditorSettings.GetValue("CellMode") as string; if (!string.IsNullOrEmpty(cellMode)) _cellMode = (NavigatorMode)Enum.Parse(typeof(NavigatorMode), cellMode); } catch { }; memoEditorSettings.Close(); } // Add the three predefined memos as content buttonReadMe_Click(null, EventArgs.Empty); buttonShortcuts_Click(null, EventArgs.Empty); buttonPersistence_Click(null, EventArgs.Empty); // Organize them buttonGridArrange_Click(null, EventArgs.Empty); // Make the first cell the selected one kryptonWorkspace.ActiveCell = kryptonWorkspace.FirstCell(); UpdateCellsFromGrouping(); UpdateButtonsFromGrouping(); UpdateButtonsFromPalette(); UpdateApplicationTitle(); UpdateOptions(); }
private void AddRecentFile(string filename) { // Search for an existing entry for that filename KryptonRibbonRecentDoc recentDoc = null; foreach(KryptonRibbonRecentDoc entry in kryptonRibbon.RibbonAppButton.AppButtonRecentDocs) if (entry.Text.Equals(filename)) { recentDoc = entry; break; } // If no existing entry then create a new one if (recentDoc == null) { recentDoc = new KryptonRibbonRecentDoc(); recentDoc.Click += new EventHandler(buttonRecentFile_Clicked); recentDoc.Text = filename; } // Remove entry from current list and insert at the top kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Remove(recentDoc); kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Insert(0, recentDoc); // Restrict list to just 9 entries if (kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Count > _maxRecentDocs) for (int i = kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Count; i > _maxRecentDocs; i--) kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.RemoveAt(kryptonRibbon.RibbonAppButton.AppButtonRecentDocs.Count - 1); }