コード例 #1
0
        //private object CreateMruMenuItemHeader(Mru _mru)
        //{
        //    TextBlock tb_header = new TextBlock();
        //    tb_header.Text = _mru.DisplayName;
        //    tb_header.VerticalAlignment = VerticalAlignment.Center;
        //    tb_header.HorizontalAlignment = HorizontalAlignment.Left;

        //    TextBlock tb_pinsymbol = new TextBlock();
        //    tb_pinsymbol.FontFamily = new FontFamily("Segoe UI Symbol");
        //    tb_pinsymbol.Text = "\uE141";
        //    tb_pinsymbol.Margin = new Thickness(10,0,5,0);
        //    tb_pinsymbol.VerticalAlignment = VerticalAlignment.Center;
        //    tb_pinsymbol.HorizontalAlignment = HorizontalAlignment.Right;

        //    Grid grid = new Grid();
        //    grid.Background = this.uc_RdsExplorerPanel_ListView.ContextMenu.Background;
        //    grid.Width = this.uc_RdsExplorerPanel_ListView.ContextMenu.Width;
        //    grid.RowDefinitions.Add(new RowDefinition());
        //    grid.ColumnDefinitions.Add(new ColumnDefinition());
        //    grid.ColumnDefinitions.Add(new ColumnDefinition());
        //    grid.Children.Add(tb_header);
        //    grid.Children.Add(tb_pinsymbol);
        //    Grid.SetColumn(tb_header, 0);
        //    Grid.SetColumn(tb_pinsymbol, 1);
        //    return grid;
        //}

        private void uc_RdsExplorerPanel_ContextMenu_LaunchMruItem(object sender, RoutedEventArgs e)
        {
            DependencyObject originalSource = (DependencyObject)e.OriginalSource;

            if (originalSource != null)
            {
                RdsApp app = (RdsApp)this.uc_RdsExplorerPanel_ListView.SelectedItem;
                app.Launch(((Mru)((MenuItem)originalSource).DataContext).Path);
            }
        }
コード例 #2
0
 private void EventHandler_AppLaunch(DependencyObject originalSource)
 {
     //DependencyObject originalSource = (DependencyObject)e.OriginalSource;
     while ((originalSource != null) && !(originalSource is ListViewItem))
     {
         originalSource = VisualTreeHelper.GetParent(originalSource);
     }
     //if it didn’t find a ListViewItem anywhere in the hierarch, it’s because the user
     //didn’t click on one. Therefore, if the variable isn’t null, run the code
     if (originalSource != null)
     {
         RdsApp app = (RdsApp)((System.Windows.FrameworkElement)originalSource).DataContext;
         app.Launch();
     }
 }
コード例 #3
0
        private void ApplyContextMenuItems_RemoteMruList(Object sender)
        {
            RdsApp app = (RdsApp)this.uc_RdsExplorerPanel_ListView.SelectedItem;

            if (app == null)
            {
                return;
            }
            MruList mru_list = app.GetRemoteMruList();

            if (mru_list == null)
            {
                return;
            }

            //if(mru_list.Count() > 0)
            //{
            //    this.uc_RdsExplorerPanel_ListView.ContextMenu.Items.Insert(0, new Separator());
            //}

            foreach (Mru mru in mru_list)
            {
                MenuItem itm = new MenuItem();

                itm.Header = mru.DisplayName;
                //itm.Icon = new Image { Source = new BitmapImage(new Uri("Resources/pin.ico")) };
                //itm.Header = CreateMruMenuItemHeader(mru);

                itm.Click      += this.uc_RdsExplorerPanel_ContextMenu_LaunchMruItem;
                itm.DataContext = mru;
                itm.ToolTip     = mru.FlybyHintText;

                Jrfc.Utility.AddItemToContextMenu(this.uc_RdsExplorerPanel_ListView.ContextMenu, itm,
                                                  Jrfc.Utility.TYPE_OF_ADD.SkipIfExists,
                                                  Utility.ADD_LOCATION.Top);
            }
        }