Esempio n. 1
0
 public IEditor NewEditor()
 {
     DocumentContent document = new DocumentContent();
     Editor editor = new Editor(document);
     document.Show(manager);
     document.Activate();
     return editor;
 }
Esempio n. 2
0
        private void CreateNewDocument(object sender, RoutedEventArgs e)
        {

            string baseDocTitle = "MyDocument";
            int i = 1;
            string title = baseDocTitle + i.ToString();

            while (dockManager.Documents.Any(d => d.Title == title))
            {
                i++;
                title = baseDocTitle + i.ToString();
            }

            DocumentContent doc = new DocumentContent() { Title = title };
            doc.Show(dockManager);

            //MyDocuments.Add(new DocumentContent() { Title = title });
        }
Esempio n. 3
0
 public static void ShowDocument(DocumentContent doc, bool floating)
 {
     doc.Show(DockingManager, floating);
     doc.Activate();
 }
        /// <summary>
        /// Initialication of the GUIEditor Tab, creating the context menu for the GUIEditor elements
        /// </summary>
        private void InitGUITab()
        {
            // Context menu
            gUIComponentContextMenu = new ContextMenu();
            gUIComponentContextMenuResize = new MenuItem();
            gUIComponentContextMenuResize.Header = Properties.Resources.GUIEditorKeyboardResize;
            gUIComponentContextMenu.Items.Add(gUIComponentContextMenuResize);
            gUIComponentContextMenuResize.Click += gUIComponentContextMenuResize_Click;

            gUIComponentContextMenuResizeStop = new MenuItem();
            gUIComponentContextMenuResizeStop.Header = Properties.Resources.GUIEditorKeyboardResizeStop;
            gUIComponentContextMenuResizeStop.IsEnabled = false;
            gUIComponentContextMenu.Items.Add(gUIComponentContextMenuResizeStop);
            gUIComponentContextMenuResizeStop.Click += gUIComponentContextMenuResizeStop_Click;

            gUIComponentContextMenu.Items.Add(new Separator());
            gUIComponentContextMenuMove = new MenuItem();
            gUIComponentContextMenuMove.Header = Properties.Resources.GUIEditorKeyboardMove;
            gUIComponentContextMenu.Items.Add(gUIComponentContextMenuMove);
            gUIComponentContextMenuMove.Click += gUIComponentContextMenuMove_Click;

            gUIComponentContextMenuMoveStop = new MenuItem();
            gUIComponentContextMenuMoveStop.Header = Properties.Resources.GUIEditorKeyboardMoveStop;
            gUIComponentContextMenuMoveStop.IsEnabled = false;
            gUIComponentContextMenu.Items.Add(gUIComponentContextMenuMoveStop);
            gUIComponentContextMenuMoveStop.Click += gUIComponentContextMenuMoveStop_Click;

            // creating the tab fot the gui designer
            DockPanel guiDockPanel = new DockPanel();
            guiDockPanel.LastChildFill = true;

            guiScrollViewer = new ScrollViewer();
            guiScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            guiScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            guiDockPanel.Children.Add(guiScrollViewer);

            guiCanvas = new Canvas();
            InitGUICanvas();
            guiCanvasBorder = new Border();
            guiCanvasBorder.BorderThickness = new Thickness(2);
            guiCanvasBorder.BorderBrush = Brushes.DarkGray;
            guiCanvasBorder.Width = guiCanvas.Width + 4;
            guiCanvasBorder.Height = guiCanvas.Height + 4;
            guiCanvasBorder.Child = guiCanvas;
            guiScrollViewer.Content = guiCanvasBorder;
            GUIEditorCanvas = new DocumentContent() {
                Title = Properties.Resources.DockGUIWindow,
                Content = guiDockPanel,
                Name = "dockGUIEditorWindowName"
            };
            GUIEditorCanvas.IsCloseable = false;
            GUIEditorCanvas.IsActiveDocumentChanged += GUIEditorCanvas_IsActiveDocumentChanged;
            GUIEditorCanvas.Show(dockManager);

            guiProp = new GUIProperties();
            guiProp.PropertyChanged += guiProp_PropertyChanged;

            // Adapt screen resolution. Screen width is 800
            switch (guiProp.ScreenRes) {
                case GUIProperties.ScreenResolution.FiveFour:
                    guiCanvas.Height = GUIFRAMEHEIGHTFIVEFOUR;
                    break;
                case GUIProperties.ScreenResolution.FourThree:
                    guiCanvas.Height = GUIFRAMEHEIGHTFOURTHREE;
                    break;
                case GUIProperties.ScreenResolution.SixteenNine:
                    guiCanvas.Height = GUIFRAMEHEIGHTSIXTEENNINE;
                    break;
            }

            guiGridCanvas = new Canvas();
            guiGridCanvas.Width = guiCanvas.Width;
            guiGridCanvas.Height = guiCanvas.Height;
            DrawGridLines();
            guiCanvas.Children.Add(guiGridCanvas);
            if (guiProp.ShowGrid == true) {
                guiGridCanvas.Visibility = System.Windows.Visibility.Visible;
            }
            else {
                guiGridCanvas.Visibility = System.Windows.Visibility.Hidden;
            }

            AddAREGUIComponent();
        }
        void BuildDockingLayout()
        {
            dockManager.Content = null;

            //TreeView dockable content
            var trv = new TreeView();
            trv.Items.Add(new TreeViewItem() { Header = "Item1" });
            trv.Items.Add(new TreeViewItem() { Header = "Item2" });
            trv.Items.Add(new TreeViewItem() { Header = "Item3" });
            trv.Items.Add(new TreeViewItem() { Header = "Item4" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem1" });
            ((TreeViewItem)trv.Items[0]).Items.Add(new TreeViewItem() { Header = "SubItem2" });
            ((TreeViewItem)trv.Items[1]).Items.Add(new TreeViewItem() { Header = "SubItem3" });
            ((TreeViewItem)trv.Items[2]).Items.Add(new TreeViewItem() { Header = "SubItem4" });
            var treeviewContent = new DockableContent() { Title = "Explorer", Content = trv };

            treeviewContent.Show(dockManager, AnchorStyle.Left);

            //TextBox invo dockable content
            var treeviewInfoContent = new DockableContent() { Title = "Explorer Info", Content = new TextBox() { Text = "Explorer Info Text", IsReadOnly = true } };
            treeviewContent.ContainerPane.Items.Add(treeviewInfoContent);


            //ListView dockable content
            var gridView = new GridView();
            gridView.Columns.Add(new GridViewColumn() { Header = "Date" });
            gridView.Columns.Add(new GridViewColumn() { Header = "Day Of Weeek", DisplayMemberBinding = new Binding("DayOfWeek") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Year", DisplayMemberBinding = new Binding("Year") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Month", DisplayMemberBinding = new Binding("Month") });
            gridView.Columns.Add(new GridViewColumn() { Header = "Second", DisplayMemberBinding = new Binding("Second") });
            var listView = new ListView() { View = gridView };
            listView.Items.Add(DateTime.Now);
            listView.Items.Add(DateTime.Now.AddYears(-1));
            listView.Items.Add(DateTime.Now.AddMonths(15));
            listView.Items.Add(DateTime.Now.AddHours(354));

            var listViewContent = new DockableContent() { Title = "Date & Times", Content = listView };
            listViewContent.ShowAsFloatingWindow(dockManager, true);

            //TextBox dockable content
            var textboxSampleContent = new DockableContent() { Title = "Date & Times Info", Content = new TextBox() { Text = "Date & Times Info Text", IsReadOnly = true } };
            listViewContent.ContainerPane.Items.Add(textboxSampleContent);


            //DataGrid document
            var dataGrid = new DataGrid();
            var rnd = new Random();
            var data = new List<Tuple<double, double, double, double>>();
            for (int i = 0; i < 100; i++)
            {
                data.Add(Tuple.Create(rnd.NextDouble(), rnd.NextDouble() * 10.0, rnd.NextDouble() * 100.0, rnd.NextDouble() * 1000.0));
            }

            dataGrid.ItemsSource = data;

            var dataGridDocument = new DocumentContent() { Title = "Data", IsLocked = true, Content = dataGrid };
            dataGridDocument.Show(dockManager);

            //DataGrid Info Text sample
            var dataGridInfoContent = new DockableContent() { Title = "Data Info", Content = new TextBox() { Text = "Data Info Text" } };
            dataGridInfoContent.ShowAsDocument(dockManager);

        }
Esempio n. 6
0
        private void ExportLayoutToDocument(object sender, RoutedEventArgs e)
        {
            DocumentContent doc = new DocumentContent()
            {
                Title = string.Format("Layout_{0}", DateTime.Now.ToString()),
                Content = new TextBox()
                {
                    AcceptsReturn = true,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                    Text = DockManager.LayoutToString()
                }
            };

            doc.Show(DockManager);
            doc.Activate();
        }
Esempio n. 7
0
        /// <summary>
        /// Initialise the proprety dock (dockManager of AvalonDock)
        /// </summary>
        void BuildDockingLayout()
        {
            dockManager.Content = null;

            // The name properties are needed to save and restore the layout
            dockManager.Name = "dockManagerName";

            BitmapImage propertiesIcon = new BitmapImage();
            propertiesIcon.BeginInit();
            propertiesIcon.UriSource = new Uri(@"/images/Properties_Icon.png", UriKind.RelativeOrAbsolute);
            propertiesIcon.EndInit();

            BitmapImage eventsIcon = new BitmapImage();
            eventsIcon.BeginInit();
            eventsIcon.UriSource = new Uri(@"/images/event.png", UriKind.RelativeOrAbsolute);
            eventsIcon.EndInit();

            dockableComponentProperties = new DockableContent() {
                Title = Properties.Resources.DockProperties,
                Content = null,
                Name = "dockComponentName",
                Icon = propertiesIcon
            };

            propertyDockScrollViewer = new ScrollViewer();
            propertyDockScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            propertyDockScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

            StackPanel sp = new StackPanel();
            dockableComponentProperties.Content = sp;
            sp.Children.Add(propertyDockScrollViewer);
            dockableComponentProperties.Show(dockManager, AnchorStyle.Right);
            dockableComponentProperties.IsCloseable = false;

            scrollCanvars = new DocumentContent() {
                Title = Properties.Resources.DockMainWindow,
                Content = scrollViewer,
                Name = "dockDeploymentWindowName"
            };
            scrollCanvars.IsCloseable = false;
            scrollCanvars.Show(dockManager);

            // creating the tab for the gui designer
            InitGUITab();

            //TreeView dockable content
            dockableInportsList = new TreeView();
            BrushConverter bc = new BrushConverter();
            dockableInportsList.Background = (Brush)bc.ConvertFrom("#FFFFFFFF");
            dockableInportsList.IsTabStop = true;
            //dockableInportsList.Background = (Brush)bc.ConvertFrom("#FFE9ECFA");
            dockableOutportsList = new TreeView();
            dockableOutportsList.Background = (Brush)bc.ConvertFrom("#FFFFFFFF");
            //dockableOutportsList.Background = (Brush)bc.ConvertFrom("#FFE9ECFA");

            dockableInportsTab = new DockableContent() {
                Title = Properties.Resources.DockInPorts,
                Content = dockableInportsList,
                Visibility = Visibility.Collapsed,
                Name = "inputPortsName",
                Icon = propertiesIcon,
                IsCloseable = false
            };
            dockableOutportsTab = new DockableContent() {
                Title = Properties.Resources.DockOutPorts,
                Content = dockableOutportsList,
                Visibility = Visibility.Collapsed,
                Name = "outputPortsName",
                Icon = propertiesIcon,
                IsCloseable = false
            };

            // EventListenerGrid
            eventListenerDockScrollViewer = new ScrollViewer();
            eventListenerDockScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            eventListenerDockScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            dockableEventListenerTab = new DockableContent() {
                Title = Properties.Resources.PropertyDockEventListenerTab,
                Content = eventListenerDockScrollViewer,
                Visibility = Visibility.Collapsed,
                Name = "eventListenerName",
                Icon = eventsIcon,
                IsCloseable = false
            };
            eventListenerDockScrollViewer.SizeChanged += dockableEventListenerTriggerTab_SizeChanged;

            // EventTriggerGrid
            eventTriggerDockScrollViewer = new ScrollViewer();
            eventTriggerDockScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            eventTriggerDockScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            dockableEventTriggerTab = new DockableContent() {
                Title = Properties.Resources.PropertyDockEventTriggerTab,
                Content = eventTriggerDockScrollViewer,
                Visibility = Visibility.Collapsed,
                Name = "eventTriggerName",
                Icon = eventsIcon,
                IsCloseable = false
            };
            eventTriggerDockScrollViewer.SizeChanged += dockableEventListenerTriggerTab_SizeChanged;

            // EventGrid
            dockEventGrid = new Grid();
            dockEventGrid.MinWidth = 200;
            dockEventGrid.Background = new SolidColorBrush(Colors.White);
            //dockEventGrid.Height = 100;

            ColumnDefinition labelColDef = new ColumnDefinition();
            ColumnDefinition comboColDef = new ColumnDefinition();
            dockEventGrid.ColumnDefinitions.Add(labelColDef);
            dockEventGrid.ColumnDefinitions.Add(comboColDef);
            dockEventGrid.HorizontalAlignment = HorizontalAlignment.Left;
            dockEventGrid.VerticalAlignment = VerticalAlignment.Top;
            dockEventGrid.Margin = new Thickness(4, 4, 4, 4);
            ScrollViewer eventDockScrollViewer = new ScrollViewer();
            eventDockScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
            eventDockScrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            eventDockScrollViewer.Content = dockEventGrid;

            dockableEventsTab = new DockableContent() {
                Title = Properties.Resources.DockEvents,
                Content = eventDockScrollViewer,
                Visibility = Visibility.Collapsed,
                Name = "events",
                Icon = eventsIcon,
                IsCloseable = false
            };
            eventDockScrollViewer.SizeChanged += dockableEventListenerTriggerTab_SizeChanged;

            dockableComponentProperties.ContainerPane.Items.Add(dockableInportsTab);
            dockableComponentProperties.ContainerPane.Items.Add(dockableOutportsTab);
            dockableComponentProperties.ContainerPane.Items.Add(dockableEventsTab);
            dockableComponentProperties.ContainerPane.Items.Add(dockableEventListenerTab);
            dockableComponentProperties.ContainerPane.Items.Add(dockableEventTriggerTab);

            sp.SizeChanged += StackPanel_SizeChanged;

            // Component "Toolbox" on left side
            // under development, do NOT delete
            //DockableContent dockableComponentToolbox = new DockableContent() {
            //    Title = "Components", Content = null, Name = "dockComponentToolbox"
            //};
            //dockableComponentToolbox.Show(dockManager, AnchorStyle.Left);
            //TreeView dockableComponentList = new TreeView();

            //dockableComponentList.Items.Add(new TreeViewItem() {
            //    Header = "Sensors", Background = new SolidColorBrush(Colors.Beige)//, ItemContainerStyle
            //});
            //dockableComponentList.Items.Add(new TreeViewItem() {
            //    Header = "Processors"
            //});
            //dockableComponentList.Items.Add(new TreeViewItem() {
            //    Header = "Actuators"
            //});
            //dockableComponentList.Items.Add(new TreeViewItem() {
            //    Header = "Special"
            //});
            //dockableComponentToolbox.Content = dockableComponentList;

            //foreach (Asterics.ACS2.componentTypesComponentType component in componentList.Values) {
            //    switch (component.type) {
            //        case Asterics.ACS2.componentType.actuator:
            //            ((TreeViewItem)dockableComponentList.Items[2]).Items.Add(new TreeViewItem {
            //                Header = component.id, Margin = new Thickness(-20, 0, 0, 0)
            //            });
            //            break;
            //        case Asterics.ACS2.componentType.processor:
            //            ((TreeViewItem)dockableComponentList.Items[1]).Items.Add(new TreeViewItem {
            //                Header = component.id, Margin = new Thickness(-20, 0, 0, 0)
            //            });
            //            break;
            //        case Asterics.ACS2.componentType.sensor:
            //            ((TreeViewItem)dockableComponentList.Items[0]).Items.Add(new TreeViewItem {
            //                Header = component.id, Margin = new Thickness(-20, 0, 0, 0)
            //            });
            //            break;
            //        case Asterics.ACS2.componentType.special:
            //            ((TreeViewItem)dockableComponentList.Items[3]).Items.Add(new TreeViewItem {
            //                Header = component.id, Margin = new Thickness(-20, 0, 0, 0)
            //            });
            //            break;
            //    }
            //}
            // End toolbox
        }