Exemple #1
0
        void dockingManager1_ActiveDocumentChanged(object sender, EventArgs e)
        {
            if (dockingManager1.ActiveDocument != null)
            {
                prev    = current;
                current = dockingManager1.ActiveDocument;
            }
            QueryDocument query = dockingManager1.ActiveDocument as QueryDocument;

            if (query != null)
            {
                btnExecute.IsEnabled  = true;
                menuExecute.IsEnabled = true;
                btnSave.IsEnabled     = true;
                menuSave.IsEnabled    = true;
                menuSaveAs.IsEnabled  = true;
            }
            else
            {
                btnExecute.IsEnabled  = false;
                menuExecute.IsEnabled = false;
                btnSave.IsEnabled     = false;
                menuSave.IsEnabled    = false;
                menuSaveAs.IsEnabled  = false;
            }
        }
Exemple #2
0
 public static T add_WinForms_Control <T>(this ManagedContent managedContent)
     where T : Control
 {
     try
     {
         var panel = managedContent.add_WinForms_Panel();
         panel.width(400)                                // give the panel a decent size to that it doesn't cause problems during the new T Control dynamic Gui creation
         .height(400);
         "[add_WinForms_Control] new control size -  width: {0} height:{0}".info(panel.width(), panel.height());
         Application.DoEvents();
         var newControl = panel.add_Control <T>();
         if (newControl.isNull())
         {
             "[add_WinForms_Control] failed the creation of control : {0}...".error(typeof(T));
         }
         else
         {
             "[add_WinForms_Control] created ok control : {0}...".info(typeof(T));
             return(newControl);
         }
     }
     catch (Exception ex)
     {
         ex.log();
         "[add_WinForms_Control] error creating control of type: {0}...".error(typeof(T));
     }
     return(null);
 }
            /// <summary>
            ///   Initializes a new instance of the <see cref = "ManagedContentConductor" /> class.
            /// </summary>
            /// <param name = "viewModel">The view model.</param>
            /// <param name = "view">The view.</param>
            public ManagedContentConductor(object viewModel, ManagedContent view)
            {
                _viewModel = viewModel;
                _view      = view;

                var activatable = viewModel as IActivate;

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

                var deactivatable = viewModel as IDeactivate;

                if (deactivatable != null)
                {
                    view.Closed += OnClosed;
                    deactivatable.Deactivated += OnDeactivated;
                }

                var guard = viewModel as IGuardClose;

                if (guard != null)
                {
                    view.Closing += OnClosing;
                }
            }
 private static void setManagedContentProperties(ILayoutItem layoutItem, ManagedContent content)
 {
     content.Content = layoutItem;
     content.Title   = layoutItem.Title;
     content.Name    = layoutItem.Name;
     content.Icon    = layoutItem.Icon;
 }
Exemple #5
0
        /// <summary>
        /// Event raised when the ActiveDocument or ActivePane property has changed.
        /// </summary>
        private static void ActiveDocumentOrPane_PropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var            c = (AvalonDockHost)d;
            ManagedContent managedContent = null;

            if (e.NewValue != null &&
                c.contentMap.TryGetValue(e.NewValue, out managedContent))
            {
                managedContent.Activate();
            }
        }
Exemple #6
0
        private void ImportLayoutFromDocument(object sender, RoutedEventArgs e)
        {
            ManagedContent managedContentDocument = DockManager.ActiveDocument as ManagedContent;

            if (DockManager.ActiveDocument != null && managedContentDocument != null &&
                managedContentDocument.Content is TextBox)
            {
                string xml_layout = (managedContentDocument.Content as TextBox).Text;
                DockManager.LayoutFromString(xml_layout);
            }
        }
Exemple #7
0
        public static void BringDocumentHeaderToView(this ManagedContent document)
        {
            if (!DocumentTabPanel.GetIsHeaderVisible(document))
            {
                DocumentPane parentPane = document.ContainerPane as DocumentPane;
                if (parentPane != null)
                {
                    parentPane.Items.Remove(document);
                    parentPane.Items.Insert(0, document);
                    document.Activate();
                }
            }

            ////document.IsSelected = true;
            ////Selector.SetIsSelected(document, true);
            //if (this.GetManager() != null)
            //    this.GetManager().ActiveContent = document;
            //document.SetAsActive();
        }
Exemple #8
0
 internal static void SetFocus(ManagedContent m, Func <IInputElement> activeChildFunc, bool forceSetFocus = false)
 {
     m.Dispatcher.BeginInvoke(
         DispatcherPriority.Background,
         new Action(
             delegate {
         // ensure that condition for FocusContent() is still fulfilled
         // (necessary to avoid focus switching loops when changing layouts)
         if (!forceSetFocus && !(m.IsActiveContent && !m.IsKeyboardFocusWithin))
         {
             WpfWorkbench.FocusDebug("{0} - not moving focus (IsActiveContent={1}, IsKeyboardFocusWithin={2})",
                                     m.Title, m.IsActiveContent, m.IsKeyboardFocusWithin);
             return;
         }
         IInputElement activeChild = activeChildFunc();
         WpfWorkbench.FocusDebug("{0} - moving focus to: {1}", m.Title, activeChild != null ? activeChild.ToString() : "<null>");
         if (activeChild != null)
         {
             Keyboard.Focus(activeChild);
         }
     }));
 }
Exemple #9
0
        /// <summary>
        /// Remove a panel from Avalondock.
        /// </summary>
        private void RemovePanel(object panel)
        {
            //
            // Look up the document in the content map.
            //
            ManagedContent managedContent = null;

            if (contentMap.TryGetValue(panel, out managedContent))
            {
                disableClosingEvent = true;

                try
                {
                    //
                    // The content was still in the map, and therefore still open, so close it.
                    //
                    managedContent.Close();
                }
                finally
                {
                    disableClosingEvent = false;
                }
            }
        }
Exemple #10
0
 public static bool IsActiveInItsGroup(this ManagedContent managedContent)
 {
     return(managedContent.ContainerPane.SelectedItem == managedContent);
 }
        InstallBasTextEditor AddEditor(string InstallBasAction)
        {
            ManagedContent mc = null;

            if (DockMan.ActiveContent == null)
            {
                mc = DockMan.DockableContents.First();
            }
            else
            {
                mc = DockMan.ActiveContent;
            }

            DockablePane cPane = mc.ContainerPane as DockablePane;

            string dc_Name = "editor_" + (VM.Editors.Count + 1).ToString();

            DockableContent dc_prev = null;

            foreach (var item in cPane.Items)
            {
                dc_prev = item as DockableContent;
                if (dc_prev.Name.Equals(dc_Name))
                {
                    break;
                }
                else
                {
                    dc_prev = null;
                }
            }
            if (dc_prev != null)
            {
                dc_Name += "_" + cPane.Items.Count.ToString();
            }


            DockableContent dc = new DockableContent();

            dc.Name  = dc_Name;
            dc.Title = dc_Name;
            cPane.Items.Add(dc);


            InstallBasTextEditor bas = new InstallBasTextEditor();

            bas.VM.SyntaxHighlighting = "VBNET";
            bas.VM.Font            = "Consolas";
            bas.VM.FontSize        = 12;
            bas.VM.CurrentFileName = dc_Name;
            if (!String.IsNullOrEmpty(InstallBasAction))
            {
                if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_INSTALL))
                {
                    bas.VM.InstallBas();
                }
                else if (InstallBasAction.Equals(MainWindowViewModel.TOOLBAR_ADD_BAS_ADD_REMOVE))
                {
                    bas.VM.RemoveBas();
                }
            }

            dc.Content = bas;

            dc.Closing += delegate(object sender, CancelEventArgs e)
            {
                this.VM.ActiveEditor.IsActive = false;
                this.VM.Editors.Remove(bas.VM);
            };
            dc.Activate();

            this.VM.Editors.Add(bas.VM);
            bas.VM.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName.Equals("CurrentFileName"))
                {
                    dc.Title = Path.GetFileName(bas.VM.CurrentFileName);
                }
            };
            return(bas);
        }