public MainWindow()
        {
            InitializeComponent();
            var ds = new DataSource();
            if (ds != null)
            {
                LayoutPanel panel = new LayoutPanel() { Caption = "Live Report", AllowClose = false };
                AccountDataSheet sheet = new AccountDataSheet() { DataContext = ds };
                panel.Content = sheet;
                documents.Add(panel);
                panel.IsActive = true;
            }

             var bds = new BenchMarkDataSource();

             if (bds != null)
             {
                 LayoutPanel panel = new LayoutPanel() { Caption = "BenchMark Report", AllowClose = false };

                 BenchMarkDataSheet sheet = new BenchMarkDataSheet() { DataContext = bds };
                 panel.Content = sheet;
                 documents.Add(panel);

                 panel = new LayoutPanel() { Caption = "Report", AllowClose = false };
                     NewReportDataSheet Nsheet = new NewReportDataSheet() { DataContext = bds };
                     panel.Content = Nsheet;
                     documents.Add(panel);

                 panel.IsActive = true;
             }
        }
 public ScriptsControlTree(LayoutPanel layoutpane,ProjectManager projectmanager )
 {
     m_layoutpane = layoutpane;
     m_projectManager = projectmanager;
     contextmenu = CreateContextMenu();
     InitializeComponent();
     //LoadTree();
 }
Exemple #3
0
 public LayoutRoot()
 { 
     RightSide = new LayoutAnchorSide();
     LeftSide = new LayoutAnchorSide();
     TopSide = new LayoutAnchorSide();
     BottomSide = new LayoutAnchorSide();
     RootPanel = new LayoutPanel(new LayoutDocumentPane());
 }
        public ChildViewBase()
        {
            SetValue(DocumentsPropertyKey, new FreezableCollection<BaseLayoutItem>());

              // Если понадобится зависимый Ribbon для DocumentPanel, то он будет объединяться.
              MDIMergeStyle = MDIMergeStyle.Always;

              LayoutGroup layoutGroup = new LayoutGroup();
              layoutGroup.Orientation = Orientation.Horizontal;
              LayoutRoot = layoutGroup;

              documentGroup = DockController.AddDocumentGroup(DockType.None);
              DockController.Dock(documentGroup, layoutGroup, DockType.Fill);
              documentGroup.ItemWidth = new GridLength(70, GridUnitType.Star);
              // При изменении активного элемента, изменим зависимое свойство.
              documentGroup.SelectedItemChanged += (s, e) =>
              {
            SelectedDocumentIndex = documentGroup.Items.IndexOf(documentGroup.SelectedItem);
              };

              propLayoutPanel = DockController.AddPanel(DockType.None);
              DockController.Dock(propLayoutPanel, layoutGroup, DockType.Right);
              propLayoutPanel.Caption = "Свойства";
              propLayoutPanel.AllowDrag = false;
              propLayoutPanel.AllowClose = false;
              propLayoutPanel.ItemWidth = new GridLength(30, GridUnitType.Star);

              AutoHideGroup autoHideGroup = new AutoHideGroup();
              autoHideGroup.DockType = Dock.Bottom;
              AutoHideGroups.Add(autoHideGroup);

              LayoutPanel outLayoutPanel = new LayoutPanel();
              outLayoutPanel.Caption = "Вывод";
              outLayoutPanel.AllowDrag = false;
              outLayoutPanel.AllowClose = false;
              autoHideGroup.Add(outLayoutPanel);

              // Элемент для вывода информации о построении.
              txtMessages = new RichTextBox();
              txtMessages.IsReadOnly = true;
              txtMessages.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
              // Уберем отступы между параграфами.
              Style noSpaceStyle = new Style(typeof(Paragraph));
              noSpaceStyle.Setters.Add(new Setter(Paragraph.MarginProperty, new Thickness(0)));
              txtMessages.Resources.Add(typeof(Paragraph), noSpaceStyle);
              // При изменении содержимого активируем панель и будем прокручивать текст вниз.
              txtMessages.TextChanged += (s, e) =>
              {
            Activate(outLayoutPanel);
            (s as RichTextBox).ScrollToEnd();
              };
              outLayoutPanel.Content = txtMessages;

              synchronizationContext = SynchronizationContext.Current;
              managedThreadId = Thread.CurrentThread.ManagedThreadId;
        }
 public HeaderBar(LayoutPanel layout, LayoutInterface notes)
 {
     if (null == layout || null == notes) {
         throw new Exception("Must pass in a valid layout");
     }
     Layout = layout;
     Notes = notes;
     HeaderToolbar();
     UpdateHeader ();
 }
        public void SaveNotequired()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout ("testguid", true, null);
            NoteDataXML_RichText note = new NoteDataXML_RichText ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                //note.UpdateLocation();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            // cannot actually save becaue LayoutPanel is just fake for this test
            // but we check that the flag was set correclty -- i..e, nothing improtant changes, nothing needs tob e saved
            //	layout.SaveTo();
            //layoutPanel.SaveLayout();

            // April 2013 - This test was flagged as Assert.False but I don't understand
            // We WANT the flag to say we need a save, no?
            Assert.True (layoutPanel.GetSaveRequired);
        }
        public void SaveAndLoadStressLoad()
        {
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            int linktable = 1;
            int extranodeadded = 1;
            _w.output("this is a slow test. 6 minutes?");
            int count = 200;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            form.Controls.Add (layoutPanel);
            form.Show ();

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            //_w.output(String.Format ("{0} Notes in Layout before save", layout.GetNotes().Count.ToString()));
            layoutPanel.SaveLayout();

            //_w.output(String.Format ("{0} Objects Saved", layout.ObjectsSaved().ToString()));
            //layoutPanel = new FakeLayoutDatabase ("testguid");
             layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layoutPanel.LoadFrom(layoutPanel);

            //_w.output(String.Format ("{0} Objects Loaded", layout.GetNotes().Count));
            //NOT DONE YET
            Assert.AreEqual (count + linktable + extranodeadded, layoutPanel.GetAllNotes().Count);
        }
        public void SaveAndLoadTest_Works()
        {
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            int linktable = 1;
            int extranodeadded = 1;
            int count = 25;
            ///FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            //layout.LoadFrom(layoutPanel);
            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {
                note.Caption = "boo" + i.ToString();
                layoutPanel.AddNote (note);
            }

            layoutPanel.SaveLayout();
            _w.output("save worked");
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel = new LayoutPanel(CoreUtilities.Constants.BLANK, false);
            layoutPanel.LoadLayout("testguid", false, null);
            //layout.LoadFrom(layoutPanel);

            //	_w.output (layout.Backup ());
            //_w.output(layout.GetNotes().Count.ToString());
            Assert.AreEqual(count+linktable +extranodeadded, layoutPanel.GetAllNotes().Count);
        }
        public void LayoutShouldNotExist()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            //	layout.SaveTo(); no save, so note should not exist

            Assert.False (MasterOfLayouts.ExistsByGUID("testguid"));
        }
        public void NoCrashIfSaveEmptyPanel()
        {
            _setupforlayoutests ();

            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataXML_Panel note = new NoteDataXML_Panel ();
            layoutPanel.AddNote (note);
            note.CreateParent(layoutPanel);
            layoutPanel.SaveLayout();

            _w.output("This often fails if we have added a new Layout Variable and it has not been set to a default value in constructor");
        }
        /*// I made the decision to suppress Errors (hence not required CreateParent, for the purpose of MOVING notes
        // This violated an earlier decision I had made and I had to disable the TryToSaveWithoutCreating a Parent Exception
        [Test]
        [ExpectedException]
        public void TryToSaveWithoutCreatingAParent()
        {
            Type TypeToTest = typeof(NoteDataXML_RichText);
            // 1. write data to notes
            _setupforlayoutests ();
            int count = 25;
            FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel ();

            NoteDataInterface note = null;
            for (int i = 0; i < count; i++) {
                note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);//new NoteDataXML ();
            //	note.CreateParent(layoutPanel);
                note.Caption = "boo" + i.ToString ();
                layout.Add (note);
            }

            note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
            note.Caption = "snake";
            string guid = note.GuidForNote;
            //note.CreateParent(layoutPanel);
            _w.output("new guid" + guid);
            layout.Add (note);
            layout.SaveTo ();
            _w.output ("save worked");
        }*/
        /// <summary>
        /// Creates the lots of notes to test different types and return proper caption.
        /// 
        /// Testing NOTE: You must CreateParent when building items. Else the save cannot work.
        /// 
        /// </summary>
        /// <returns>
        /// The lots of notes to test different types and return proper caption.
        /// </returns>
        /// <param name='TestCaption'>
        /// Test caption.
        /// </param>
        /// <param name='TypeToTest'>
        /// Type to test.
        /// </param>
        private string CreateLotsOfNotesToTestDifferentTypesAndReturnProperCaption(string TestCaption, Type TypeToTest)
        {
            // 1. write data to notes
            //System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _TestSingleTon.Instance._SetupForLayoutPanelTests();

            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);

            NoteDataInterface note = null;
            for (int i = 0; i < count; i++) {
                note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);//new NoteDataXML ();

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }

            note = (NoteDataInterface)Activator.CreateInstance(TypeToTest);
            note.Caption = TestCaption;
            string guid = note.GuidForNote;
            note.CreateParent(layoutPanel);
            _w.output("new guid" + guid);
            layoutPanel.AddNote (note);
            layoutPanel.SaveLayout ();
            _w.output ("save worked");

            // 2. Now we pretend that later one, elsewhere in code, we need to get access to this (i.e., a Random Table)
            layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            //layout = new FakeLayoutDatabase ("testguid");
            layoutPanel.LoadLayout("testguid",false, null);

            //layoutPanel.LoadLayout( (null);
            //	_w.output (layout.Backup ());
            //_w.output(layoutPanel.GetNotes().Count.ToString());
            foreach (NoteDataXML _note in layoutPanel.GetAllNotes()) {

                if( _note.GuidForNote == guid)
                {
                    _w.output(_note.Caption);
                    return note.Caption;
                }

            }
            return "<error>";
        }
Exemple #12
0
        private void AddLayoutDocument(LayoutDocument layoutDocument)
        {
            var existingLayoutDocumentPane = dockingManager.Layout.RootPanel.Children.FirstOrDefault(x => x.GetType() == typeof (LayoutDocumentPane));

            if (existingLayoutDocumentPane != null)
            {
                 dockingManager.Layout.RootPanel.Children.Remove(existingLayoutDocumentPane);
            }

            var layoutPanel = dockingManager.Layout.RootPanel.Descendents().OfType<LayoutPanel>().FirstOrDefault();

            if (layoutPanel == null)
            {
                layoutPanel = new LayoutPanel(new LayoutDocumentPane());
                dockingManager.Layout.RootPanel.Children.Add(layoutPanel);
            }

            var layoutDocumentPane = layoutPanel.Descendents().OfType<LayoutDocumentPane>().FirstOrDefault();

            if (layoutDocumentPane == null)
            {
                layoutDocumentPane = new LayoutDocumentPane();
                layoutPanel.Children.Add(layoutDocumentPane);
            }

            var correspondingTab = GetDocumentById(layoutDocument.ContentId);
            if (correspondingTab != null)
            {
                correspondingTab.IsActive = true;
                correspondingTab.IsSelected = true;
            }
            else
            {
                layoutDocumentPane.Children.Add(layoutDocument);
                layoutDocument.IsSelected = true;
                layoutDocument.IsActive = true;
                layoutDocument.IsActiveChanged += DocumentIsActiveChanged;
            }
        }
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane     targetModel = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocumentPaneGroup parentGroup;
            LayoutPanel             parentGroupPanel;

            FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel);

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockAsAnchorableBottom:
                #region DropTargetType.DocumentPaneDockAsAnchorableBottom
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel) + 1,
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Add(floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableTop:
                #region DropTargetType.DocumentPaneDockAsAnchorableTop
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel),
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableLeft:
                #region DropTargetType.DocumentPaneDockAsAnchorableLeft
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel),
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableRight:
                #region DropTargetType.DocumentPaneDockAsAnchorableRight
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel) + 1,
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Add(floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
        void anchorablesSourceElementsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Layout == null)
                return;

            //When deserializing documents are created automatically by the deserializer
            if (SuspendAnchorablesSourceBinding)
                return;

            //handle remove
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
            {
                if (e.OldItems != null)
                {
                    var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().Where(d => e.OldItems.Contains(d.Content)).ToArray();
                    foreach (var anchorableToRemove in anchorablesToRemove)
                    {
                        (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                            anchorableToRemove);
                    }
                }
            }

            //handle add
            if (e.NewItems != null &&
                (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace))
            {
                if (e.NewItems != null)
                {
                    LayoutAnchorablePane anchorablePane = null;

                    if (Layout.ActiveContent != null)
                    {
                        //look for active content parent pane
                        anchorablePane = Layout.ActiveContent.Parent as LayoutAnchorablePane;
                    }

                    if (anchorablePane == null)
                    {
                        //look for a pane on the right side
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
                    }

                    if (anchorablePane == null)
                    {
                        //look for an available pane
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
                    }

                    _suspendLayoutItemCreation = true;
                    foreach (var anchorableContentToImport in e.NewItems)
                    {
                        var anchorableToImport = new LayoutAnchorable()
                        {
                            Content = anchorableContentToImport
                        };

                        bool added = false;
                        if (LayoutUpdateStrategy != null)
                        {
                            added = LayoutUpdateStrategy.BeforeInsertAnchorable(Layout, anchorableToImport, anchorablePane);
                        }

                        if (!added)
                        {
                            if (anchorablePane == null)
                            {
                                var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                                if (Layout.RootPanel != null)
                                {
                                    mainLayoutPanel.Children.Add(Layout.RootPanel);
                                }

                                Layout.RootPanel = mainLayoutPanel;
                                anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                                mainLayoutPanel.Children.Add(anchorablePane);
                            }

                            anchorablePane.Children.Add(anchorableToImport);
                            added = true;
                        }

                        if (LayoutUpdateStrategy != null)
                        {
                            LayoutUpdateStrategy.AfterInsertAnchorable(Layout, anchorableToImport);
                        }

                        var root = anchorableToImport.Root;

                        if (root != null && root.Manager == this)
                        {
                            CreateAnchorableLayoutItem(anchorableToImport);
                        }

                    }
                    _suspendLayoutItemCreation = false;
                }
            }

            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                //NOTE: I'm going to clear every anchorable present in layout but
                //some anchorable may have been added directly to the layout, for now I clear them too
                var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().ToArray();
                foreach (var anchorableToRemove in anchorablesToRemove)
                {
                    (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                        anchorableToRemove);
                }
            }

            if (Layout != null)
                Layout.CollectGarbage();
        }
Exemple #15
0
		protected override void InternalDock()
		{
			var root = Root as LayoutRoot;
			LayoutAnchorablePane anchorablePane = null;

			if (root.ActiveContent != null &&
				root.ActiveContent != this)
			{
				//look for active content parent pane
				anchorablePane = root.ActiveContent.Parent as LayoutAnchorablePane;
			}

			if (anchorablePane == null)
			{
				//look for a pane on the right side
				anchorablePane = root.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
			}

			if (anchorablePane == null)
			{
				//look for an available pane
				anchorablePane = root.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
			}


			bool added = false;
			if (root.Manager.LayoutUpdateStrategy != null)
			{
				added = root.Manager.LayoutUpdateStrategy.BeforeInsertAnchorable(root, this, anchorablePane);
			}

			if (!added)
			{
				if (anchorablePane == null)
				{
					var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
					if (root.RootPanel != null)
					{
						mainLayoutPanel.Children.Add(root.RootPanel);
					}

					root.RootPanel = mainLayoutPanel;
					anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
					mainLayoutPanel.Children.Add(anchorablePane);
				}

				anchorablePane.Children.Add(this);
				added = true;
			}

			if (root.Manager.LayoutUpdateStrategy != null)
			{
				root.Manager.LayoutUpdateStrategy.AfterInsertAnchorable(root, this);
			}

			base.InternalDock();
		}
Exemple #16
0
		public void ToggleAutoHide()
		{
			#region Anchorable is already auto hidden
			if (IsAutoHidden)
			{
				var parentGroup = Parent as LayoutAnchorGroup;
				var parentSide = parentGroup.Parent as LayoutAnchorSide;
				var previousContainer = ((ILayoutPreviousContainer)parentGroup).PreviousContainer as LayoutAnchorablePane;

				if (previousContainer == null)
				{
					AnchorSide side = (parentGroup.Parent as LayoutAnchorSide).Side;
					switch (side)
					{
						case AnchorSide.Right:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Add(previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Horizontal };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(oldRootPanel);
								panel.Children.Add(previousContainer);
							}
							break;
						case AnchorSide.Left:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Horizontal };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(previousContainer);
								panel.Children.Add(oldRootPanel);
							}
							break;
						case AnchorSide.Top:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Vertical };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(previousContainer);
								panel.Children.Add(oldRootPanel);
							}
							break;
						case AnchorSide.Bottom:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Add(previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Vertical };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(oldRootPanel);
								panel.Children.Add(previousContainer);
							}
							break;
					}
				}
				else
				{
					//I'm about to remove parentGroup, redirect any content (ie hidden contents) that point to it
					//to previousContainer
					LayoutRoot root = parentGroup.Root as LayoutRoot;
					foreach (var cnt in root.Descendents().OfType<ILayoutPreviousContainer>().Where(c => c.PreviousContainer == parentGroup))
					{
						cnt.PreviousContainer = previousContainer;
					}
				}


				foreach (var anchorableToToggle in parentGroup.Children.ToArray())
				{
					previousContainer.Children.Add(anchorableToToggle);
				}

				parentSide.Children.Remove(parentGroup);
			}
			#endregion
			#region Anchorable is docked
			else if (Parent is LayoutAnchorablePane)
			{
				var root = Root;
				var parentPane = Parent as LayoutAnchorablePane;

				var newAnchorGroup = new LayoutAnchorGroup();

				((ILayoutPreviousContainer)newAnchorGroup).PreviousContainer = parentPane;

				foreach (var anchorableToImport in parentPane.Children.ToArray())
					newAnchorGroup.Children.Add(anchorableToImport);

				//detect anchor side for the pane
				var anchorSide = parentPane.GetSide();

				switch (anchorSide)
				{
					case AnchorSide.Right:
						root.RightSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Left:
						root.LeftSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Top:
						root.TopSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Bottom:
						root.BottomSide.Children.Add(newAnchorGroup);
						break;
				}
			}
			#endregion
		}
Exemple #17
0
 public void ShowView(string name, FrameworkElement element)
 {
     LayoutPanel newpanel2 = new LayoutPanel();
     newpanel2.Caption = name;
     newpanel2.Name = name;
     newpanel2.Content = element;
     mainLayoutManager.DockController.Dock(newpanel2);
 }
Exemple #18
0
        bool FindParentLayoutDocumentPane(ILayoutDocumentPane documentPane, out LayoutDocumentPaneGroup containerPaneGroup, out LayoutPanel containerPanel)
        {
            containerPaneGroup = null;
            containerPanel     = null;

            if (documentPane.Parent is LayoutPanel)
            {
                containerPaneGroup = null;
                containerPanel     = documentPane.Parent as LayoutPanel;
                return(true);
            }
            else if (documentPane.Parent is LayoutDocumentPaneGroup)
            {
                var currentDocumentPaneGroup = documentPane.Parent as LayoutDocumentPaneGroup;
                while (!(currentDocumentPaneGroup.Parent is LayoutPanel))
                {
                    currentDocumentPaneGroup = currentDocumentPaneGroup.Parent as LayoutDocumentPaneGroup;

                    if (currentDocumentPaneGroup == null)
                    {
                        break;
                    }
                }

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

                containerPaneGroup = currentDocumentPaneGroup;
                containerPanel     = currentDocumentPaneGroup.Parent as LayoutPanel;
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Starts the fact gathering.
        /// 
        /// We return an error code for displaying errors.
        /// 
        /// </summary>
        public int StartFactGathering(ref List<string> results,/* string _FactParseNote, */string textFromNote)
        {
            try {

                /*if (Constants.BLANK == _FactParseNote ) {
                    return 1;
                } else*/
                    // Step 1 - Link to a note on this page with the name(s) of another note : Loop

                    if (textFromNote == Constants.BLANK) {
                        return 2;

                    } else {
                        //NewMessage.Show ("Found = " + note.Data1); // worked

                        // to do: will need to parse .data1 and grab lines

                        //The Pool;[[Group,Storyboard,Chapters*,*]]

                        //string textFromNote = note.GetAsText ();
                        string[] lines = textFromNote.Split (new char[1]{'\n'}, StringSplitOptions.RemoveEmptyEntries);
                        if (lines != null && lines.Length > 0) {
                            // for each Layout we have to open we added to the results list
                            // results are stored on the note
                            //	List<string> results = new List<string>();
                            foreach (string theLine in lines) {

                                string noteData1 = theLine;//"The Pool;[[Group,Storyboard,Chapters*,*]]";
                                string[] RawView = noteData1.Split (new char[1] {';'}, StringSplitOptions.RemoveEmptyEntries);
                                if (RawView != null && RawView.Length == 2) {

                                    // Second part -- fine deatils

                                    // Strings will be formatted like this[[Group,Storyboard,Chapters*,*]]
                                    // logic - strip out [[ and ]]
                                    // break into stringarray , seperate by ','
                                    // string[0] = word Group. We ignore and always fill in Group
                                    // string[1] = Storyboard  -- this is the important bit -- the name of the Storyboard to look
                                    // string[2] = which "folder" to look in on the storyboard

                                    // Step 2 - Open that other note
                                    string LayoutName = RawView [0];//"LayoutToFind";
                                    string Code = RawView [1];
                                    string LayoutGUID = MasterOfLayouts.GetGuidFromName (LayoutName);
                                    if (LayoutGUID != Constants.BLANK && Code != Constants.BLANK) {

                                        LayoutPanel temporaryLayoutPanel = new LayoutPanel ("", false);
                                        temporaryLayoutPanel.LoadLayout (LayoutGUID, false, null, true);
                                        if (temporaryLayoutPanel == null)
                                        {
                                            return 100;
                                        }

                                    //NewMessage.Show (temporaryLayoutPanel.Count ().ToString());

                                        string[] code = new string[3];
                                        // we fake a string array to meet the Fact-Parse system's expectations of Storyboard/GrouporNoGroup/Details
                                        // even though we do not need the first two lines
                                        code [0] = "[[factlist]]";
                                        code [1] = "[[bygroup]]";

                                        code [2] = Code;
                                    //NewMessage.Show (Code);
                                        Hashtable hResults = Addin_YourothermindMarkup.GetFactsOnRemoteNote (temporaryLayoutPanel, code);

                                        if (hResults != null) {
                                            foreach (DictionaryEntry gg in hResults) {
                                        //	NewMessage.Show ("Matching " + gg.Key.ToString() + " with " + token);
                                            if (gg.Key.ToString () == token)
                                            {
                                                string[] factsforentry = gg.Value.ToString().Split(new string[1]{FactListMaker.SEP_PHRASES}, StringSplitOptions.RemoveEmptyEntries);
                                                if (factsforentry != null)
                                                {

                                                    foreach (string s in factsforentry)
                                                    {
                                                        string sresult = /*gg.Value*/s + FactListMaker.SEP_INSIDEPHRASE + token + FactListMaker.SEP_INSIDEPHRASE + LayoutGUID;
                                                        results.Add (sresult);
                                                    }

                                                }
                                            }

            //												// only add if they matc h the search criteria
            //												if (gg.Key.ToString () == token)
            //												{
            //													string sresult = gg.Value + FactListMaker.SEP_INSIDEPHRASE + gg.Key + FactListMaker.SEP_INSIDEPHRASE + LayoutGUID;
            //													results.Add (sresult);
            //												}

                                            }
                                        }

                                        // now we have to run the actual Fact - Parsing
                                        // Step 3 - On that Other Note run the indicated fact search (from Step 1)

                                        // Step 4 - Return the list of facts/positions in a usable manner to here.

                                    // dispose memory 09/07/2014
                                    hResults = null;
                                    temporaryLayoutPanel.Dispose();
                                    } else {
                                        return 3;
                                    }
                                } else {
                                    return 4;

                                }

                            } // foreach line

                            // Step 6 - Now we parse the results and add them to the form.
                            //  -- nope we have this called in the Progress thing

                        }//lines
                    else {
                            return 5;
                        }
                    }

            } catch (Exception ex) {
                lg.Instance.Line ("StartFactGathering", ProblemType.EXCEPTION, ex.ToString ());

            }

            return 0;
        }
        public void SaveRequired()
        {
            _setupforlayoutests ();
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", false, null);
            NoteDataXML_RichText note = new NoteDataXML_RichText ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();

                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
                note.UpdateLocation();
            }
            //layout.SaveTo();
            Assert.True (layoutPanel.GetSaveRequired);
        }
        void AttachAnchorablesSource(LayoutRoot layout, IEnumerable anchorablesSource)
        {
            if (anchorablesSource == null)
                return;

            if (layout == null)
                return;

            //if (layout.Descendents().OfType<LayoutAnchorable>().Any())
            //    throw new InvalidOperationException("Unable to set the AnchorablesSource property if LayoutAnchorable objects are already present in the model");
            var anchorablesImported = layout.Descendents().OfType<LayoutAnchorable>().Select(d => d.Content).ToArray();
            var anchorables = anchorablesSource as IEnumerable;
            var listOfAnchorablesToImport = new List<object>(anchorables.OfType<object>());

            foreach (var document in listOfAnchorablesToImport.ToArray())
            {
                if (anchorablesImported.Contains(document))
                    listOfAnchorablesToImport.Remove(document);
            }

            LayoutAnchorablePane anchorablePane = null;
            if (layout.ActiveContent != null)
            {
                //look for active content parent pane
                anchorablePane = layout.ActiveContent.Parent as LayoutAnchorablePane;
            }

            if (anchorablePane == null)
            {
                //look for a pane on the right side
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
            }

            if (anchorablePane == null)
            {
                //look for an available pane
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
            }

            _suspendLayoutItemCreation = true;
            foreach (var anchorableContentToImport in listOfAnchorablesToImport)
            {
                var anchorableToImport = new LayoutAnchorable()
                {
                    Content = anchorableContentToImport
                };

                bool added = false;
                if (LayoutUpdateStrategy != null)
                {
                    added = LayoutUpdateStrategy.BeforeInsertAnchorable(layout, anchorableToImport, anchorablePane);
                }

                if (!added)
                {
                    if (anchorablePane == null)
                    {
                        var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                        if (layout.RootPanel != null)
                        {
                            mainLayoutPanel.Children.Add(layout.RootPanel);
                        }

                        layout.RootPanel = mainLayoutPanel;
                        anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                        mainLayoutPanel.Children.Add(anchorablePane);
                    }

                    anchorablePane.Children.Add(anchorableToImport);
                    added = true;
                }

                if (LayoutUpdateStrategy != null)
                    LayoutUpdateStrategy.AfterInsertAnchorable(layout, anchorableToImport);

                CreateAnchorableLayoutItem(anchorableToImport);

            }

            _suspendLayoutItemCreation = false;

            var anchorablesSourceAsNotifier = anchorablesSource as INotifyCollectionChanged;
            if (anchorablesSourceAsNotifier != null)
                anchorablesSourceAsNotifier.CollectionChanged += new NotifyCollectionChangedEventHandler(anchorablesSourceElementsChanged);
        }
        public void TryMixedTypeSave()
        {
            // 1. write data to notes
            _setupforlayoutests ();
            int count = 25;
            //	FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);
            NoteDataInterface note = null;
            for (int i = 0; i < count; i++) {
                note = (NoteDataInterface)Activator.CreateInstance(typeof(NoteDataXML));//new NoteDataXML ();

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }

            // store a SECOND TYPE into the mix
            note = (NoteDataInterface)Activator.CreateInstance(typeof(NoteDataXML_RichText));
            note.Caption = "textnote";
            string guid = note.GuidForNote;

            _w.output("new guid" + guid);
            layoutPanel.AddNote (note);
            note.CreateParent(layoutPanel);
            layoutPanel.SaveLayout ();
        }
        public void LayoutExists()
        {
            System.Windows.Forms .Form form = new System.Windows.Forms.Form();
            _w.output("1");
            _TestSingleTon.Instance._SetupForLayoutPanelTests();
            _w.output("2");
            int count = 25;
            //FakeLayoutDatabase layout = new FakeLayoutDatabase ("testguid");
            LayoutPanel layoutPanel = new LayoutPanel (CoreUtilities.Constants.BLANK, false);
            layoutPanel.NewLayout("testguid", true, null);

            NoteDataXML note = new NoteDataXML ();
            for (int i = 0; i < count; i++) {

                note.Caption = "boo" + i.ToString ();
                layoutPanel.AddNote (note);
                note.CreateParent(layoutPanel);
            }
            layoutPanel.SaveLayout();
            layoutPanel.Dispose ();
            Assert.True (MasterOfLayouts.ExistsByGUID("testguid"));
        }
Exemple #24
0
 internal LayoutPanelControl(LayoutPanel model)
     : base(model, model.Orientation)
 {
     _model = model;
 }
 internal override LayoutElement Convert(UiManager uiManager)
 {
     var lr = new LayoutPanel
     {
         DockWidth = new GridLength(Width.Value, Width.Unit),
         DockHeight = new GridLength(Height.Value, Height.Unit),
         Orientation = Orientation
     };
     foreach (var x in Children)
     {
         if (x is LayoutInfo)
             lr.Children.Add((ILayoutPanelElement)((LayoutInfo)x).Convert(uiManager));
         else if (x is PaneInfo)
             lr.Children.Add((ILayoutPanelElement)((PaneInfo)x).Convert(uiManager));
     }
     return lr;
 }