protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this._selectionService != null)
         {
             this._selectionService.SelectionChanging -= new EventHandler(this.OnSelectionChanging);
             this._selectionService = null;
         }
         if (this._serviceProvider != null)
         {
             this._serviceProvider = null;
             TypeDescriptor.Refreshed -= new RefreshEventHandler(this.OnTypeRefreshed);
         }
         IDictionaryEnumerator enumerator = this._commandGroups.GetEnumerator();
         while (enumerator.MoveNext())
         {
             ArrayList list = (ArrayList) enumerator.Value;
             foreach (MenuCommand command in list)
             {
                 command.CommandChanged -= this._commandChangedHandler;
             }
             list.Clear();
         }
     }
 }
 public CommandSet(ISite site)
 {
     this.site = site;
     this.eventService = (IEventHandlerService) site.GetService(typeof(IEventHandlerService));
     this.eventService.EventHandlerChanged += new EventHandler(this.OnEventHandlerChanged);
     IDesignerHost host = (IDesignerHost) site.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activated += new EventHandler(this.UpdateClipboardItems);
     }
     this.statusCommandUI = new StatusCommandUI(site);
     IUIService uiService = site.GetService(typeof(IUIService)) as IUIService;
     this.commandSet = new CommandSetItem[] {
         new CommandSetItem(this, new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut, uiService), new ImmediateCommandSetItem(this, new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusSelectAll), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), MenuCommands.DesignerProperties, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusPrimarySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight, true), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeLeft, true, uiService),
         new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeRight, true, uiService)
      };
     this.selectionService = (ISelectionService) site.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.menuService = (IMenuCommandService) site.GetService(typeof(IMenuCommandService));
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.AddCommand(this.commandSet[i]);
         }
     }
     IDictionaryService service = site.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service != null)
     {
         service.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0));
     }
 }
 public SelectionUIService(IDesignerHost host)
 {
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.StandardClick | ControlStyles.Opaque, true);
     this.host = host;
     this.dragHandler = null;
     this.dragComponents = null;
     this.selectionItems = new Hashtable();
     this.selectionHandlers = new Hashtable();
     this.AllowDrop = true;
     this.Text = "SelectionUIOverlay";
     this.selSvc = (ISelectionService) host.GetService(typeof(ISelectionService));
     if (this.selSvc != null)
     {
         this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     host.TransactionOpened += new EventHandler(this.OnTransactionOpened);
     host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
     if (host.InTransaction)
     {
         this.OnTransactionOpened(host, EventArgs.Empty);
     }
     IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemove);
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);
 }
 public SelectionController(ISelectionService selectionService, ITickerRepository tickerRepository, ITimeFrameRepository timeFrameRepository, IStrategyInfoRepository strategyInfoRepository)
 {
     this.selectionService = selectionService;
     this.tickerRepository = tickerRepository;
     this.timeFrameRepository = timeFrameRepository;
     this.strategyInfoRepository = strategyInfoRepository;
 }
		private void GetService ()
		{
			selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
			if (selectionService != null)
			{
				selectionService.SelectionChanged += OnSelectionChanged;
			}
		}
 public MusicPropertiesController(IShellService shellService, IMusicFileContext musicFileContext, ISelectionService selectionService, Lazy<MusicPropertiesViewModel> musicPropertiesViewModel)
 {
     this.shellService = shellService;
     this.musicFileContext = musicFileContext;
     this.selectionService = selectionService;
     this.musicPropertiesViewModel = musicPropertiesViewModel;
     this.musicFilesToSaveAfterPlaying = new HashSet<MusicFile>();
 }
 public override void Initialize(System.ComponentModel.IComponent component)
 {
     base.Initialize(component);
     SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
     SelectionService.SelectionChanged += OnComponentSelected;
     ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
     ComponentChangeService.ComponentRename += OnComponentRename;
 }
		public GraphicsPixelHistoryViewModel(ISelectionService selectionService)
		{
		    DisplayName = "Pixel History";

			_selectionService = selectionService;
			_pixelEvents = new BindableCollection<PixelHistoryEventViewModel>();
			selectionService.SelectedPixelChanged += OnSelectedPixelChanged;
		}
		public GraphicsEventListViewModel(ISelectionService selectionService)
		{
		    DisplayName = "Graphics Event List";

			_selectionService = selectionService;
			_events = new BindableCollection<TracefileEventViewModel>();
			selectionService.SelectedFrameChanged += OnSelectedFrameChanged;
			OnSelectedFrameChanged(this, new TracefileFrameChangedEventArgs(selectionService.SelectedFrame));
		}
        public GraphicsObjectTableViewModel(ISelectionService selectionService)
		{
		    DisplayName = "Graphics Object Table";

			_selectionService = selectionService;
            _objects = new BindableCollection<GraphicsObjectViewModel>();
			selectionService.SelectedEventChanged += OnSelectedEventChanged;

            if (_selectionService.SelectedFrame != null && _selectionService.SelectedEvent != null)
                OnSelectedEventChanged(this, null);
		}
        public override void Next(ISelectionService selection)
        {
            if (Finishing()) return;

            WizardEventArgs args;

            if (UserAllowsMoveToProceed(Direction.Forward, out args) && _wizard.MoreThanOnePageExists())
            {
                MoveToNextPage(args);
                SetButtonStates();
            }
        }
        public GraphicsPipelineStagesViewModel(ISelectionService selectionService)
		{
		    DisplayName = "Graphics Pipeline Stages";

            _inputAssemblerOutputs = new BindableCollection<VertexViewModel>();

			_selectionService = selectionService;
			selectionService.SelectedEventChanged += OnSelectedEventChanged;

            if (_selectionService.SelectedFrame != null && _selectionService.SelectedEvent != null)
                OnSelectedEventChanged(this, null);
		}
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.PopBehavior();
         if (this.selectionService != null)
         {
             this.selectionService.SelectionChanged -= new EventHandler(this.selectionService_SelectionChanged);
         }
         this.selectionService = null;
         this.behaviorService = null;
     }
 }
		private void GetService ()
		{
			selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
			if (selectionService != null)
			{
				selectionService.SelectionChanged += OnSelectionChanged;
			}
			
			componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
			if (componentChangeService != null) {
				componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename);
			}
		}
 internal DesignerToolboxInfo(ToolboxService toolboxService, IDesignerHost host)
 {
     this._toolboxService = toolboxService;
     this._host = host;
     this._selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService;
     if (this._selectionService != null)
     {
         this._selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     if (this._host.RootComponent != null)
     {
         this._host.RootComponent.Disposed += new EventHandler(this.OnDesignerDisposed);
     }
     TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeDescriptorRefresh);
 }
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            if (Control is SettingsTree)
            {
                designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
                menuService = GetService(typeof(IMenuCommandService)) as IMenuCommandService;
                selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
                settingsTree = Control as SettingsTree;
                settingsTree.TreeView.AfterSelect += OnNodeSelect;
            }


        }
        void GetService()
        {
            selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
            if (selectionService != null)
            {
                selectionService.SelectionChanged += OnSelectionChanged;
            }

            componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            if (componentChangeService != null) {
                componentChangeService.ComponentRename += OnComponentRename;
                componentChangeService.ComponentAdding += (sender, e) => {
                };
            }
        }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     if (component.Site != null)
     {
         this.selectionService = this.GetService(typeof(ISelectionService)) as ISelectionService;
         this.behaviorService = this.GetService(typeof(BehaviorService)) as BehaviorService;
         if ((this.behaviorService != null) && (this.selectionService != null))
         {
             this.behavior = new FilterCutCopyPasteDeleteBehavior(true, this.behaviorService);
             this.UpdateBehavior();
             this.selectionService.SelectionChanged += new EventHandler(this.selectionService_SelectionChanged);
         }
     }
 }
 public CommandSet(IServiceProvider serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     this.menuCommandService = (IMenuCommandService) this.serviceProvider.GetService(typeof(IMenuCommandService));
     if (this.menuCommandService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(IMenuCommandService).FullName }));
     }
     this.workflowView = serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView;
     if (this.workflowView == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(WorkflowView).FullName }));
     }
     this.selectionService = (ISelectionService) this.serviceProvider.GetService(typeof(ISelectionService));
     if (this.selectionService == null)
     {
         throw new InvalidOperationException(SR.GetString("General_MissingService", new object[] { typeof(ISelectionService).FullName }));
     }
     this.commandSet = new List<System.Workflow.ComponentModel.Design.CommandSetItem>();
     this.commandSet.AddRange(new System.Workflow.ComponentModel.Design.CommandSetItem[] { 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSaveWorkflowAsImage), WorkflowMenuCommands.SaveAsImage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuCopyToClipboard), WorkflowMenuCommands.CopyToClipboard), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPrint), new EventHandler(this.OnMenuPrint), WorkflowMenuCommands.Print), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPageSetup), new EventHandler(this.OnMenuPageSetup), WorkflowMenuCommands.PageSetup), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), WorkflowMenuCommands.DesignerProperties), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnViewCode), new CommandID(StandardCommands.Cut.Guid, 0x14d)), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft), 
         new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectNext), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyMove), MenuCommands.KeySelectPrevious), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Expand), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusExpandCollapse), new EventHandler(this.OnExpandCollapse), WorkflowMenuCommands.Collapse), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Disable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusEnable), new EventHandler(this.OnEnable), WorkflowMenuCommands.Enable, true), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnCreateTheme), WorkflowMenuCommands.CreateTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnChangeTheme), WorkflowMenuCommands.ChangeTheme), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageUp), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyPageDnUp), WorkflowMenuCommands.PageDown)
      });
     this.zoomCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom400Mode, DR.GetString("Zoom400Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom300Mode, DR.GetString("Zoom300Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom200Mode, DR.GetString("Zoom200Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom150Mode, DR.GetString("Zoom150Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom100Mode, DR.GetString("Zoom100Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom75Mode, DR.GetString("Zoom75Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.Zoom50Mode, DR.GetString("Zoom50Mode", new object[0])), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusZoom), new EventHandler(this.OnZoom), WorkflowMenuCommands.ShowAll, DR.GetString("ZoomShowAll", new object[0])) };
     this.commandSet.AddRange(this.zoomCommands);
     this.layoutCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.DefaultPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreviewPage), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusLayout), new EventHandler(this.OnPageLayout), WorkflowMenuCommands.PrintPreview) };
     this.commandSet.AddRange(this.layoutCommands);
     this.navigationToolCommands = new System.Workflow.ComponentModel.Design.CommandSetItem[] { new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[0]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[1]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[2]), new System.Workflow.ComponentModel.Design.CommandSetItem(new EventHandler(this.OnStatusMessageFilter), new EventHandler(this.OnMessageFilterChanged), NavigationToolCommandIds[3]) };
     this.commandSet.AddRange(this.navigationToolCommands);
     for (int i = 0; i < this.commandSet.Count; i++)
     {
         if (this.menuCommandService.FindCommand(this.commandSet[i].CommandID) == null)
         {
             this.menuCommandService.AddCommand(this.commandSet[i]);
         }
     }
     IComponentChangeService service = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
     if (service != null)
     {
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     IDictionaryService service2 = this.serviceProvider.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service2 != null)
     {
         service2.SetValue(typeof(CommandID), new CommandID(new Guid("5f1c3c8d-60f1-4b98-b85b-8679f97e8eac"), 0));
     }
 }
 public DesignerActionService(IServiceProvider serviceProvider)
 {
     if (serviceProvider != null)
     {
         this.serviceProvider = serviceProvider;
         ((IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost))).AddService(typeof(DesignerActionService), this);
         IComponentChangeService service = (IComponentChangeService) serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
         }
         this.selSvc = (ISelectionService) serviceProvider.GetService(typeof(ISelectionService));
         ISelectionService selSvc = this.selSvc;
     }
     this.designerActionLists = new Hashtable();
     this.componentToVerbsEventHookedUp = new Hashtable();
 }
Exemple #21
0
        /*
                public void Host_OnLoadComplete(object sender, EventArgs e)
                {	
                    if(!_rebar.Created) _rebar.CreateControl();
                }
        */
        public override void Initialize( IComponent component ) {
            base.Initialize( component );

            if ( Control is Rebar ) {
                _rebar = (Rebar)Control;
                /*
                mPropertyTree.PaneActivated += 
                    new PropertyTree.PaneActivatedEventHandler(ptPaneActivated); 
                    */
                _host = (IDesignerHost)
                    GetService( typeof( IDesignerHost ) );
                _selService = (ISelectionService)
                    GetService( typeof( ISelectionService ) );
                //_host.LoadComplete += new EventHandler(Host_OnLoadComplete);
                //if(!_rebar.Created) _rebar.CreateControl();
            }
        }
Exemple #22
0
		public UISelectionService (IServiceProvider serviceProvider)
		{
			if (serviceProvider == null)
				throw new ArgumentNullException ("serviceProvider");

			_serviceProvider = serviceProvider;
			_transaction = null;

			_selectionService = serviceProvider.GetService (typeof (ISelectionService)) as ISelectionService;
			if (_selectionService == null) {
				IServiceContainer serviceContainer = serviceProvider.GetService (typeof (IServiceContainer)) as IServiceContainer;
				_selectionService = new SelectionService (serviceContainer);
				serviceContainer.AddService (typeof (ISelectionService), (ISelectionService) _selectionService);
			}

			_selectionService.SelectionChanged += new EventHandler (OnSelectionChanged);
		}
 public PlayerController(IShellService shellService, IEnvironmentService environmentService, ISelectionService selectionService, PlayerService playerService, 
     Lazy<PlayerViewModel> playerViewModel, ExportFactory<InfoViewModel> infoViewModelFactory)
 {
     this.shellService = shellService;
     this.environmentService = environmentService;
     this.selectionService = selectionService;
     this.playerService = playerService;
     this.playerViewModel = playerViewModel;
     this.infoViewModelFactory = infoViewModelFactory;
     this.playAllCommand = new DelegateCommand(PlayAll, CanPlayAll);
     this.playSelectedCommand = new DelegateCommand(PlaySelected, CanPlaySelected);
     this.enqueueAllCommand = new DelegateCommand(EnqueueAll, CanEnqueueAll);
     this.enqueueSelectedCommand = new DelegateCommand(EnqueueSelected, CanEnqueueSelected);
     this.previousTrackCommand = new DelegateCommand(PreviousTrack, CanPreviousTrack);
     this.nextTrackCommand = new DelegateCommand(NextTrack, CanNextTrack);
     this.infoCommand = new DelegateCommand(ShowInfo);
 }
Exemple #24
0
		public DesignForm(Form originalForm, System.Collections.ObjectModel.Collection<string> propertiesToDesign)
		{
			// Copy parameters to fields
			_originalForm = originalForm;
			_propertiesToDesign = propertiesToDesign;

			// Create hashtables
			_reparentedControls = new Hashtable();
			_customTypeDescriptors = new Hashtable();

			// Create the DesignSurface and get the View from it;
			_surface = new DesignSurface(typeof(Form));

			// Setup UI, note, this can't be called until _surface is non-null 
			SetupUI();
				
			// Get the IDesignerHost for the surface
			_host = _surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

			// Get the ISelectionService and hook the SelectionChanged event
			_selection = _surface.GetService(typeof(ISelectionService)) as ISelectionService;

			if (_selection != null)
			{
				_selection.SelectionChanged += new EventHandler(SelectionChanged);
			}

			// Get the rootForm from the IDesignerHost
			Form rootForm = _host.RootComponent as Form;
			if (rootForm != null)
			{
				//  Clone the Form's properties
				CloneControlProperties(_originalForm, rootForm);

				// Now that a customTypeDescriptor is around for the Form, use it
				SampleCustomTypeDescriptor formDesc = _customTypeDescriptors[rootForm] as SampleCustomTypeDescriptor;
				if (formDesc != null)
				{
					_grid.SelectedObject = formDesc;
				}
				
				// Clone the controls on the Form
				CloneControlsRecursive(_originalForm.Controls, rootForm);
			}
		}
 public TranscodingController(IMessageService messageService, IShellService shellService, IMusicFileContext musicFileContext, ISelectionService selectionService, 
     TranscodingService transcodingService, Lazy<ITranscoder> transcoder, Lazy<TranscodingListViewModel> transcodingListViewModel)
 {
     this.messageService = messageService;
     this.shellService = shellService;
     this.musicFileContext = musicFileContext;
     this.selectionService = selectionService;
     this.transcodingService = transcodingService;
     this.transcoder = transcoder;
     this.transcodingListViewModel = transcodingListViewModel;
     this.cancellationTokenSources = new Dictionary<TranscodeItem, CancellationTokenSource>();
     this.convertToMp3AllCommand = new DelegateCommand(ConvertToMp3All, CanConvertToMp3All);
     this.convertToMp3SelectedCommand = new DelegateCommand(ConvertToMp3Selected, CanConvertToMp3Selected);
     this.cancelAllCommand = new DelegateCommand(CancelAll, CanCancelAll);
     this.cancelSelectedCommand = new DelegateCommand(CancelSelected, CanCancelSelected);
     this.throttler = new SemaphoreSlim(Environment.ProcessorCount);  // Do not dispose the throttler; it is used after Shutdown to cancel the open tasks
     this.transcodingManager = new TranscodingManager();
 }
 public DesignerActionUI(IServiceProvider serviceProvider, Adorner containerAdorner)
 {
     this.serviceProvider = serviceProvider;
     this.designerActionAdorner = containerAdorner;
     this.behaviorService = (BehaviorService) serviceProvider.GetService(typeof(BehaviorService));
     this.menuCommandService = (IMenuCommandService) serviceProvider.GetService(typeof(IMenuCommandService));
     this.selSvc = (ISelectionService) serviceProvider.GetService(typeof(ISelectionService));
     if ((this.behaviorService != null) && (this.selSvc != null))
     {
         this.designerActionService = (DesignerActionService) serviceProvider.GetService(typeof(DesignerActionService));
         if (this.designerActionService == null)
         {
             this.designerActionService = new DesignerActionService(serviceProvider);
             this.disposeActionService = true;
         }
         this.designerActionUIService = (DesignerActionUIService) serviceProvider.GetService(typeof(DesignerActionUIService));
         if (this.designerActionUIService == null)
         {
             this.designerActionUIService = new DesignerActionUIService(serviceProvider);
             this.disposeActionUIService = true;
         }
         this.designerActionUIService.DesignerActionUIStateChange += new DesignerActionUIStateChangeEventHandler(this.OnDesignerActionUIStateChange);
         this.designerActionService.DesignerActionListsChanged += new DesignerActionListsChangedEventHandler(this.OnDesignerActionsChanged);
         this.lastPanelComponent = null;
         IComponentChangeService service = (IComponentChangeService) serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
         }
         if (this.menuCommandService != null)
         {
             this.cmdShowDesignerActions = new MenuCommand(new EventHandler(this.OnKeyShowDesignerActions), MenuCommands.KeyInvokeSmartTag);
             this.menuCommandService.AddCommand(this.cmdShowDesignerActions);
         }
         this.uiService = (IUIService) serviceProvider.GetService(typeof(IUIService));
         if (this.uiService != null)
         {
             this.mainParentWindow = this.uiService.GetDialogOwnerWindow();
         }
         this.componentToGlyph = new Hashtable();
         this.marshalingControl = new Control();
         this.marshalingControl.CreateControl();
     }
 }
		private RootDesignerView (IDesignerHost host)
			: base()
		{
			//it's through this that we communicate with JavaScript
			comm = new CommandManager (this);

			//we use the host to get services and designers
			this.host =  host as DesignerHost;
			if (this.host == null)
				throw new ArgumentNullException ("host");

			//We use this to monitor component changes and update as necessary
			changeService = host.GetService (typeof (IComponentChangeService)) as IComponentChangeService;
			if (changeService == null)
				throw new Exception ("Could not obtain IComponentChangeService from host");

			//We use this to monitor and set selections
			selectionService = host.GetService (typeof (ISelectionService)) as ISelectionService;
			if (selectionService == null)
				throw new Exception ("Could not obtain ISelectionService from host");

			//This is used to add undo/redo, cut/paste etc commands to menu
			//Also to launch right-click menu
			menuService = host.GetService (typeof (IMenuCommandService)) as IMenuCommandService;
			//if (menuService == null)
			//	return;

			//Now we've got all services, register our events
			changeService.ComponentChanged += new ComponentChangedEventHandler (changeService_ComponentChanged);
			selectionService.SelectionChanged += new EventHandler (selectionService_SelectionChanged);
	
			//Register incoming calls from JavaScript
			comm.RegisterJSHandler ("Click", new ClrCall (JSClick));
			comm.RegisterJSHandler ("Activate", new ClrCall (JSActivate));
			comm.RegisterJSHandler ("ThrowException", new ClrCall (JSException));
			comm.RegisterJSHandler ("DebugStatement", new ClrCall (JSDebugStatement));
			comm.RegisterJSHandler ("ResizeControl", new ClrCall (JSResize));
			comm.RegisterJSHandler ("DocumentReturn", new ClrCall (JSDocumentReturn));
			comm.RegisterJSHandler ("RemoveControl", new ClrCall (JSRemoveControl));
			comm.RegisterJSHandler ("DeserializeAndAdd", new ClrCall (JSDeserializeAndAdd));
			comm.RegisterJSHandler ("Serialize", new ClrCall (JSSerialize));
			System.Diagnostics.Trace.WriteLine ("RootDesignerView created");
		}
        /// <summary>
        /// component kontrol et ve servisleri yükle
        /// </summary>
        /// <param name="component"></param>
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            if (component == null)
                throw new NullReferenceException("Component cannot be null");

            if (!(component is NavigateBar))
                throw new System.ArgumentException("Component not NavigateBar or derived ", "component");

            this.actionUISvc = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
            this.componentChnSvc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            this.designerHost = (IDesignerHost)GetService(typeof(IDesignerHost));
            this.selectionSvc = (ISelectionService)GetService(typeof(ISelectionService));

            // Eventlar
            this.componentChnSvc.ComponentRemoving += new ComponentEventHandler(componentChnSvc_ComponentRemoving);
            this.selectionSvc.SelectionChanged += new EventHandler(selectionSvc_SelectionChanged);
        }
		public override void Initialize(IComponent component)
		{
			if (component == null) {
				throw new ArgumentNullException("component");
			}
			base.Initialize(component);
			
			this.componentChangeService = (IComponentChangeService)component.Site.GetService(typeof(IComponentChangeService));
			if (componentChangeService != null) {
				componentChangeService.ComponentChanging += OnComponentChanging;
				componentChangeService.ComponentChanged += OnComponentChanged;
			}
			
			selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
			if (selectionService != null)
			{
				selectionService.SelectionChanged += OnSelectionChanged;
			}
			
		}
 public ToolStripKeyboardHandlingService(IServiceProvider serviceProvider)
 {
     this.provider = serviceProvider;
     this.selectionService = (ISelectionService) serviceProvider.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanging += new EventHandler(this.OnSelectionChanging);
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.designerHost = (IDesignerHost) this.provider.GetService(typeof(IDesignerHost));
     if (this.designerHost != null)
     {
         this.designerHost.AddService(typeof(ToolStripKeyboardHandlingService), this);
     }
     this.componentChangeSvc = (IComponentChangeService) this.designerHost.GetService(typeof(IComponentChangeService));
     if (this.componentChangeSvc != null)
     {
         this.componentChangeSvc.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
     }
 }
Exemple #31
0
 public DetailsController(IShellService shellService, ISelectionService selectionService, IManagerService managerService)
 {
     this.shellService     = shellService;
     this.selectionService = selectionService;
     blogsToSave           = new HashSet <IBlog>();
 }
Exemple #32
0
 public MarqueeSelectionTool(ISelectionService selectionService)
 {
     this.selectionService = selectionService;
     this.renderer         = new MarqueeRenderer();
 }
        private PageEditorViewModel OpenWidgetPage(IWidget widget, Guid SelWdgGID, bool bIsSelect, bool bIsgroup)
        {
            PageEditorViewModel newPage           = null;
            ISelectionService   _selectionService = ServiceLocator.Current.GetInstance <SelectionServiceProvider>();
            IPagePropertyData   activePage        = _selectionService.GetCurrentPage();

            Guid parentGID = widget.ParentPage.Guid;

            switch (widget.WidgetType)
            {
            case WidgetType.DynamicPanel:
            {
                //Active an exist page editor,20140220
                foreach (var pageItem in EditPages.OfType <DynamicPageEditorViewModel>())
                {
                    if (pageItem.ContentId == widget.Guid.ToString())
                    {
                        pageItem.IsActive = true;
                        return(pageItem);
                    }
                }

                ////Create a new page editor,20140220
                newPage = new DynamicPageEditorViewModel(widget);
                newPage.WdgMgrSetTargeComponent(SelWdgGID, bIsSelect, bIsgroup);
                break;
            }

            case WidgetType.Toast:
            {
                foreach (var pageItem in EditPages.OfType <ToastPageEditorViewModel>())
                {
                    if (pageItem.ContentId == widget.Guid.ToString())
                    {
                        pageItem.IsActive = true;
                        return(pageItem);
                    }
                }

                newPage = new ToastPageEditorViewModel(widget);
                newPage.WdgMgrSetTargeComponent(SelWdgGID, bIsSelect, bIsgroup);
                break;
            }

            case WidgetType.HamburgerMenu:
            {
                //Active an exist page editor,20140220
                foreach (var pageItem in EditPages.OfType <HamburgerPageEditorViewModel>())
                {
                    if (pageItem.ContentId == widget.Guid.ToString())
                    {
                        pageItem.IsActive = true;
                        return(pageItem);
                    }
                }
                //Create a new page editor,20140220
                newPage = new HamburgerPageEditorViewModel(widget);
                newPage.WdgMgrSetTargeComponent(SelWdgGID, bIsSelect, bIsgroup);
                break;
            }
            }

            DeselectAllPages();

            //if child page is not set(value is 100%)
            //Set scale the same as parent page(only create child page, not active child page)
            if (newPage.EditorScale == 1)
            {
                newPage.EditorScale = activePage.EditorScale;
            }
            newPage.Open();
            EditPages.Add(newPage);
            newPage.IsActive = true;
            newPage.Update();
            return(null);
        }
 public OrderingDownContactCommand(ISelectionService selectionService
                                   , IDbSessionFactory sessionFactory)
     : base(selectionService, sessionFactory)
 {
 }
        // This method is called when a user double-clicks (the representation of) a component.
        // Tries to bind the default event to a method or creates a new one.
        //
        public virtual void DoDefaultAction()
        {
            IDesignerHost       host        = (IDesignerHost)this.GetService(typeof(IDesignerHost));
            DesignerTransaction transaction = null;

            if (host != null)
            {
                transaction = host.CreateTransaction("ComponentDesigner_AddEvent");
            }

            IEventBindingService eventBindingService    = GetService(typeof(IEventBindingService)) as IEventBindingService;
            EventDescriptor      defaultEventDescriptor = null;

            if (eventBindingService != null)
            {
                ISelectionService selectionService = this.GetService(typeof(ISelectionService)) as ISelectionService;
                try {
                    if (selectionService != null)
                    {
                        ICollection selectedComponents = selectionService.GetSelectedComponents();

                        foreach (IComponent component in selectedComponents)
                        {
                            EventDescriptor eventDescriptor = TypeDescriptor.GetDefaultEvent(component);
                            if (eventDescriptor != null)
                            {
                                PropertyDescriptor eventProperty = eventBindingService.GetEventProperty(eventDescriptor);
                                if (eventProperty != null && !eventProperty.IsReadOnly)
                                {
                                    string methodName = eventProperty.GetValue(component) as string;
                                    bool   newMethod  = true;

                                    if (methodName != null || methodName != String.Empty)
                                    {
                                        ICollection compatibleMethods = eventBindingService.GetCompatibleMethods(eventDescriptor);
                                        foreach (string signature in compatibleMethods)
                                        {
                                            if (signature == methodName)
                                            {
                                                newMethod = false;
                                                break;
                                            }
                                        }
                                    }
                                    if (newMethod)
                                    {
                                        if (methodName == null)
                                        {
                                            methodName = eventBindingService.CreateUniqueMethodName(component, eventDescriptor);
                                        }

                                        eventProperty.SetValue(component, methodName);
                                    }

                                    if (component == _component)
                                    {
                                        defaultEventDescriptor = eventDescriptor;
                                    }
                                }
                            }
                        }
                    }
                }
                catch {
                    if (transaction != null)
                    {
                        transaction.Cancel();
                        transaction = null;
                    }
                }
                finally {
                    if (transaction != null)
                    {
                        transaction.Commit();
                    }
                }

                if (defaultEventDescriptor != null)
                {
                    eventBindingService.ShowCode(_component, defaultEventDescriptor);
                }
            }
        }
Exemple #36
0
        // Reminder: We set control.Parent so that it gets serialized for Undo/Redo
        //
        private void Paste(object sender, EventArgs args)
        {
            IDesignerSerializationService stateSerializer = GetService(typeof(IDesignerSerializationService)) as IDesignerSerializationService;
            ISelectionService             selection       = GetService(typeof(ISelectionService)) as ISelectionService;
            IDesignerHost           host          = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (host == null || stateSerializer == null)
            {
                return;
            }
            //
            // TODO: MWF X11 doesn't seem to support custom clipboard formats - bug #357642
            //
            // IDataObject dataObject = Clipboard.GetDataObject ();
            // byte[] data = dataObject == null ? null : dataObject.GetData (DT_DATA_FORMAT) as byte[];
            // if (data != null) {
            //  MemoryStream stream = new MemoryStream (data);
            //  stateSerializer.Deserialize (new BinaryFormatter().Deserialize (stream));
            // .....
            // }
            //
            if (_clipboard == null)
            {
                return;
            }

            DesignerTransaction transaction = host.CreateTransaction("Paste");
            ICollection         components  = stateSerializer.Deserialize(_clipboard);

            // Console.WriteLine ("Pasted components: ");
            // foreach (object c in components)
            //  Console.WriteLine (((IComponent)c).Site.Name);
            foreach (object component in components)
            {
                Control control = component as Control;
                if (control == null)
                {
                    continue;                     // pure Components are added to the ComponentTray by the DocumentDesigner
                }
                PropertyDescriptor parentProperty = TypeDescriptor.GetProperties(control)["Parent"];
                if (control.Parent != null)
                {
                    // Already parented during deserialization?
                    // In that case explicitly raise component changing/ed for the Parent property,
                    // so it get's cought by the UndoEngine
                    if (changeService != null)
                    {
                        changeService.OnComponentChanging(control, parentProperty);
                        changeService.OnComponentChanged(control, parentProperty, null, control.Parent);
                    }
                }
                else
                {
                    ParentControlDesigner parentDesigner = null;
                    if (selection != null && selection.PrimarySelection != null)
                    {
                        parentDesigner = host.GetDesigner((IComponent)selection.PrimarySelection) as ParentControlDesigner;
                    }
                    if (parentDesigner == null)
                    {
                        parentDesigner = host.GetDesigner(host.RootComponent) as DocumentDesigner;
                    }
                    if (parentDesigner != null && parentDesigner.CanParent(control))
                    {
                        parentProperty.SetValue(control, parentDesigner.Control);
                    }
                }
            }
            _clipboard = null;
            transaction.Commit();
            ((IDisposable)transaction).Dispose();
        }
Exemple #37
0
        protected override CommandBase TestCommand(IVBE vbe, RubberduckParserState state, IRewritingManager rewritingManager, ISelectionService selectionService)
        {
            var msgBox  = new Mock <IMessageBox>().Object;
            var factory = new Mock <IRefactoringPresenterFactory>().Object;
            var selectedDeclarationProvider = new SelectedDeclarationProvider(selectionService, state);
            var uiDispatcherMock            = new Mock <IUiDispatcher>();

            uiDispatcherMock
            .Setup(m => m.Invoke(It.IsAny <Action>()))
            .Callback((Action action) => action.Invoke());
            var refactoring = new RemoveParametersRefactoring(state, factory, rewritingManager, selectionService, selectedDeclarationProvider, uiDispatcherMock.Object);
            var notifier    = new RemoveParameterFailedNotifier(msgBox);

            return(new RefactorRemoveParametersCommand(refactoring, notifier, state, selectionService, selectedDeclarationProvider));
        }
Exemple #38
0
        private void Given_MainFormInteractor()
        {
            program       = CreateFakeProgram();
            svcFactory    = mr.StrictMock <IServiceFactory>();
            archSvc       = mr.StrictMock <IArchiveBrowserService>();
            dlgFactory    = mr.StrictMock <IDialogFactory>();
            memSvc        = mr.StrictMock <ILowLevelViewService>();
            disasmSvc     = mr.StrictMock <IDisassemblyViewService>();
            typeLibSvc    = mr.StrictMock <ITypeLibraryLoaderService>();
            brSvc         = mr.Stub <IProjectBrowserService>();
            uiPrefs       = mr.StrictMock <IUiPreferencesService>();
            fsSvc         = mr.StrictMock <IFileSystemService>();
            tcHostSvc     = mr.StrictMock <ITabControlHostService>();
            dcSvc         = mr.StrictMock <IDecompilerService>();
            srSvc         = MockRepository.GenerateMock <ISearchResultService, IWindowPane>();
            diagnosticSvc = MockRepository.GenerateMock <IDiagnosticsService, IWindowPane>();
            resEditSvc    = mr.StrictMock <IResourceEditorService>();
            cgvSvc        = mr.StrictMock <ICallGraphViewService>();
            loader        = mr.StrictMock <ILoader>();
            sbSvc         = mr.Stub <IStatusBarService>();
            vimpSvc       = mr.StrictMock <IViewImportsService>();
            cvSvc         = mr.StrictMock <ICodeViewerService>();
            imgSegSvc     = mr.StrictMock <ImageSegmentService>();
            symLoadSvc    = mr.StrictMock <ISymbolLoadingService>();
            selSvc        = mr.StrictMock <ISelectionService>();

            svcFactory.Stub(s => s.CreateArchiveBrowserService()).Return(archSvc);
            svcFactory.Stub(s => s.CreateCodeViewerService()).Return(cvSvc);
            svcFactory.Stub(s => s.CreateDecompilerConfiguration()).Return(new FakeDecompilerConfiguration());
            svcFactory.Stub(s => s.CreateDiagnosticsService()).Return(diagnosticSvc);
            svcFactory.Stub(s => s.CreateDecompilerService()).Return(dcSvc);
            svcFactory.Stub(s => s.CreateDisassemblyViewService()).Return(disasmSvc);
            svcFactory.Stub(s => s.CreateMemoryViewService()).Return(memSvc);
            svcFactory.Stub(s => s.CreateDecompilerEventListener()).Return(new FakeDecompilerEventListener());
            svcFactory.Stub(s => s.CreateImageSegmentService()).Return(imgSegSvc);
            svcFactory.Stub(s => s.CreateInitialPageInteractor()).Return(new FakeInitialPageInteractor());
            svcFactory.Stub(s => s.CreateScannedPageInteractor()).Return(new FakeScannedPageInteractor());
            svcFactory.Stub(s => s.CreateTypeLibraryLoaderService()).Return(typeLibSvc);
            svcFactory.Stub(s => s.CreateProjectBrowserService()).Return(brSvc);
            svcFactory.Stub(s => s.CreateUiPreferencesService()).Return(uiPrefs);
            svcFactory.Stub(s => s.CreateFileSystemService()).Return(fsSvc);
            svcFactory.Stub(s => s.CreateStatusBarService()).Return(sbSvc);
            svcFactory.Stub(s => s.CreateTabControlHost()).Return(tcHostSvc);
            svcFactory.Stub(s => s.CreateLoader()).Return(loader);
            svcFactory.Stub(s => s.CreateSearchResultService()).Return(srSvc);
            svcFactory.Stub(s => s.CreateResourceEditorService()).Return(resEditSvc);
            svcFactory.Stub(s => s.CreateCallGraphViewService()).Return(cgvSvc);
            svcFactory.Stub(s => s.CreateViewImportService()).Return(vimpSvc);
            svcFactory.Stub(s => s.CreateSymbolLoadingService()).Return(symLoadSvc);
            svcFactory.Stub(s => s.CreateSelectionService()).Return(selSvc);
            services.AddService(typeof(IDialogFactory), dlgFactory);
            services.AddService(typeof(IServiceFactory), svcFactory);
            brSvc.Stub(b => b.Clear());

            form = mr.StrictMock <IMainForm>();
            form.Stub(f => f.Dispose());
            form.Stub(f => f.UpdateToolbarState());
            form.Closed += null;
            LastCall.IgnoreArguments();
            tcHostSvc.Stub(t => t.QueryStatus(
                               Arg <CommandID> .Is.Anything,
                               Arg <CommandStatus> .Is.Anything,
                               Arg <CommandText> .Is.Anything)).Return(false);
            tcHostSvc.Stub(t => t.Execute(Arg <CommandID> .Is.Anything)).Return(false);

            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
            brSvc.Stub(u => u.ContainsFocus).Return(false);
            tcHostSvc.Stub(u => u.ContainsFocus).Return(false);

            // We currently don't care about testing the appearance of the Main window text.
            // Should this be required, you will need to remove the line below and add an
            // appropriate stub/expectation in all the tests below. Good luck with that.
            form.Stub(f => f.TitleText = "").IgnoreArguments();
        }
        /// <summary>
        ///  Here is where all the fun stuff starts.  We create the structure and apply the naming here.
        /// </summary>
        private void CreateStandardMenuStrip(System.ComponentModel.Design.IDesignerHost host, MenuStrip tool)
        {
            // build the static menu items structure.
            string[][] menuItemNames = new string[][]
            {
                new string[] { SR.StandardMenuFile, SR.StandardMenuNew, SR.StandardMenuOpen, "-", SR.StandardMenuSave, SR.StandardMenuSaveAs, "-", SR.StandardMenuPrint, SR.StandardMenuPrintPreview, "-", SR.StandardMenuExit },
                new string[] { SR.StandardMenuEdit, SR.StandardMenuUndo, SR.StandardMenuRedo, "-", SR.StandardMenuCut, SR.StandardMenuCopy, SR.StandardMenuPaste, "-", SR.StandardMenuSelectAll },
                new string[] { SR.StandardMenuTools, SR.StandardMenuCustomize, SR.StandardMenuOptions },
                new string[] { SR.StandardMenuHelp, SR.StandardMenuContents, SR.StandardMenuIndex, SR.StandardMenuSearch, "-", SR.StandardMenuAbout }
            };

            // build the static menu items image list that maps one-one with above menuItems structure. this is required so that the in LOCALIZED build we dont use the Localized item string.
            string[][] menuItemImageNames = new string[][]
            {
                new string[] { "", "new", "open", "-", "save", "", "-", "print", "printPreview", "-", "" },
                new string[] { "", "", "", "-", "cut", "copy", "paste", "-", "" },
                new string[] { "", "", "" },
                new string[] { "", "", "", "", "-", "" }
            };

            Keys[][] menuItemShortcuts = new Keys[][]
            {
                new Keys[] { /*File*/ Keys.None, /*New*/ Keys.Control | Keys.N, /*Open*/ Keys.Control | Keys.O, /*Separator*/ Keys.None, /*Save*/ Keys.Control | Keys.S, /*SaveAs*/ Keys.None, Keys.None, /*Print*/ Keys.Control | Keys.P, /*PrintPreview*/ Keys.None, /*Separator*/ Keys.None, /*Exit*/ Keys.None },
                new Keys[] { /*Edit*/ Keys.None, /*Undo*/ Keys.Control | Keys.Z, /*Redo*/ Keys.Control | Keys.Y, /*Separator*/ Keys.None, /*Cut*/ Keys.Control | Keys.X, /*Copy*/ Keys.Control | Keys.C, /*Paste*/ Keys.Control | Keys.V, /*Separator*/ Keys.None, /*SelectAll*/ Keys.None },
                new Keys[] { /*Tools*/ Keys.None, /*Customize*/ Keys.None, /*Options*/ Keys.None },
                new Keys[] { /*Help*/ Keys.None, /*Contents*/ Keys.None, /*Index*/ Keys.None, /*Search*/ Keys.None, /*Separator*/ Keys.None, /*About*/ Keys.None }
            };

            Debug.Assert(host != null, "can't create standard menu without designer _host.");
            if (host is null)
            {
                return;
            }

            tool.SuspendLayout();
            ToolStripDesigner.s_autoAddNewItems = false;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction createMenu = _host.CreateTransaction(SR.StandardMenuCreateDesc);

            try
            {
                INameCreationService nameCreationService = (INameCreationService)_provider.GetService(typeof(INameCreationService));
                string defaultName = "standardMainMenuStrip";
                string name        = defaultName;
                int    index       = 1;

                if (host != null)
                {
                    while (_host.Container.Components[name] != null)
                    {
                        name = defaultName + (index++).ToString(CultureInfo.InvariantCulture);
                    }
                }

                // now build the menu items themselves.
                for (int j = 0; j < menuItemNames.Length; j++)
                {
                    string[]          menuArray = menuItemNames[j];
                    ToolStripMenuItem rootItem  = null;
                    for (int i = 0; i < menuArray.Length; i++)
                    {
                        name = null;
                        // for separators, just use the default name.  Otherwise, remove any non-characters and  get the name from the text.
                        string itemText = menuArray[i];
                        name = NameFromText(itemText, typeof(ToolStripMenuItem), nameCreationService, true);
                        ToolStripItem item = null;
                        if (name.Contains("Separator"))
                        {
                            // create the componennt.
                            item = (ToolStripSeparator)_host.CreateComponent(typeof(ToolStripSeparator), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }

                            item.Text = itemText;
                        }
                        else
                        {
                            // create the componennt.
                            item = (ToolStripMenuItem)_host.CreateComponent(typeof(ToolStripMenuItem), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }

                            item.Text = itemText;
                            Keys shortcut = menuItemShortcuts[j][i];
                            if ((item is ToolStripMenuItem) && shortcut != Keys.None)
                            {
                                if (!ToolStripManager.IsShortcutDefined(shortcut) && ToolStripManager.IsValidShortcut(shortcut))
                                {
                                    ((ToolStripMenuItem)item).ShortcutKeys = shortcut;
                                }
                            }

                            Bitmap image = null;
                            try
                            {
                                image = GetImage(menuItemImageNames[j][i]);
                            }
                            catch
                            {
                                // eat the exception.. as you may not find image for all MenuItems.
                            }

                            if (image != null)
                            {
                                PropertyDescriptor imageProperty = TypeDescriptor.GetProperties(item)["Image"];
                                Debug.Assert(imageProperty != null, "Could not find 'Image' property in ToolStripItem.");
                                if (imageProperty != null)
                                {
                                    imageProperty.SetValue(item, image);
                                }

                                item.ImageTransparentColor = Color.Magenta;
                            }
                        }

                        // the first item in each array is the root item.
                        if (i == 0)
                        {
                            rootItem = (ToolStripMenuItem)item;
                            rootItem.DropDown.SuspendLayout();
                        }
                        else
                        {
                            rootItem.DropDownItems.Add(item);
                        }

                        //If Last SubItem Added the Raise the Events
                        if (i == menuArray.Length - 1)
                        {
                            // member is OK to be null...
                            MemberDescriptor member = TypeDescriptor.GetProperties(rootItem)["DropDownItems"];
                            _componentChangeSvc.OnComponentChanging(rootItem, member);
                            _componentChangeSvc.OnComponentChanged(rootItem, member, null, null);
                        }
                    }

                    // finally, add it to the MainMenu.
                    rootItem.DropDown.ResumeLayout(false);
                    tool.Items.Add(rootItem);
                    //If Last SubItem Added the Raise the Events
                    if (j == menuItemNames.Length - 1)
                    {
                        // member is OK to be null...
                        MemberDescriptor topMember = TypeDescriptor.GetProperties(tool)["Items"];
                        _componentChangeSvc.OnComponentChanging(tool, topMember);
                        _componentChangeSvc.OnComponentChanged(tool, topMember, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (createMenu != null)
                {
                    createMenu.Cancel();
                    createMenu = null;
                }
            }
            finally
            {
                ToolStripDesigner.s_autoAddNewItems = true;
                if (createMenu != null)
                {
                    createMenu.Commit();
                    createMenu = null;
                }

                tool.ResumeLayout();
                // Select the Main Menu...
                ISelectionService selSvc = (ISelectionService)_provider.GetService(typeof(ISelectionService));
                if (selSvc != null)
                {
                    selSvc.SetSelectedComponents(new object[] { _designer.Component });
                }

                //Refresh the Glyph
                DesignerActionUIService actionUIService = (DesignerActionUIService)_provider.GetService(typeof(DesignerActionUIService));
                if (actionUIService != null)
                {
                    actionUIService.Refresh(_designer.Component);
                }

                // this will invalidate the Selection Glyphs.
                SelectionManager selMgr = (SelectionManager)_provider.GetService(typeof(SelectionManager));
                selMgr.Refresh();
            }
        }
        /// <summary>
        ///  Here is where all the fun stuff starts.  We create the structure and apply the naming here.
        /// </summary>
        private void CreateStandardToolStrip(IDesignerHost host, ToolStrip tool)
        {
            // build the static menu items structure.
            //
            string[] menuItemNames = new string[] { SR.StandardMenuNew, SR.StandardMenuOpen, SR.StandardMenuSave, SR.StandardMenuPrint, "-", SR.StandardToolCut, SR.StandardMenuCopy, SR.StandardMenuPaste, "-", SR.StandardToolHelp };

            // build a image list mapping one-one the above menuItems list... this is required so that the in LOCALIZED build we dont use the Localized item string.
            string[] menuItemImageNames = new string[] { "new", "open", "save", "print", "-", "cut", "copy", "paste", "-", "help" };
            Debug.Assert(host != null, "can't create standard menu without designer _host.");

            if (host is null)
            {
                return;
            }

            tool.SuspendLayout();
            ToolStripDesigner.s_autoAddNewItems = false;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction createMenu = _host.CreateTransaction(SR.StandardMenuCreateDesc);

            try
            {
                INameCreationService nameCreationService = (INameCreationService)_provider.GetService(typeof(INameCreationService));
                string defaultName = "standardMainToolStrip";
                string name        = defaultName;
                int    index       = 1;
                if (host != null)
                {
                    while (_host.Container.Components[name] != null)
                    {
                        name = defaultName + (index++).ToString(CultureInfo.InvariantCulture);
                    }
                }

                //keep an index in the MenuItemImageNames .. so that mapping is maintained.
                int menuItemImageNamesCount = 0;
                // now build the menu items themselves.
                foreach (string itemText in menuItemNames)
                {
                    name = null;
                    // for separators, just use the default name.  Otherwise, remove any non-characters and get the name from the text.
                    defaultName = "ToolStripButton";
                    name        = NameFromText(itemText, typeof(ToolStripButton), nameCreationService, true);
                    ToolStripItem item = null;
                    if (name.Contains("Separator"))
                    {
                        // create the componennt.
                        item = (ToolStripSeparator)_host.CreateComponent(typeof(ToolStripSeparator), name);
                        IDesigner designer = _host.GetDesigner(item);
                        if (designer is ComponentDesigner)
                        {
                            ((ComponentDesigner)designer).InitializeNewComponent(null);
                        }
                    }
                    else
                    {
                        // create the component.
                        item = (ToolStripButton)_host.CreateComponent(typeof(ToolStripButton), name);
                        IDesigner designer = _host.GetDesigner(item);
                        if (designer is ComponentDesigner)
                        {
                            ((ComponentDesigner)designer).InitializeNewComponent(null);
                        }

                        PropertyDescriptor displayStyleProperty = TypeDescriptor.GetProperties(item)["DisplayStyle"];
                        Debug.Assert(displayStyleProperty != null, "Could not find 'Text' property in ToolStripItem.");
                        if (displayStyleProperty != null)
                        {
                            displayStyleProperty.SetValue(item, ToolStripItemDisplayStyle.Image);
                        }

                        PropertyDescriptor textProperty = TypeDescriptor.GetProperties(item)["Text"];
                        Debug.Assert(textProperty != null, "Could not find 'Text' property in ToolStripItem.");
                        if (textProperty != null)
                        {
                            textProperty.SetValue(item, itemText);
                        }

                        Bitmap image = null;
                        try
                        {
                            image = GetImage(menuItemImageNames[menuItemImageNamesCount]);
                        }
                        catch
                        {
                            // eat the exception.. as you may not find image for all MenuItems.
                        }

                        if (image != null)
                        {
                            PropertyDescriptor imageProperty = TypeDescriptor.GetProperties(item)["Image"];
                            Debug.Assert(imageProperty != null, "Could not find 'Image' property in ToolStripItem.");
                            if (imageProperty != null)
                            {
                                imageProperty.SetValue(item, image);
                            }

                            item.ImageTransparentColor = Color.Magenta;
                        }
                    }

                    tool.Items.Add(item);
                    //increment the counter...
                    menuItemImageNamesCount++;
                }

                // finally, add it to the Main ToolStrip.
                MemberDescriptor topMember = TypeDescriptor.GetProperties(tool)["Items"];
                _componentChangeSvc.OnComponentChanging(tool, topMember);
                _componentChangeSvc.OnComponentChanged(tool, topMember, null, null);
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }

                if (createMenu != null)
                {
                    createMenu.Cancel();
                    createMenu = null;
                }
            }
            finally
            {
                //Reset the AutoAdd state
                ToolStripDesigner.s_autoAddNewItems = true;
                if (createMenu != null)
                {
                    createMenu.Commit();
                    createMenu = null;
                }

                tool.ResumeLayout();
                // Select the Main Menu...
                ISelectionService selSvc = (ISelectionService)_provider.GetService(typeof(ISelectionService));
                if (selSvc != null)
                {
                    selSvc.SetSelectedComponents(new object[] { _designer.Component });
                }

                //Refresh the Glyph
                DesignerActionUIService actionUIService = (DesignerActionUIService)_provider.GetService(typeof(DesignerActionUIService));
                if (actionUIService != null)
                {
                    actionUIService.Refresh(_designer.Component);
                }

                // this will invalidate the Selection Glyphs.
                SelectionManager selMgr = (SelectionManager)_provider.GetService(typeof(SelectionManager));
                selMgr.Refresh();
            }
        }
        protected override IRefactoring TestRefactoring(IRewritingManager rewritingManager, RubberduckParserState state, IRefactoringPresenterFactory factory, ISelectionService selectionService)
        {
            var indenter = CreateIndenter(); //The refactoring only uses method independent of the VBE instance.
            var selectedDeclarationProvider = new SelectedDeclarationProvider(selectionService, state);
            var uiDispatcherMock            = new Mock <IUiDispatcher>();

            uiDispatcherMock
            .Setup(m => m.Invoke(It.IsAny <Action>()))
            .Callback((Action action) => action.Invoke());
            return(new EncapsulateFieldRefactoring(state, indenter, factory, rewritingManager, selectionService, selectedDeclarationProvider, uiDispatcherMock.Object));
        }
        public IdentifierReferencesListDockablePresenter(IVBE vbe, IAddIn addin, SimpleListControl control, ISelectionService selectionService, Declaration target)
            : base(vbe, addin, control, null)
        {
            _selectionService = selectionService;

            BindTarget(target);
        }
Exemple #43
0
        public WorkflowOutline(IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
            Debug.Assert(serviceProvider != null, "Creating WorkflowOutline without service host");

            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (designerHost == null)
            {
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IDesignerHost).FullName));
            }

            // listen for loaded and unloaded events
            DesignSurface surface = GetService(typeof(DesignSurface)) as DesignSurface;

            if (surface == null)
            {
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(DesignSurface).FullName));
            }
            surface.Loaded += new LoadedEventHandler(OnSurfaceLoaded);

            IComponentChangeService componentChangeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (componentChangeService != null)
            {
                componentChangeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
                componentChangeService.ComponentRename  += new ComponentRenameEventHandler(OnComponentRename);
            }

            WorkflowTheme.ThemeChanged += new EventHandler(OnThemeChanged);

            // Get an ISelectionService service
            ISelectionService selectionService = GetService(typeof(ISelectionService)) as ISelectionService;

            if (selectionService != null)
            {
                selectionService.SelectionChanged += new System.EventHandler(this.OnSelectionChanged);
            }

            IUIService uiService = GetService(typeof(IUIService)) as IUIService;

            if (uiService != null)
            {
                this.Font = (Font)uiService.Styles["DialogFont"];
            }

            // Set up treeview
            this.treeView               = new TreeView();
            this.treeView.Dock          = DockStyle.Fill;
            this.treeView.HideSelection = false;
            this.treeView.AfterSelect  += new TreeViewEventHandler(this.OnTreeViewAfterSelect);
            this.treeView.MouseDown    += new MouseEventHandler(this.OnTreeViewMouseDown);
            this.treeView.Font          = this.Font;
            this.treeView.ItemHeight    = Math.Max(this.treeView.ItemHeight, 18);
            this.Controls.Add(this.treeView);
        }
Exemple #44
0
 public EncapsulateFieldQuickFix(RubberduckParserState state, IIndenter indenter, IRefactoringPresenterFactory factory, IRewritingManager rewritingManager, ISelectionService selectionService)
     : base(typeof(EncapsulatePublicFieldInspection))
 {
     _state            = state;
     _selectionService = selectionService;
     _rewritingManager = rewritingManager;
     _indenter         = indenter;
     _factory          = factory;
 }
Exemple #45
0
 public NavigateCommand(ISelectionService selectionService)
     : base(LogManager.GetCurrentClassLogger())
 {
     _selectionService = selectionService;
 }
Exemple #46
0
        public IComponent[] CreateTool(ToolboxItem tool, Control parent, int x, int y, int width, int height, bool hasLocation, bool hasSize, ToolboxSnapDragDropEventArgs e)
        {
            // Services we will need
            //
            IToolboxService   toolboxSvc = (IToolboxService)GetService(typeof(IToolboxService));
            ISelectionService selSvc     = (ISelectionService)GetService(typeof(ISelectionService));
            IDesignerHost     host       = (IDesignerHost)GetService(typeof(IDesignerHost));

            IComponent[] comps = Array.Empty <IComponent>();

            Cursor oldCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            DesignerTransaction trans = null;

            try
            {
                try
                {
                    if (host != null)
                    {
                        trans = host.CreateTransaction(string.Format(SR.DesignerBatchCreateTool, tool.ToString()));
                    }
                }
                catch (CheckoutException cxe)
                {
                    if (cxe == CheckoutException.Canceled)
                    {
                        return(comps);
                    }

                    throw;
                }

                try
                {
                    try
                    {
                        // First check if we are currently in localization mode (i.e., language is non-default).
                        // If so, we should not permit addition of new components. This is an intentional
                        // change from Everett - see VSWhidbey #292249.
                        if (host != null && CurrentlyLocalizing(host.RootComponent))
                        {
                            IUIService uiService = (IUIService)GetService(typeof(IUIService));
                            if (uiService != null)
                            {
                                uiService.ShowMessage(SR.LocalizingCannotAdd);
                            }

                            comps = Array.Empty <IComponent>();
                            return(comps);
                        }

                        // Create a dictionary of default values that the designer can
                        // use to initialize a control with.
                        Hashtable defaultValues = new Hashtable();
                        if (parent != null)
                        {
                            defaultValues["Parent"] = parent;
                        }

                        // adjust the location if we are in a mirrored parent. That is because the origin
                        // will then be in the upper right rather than upper left.
                        if (parent != null && parent.IsMirrored)
                        {
                            x += width;
                        }

                        if (hasLocation)
                        {
                            defaultValues["Location"] = new Point(x, y);
                        }
                        if (hasSize)
                        {
                            defaultValues["Size"] = new Size(width, height);
                        }
                        //store off extra behavior drag/drop information
                        if (e != null)
                        {
                            defaultValues["ToolboxSnapDragDropEventArgs"] = e;
                        }

                        comps = tool.CreateComponents(host, defaultValues);
                    }
                    catch (CheckoutException checkoutEx)
                    {
                        if (checkoutEx == CheckoutException.Canceled)
                        {
                            comps = Array.Empty <IComponent>();
                        }
                        else
                        {
                            throw;
                        }
                    }
                    catch (ArgumentException argumentEx)
                    {
                        IUIService uiService = (IUIService)GetService(typeof(IUIService));
                        if (uiService != null)
                        {
                            uiService.ShowError(argumentEx);
                        }
                    }
                    catch (Exception ex)
                    {
                        IUIService uiService = (IUIService)GetService(typeof(IUIService));

                        string exceptionMessage = string.Empty;
                        if (ex.InnerException != null)
                        {
                            exceptionMessage = ex.InnerException.ToString();
                        }

                        if (string.IsNullOrEmpty(exceptionMessage))
                        {
                            exceptionMessage = ex.ToString();
                        }

                        if (ex is InvalidOperationException)
                        {
                            exceptionMessage = ex.Message;
                        }

                        if (uiService != null)
                        {
                            uiService.ShowError(ex, string.Format(SR.FailedToCreateComponent, tool.DisplayName, exceptionMessage));
                        }
                        else
                        {
                            throw;
                        }
                    }

                    if (comps == null)
                    {
                        comps = Array.Empty <IComponent>();
                    }
                }
                finally
                {
                    if (toolboxSvc != null && tool.Equals(toolboxSvc.GetSelectedToolboxItem(host)))
                    {
                        toolboxSvc.SelectedToolboxItemUsed();
                    }
                }
            }
            finally
            {
                if (trans != null)
                {
                    trans.Commit();
                }

                Cursor.Current = oldCursor;
            }

            // Finally, select the newly created components.
            //
            if (selSvc != null && comps.Length > 0)
            {
                if (host != null)
                {
                    host.Activate();
                }

                ArrayList selectComps = new ArrayList(comps);

                for (int i = 0; i < comps.Length; i++)
                {
                    if (!TypeDescriptor.GetAttributes(comps[i]).Contains(DesignTimeVisibleAttribute.Yes))
                    {
                        selectComps.Remove(comps[i]);
                    }
                }

                selSvc.SetSelectedComponents(selectComps.ToArray(), SelectionTypes.Replace);
            }

            codemarkers.CodeMarker((int)CodeMarkerEvent.perfFXDesignCreateComponentEnd);
            return(comps);
        }
Exemple #47
0
        // Keep in mind that messages are recieved for the child controls if routed
        //
        protected virtual void WndProc(ref Message m)
        {
            // Filter out kb input
            //
            if ((Native.Msg)m.Msg >= Native.Msg.WM_KEYFIRST && (Native.Msg)m.Msg <= Native.Msg.WM_KEYLAST)
            {
                return;
            }

            // Mouse messages should be routed the control, if GetHitTest (virtual) returns true.
            //
            if (IsMouseMessage((Native.Msg)m.Msg) &&
                this.GetHitTest(new Point(Native.LoWord((int)m.LParam), Native.HiWord(((int)m.LParam)))))
            {
                this.DefWndProc(ref m);
                return;
            }

            switch ((Native.Msg)m.Msg)
            {
            case Native.Msg.WM_CREATE:
                this.DefWndProc(ref m);
                if (m.HWnd == this.Control.Handle)
                {
                    OnCreateHandle();
                }
                break;

            case Native.Msg.WM_CONTEXTMENU:
                OnContextMenu(Native.LoWord((int)m.LParam), Native.HiWord((int)m.LParam));
                break;

            case Native.Msg.WM_SETCURSOR:
                if (this.GetHitTest(new Point(Native.LoWord((int)m.LParam), Native.HiWord((int)m.LParam))))
                {
                    this.DefWndProc(ref m);
                }
                else
                {
                    OnSetCursor();
                }
                break;

            case Native.Msg.WM_SETFOCUS:
                this.DefWndProc(ref m);
                break;

            case Native.Msg.WM_PAINT:
                // Wait for control's WM_PAINT to complete first.
                //
                this.DefWndProc(ref m);

                Graphics       gfx  = Graphics.FromHwnd(m.HWnd);
                PaintEventArgs args = new PaintEventArgs(gfx, this.Control.Bounds);
                OnPaintAdornments(args);
                gfx.Dispose();
                args.Dispose();
                break;

            case Native.Msg.WM_NCRBUTTONDOWN:
            case Native.Msg.WM_NCMBUTTONDOWN:
            case Native.Msg.WM_NCLBUTTONDBLCLK:
            case Native.Msg.WM_NCRBUTTONDBLCLK:
                break;

            case Native.Msg.WM_LBUTTONDBLCLK:
            case Native.Msg.WM_RBUTTONDBLCLK:
            case Native.Msg.WM_MBUTTONDBLCLK:
                if ((Native.Msg)m.Msg == Native.Msg.WM_LBUTTONDBLCLK)
                {
                    _mouseButtonDown = MouseButtons.Left;
                }
                else if ((Native.Msg)m.Msg == Native.Msg.WM_RBUTTONDBLCLK)
                {
                    _mouseButtonDown = MouseButtons.Right;
                }
                else if ((Native.Msg)m.Msg == Native.Msg.WM_MBUTTONDBLCLK)
                {
                    _mouseButtonDown = MouseButtons.Middle;
                }
                OnMouseDoubleClick();
                this.BaseWndProc(ref m);
                break;

            case Native.Msg.WM_MOUSEHOVER:
                OnMouseHover();
                break;

            case Native.Msg.WM_LBUTTONDOWN:
            case Native.Msg.WM_RBUTTONDOWN:
            case Native.Msg.WM_MBUTTONDOWN:
                if ((Native.Msg)m.Msg == Native.Msg.WM_LBUTTONDOWN)
                {
                    _mouseButtonDown = MouseButtons.Left;
                }
                else if ((Native.Msg)m.Msg == Native.Msg.WM_RBUTTONDOWN)
                {
                    _mouseButtonDown = MouseButtons.Right;
                }
                else if ((Native.Msg)m.Msg == Native.Msg.WM_MBUTTONDOWN)
                {
                    _mouseButtonDown = MouseButtons.Middle;
                }

                if (_firstMouseMoveInClient)
                {
                    OnMouseEnter();
                    _firstMouseMoveInClient = false;
                }
                this.OnMouseDown(Native.LoWord((int)m.LParam), Native.HiWord((int)m.LParam));
                this.BaseWndProc(ref m);
                break;

            case Native.Msg.WM_MOUSELEAVE:
                _firstMouseMoveInClient = false;
                OnMouseLeave();
                this.BaseWndProc(ref m);
                break;

            // The WM_CANCELMODE message is sent to cancel certain modes, such as mouse capture.
            // For example, the system sends this message to the active window when a dialog box
            // or message box is displayed. Certain functions also send this message explicitly to
            // the specified window regardless of whether it is the active window. For example,
            // the EnableWindow function sends this message when disabling the specified window.
            //
            case Native.Msg.WM_CANCELMODE:
                OnMouseDragEnd(true);
                this.DefWndProc(ref m);
                break;

            case Native.Msg.WM_LBUTTONUP:
            case Native.Msg.WM_RBUTTONUP:
            case Native.Msg.WM_NCLBUTTONUP:
            case Native.Msg.WM_NCRBUTTONUP:
            case Native.Msg.WM_MBUTTONUP:
            case Native.Msg.WM_NCMBUTTONUP:
                this.OnMouseUp();
                this.BaseWndProc(ref m);
                break;

            // MWF Specific msg! - must reach control
            //
            case Native.Msg.WM_MOUSE_ENTER:
                _firstMouseMoveInClient = false;                         // just so that nothing will get fired in WM_MOUSEMOVE
                OnMouseEnter();
                this.DefWndProc(ref m);
                break;

            case Native.Msg.WM_MOUSEMOVE:
                // If selection is in progress pass the mouse move msg to the primary selection.
                // If resizing is in progress pass to the parent of the primary selection (remmember that the selection
                // frame is not a control and is drawn in the parent of the primary selection).
                //
                // Required in order for those 2 operations to continue when the mouse is moving over a control covering
                // the one where the action takes place.
                //
                IUISelectionService uiSelectionServ = this.GetService(typeof(IUISelectionService)) as IUISelectionService;
                ISelectionService   selectionServ   = this.GetService(typeof(ISelectionService)) as ISelectionService;
                IDesignerHost       host            = this.GetService(typeof(IDesignerHost)) as IDesignerHost;


                if (uiSelectionServ != null && selectionServ != null && host != null)
                {
                    Control primarySelection = selectionServ.PrimarySelection as Control;
                    Point   location         = new Point(Native.LoWord((int)m.LParam), Native.HiWord((int)m.LParam));

                    if (uiSelectionServ.SelectionInProgress &&
                        this.Component != host.RootComponent &&
                        this.Component != selectionServ.PrimarySelection)
                    {
                        location = primarySelection.PointToClient(this.Control.PointToScreen(location));
                        Native.SendMessage(primarySelection.Handle, (Native.Msg)m.Msg, m.WParam, Native.LParam(location.X, location.Y));
                    }
                    else if (uiSelectionServ.ResizeInProgress &&
                             // this.Component != host.RootComponent &&
                             this.Control.Parent == ((Control)selectionServ.PrimarySelection).Parent)
                    {
                        location = this.Control.Parent.PointToClient(this.Control.PointToScreen(location));
                        Native.SendMessage(this.Control.Parent.Handle, (Native.Msg)m.Msg, m.WParam, Native.LParam(location.X, location.Y));
                    }
                    else
                    {
                        this.OnMouseMove(location.X, location.Y);
                    }
                }
                else
                {
                    this.OnMouseMove(Native.LoWord((int)m.LParam), Native.HiWord((int)m.LParam));
                }
                this.BaseWndProc(ref m);
                break;

            default:
                // Pass everything else to the control and return
                //
                this.DefWndProc(ref m);
                break;
            }
        }
Exemple #48
0
        public void DoOleDragDrop(DragEventArgs de)
        {
            // ASURT 43757: By the time we come here, it means that the user completed the drag-drop and
            // we compute the new location/size of the controls if needed and set the property values.
            // We have to stop freezePainting right here, so that controls can get a chance to validate
            // their new rects.
            //
            freezePainting = false;

            if (selectionHandler == null)
            {
                Debug.Fail("selectionHandler should not be null");
                de.Effect = DragDropEffects.None;
                return;
            }

            // make sure we've actually moved
            if ((localDrag && de.X == dragBase.X && de.Y == dragBase.Y) ||
                de.AllowedEffect == DragDropEffects.None ||
                (!localDrag && !dragOk))
            {
                de.Effect = DragDropEffects.None;
                return;
            }

            bool localMoveOnly = ((int)de.AllowedEffect & AllowLocalMoveOnly) != 0 && localDragInside;

            // if we are dragging inside the local dropsource/target, and and AllowLocalMoveOnly flag is set,
            // we just consider this a normal move.
            //
            bool moveAllowed = (de.AllowedEffect & DragDropEffects.Move) != DragDropEffects.None || localMoveOnly;
            bool copyAllowed = (de.AllowedEffect & DragDropEffects.Copy) != DragDropEffects.None;

            if ((de.Effect & DragDropEffects.Move) != 0 && !moveAllowed)
            {
                // Try copy instead?
                de.Effect = DragDropEffects.Copy;
            }

            // make sure the copy is allowed
            if ((de.Effect & DragDropEffects.Copy) != 0 && !copyAllowed)
            {
                // if copy isn't allowed, don't do anything

                de.Effect = DragDropEffects.None;
                return;
            }

            if (localMoveOnly && (de.Effect & DragDropEffects.Move) != 0)
            {
                de.Effect |= (DragDropEffects)AllowLocalMoveOnly | DragDropEffects.Move;
            }
            else if ((de.Effect & DragDropEffects.Copy) != 0)
            {
                de.Effect = DragDropEffects.Copy;
            }

            if (forceDrawFrames || localDragInside)
            {
                // undraw the drag rect
                localDragOffset = DrawDragFrames(dragComps, localDragOffset, localDragEffect,
                                                 Point.Empty, DragDropEffects.None, forceDrawFrames);
                forceDrawFrames = false;
            }

            Cursor oldCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                if (dragOk || (localDragInside && de.Effect == DragDropEffects.Copy))
                {
                    // add em to this parent.
                    IDesignerHost host      = (IDesignerHost)GetService(typeof(IDesignerHost));
                    IContainer    container = host.RootComponent.Site.Container;

                    object[]    components;
                    IDataObject dataObj        = de.Data;
                    bool        updateLocation = false;

                    if (dataObj is ComponentDataObjectWrapper)
                    {
                        dataObj = ((ComponentDataObjectWrapper)dataObj).InnerData;
                        ComponentDataObject cdo = (ComponentDataObject)dataObj;

                        // if we're moving ot a different container, do a full serialization
                        // to make sure we pick up design time props, etc.
                        //
                        IComponent dragOwner        = GetDragOwnerComponent(de.Data);
                        bool       newContainer     = dragOwner == null || client.Component == null || dragOwner.Site.Container != client.Component.Site.Container;
                        bool       collapseChildren = false;
                        if (de.Effect == DragDropEffects.Copy || newContainer)
                        {
                            // this causes new elements to be created
                            //
                            cdo.Deserialize(serviceProvider, (de.Effect & DragDropEffects.Copy) == 0);
                        }
                        else
                        {
                            collapseChildren = true;
                        }

                        updateLocation = true;
                        components     = cdo.Components;

                        if (collapseChildren)
                        {
                            components = GetTopLevelComponents(components);
                        }
                    }
                    else
                    {
                        object serializationData = dataObj.GetData(DataFormat, true);

                        if (serializationData == null)
                        {
                            Debug.Fail("data object didn't return any data, so how did we allow the drop?");
                            components = Array.Empty <IComponent>();
                        }
                        else
                        {
                            dataObj        = new ComponentDataObject(client, serviceProvider, serializationData);
                            components     = ((ComponentDataObject)dataObj).Components;
                            updateLocation = true;
                        }
                    }

                    // now we need to offset the components locations from the drop mouse
                    // point to the parent, since their current locations are relative
                    // the mouse pointer
                    if (components != null && components.Length > 0)
                    {
                        Debug.Assert(container != null, "Didn't get a container from the site!");
                        string     name;
                        IComponent comp = null;

                        DesignerTransaction trans = null;

                        try
                        {
                            trans = host.CreateTransaction(SR.DragDropDropComponents);
                            if (!localDrag)
                            {
                                host.Activate();
                            }

                            ArrayList selectComps = new ArrayList();

                            for (int i = 0; i < components.Length; i++)
                            {
                                comp = components[i] as IComponent;

                                if (comp == null)
                                {
                                    comp = null;
                                    continue;
                                }

                                try
                                {
                                    name = null;
                                    if (comp.Site != null)
                                    {
                                        name = comp.Site.Name;
                                    }

                                    Control oldDesignerControl = null;
                                    if (updateLocation)
                                    {
                                        oldDesignerControl = client.GetDesignerControl();
                                        User32.SendMessageW(oldDesignerControl.Handle, User32.WM.SETREDRAW);
                                    }

                                    Point dropPt = client.GetDesignerControl().PointToClient(new Point(de.X, de.Y));

                                    // First check if the component we are dropping have a TrayLocation, and if so, use it
                                    PropertyDescriptor loc = TypeDescriptor.GetProperties(comp)["TrayLocation"];
                                    if (loc == null)
                                    {
                                        // it didn't, so let's check for the regular Location
                                        loc = TypeDescriptor.GetProperties(comp)["Location"];
                                    }

                                    if (loc != null && !loc.IsReadOnly)
                                    {
                                        Rectangle bounds = new Rectangle();
                                        Point     pt     = (Point)loc.GetValue(comp);
                                        bounds.X = dropPt.X + pt.X;
                                        bounds.Y = dropPt.Y + pt.Y;
                                        bounds   = selectionHandler.GetUpdatedRect(Rectangle.Empty, bounds, false);
                                    }

                                    if (!client.AddComponent(comp, name, false))
                                    {
                                        // this means that we just moved the control
                                        // around in the same designer.

                                        de.Effect = DragDropEffects.None;
                                    }
                                    else
                                    {
                                        // make sure the component was added to this client
                                        if (client.GetControlForComponent(comp) == null)
                                        {
                                            updateLocation = false;
                                        }
                                    }

                                    if (updateLocation)
                                    {
                                        ParentControlDesigner parentDesigner = client as ParentControlDesigner;
                                        if (parentDesigner != null)
                                        {
                                            Control c = client.GetControlForComponent(comp);
                                            dropPt     = parentDesigner.GetSnappedPoint(c.Location);
                                            c.Location = dropPt;
                                        }
                                    }

                                    if (oldDesignerControl != null)
                                    {
                                        //((ComponentDataObject)dataObj).ShowControls();
                                        User32.SendMessageW(oldDesignerControl.Handle, User32.WM.SETREDRAW, (IntPtr)1);
                                        oldDesignerControl.Invalidate(true);
                                    }

                                    if (TypeDescriptor.GetAttributes(comp).Contains(DesignTimeVisibleAttribute.Yes))
                                    {
                                        selectComps.Add(comp);
                                    }
                                }
                                catch (CheckoutException ceex)
                                {
                                    if (ceex == CheckoutException.Canceled)
                                    {
                                        break;
                                    }

                                    throw;
                                }
                            }

                            if (host != null)
                            {
                                host.Activate();
                            }

                            // select the newly added components
                            ISelectionService selService = (ISelectionService)GetService(typeof(ISelectionService));

                            selService.SetSelectedComponents((object[])selectComps.ToArray(typeof(IComponent)), SelectionTypes.Replace);
                            localDragInside = false;
                        }
                        finally
                        {
                            if (trans != null)
                            {
                                trans.Commit();
                            }
                        }
                    }
                }

                if (localDragInside)
                {
                    ISelectionUIService selectionUISvc = (ISelectionUIService)GetService(typeof(ISelectionUIService));
                    Debug.Assert(selectionUISvc != null, "Unable to get selection ui service when adding child control");

                    if (selectionUISvc != null)
                    {
                        // We must check to ensure that UI service is still in drag mode.  It is
                        // possible that the user hit escape, which will cancel drag mode.
                        //
                        if (selectionUISvc.Dragging && moveAllowed)
                        {
                            Rectangle offset = new Rectangle(de.X - dragBase.X, de.Y - dragBase.Y, 0, 0);
                            selectionUISvc.DragMoved(offset);
                        }
                    }
                }

                dragOk = false;
            }
            finally
            {
                Cursor.Current = oldCursor;
            }
        }
        protected override CommandBase TestCommand(IVBE vbe, RubberduckParserState state, IRewritingManager rewritingManager, ISelectionService selectionService)
        {
            var msgBox = new Mock <IMessageBox>().Object;
            var addImplementationsBaseRefactoring = new AddInterfaceImplementationsRefactoringAction(rewritingManager, new CodeBuilder());
            var baseRefactoring = new ImplementInterfaceRefactoringAction(addImplementationsBaseRefactoring, rewritingManager);
            var refactoring     = new ImplementInterfaceRefactoring(baseRefactoring, state, selectionService);
            var notifier        = new ImplementInterfaceFailedNotifier(msgBox);

            return(new RefactorImplementInterfaceCommand(refactoring, notifier, state, selectionService));
        }
Exemple #50
0
 public CodePaneRefactorRenameCommand(RubberduckParserState state, IMessageBox messageBox, IRefactoringPresenterFactory factory, IRewritingManager rewritingManager, ISelectionService selectionService)
     : base(rewritingManager, selectionService)
 {
     _state      = state;
     _messageBox = messageBox;
     _factory    = factory;
 }
Exemple #51
0
 public TranscodingController(IMessageService messageService, IShellService shellService, IMusicFileContext musicFileContext, ISelectionService selectionService,
                              TranscodingService transcodingService, Lazy <ITranscoder> transcoder, Lazy <TranscodingListViewModel> transcodingListViewModel)
 {
     this.messageService              = messageService;
     this.shellService                = shellService;
     this.musicFileContext            = musicFileContext;
     this.selectionService            = selectionService;
     this.transcodingService          = transcodingService;
     this.transcoder                  = transcoder;
     this.transcodingListViewModel    = transcodingListViewModel;
     this.cancellationTokenSources    = new Dictionary <TranscodeItem, CancellationTokenSource>();
     this.convertToMp3AllCommand      = new DelegateCommand(ConvertToMp3All, CanConvertToMp3All);
     this.convertToMp3SelectedCommand = new DelegateCommand(ConvertToMp3Selected, CanConvertToMp3Selected);
     this.cancelAllCommand            = new DelegateCommand(CancelAll, CanCancelAll);
     this.cancelSelectedCommand       = new DelegateCommand(CancelSelected, CanCancelSelected);
     this.throttler          = new SemaphoreSlim(Environment.ProcessorCount); // Do not dispose the throttler; it is used after Shutdown to cancel the open tasks
     this.transcodingManager = new TranscodingManager();
 }
 private bool SelectCompnentMouseUp_DG(CanvasItem canvasItem, Point point)
 {
     if (canvasItem == null)
     {
         return(false);
     }
     //
     foreach (BaseItem one in canvasItem.BaseItems)
     {
         if (this.SelectCompnentMouseUp(one as RibbonGalleryItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp(one as ButtonGroupItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as BaseItemStackExItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as BaseItemStackItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseUp_DG(one as CanvasItem, point))
         {
             return(true);
         }
         ////
         //if (one.DesignMouseClickRectangleContainsEx(point))
         //{
         //    ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
         //    if (pSelectionService != null)
         //    {
         //        this.m_Item2 = one;
         //        if (canvasItem.BaseItems.ExchangeItem(this.m_Item1, this.m_Item2))
         //        {
         //            pSelectionService.SetSelectedComponents(new Component[] { this.m_Item1 as Component }, SelectionTypes.Primary);
         //            this.m_BaseBar.Refresh();
         //            return true;
         //        }
         //        else
         //        {
         //            pSelectionService.SetSelectedComponents(new Component[] { one as Component }, SelectionTypes.Primary);
         //            this.m_BaseBar.Refresh();
         //            return true;
         //        }
         //    }
         //}
     }
     if (this.m_Item1 != null)
     {
         if (this.m_MouseDownPoint != Point.Empty)
         {
             ISetBaseItemHelper pSetBaseItemHelper = this.m_Item1 as ISetBaseItemHelper;
             if (pSetBaseItemHelper != null)
             {
                 int iX = point.X - this.m_MouseDownPoint.X;
                 int iY = point.Y - this.m_MouseDownPoint.Y;
                 pSetBaseItemHelper.SetLocation(this.m_Item1.Location.X + iX, this.m_Item1.Location.Y + iY);
                 this.Translation_DG(this.m_Item1 as CanvasItem, iX, iY);
                 this.m_MouseDownPoint = Point.Empty;
                 this.m_RibbonPage.Refresh();
             }
         }
         //
         ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
         if (pSelectionService != null)
         {
             pSelectionService.SetSelectedComponents(new Component[] { m_Item1 as Component }, SelectionTypes.Primary);
         }
         //
         this.m_Item1 = null;
         //
         return(true);
     }
     //
     return(false);
 }
        /// <summary>
        /// In response to a MouseDown, the SelectionBehavior will push (initiate) a dragBehavior by alerting the SelectionMananger that a new control has been selected and the mouse is down. Note that this is only if we find the related control's Dock property == none.
        /// </summary>
        public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc)
        {
            //we only care about the right mouse button for resizing
            if (button != MouseButtons.Left)
            {
                //pass any other mouse click along - unless we've already started our resize in which case we'll ignore it
                return(_pushedBehavior);
            }
            //start with no selection rules and try to obtain this info from the glyph
            _targetResizeRules = SelectionRules.None;
            if (g is SelectionGlyphBase sgb)
            {
                _targetResizeRules = sgb.SelectionRules;
                _cursor            = sgb.HitTestCursor;
            }

            if (_targetResizeRules == SelectionRules.None)
            {
                return(false);
            }

            ISelectionService selSvc = (ISelectionService)_serviceProvider.GetService(typeof(ISelectionService));

            if (selSvc == null)
            {
                return(false);
            }

            _initialPoint = mouseLoc;
            _lastMouseLoc = mouseLoc;
            //build up a list of our selected controls
            _primaryControl = selSvc.PrimarySelection as Control;

            // Since we don't know exactly how many valid objects we are going to have we use this temp
            ArrayList components = new ArrayList();

            foreach (object o in selSvc.GetSelectedComponents())
            {
                if (o is Control)
                {
                    //don't drag locked controls
                    PropertyDescriptor prop = TypeDescriptor.GetProperties(o)["Locked"];
                    if (prop != null)
                    {
                        if ((bool)prop.GetValue(o))
                        {
                            continue;
                        }
                    }
                    components.Add(o);
                }
            }

            if (components.Count == 0)
            {
                return(false);
            }

            _resizeComponents = new ResizeComponent[components.Count];
            for (int i = 0; i < components.Count; i++)
            {
                _resizeComponents[i].resizeControl = components[i];
            }

            //push this resizebehavior
            _pushedBehavior = true;
            BehaviorService.PushCaptureBehavior(this);
            return(false);
        }
        private PageEditorViewModel OpenSwipePage(IWidget widget, Guid childPageGID, Guid SelWdgGID, bool bIsSelect, bool bIsGroup)
        {
            PageEditorViewModel newPage           = null;
            ISelectionService   _selectionService = ServiceLocator.Current.GetInstance <SelectionServiceProvider>();
            IPagePropertyData   activePage        = _selectionService.GetCurrentPage();

            Guid parentGID = widget.ParentPage.Guid;

            if (widget.WidgetType != WidgetType.DynamicPanel)
            {
                return(null);
            }


            //Active an exist page editor,20140220
            DynamicPageEditorViewModel CurrentDynmicPanel = null;

            foreach (var pageItem in EditPages.OfType <DynamicPageEditorViewModel>())
            {
                if (pageItem.ContentId == widget.Guid.ToString())
                {
                    CurrentDynmicPanel = pageItem;
                    if (pageItem.ActivePage.Guid == childPageGID)
                    {
                        pageItem.IsActive = true;
                        return(pageItem);
                    }
                    break;
                }
            }

            //Only Update the target panel
            if (CurrentDynmicPanel != null)
            {
                //TODO:???????
                CurrentDynmicPanel.IsActive = true;
                foreach (DynamicChildNodViewModel item in CurrentDynmicPanel.DynamicChildren)
                {
                    if (item.GID == childPageGID)
                    {
                        CurrentDynmicPanel.WdgMgrSetTargeComponent(SelWdgGID, bIsSelect, bIsGroup);
                        item.IsChecked = true;
                        break;
                    }
                }
                return(null);
            }

            DeselectAllPages();

            //Create a new page with target panel
            newPage = new DynamicPageEditorViewModel(widget, childPageGID);
            newPage.WdgMgrSetTargeComponent(SelWdgGID, bIsSelect, bIsGroup);

            //if child page is not set(value is 100%)
            //Set scale the same as parent page(only create child page, not active child page)
            if (newPage.EditorScale == 1)
            {
                newPage.EditorScale = activePage.EditorScale;
            }
            newPage.Open();
            EditPages.Add(newPage);
            newPage.IsActive = true;
            newPage.Update();
            return(null);
        }
Exemple #55
0
        protected override void OnPaintAdornments(PaintEventArgs pe)
        {
            base.OnPaintAdornments(pe);

            using (Pen p = new Pen(Color.Black))
            {
                p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                ISelectionService host = GetService(typeof(ISelectionService)) as ISelectionService;

                if (host != null)
                {
                    foreach (IComponent comp in host.GetSelectedComponents())
                    {
                        if (comp is RibbonContext)
                        {
                            RibbonContext item = comp as RibbonContext;
                            if (item != null)
                            {
                                Rectangle selection = (item.ContextualTabsCount > 0) ? item.HeaderBounds : item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonTab)
                        {
                            RibbonTab item = comp as RibbonTab;
                            if (item != null)
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonPanel)
                        {
                            RibbonPanel item = comp as RibbonPanel;
                            if (item != null)
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(-1, -1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                        else if (comp is RibbonItem)
                        {
                            RibbonItem item = comp as RibbonItem;
                            if (item != null && !Ribbon.OrbDropDown.AllItems.Contains(item))
                            {
                                Rectangle selection = item.Bounds;
                                selection.Inflate(1, 1);

                                pe.Graphics.DrawRectangle(p, selection);
                            }
                        }
                    }
                }
            }
        }
Exemple #56
0
 public MoveFieldCloserToUsageQuickFix(RubberduckParserState state, IMessageBox messageBox, IRewritingManager rewritingManager, ISelectionService selectionService)
     : base(typeof(MoveFieldCloserToUsageInspection))
 {
     _selectionService = selectionService;
     _state            = state;
     _rewritingManager = rewritingManager;
     _messageBox       = messageBox;
 }
        void LoadDesigner()
        {
            LoggingService.Info("Form Designer: BEGIN INITIALIZE");

            DefaultServiceContainer serviceContainer = new DefaultServiceContainer();

            serviceContainer.AddService(typeof(System.Windows.Forms.Design.IUIService), new UIService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IToolboxService), ToolboxProvider.ToolboxService);

            serviceContainer.AddService(typeof(IHelpService), new HelpService());
            serviceContainer.AddService(typeof(System.Drawing.Design.IPropertyValueUIService), new PropertyValueUIService());

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IResourceService), new DesignerResourceService(this.resourceStore));
            AmbientProperties ambientProperties = new AmbientProperties();

            serviceContainer.AddService(typeof(AmbientProperties), ambientProperties);
            this.typeResolutionService = new TypeResolutionService(this.PrimaryFileName);
            serviceContainer.AddService(typeof(ITypeResolutionService), this.typeResolutionService);
            serviceContainer.AddService(typeof(DesignerOptionService), new SharpDevelopDesignerOptionService());
            serviceContainer.AddService(typeof(ITypeDiscoveryService), new TypeDiscoveryService());
            serviceContainer.AddService(typeof(MemberRelationshipService), new DefaultMemberRelationshipService());
            serviceContainer.AddService(typeof(ProjectResourceService), CreateProjectResourceService());

            // Provide the ImageResourceEditor for all Image and Icon properties
            this.addedTypeDescriptionProviders.Add(typeof(Image), TypeDescriptor.AddAttributes(typeof(Image), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));
            this.addedTypeDescriptionProviders.Add(typeof(Icon), TypeDescriptor.AddAttributes(typeof(Icon), new EditorAttribute(typeof(ImageResourceEditor), typeof(System.Drawing.Design.UITypeEditor))));

            if (generator.CodeDomProvider != null)
            {
                serviceContainer.AddService(typeof(System.CodeDom.Compiler.CodeDomProvider), generator.CodeDomProvider);
            }

            designSurface            = CreateDesignSurface(serviceContainer);
            designSurface.Loading   += this.DesignerLoading;
            designSurface.Loaded    += this.DesignerLoaded;
            designSurface.Flushed   += this.DesignerFlushed;
            designSurface.Unloading += this.DesignerUnloading;

            serviceContainer.AddService(typeof(System.ComponentModel.Design.IMenuCommandService), new ICSharpCode.FormsDesigner.Services.MenuCommandService(this, designSurface));
            ICSharpCode.FormsDesigner.Services.EventBindingService eventBindingService = new ICSharpCode.FormsDesigner.Services.EventBindingService(this, designSurface);
            serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), eventBindingService);

            this.loader = loaderProvider.CreateLoader(generator);
            designSurface.BeginLoad(this.loader);

            if (!designSurface.IsLoaded)
            {
                throw new FormsDesignerLoadException(FormatLoadErrors(designSurface));
            }

            undoEngine = new FormsDesignerUndoEngine(Host);
            serviceContainer.AddService(typeof(UndoEngine), undoEngine);

            IComponentChangeService componentChangeService = (IComponentChangeService)designSurface.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentChanged += ComponentChanged;
            componentChangeService.ComponentAdded   += ComponentListChanged;
            componentChangeService.ComponentRemoved += ComponentListChanged;
            componentChangeService.ComponentRename  += ComponentListChanged;
            this.Host.TransactionClosed             += TransactionClose;

            ISelectionService selectionService = (ISelectionService)designSurface.GetService(typeof(ISelectionService));

            selectionService.SelectionChanged += SelectionChangedHandler;

            if (IsTabOrderMode)               // fixes SD2-1015
            {
                tabOrderMode = false;         // let ShowTabOrder call the designer command again
                ShowTabOrder();
            }

            UpdatePropertyPad();

            hasUnmergedChanges = false;

            LoggingService.Info("Form Designer: END INITIALIZE");
        }
 private bool SelectCompnentMouseDown_DG(BaseItemStackExItem ribbonBaseItemStackExItem, Point point)
 {
     if (ribbonBaseItemStackExItem == null)
     {
         return(false);
     }
     //
     foreach (BaseItem one in ribbonBaseItemStackExItem.BaseItems)
     {
         if (this.SelectCompnentMouseDown(one as RibbonGalleryItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseDown(one as ButtonGroupItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseDown_DG(one as BaseItemStackExItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseDown_DG(one as BaseItemStackItem, point))
         {
             return(true);
         }
         if (this.SelectCompnentMouseDown_DG(one as CanvasItem, point))
         {
             return(true);
         }
         //
         if (one.DesignMouseClickRectangleContainsEx(point))
         {
             ISelectionService pSelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
             if (pSelectionService != null)
             {
                 this.m_Item1 = one;
                 pSelectionService.SetSelectedComponents(new Component[] { one as Component }, SelectionTypes.Primary);
                 this.m_RibbonPage.Refresh();
                 return(true);
             }
         }
     }
     //
     //switch (ribbonBaseItemStackExItem.eOrientation)
     //{
     //    case Orientation.Horizontal:
     //        if (ribbonBaseItemStackExItem.LeftButtonVisible &&
     //            ribbonBaseItemStackExItem.LeftButtonRectangle.Contains(point)) ribbonBaseItemStackExItem.TopViewItemIndex++;
     //        if (ribbonBaseItemStackExItem.RightButtonVisible &&
     //            ribbonBaseItemStackExItem.RightButtonRectangle.Contains(point)) ribbonBaseItemStackExItem.TopViewItemIndex--;
     //        break;
     //    case Orientation.Vertical:
     //        if (ribbonBaseItemStackExItem.TopButtonVisible &&
     //            ribbonBaseItemStackExItem.TopButtonRectangle.Contains(point)) ribbonBaseItemStackExItem.TopViewItemIndex++;
     //        if (ribbonBaseItemStackExItem.BottomButtonVisible &&
     //            ribbonBaseItemStackExItem.BottomButtonRectangle.Contains(point)) ribbonBaseItemStackExItem.TopViewItemIndex--;
     //        break;
     //}
     if (ribbonBaseItemStackExItem.PreButtonVisible &&
         ribbonBaseItemStackExItem.PreButtonRectangle.Contains(point))
     {
         if (ribbonBaseItemStackExItem.PreButtonIncreaseIndex)
         {
             ribbonBaseItemStackExItem.TopViewItemIndex++;
         }
         else
         {
             ribbonBaseItemStackExItem.TopViewItemIndex--;
         }
     }
     if (ribbonBaseItemStackExItem.NextButtonVisible &&
         ribbonBaseItemStackExItem.NextButtonRectangle.Contains(point))
     {
         if (ribbonBaseItemStackExItem.PreButtonIncreaseIndex)
         {
             ribbonBaseItemStackExItem.TopViewItemIndex--;
         }
         else
         {
             ribbonBaseItemStackExItem.TopViewItemIndex++;
         }
     }
     //
     return(false);
 }
Exemple #59
0
        /// <summary>
        /// 粘贴
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Paste(object sender, EventArgs args)
        {
            IDesignerSerializationService serialService = this.GetService(typeof(IDesignerSerializationService)) as IDesignerSerializationService;
            IDesignerHost           host          = GetService(typeof(IDesignerHost)) as IDesignerHost;
            ISelectionService       selection     = GetService(typeof(ISelectionService)) as ISelectionService;
            IComponentChangeService changeService = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            if (host == null || serialService == null || clipboardData == null)
            {
                return;
            }

            //从获取上次剪切/复制的数据并反序列化
            ICollection components = serialService.Deserialize(clipboardData);

            //如果当前选中的控件是容器控件则添加到容器中
            //否则添加到根设计器中
            if (components != null && components.Count > 0)
            {
                DesignerTransaction transaction = host.CreateTransaction("Paste");

                foreach (Component item in components)
                {
                    Control control = item as Control;
                    if (control == null)
                    {
                        continue;
                    }

                    //if (control is IDBColProperty)
                    //{
                    //    (control as IDBColProperty).DBColName = string.Empty;
                    //}

                    PropertyDescriptor parentProperty = TypeDescriptor.GetProperties(control)["Parent"];

                    //获取粘贴到的父容器
                    ParentControlDesigner parentDesigner = null;
                    if (selection != null && selection.PrimarySelection != null)
                    {
                        parentDesigner = host.GetDesigner((IComponent)selection.PrimarySelection) as ParentControlDesigner;
                    }

                    if (parentDesigner == null)
                    {
                        parentDesigner = host.GetDesigner(host.RootComponent) as DocumentDesigner;
                    }

                    if (parentDesigner != null && parentDesigner.CanParent(control))
                    {
                        //粘贴时粘贴到父容器中间
                        //control.Location = new Point(parentDesigner.Control.Width / 2 - control.Width / 2, parentDesigner.Control.Height / 2 - control.Height / 2);
                        parentProperty.SetValue(control, parentDesigner.Control);
                    }
                }

                clipboardData = null;
                transaction.Commit();
                ((IDisposable)transaction).Dispose();

                selection.SetSelectedComponents(components);
                this.GlobalInvoke(StandardCommands.BringToFront);
            }
        }
        void UnloadDesigner()
        {
            LoggingService.Debug("FormsDesigner unloading, setting ActiveDesignSurface to null");
            designSurfaceManager.ActiveDesignSurface = null;

            bool savedIsDirty = (this.DesignerCodeFile == null) ? false : this.DesignerCodeFile.IsDirty;

            this.UserContent = this.pleaseWaitLabel;
            if (this.DesignerCodeFile != null)
            {
                this.DesignerCodeFile.IsDirty = savedIsDirty;
            }

            if (designSurface != null)
            {
                designSurface.Loading   -= this.DesignerLoading;
                designSurface.Loaded    -= this.DesignerLoaded;
                designSurface.Flushed   -= this.DesignerFlushed;
                designSurface.Unloading -= this.DesignerUnloading;

                IComponentChangeService componentChangeService = designSurface.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                if (componentChangeService != null)
                {
                    componentChangeService.ComponentChanged -= ComponentChanged;
                    componentChangeService.ComponentAdded   -= ComponentListChanged;
                    componentChangeService.ComponentRemoved -= ComponentListChanged;
                    componentChangeService.ComponentRename  -= ComponentListChanged;
                }
                if (this.Host != null)
                {
                    this.Host.TransactionClosed -= TransactionClose;
                }

                ISelectionService selectionService = designSurface.GetService(typeof(ISelectionService)) as ISelectionService;
                if (selectionService != null)
                {
                    selectionService.SelectionChanged -= SelectionChangedHandler;
                }

                designSurface.Unloaded += delegate {
                    ServiceContainer serviceContainer = designSurface.GetService(typeof(ServiceContainer)) as ServiceContainer;
                    if (serviceContainer != null)
                    {
                        // Workaround for .NET bug: .NET unregisters the designer host only if no component throws an exception,
                        // but then in a finally block assumes that the designer host is already unloaded.
                        // Thus we would get the confusing "InvalidOperationException: The container cannot be disposed at design time"
                        // when any component throws an exception.

                        // See http://community.sharpdevelop.net/forums/p/10928/35288.aspx
                        // Reproducible with a custom control that has a designer that crashes on unloading
                        // e.g. http://www.codeproject.com/KB/toolbars/WinFormsRibbon.aspx

                        // We work around this problem by unregistering the designer host manually.
                        try {
                            var services = (Dictionary <Type, object>) typeof(ServiceContainer).InvokeMember(
                                "Services",
                                BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.NonPublic,
                                null, serviceContainer, null);
                            foreach (var pair in services.ToArray())
                            {
                                if (pair.Value is IDesignerHost)
                                {
                                    serviceContainer.GetType().InvokeMember(
                                        "RemoveFixedService",
                                        BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
                                        null, serviceContainer, new object[] { pair.Key });
                                }
                            }
                        } catch (Exception ex) {
                            LoggingService.Error(ex);
                        }
                    }
                };
                try {
                    designSurface.Dispose();
                } catch (ExceptionCollection exceptions) {
                    foreach (Exception ex in exceptions.Exceptions)
                    {
                        LoggingService.Error(ex);
                    }
                } finally {
                    designSurface = null;
                }
            }

            this.typeResolutionService = null;
            this.loader = null;

            foreach (KeyValuePair <Type, TypeDescriptionProvider> entry in this.addedTypeDescriptionProviders)
            {
                TypeDescriptor.RemoveProvider(entry.Value, entry.Key);
            }
            this.addedTypeDescriptionProviders.Clear();
        }