void grdLister_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null) { return; } else if (cell.GridControl.Name == "grdLister") { if (this.MessageType.ToLower() == "pda") { menu.Items[2].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; } else { menu.Items[2].Visibility = Telerik.WinControls.ElementVisibility.Visible; } e.ContextMenu = menu; return; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
void grdLister_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null) { return; } else if (cell.GridControl.Name == "grdLister") { if (menu_Job == null) { menu_Job = new RadDropDownMenu(); RadMenuItem viewJobItem1 = new RadMenuItem("View Job"); viewJobItem1.ForeColor = Color.DarkBlue; viewJobItem1.BackColor = Color.Orange; viewJobItem1.Font = new Font("Tahoma", 10, FontStyle.Bold); viewJobItem1.Click += new EventHandler(viewJobItem1_Click); menu_Job.Items.Add(viewJobItem1); } e.ContextMenu = menu_Job; return; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void webControlContextMenu_Opening(object sender, ContextMenuOpeningEventArgs e) { // Update the visibility of our menu items based on the // latest context data. openSeparator.Visible = openMenuItem.Visible = !e.Info.IsEditable && (webView.Source != null); }
private void ForumContextMenu_Opening(object sender, ContextMenuOpeningEventArgs e) { var context = (e.FocusedElement as FrameworkElement).DataContext; bool isPinned = (context as ForumDataSource).IsPinned; _togglePinned.Content = isPinned ? UNPIN : PIN; }
private void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // Needed on every UI interaction SdkService.MegaSdkFolderLinks.retryPendingConnections(); try { if (_folderLinkViewModel != null && _folderLinkViewModel.FolderLink != null) { var focusedListBoxItem = e.FocusedElement as RadDataBoundListBoxItem; if (focusedListBoxItem == null || !(focusedListBoxItem.DataContext is IMegaNode)) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; } else { _folderLinkViewModel.FolderLink.FocusedNode = (IMegaNode)focusedListBoxItem.DataContext; } } else { e.Cancel = true; } } catch (Exception) { e.Cancel = true; } }
private void SfDataGrid1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { if (e.ContextMenutype == ContextMenuType.GroupCaption) { grid = (e.ContextMenuInfo as RowContextMenuInfo).DataGrid; group = (e.ContextMenuInfo as RowContextMenuInfo).Row as Group; } if (e.ContextMenutype == ContextMenuType.GroupDropAreaItem || e.ContextMenutype == ContextMenuType.ColumnHeader) { grid = (e.ContextMenuInfo as ColumnContextMenuInfo).DataGrid; column = (e.ContextMenuInfo as ColumnContextMenuInfo).Column; } if (e.ContextMenutype == ContextMenuType.GroupDropArea) { grid = (e.ContextMenuInfo as GroupDropAreaContextMenuInfo).DataGrid; } if (e.ContextMenutype == ContextMenuType.GroupSummary || e.ContextMenutype == ContextMenuType.TableSummary) { grid = (e.ContextMenuInfo as RowContextMenuInfo).DataGrid; summary = (e.ContextMenuInfo as RowContextMenuInfo).Row as SummaryRecordEntry; } if (e.ContextMenutype == ContextMenuType.Record || e.ContextMenutype == ContextMenuType.RowHeader) { grid = (e.ContextMenuInfo as RowContextMenuInfo).DataGrid; row = e.RowIndex; columnIndex = e.ColumnIndex; record = (e.ContextMenuInfo as RowContextMenuInfo).Row; } }
/// <summary> /// add an option to open a console here if it's a directory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void host_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // we only show the context menu if every item selected in the tree is valid to be compiled IList <string> paths = new List <string>(); var showContextMenu = e.Items.Count > 0; foreach (ISiteItem item in e.Items) { if (item == null || !(item is ISiteFolder)) { showContextMenu = false; break; } else { paths.Add((item as ISiteFolder).Path); } } // if all of the files in the list are valid, show the command window option if (showContextMenu) { var menuItem = new ContextMenuItem("Open Command Window", null, new DelegateCommand(new Action <object>(OpenCMD)), paths); e.AddMenuItem(menuItem); } }
private void radGridViewControlTech_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; // deny custom contextmenu for non cell elements clicked if (cell == null) { return; } RadMenuItem customMenuItemValidateArrival = new RadMenuItem(); customMenuItemValidateArrival.Text = "Valider arrivée de cette objet"; customMenuItemValidateArrival.ForeColor = Color.Green; RadMenuSeparatorItem separator = new RadMenuSeparatorItem(); e.ContextMenu.Items.Add(separator); e.ContextMenu.Items.Add(customMenuItemValidateArrival); customMenuItemValidateArrival.Click += new EventHandler(customMenuItemValidateArrival_Click); RadMenuItem customMenuItemAnnulateArrival = new RadMenuItem(); customMenuItemAnnulateArrival.Text = "Annuler arrivée de cette objet"; customMenuItemAnnulateArrival.ForeColor = Color.Red; e.ContextMenu.Items.Add(customMenuItemAnnulateArrival); customMenuItemAnnulateArrival.Click += new EventHandler(customMenuItemAnnulateArrival_Click); }
private void radGridView_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null || this.radGridView.Rows.Count <= 0) { return; } // Memorizzo l'elemento selezionato relation = new ArchiveStorage(); relation.Active = (bool)this.radGridView.Rows[cell.RowIndex].Cells["Active"].Value; relation.Archive = new Archive(); relation.Archive = (Archive)this.radGridView.Rows[cell.RowIndex].Cells["Archive"].Value; relation.Storage = new Storage(); relation.Storage = (Storage)this.radGridView.Rows[cell.RowIndex].Cells["Storage"].Value; ddlRelatedEntity.Enabled = false; switch (InputParameters["Action"].ToString().ToLower()) { case "relationtoarchive": { ddlRelatedEntity.Text = this.radGridView.Rows[cell.RowIndex].Cells["Storage.Name"].Value.ToString(); break; } case "relationtostorage": { ddlRelatedEntity.Text = this.radGridView.Rows[cell.RowIndex].Cells["Archive.Name"].Value.ToString(); break; } } e.ContextMenu = menu.DropDown; }
/// <summary> /// If the selected file can be compressed to a data uri, this will place it on the clipboard /// </summary> /// <param name="e"></param> protected void AddCopyDataURIMenu(ContextMenuOpeningEventArgs e) { if (e.Items.Count == 1) { var item = e.Items.First(); if (item is ISiteFile) { var path = (item as ISiteFile).Path; if (OrangeCompiler.CanGetDataURI(path)) { var menuItem = new ContextMenuItem("Copy Data URI", null, new DelegateCommand((filePath) => { var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { var data = "data:image/" + Path.GetExtension(filePath as string).Replace(".", "") + ";base64," + Convert.ToBase64String(File.ReadAllBytes(filePath as string)); return(data); }).ContinueWith((x) => { Clipboard.SetText(x.Result); }, scheduler); }), path); e.AddMenuItem(menuItem); } } } }
void grdLister_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null) { return; } if (statsContextMenu == null) { statsContextMenu = new RadDropDownMenu(); RadMenuItem menu_showJobs = new RadMenuItem("Show Bookings"); menu_showJobs.ForeColor = Color.Blue; menu_showJobs.BackColor = Color.Blue; menu_showJobs.Font = new Font("Tahoma", 10, FontStyle.Bold); menu_showJobs.Click += new EventHandler(menu_showJobs_Click); statsContextMenu.Items.Add(menu_showJobs); } e.ContextMenu = statsContextMenu; } catch (Exception ex) { // ENUtils.ShowMessage(ex.Message); } }
void OnMenuOpening(ContextMenuOpeningEventArgs args) { args.Cancel = CancelOpening; var pos = args.Info.TargetPosition; args.Info.TargetPosition = pos.Offset(HorizontalMenuOffset, VerticalMenuOffset); }
/// <summary> /// add context menu options based on the capabilities of the selected files /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void host_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { AddMultiMenu(e, OrangeCompiler.supportedCompileExtensions, OrangeJob.JobType.Compile, "Compile", "Compile"); AddMultiMenu(e, OrangeCompiler.supportedMinifyExtensions, OrangeJob.JobType.Minify, "Minify", "Minify"); AddMultiMenu(e, OrangeCompiler.supportedOptimizeExtensions, OrangeJob.JobType.Optimize, "Optimize Image", "Optimize Images"); AddCopyDataURIMenu(e); AddOptions(e); }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; } }
void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { var context = (e.FocusedElement as FrameworkElement).DataContext; var thread = context as ThreadDataSource; bool isBookmarked = MainDataSource.Instance.Bookmarks.Contains(thread); _toggleBookmarks.CommandParameter = thread; _toggleBookmarks.Content = isBookmarked ? UNMARK : MARK; _clearMarkedPosts.CommandParameter = thread; }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; return; } e.Cancel = !ViewModel.CanRemoveCatalog((CatalogDataModel) _focusedItem.DataContext); }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; return; } e.Cancel = !ViewModel.CanRemoveCatalog((CatalogDataModel)_focusedItem.DataContext); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected void AddMultiMenu(ContextMenuOpeningEventArgs e, string[] supportedExtensions, OrangeJob.JobType jobType, string title, string multipleTitle) { var jobs = new List <OrangeJob>(); foreach (ISiteItem item in e.Items) { var fsi = item as ISiteFileSystemItem; if (fsi != null) { if (fsi is ISiteFolder) { // get all of the pngs under the selected path and add a job var dir = new DirectoryInfo((fsi as ISiteFolder).Path); var files = supportedExtensions.SelectMany(x => dir.GetFiles("*" + x, SearchOption.AllDirectories)); foreach (var f in files) { if (jobType != OrangeJob.JobType.Minify || (!f.FullName.EndsWith(".min.js") && !f.FullName.EndsWith(".min.css"))) { jobs.Add(new OrangeJob() { Path = f.FullName, OutputPath = GetOutputPath(f.FullName), Type = jobType, Source = OrangeJob.JobSource.Context }); } } } else if (supportedExtensions.Contains((new FileInfo(fsi.Path)).Extension.ToLower())) { if (jobType != OrangeJob.JobType.Minify || (!fsi.Path.EndsWith(".min.js") && !fsi.Path.EndsWith(".min.css"))) { jobs.Add(new OrangeJob() { Path = fsi.Path, OutputPath = GetOutputPath(fsi.Path), Type = jobType, Source = OrangeJob.JobSource.Context }); } } } } if (jobs.Count > 0) { var menuTitle = jobs.Count > 1 ? multipleTitle : title; var menuItem = new ContextMenuItem(menuTitle, null, new DelegateCommand(new Action <object>(AddJob)), jobs); e.AddMenuItem(menuItem); } }
void grdSelectedPostCodes_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null) { e.Cancel = true; return; } else if (cell.GridControl.Name == "grdSelectedPostCodes") { if (Update == null) { Update = new RadDropDownMenu(); Update.BackColor = Color.Orange; RadMenuItem UpdateCurrent = new RadMenuItem("Update Coordinates"); UpdateCurrent.ForeColor = Color.DarkBlue; UpdateCurrent.BackColor = Color.Orange; UpdateCurrent.Font = new Font("Tahoma", 10, FontStyle.Bold); UpdateCurrent.Click += new EventHandler(UpdateCurrent_Click); Update.Items.Add(UpdateCurrent); RadMenuItem UpdateUp = new RadMenuItem("Move Up"); UpdateUp.ForeColor = Color.DarkBlue; UpdateUp.BackColor = Color.Orange; UpdateUp.Font = new Font("Tahoma", 10, FontStyle.Bold); UpdateUp.Click += new EventHandler(UpdateUp_Click); Update.Items.Add(UpdateUp); RadMenuItem UpdateDown = new RadMenuItem("Move Down"); UpdateDown.ForeColor = Color.DarkBlue; UpdateDown.BackColor = Color.Orange; UpdateDown.Font = new Font("Tahoma", 10, FontStyle.Bold); UpdateDown.Click += new EventHandler(UpdateDown_Click); Update.Items.Add(UpdateDown); } e.ContextMenu = Update; return; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; return; } var item = (DownloadItemDataModel)_focusedItem.DataContext; RestartMenuItem.Visibility = item.Status == DownloadStatus.Error ? Visibility.Visible : Visibility.Collapsed; }
private void GridLibros_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { var gridCell = e.ContextMenuProvider as GridDataCellElement; if (gridCell != null) { tituloSeleccionadoContextMenu = gridCell.RowInfo.DataBoundItem as TituloDto; if (tituloSeleccionadoContextMenu != null) { if (tituloSeleccionadoContextMenu.EstaConsignado) { e.ContextMenu = librosContextMenu; } } } }
void grdJobDetails_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { if (contextMenu == null) { contextMenu = new RadDropDownMenu(); RadMenuItem firstContextMenuItem1 = new RadMenuItem("View Jobs"); firstContextMenuItem1.Font = new Font("Tahoma", 10, FontStyle.Bold); firstContextMenuItem1.Click += new EventHandler(firstContextMenuItem1_Click); contextMenu.Items.Add(firstContextMenuItem1); } e.ContextMenu = contextMenu; }
private void RadGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { for (int i = 0; i < e.ContextMenu.Items.Count; i++) { String contextMenuText = e.ContextMenu.Items[i].Text; switch (contextMenuText) { case "Conditional Formatting": e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; e.ContextMenu.Items[i + 1].Visibility = ElementVisibility.Collapsed; break; case "Hide Column": e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; break; case "Pinned state": e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; break; case "Best Fit": e.ContextMenu.Items[i].Visibility = Telerik.WinControls.ElementVisibility.Collapsed; break; case "Cut": e.ContextMenu.Items[i].Click += Delete_Row_Click; break; case "Copy": break; case "Paste": break; case "Edit": break; case "Clear Value": break; case "Delete Row": e.ContextMenu.Items[i].Click += Delete_Row_Click; break; } } }
void webMatrixHost_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { ISiteItem siteItem = e.Items.FirstOrDefault <ISiteItem>(); if (siteItem != null) { ISiteFolder siteFolder = siteItem as ISiteFolder; if (siteFolder != null) // folders must end with '\' { e.AddMenuItem(new ContextMenuItem("Compile TypeScript files in folder", _typescriptCompileImageSmall, new DelegateCommand(CanExecute, (parameter) => { if (!_executer.Start()) { return; } var tsfiles = Directory.GetFiles(siteFolder.Path, "*.ts", SearchOption.AllDirectories); CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End()); }), null)); } else { var siteFile = siteItem as ISiteFile; if (siteFile != null && Path.GetExtension(siteFile.Path) == ".ts") { e.AddMenuItem(new ContextMenuItem("Compile TypeScript file", _typescriptCompileImageSmall, new DelegateCommand(CanExecute, (parameter) => { if (!_executer.Start()) { return; } var tsfiles = new string[] { siteFile.Path }; CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End()); }), null)); } } } } catch (Exception ex) { _webMatrixHost.ShowExceptionMessage("Compile TypeScript (context menu)", "The following error occured. Please report at https://github.com/MacawNL/TypeScript4WebMatrix/issues.", ex); } }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; return; } bool onlyFavourited = ViewModel.ShowOnlyFavourites; RemoveFromFavouritesMenuItem.Visibility = onlyFavourited ? Visibility.Visible : Visibility.Collapsed; DeleteMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible; PinMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible; bool canPinToStart = ViewModel.CanPinToStart((BookModel) _focusedItem.DataContext); PinMenuItem.IsEnabled = canPinToStart; }
private void OnContactRequestsMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // Needed on every UI interaction App.MegaSdk.retryPendingConnections(); var focusedListBoxItem = e.FocusedElement as RadDataBoundListBoxItem; if (focusedListBoxItem == null || !(focusedListBoxItem.DataContext is ContactRequest)) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; } else { _contactsViewModel.FocusedContactRequest = (ContactRequest)focusedListBoxItem.DataContext; } }
private void RadContextMenu_OnOpening(object sender, ContextMenuOpeningEventArgs e) { _focusedItem = e.FocusedElement as RadDataBoundListBoxItem; if (_focusedItem == null) { // We don't want to open the menu if the focused element is not a list box item. // If the list box is empty focusedItem will be null. e.Cancel = true; return; } bool onlyFavourited = ViewModel.ShowOnlyFavourites; RemoveFromFavouritesMenuItem.Visibility = onlyFavourited ? Visibility.Visible : Visibility.Collapsed; DeleteMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible; PinMenuItem.Visibility = onlyFavourited ? Visibility.Collapsed : Visibility.Visible; bool canPinToStart = ViewModel.CanPinToStart((BookModel)_focusedItem.DataContext); PinMenuItem.IsEnabled = canPinToStart; }
void grdLister_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { GridDataCellElement cell = e.ContextMenuProvider as GridDataCellElement; if (cell == null) { return; } else if (cell.GridControl.Name == "grdLister") { e.ContextMenu = menu; return; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void RadGridView1ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { var customMenuItem = new RadMenuItem(); customMenuItem.Click += new EventHandler(ViewContextMenuItem_Click); customMenuItem.Text = "Просмотр"; var separator = new RadMenuSeparatorItem(); e.ContextMenu.Items.Add(separator); e.ContextMenu.Items.Add(customMenuItem); var deleteMenuItem = new RadMenuItem(); deleteMenuItem.Click += new EventHandler(deleteContextMenuItem_Click); deleteMenuItem.Text = "Удалить заказ"; e.ContextMenu.Items.Add(separator); e.ContextMenu.Items.Add(deleteMenuItem); var customMenuItemPr = new RadMenuItem(); customMenuItemPr.Click += new EventHandler(PrintContextMenuItem_Click); customMenuItemPr.Text = "Печать"; e.ContextMenu.Items.Add(separator); e.ContextMenu.Items.Add(customMenuItemPr); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected void AddOptions(ContextMenuOpeningEventArgs e) { // we only show the context menu if every item selected in the tree is valid to be compiled var jobs = new List <OrangeJob>(); var showMenu = e.Items.Count > 0; Type itemType = null; // determine if we're dealing with folders or files. If it's mixed, bug out foreach (ISiteItem item in e.Items) { if (itemType == null) { itemType = item.GetType(); } else if (itemType != item.GetType()) { return; } } var menuItem = new ContextMenuItem("OrangeBits Options", null, new DelegateCommand((items) => { var selectedItems = items as IEnumerable <ISiteItem>; var dialog = new OptionsUI(); var vm = new OptionViewModel() { Paths = selectedItems.Select(x => (x as ISiteFileSystemItem).Path).ToArray() }; prefUtility.LoadOptions(vm); dialog.DataContext = vm; var result = _host.ShowDialog("OrangeBits Options", dialog); if (result.HasValue && result.Value) { prefUtility.SaveOptions(vm); } }), e.Items); e.AddMenuItem(menuItem); }
/// <summary> /// Occurs when the window's system menu is opening. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The <see cref="ContextMenuOpeningEventArgs"/> that contains the event data.</param> private void OnWindowSystemMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // If not allowing a custom system menu, clear e.Menu and quit if (!true.Equals(useCustomSystemMenuCheckBox.IsChecked)) { e.Menu = null; return; } var separator = e.Menu.Items.OfType <Separator>().LastOrDefault(); var index = (separator != null ? e.Menu.Items.IndexOf(separator) : e.Menu.Items.Count); // Inject a Help menu item e.Menu.Items.Insert(index++, new Separator()); e.Menu.Items.Insert(index++, new MenuItem() { Header = "Help", Command = ApplicationCommands.Help, CommandTarget = this, InputGestureText = "F1" }); }
/// <summary> /// Occurs when context menu on the tab is opening. /// </summary> private void TabbedFormControl_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { clickedTab = e.Tab; var tabs = tabbedFormControl.Tabs.OfType <TabPageAdv>(); var tabsExistsInRight = tabs.Any(tab => tab.TabIndex > e.Tab.TabIndex); if (tabs.Count() == 1) { e.ContextMenu.Items[1].Enabled = false; e.ContextMenu.Items[2].Enabled = false; } else if (!tabsExistsInRight) { e.ContextMenu.Items[2].Enabled = false; } else { e.ContextMenu.Items[0].Enabled = true; e.ContextMenu.Items[1].Enabled = true; e.ContextMenu.Items[2].Enabled = true; } }
private void RadGridView1ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { if (e.ContextMenu.Items.Count == 0) { e.Cancel = true; } RadItemOwnerCollection collection = new RadItemOwnerCollection { e.ContextMenu.Items[2] }; e.ContextMenu.Items.Clear(); collection[0].Text = Program.LanguageDefault.DictionaryMenuPlena["clearSorting"]; e.ContextMenu.Items.Add(collection[0]); } catch (Exception) { } }
//禁用系统自带的上下文菜单 /// <summary> /// 禁用系统自带的上下文菜单 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected override void OnContextMenuOpening(object sender, ContextMenuOpeningEventArgs args) { base.OnContextMenuOpening(sender, args); args.Cancel = true; }
private void gvOrder_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { e.ContextMenu = cmOrder.DropDown; }
private void gvInstrument_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { e.ContextMenu = cmMarket.DropDown; }
private void PostMenu_Opening(object sender, ContextMenuOpeningEventArgs e) { if (_quoteEnabled) { var menu = sender as RadContextMenu; var edit = menu.Items[0] as RadContextMenuItem; edit.IsEnabled = false; } }
/// <summary> /// add an option to open a console here if it's a directory /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void host_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // we only show the context menu if every item selected in the tree is valid to be compiled IList<string> paths = new List<string>(); var showContextMenu = e.Items.Count > 0; foreach (ISiteItem item in e.Items) { if (item == null || !(item is ISiteFolder)) { showContextMenu = false; break; } else { paths.Add((item as ISiteFolder).Path); } } // if all of the files in the list are valid, show the command window option if (showContextMenu) { var menuItem = new ContextMenuItem("Open Command Window", null, new DelegateCommand(new Action<object>(OpenCMD)), paths); e.AddMenuItem(menuItem); } }
void webMatrixHost_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { ISiteItem siteItem = e.Items.FirstOrDefault<ISiteItem>(); if (siteItem != null) { ISiteFile siteFile = siteItem as ISiteFile; if (tracker.HasGitRepository) { if (siteFile != null) { var status = tracker.GetFileStatus(siteFile.Path); if (status == GitFileStatus.Modified || status == GitFileStatus.Staged) { //e.AddMenuItem(new ContextMenuItem("Compare ...", Utility.ConvertBitmapToImageSource(Resources.git_16), this.gitCompareFileCommand, siteFile.Path)); e.AddMenuItem(new ContextMenuItem("Undo File Changes ", Utility.ConvertBitmapToImageSource(Resources.git_16), this.gitUndoFileChangeCommand, siteFile.Path)); } } //e.AddMenuItem(new ContextMenuItem("Commit Changes", Utility.ConvertBitmapToImageSource(Resources.git_16), this.gitCommitCommand, null)); //e.AddMenuItem(new ContextMenuItem("View Log/History", Utility.ConvertBitmapToImageSource(Resources.git_16), this.gitLogCommand, null)); } else { e.AddMenuItem(new ContextMenuItem("Create Git Repository", Utility.ConvertBitmapToImageSource(Resources.git_16), this.gitInitCommand, null)); } } }
/// <summary> /// If the selected file can be compressed to a data uri, this will place it on the clipboard /// </summary> /// <param name="e"></param> protected void AddCopyDataURIMenu(ContextMenuOpeningEventArgs e) { if (e.Items.Count == 1) { var item = e.Items.First(); if (item is ISiteFile) { var path = (item as ISiteFile).Path; if (OrangeCompiler.CanGetDataURI(path)) { var menuItem = new ContextMenuItem("Copy Data URI", null, new DelegateCommand((filePath) => { var scheduler = TaskScheduler.FromCurrentSynchronizationContext(); Task.Factory.StartNew(() => { var data = "data:image/" + Path.GetExtension(filePath as string).Replace(".", "") + ";base64," + Convert.ToBase64String(File.ReadAllBytes(filePath as string)); return data; }).ContinueWith((x) => { Clipboard.SetText(x.Result); }, scheduler); }), path); e.AddMenuItem(menuItem); } } } }
/// <summary> /// /// </summary> /// <param name="e"></param> protected void AddMultiMenu(ContextMenuOpeningEventArgs e, string[] supportedExtensions, OrangeJob.JobType jobType, string title, string multipleTitle) { var jobs = new List<OrangeJob>(); foreach (ISiteItem item in e.Items) { var fsi = item as ISiteFileSystemItem; if (fsi != null) { if (fsi is ISiteFolder) { // get all of the pngs under the selected path and add a job var dir = new DirectoryInfo((fsi as ISiteFolder).Path); var files = supportedExtensions.SelectMany(x => dir.GetFiles("*" + x, SearchOption.AllDirectories)); foreach (var f in files) { if (jobType != OrangeJob.JobType.Minify || (!f.FullName.EndsWith(".min.js") && !f.FullName.EndsWith(".min.css"))) { jobs.Add(new OrangeJob() { Path = f.FullName, OutputPath = GetOutputPath(f.FullName), Type = jobType, Source = OrangeJob.JobSource.Context }); } } } else if (supportedExtensions.Contains((new FileInfo(fsi.Path)).Extension.ToLower())) { if (jobType != OrangeJob.JobType.Minify || (!fsi.Path.EndsWith(".min.js") && !fsi.Path.EndsWith(".min.css"))) { jobs.Add(new OrangeJob() { Path = fsi.Path, OutputPath = GetOutputPath(fsi.Path), Type = jobType, Source = OrangeJob.JobSource.Context }); } } } } if (jobs.Count > 0) { var menuTitle = jobs.Count > 1 ? multipleTitle : title; var menuItem = new ContextMenuItem(menuTitle, null, new DelegateCommand(new Action<object>(AddJob)), jobs); e.AddMenuItem(menuItem); } }
/// <summary> /// /// </summary> /// <param name="e"></param> protected void AddOptions(ContextMenuOpeningEventArgs e) { // we only show the context menu if every item selected in the tree is valid to be compiled var jobs = new List<OrangeJob>(); var showMenu = e.Items.Count > 0; Type itemType = null; // determine if we're dealing with folders or files. If it's mixed, bug out foreach (ISiteItem item in e.Items) { if (itemType == null) { itemType = item.GetType(); } else if (itemType != item.GetType()) { return; } } var menuItem = new ContextMenuItem("OrangeBits Options", null, new DelegateCommand((items) => { var selectedItems = items as IEnumerable<ISiteItem>; var dialog = new OptionsUI(); var vm = new OptionViewModel() { Paths = selectedItems.Select(x => (x as ISiteFileSystemItem).Path).ToArray() }; prefUtility.LoadOptions(vm); dialog.DataContext = vm; var result = _host.ShowDialog("OrangeBits Options", dialog); if (result.HasValue && result.Value) { prefUtility.SaveOptions(vm); } }), e.Items); e.AddMenuItem(menuItem); }
protected void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { RadDataBoundListBoxItem focused = e.FocusedElement as RadDataBoundListBoxItem; if (focused == null) { e.Cancel = true; return; } else { ThreadData thread = focused.DataContext as ThreadData; this.SelectedThread = thread; } }
void webMatrixHost_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e) { try { ISiteItem siteItem = e.Items.FirstOrDefault<ISiteItem>(); if (siteItem != null) { ISiteFolder siteFolder = siteItem as ISiteFolder; if (siteFolder != null) // folders must end with '\' { e.AddMenuItem(new ContextMenuItem("Compile TypeScript files in folder", _typescriptCompileImageSmall, new DelegateCommand(CanExecute, (parameter) => { if (!_executer.Start()) { return; } var tsfiles = Directory.GetFiles(siteFolder.Path, "*.ts", SearchOption.AllDirectories); CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End()); }), null)); } else { var siteFile = siteItem as ISiteFile; if (siteFile != null && Path.GetExtension(siteFile.Path) == ".ts") { e.AddMenuItem(new ContextMenuItem("Compile TypeScript file", _typescriptCompileImageSmall, new DelegateCommand(CanExecute, (parameter) => { if (!_executer.Start()) { return; } var tsfiles = new string[] {siteFile.Path}; CompileTypeScriptFilesAsync(tsfiles).ContinueWith((antecedent) => _executer.End()); }), null)); } } } } catch(Exception ex) { _webMatrixHost.ShowExceptionMessage("Compile TypeScript (context menu)", "The following error occured. Please report at https://github.com/MacawNL/TypeScript4WebMatrix/issues.", ex); } }
private void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { // Since the menu is set to the list box itself, do not open it if there is no item under the menu. // For example if the list box is empty we don't want to show the menu. e.Cancel = !(e.FocusedElement is RadDataBoundListBoxItem); }
void OnMenuOpening(object sender, ContextMenuOpeningEventArgs e) { if (this._AuthorFilterEnabled) { this._byAuthor.Content = "show all posts"; } else { this._byAuthor.Content = "show posts by author"; } }