Esempio n. 1
0
        private void viewCodeMenuItem_Click(object sender, EventArgs e)
        {
            if (!(this.tabControl1.SelectedTab.Controls[0] is HostControl))
            {
                return;
            }
            HostSurface hostSurface = (this.tabControl1.SelectedTab.Controls[0] as HostControl).HostSurface;

            foreach (TabPage tp in this.tabControl1.TabPages)
            {
                if (hostSurface.Equals(tp.Tag as HostSurface))
                {
                    this.tabControl1.SelectedTab = tp;
                    return;
                }
            }
            string code     = hostSurface.GetCode();
            string language = this.tabControl1.SelectedTab.Tag.ToString();

            if (String.IsNullOrEmpty(code))
            {
                return;
            }
            string            tabName = this.tabControl1.SelectedTab.Text.Replace("Design", "Code");
            TabPage           tabpage = new TabPage(tabName);
            CodeEditorControl cec     = new CodeEditorControl();

            cec.Parent = tabpage;
            cec.Dock   = DockStyle.Fill;
            cec.ShowText(code, language);
            tabpage.Tag = hostSurface;
            this.tabControl1.TabPages.Add(tabpage);
            this.tabControl1.SelectedTab = tabpage;
        }
Esempio n. 2
0
        private void AddDesigner()
        {
            Lazy <HostSurfaceFactory, IDesignerMetadataView> exportSurfaceFactory = fileNewDialog.GetHostFactory();
            HostControl hc = new HostControl();

            if (designerCounts.ContainsKey(exportSurfaceFactory.Metadata.ItemType))
            {
                designerCounts[exportSurfaceFactory.Metadata.ItemType]++;
            }
            else
            {
                designerCounts.Add(exportSurfaceFactory.Metadata.ItemType, 1);
            }
            string      siteName    = exportSurfaceFactory.Metadata.ItemType + designerCounts[exportSurfaceFactory.Metadata.ItemType].ToString();
            HostSurface hostSurface = exportSurfaceFactory.Value.CreateNew(siteName);

            hc.InitializeHost(hostSurface);
            string  fileName = siteName + "." + exportSurfaceFactory.Metadata.FileExtension;
            TabPage tabpage  = new TabPage(fileName + " - Design");

            tabpage.Tag = exportSurfaceFactory.Metadata.Language;
            hc.Parent   = tabpage;
            hc.Dock     = DockStyle.Fill;
            this.tabControl1.TabPages.Add(tabpage);
            this.tabControl1.SelectedIndex = this.tabControl1.TabPages.Count - 1;
            this.outputWindow.Writeline("Opened new host.");
            this.toolbox.DesignerHost = hostSurface.DesignerHost;
            this.solutionExplorer.AddFileNode(fileName);
            SetupMenus(hostSurface);
        }
Esempio n. 3
0
        private void InvalidatePropertyGrid( )
        {
            try
            {
                HostSurface surface = (HostSurface)OwnerStudio.SurfaceManager.ActiveDesignSurface;
                if (surface != null && surface.ServiceSelection != null)
                {
                    ICollection selectedComponents = surface.ServiceSelection.GetSelectedComponents();

                    object[] comps = new object[selectedComponents.Count];
                    int      i     = 0;

                    foreach (Object o in selectedComponents)
                    {
                        comps[i] = o;
                        i++;
                    }

                    OwnerStudio.PropertyGrid.SelectedObjects = comps;
                    OwnerStudio.PropertyGrid.Refresh();
                    if (surface.ServiceSelection.PrimarySelection != null)
                    {
                        OwnerStudio.ControlListsGrid.SetFocusComponent(((Component)surface.ServiceSelection.PrimarySelection).Site.Name);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 4
0
        public static void Paste(HostSurface hostSurface)
        {
            IMenuCommandService ims = hostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            if (ims != null)
            {
                ims.GlobalInvoke(StandardCommands.Paste);
            }
        }
Esempio n. 5
0
        void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            ComponentObject obj = (ComponentObject)this.gridView1.GetRow(this.gridView1.FocusedRowHandle);

            if (obj != null)
            {
                HostSurface surface = (HostSurface)Studio.SurfaceManager.ActiveDesignSurface;
                surface.ServiceSelection.SetSelectedComponents(new Component[] { (Component)obj.Component });
            }
        }
Esempio n. 6
0
        public DevExpress.XtraTab.XtraTabPage GetTabPageFromHostSurface(HostSurface surface)
        {
            foreach (DevExpress.XtraTab.XtraTabPage tabPage in OwnerStudio.TabViewControl.TabPages)
            {
                if (tabPage.Tag is HostControl && ((HostControl)tabPage.Tag).HostSurface != null && ((HostControl)tabPage.Tag).HostSurface == surface)
                {
                    return(tabPage);
                }
            }

            return(null);
        }
Esempio n. 7
0
        public void ReloadFieldNodes(HostSurface Surface)
        {
            ABCView view = (ABCView)Surface.DesignerHost.RootComponent;

            Surface.TreeFieldNodes = new ABCCommonTreeListNode(null, null);

            if (view != null && view.DataConfig != null && view.DataConfig.BindingList != null)
            {
                foreach (ABCScreen.ABCBindingConfig config in view.DataConfig.BindingList.TreeValues)
                {
                    InitTable(Surface.TreeFieldNodes, config);
                }
            }
        }
Esempio n. 8
0
        public void InitializeHost(HostSurface hostSurface)
        {
            if (hostSurface == null)
            {
                return;
            }

            Control control = hostSurface.View as Control;

            control.Parent   = this;
            control.Dock     = DockStyle.Fill;
            control.Visible  = true;
            this.hostSurface = hostSurface;
        }
Esempio n. 9
0
        private void refreshMenuItem_Click(object sender, EventArgs e)
        {
            refresh();
            toolbox.RefreshControls();
            if (this.tabControl1.TabPages == null || this.tabControl1.TabPages.Count <= 0)
            {
                return;
            }
            var host = this.tabControl1.SelectedTab.Controls[0] as HostControl;

            if (host != null)
            {
                HostSurface hostSurface = host.HostSurface;
                SetupMenus(hostSurface);
            }
        }
Esempio n. 10
0
 private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.tabControl1.SelectedTab.Controls[0] is HostControl)
     {
         // Clicked on designer tab
         HostSurface hostSurface = (this.tabControl1.SelectedTab.Controls[0] as HostControl).HostSurface;
         this.toolbox.DesignerHost = hostSurface.DesignerHost;
         SetupMenus(hostSurface);
         this.propertyGrid.SetSelectedObjects(new object[] { hostSurface.DesignerHost.RootComponent });
     }
     else
     {
         // Clicked on Code tab
         HostSurface       hostSurface = tabControl1.SelectedTab.Tag as HostSurface;
         CodeEditorControl cec         = tabControl1.SelectedTab.Controls[0] as CodeEditorControl;
         cec.ShowText(hostSurface.GetCode(), cec.Language);
         SetupMenus(null);
         this.propertyGrid.SetSelectedObjects(null);
     }
 }
Esempio n. 11
0
        private void SetupMenus(HostSurface hostSurface)
        {
            foreach (MenuItem mi in menuItems)
            {
                mi.Dispose();
            }
            menuItems.Clear();
            if (hostSurface == null)
            {
                return;
            }
            IEnumerable <Lazy <Action <HostSurface>, ICommandMetadataView> > commands = hostSurface.HostSurfaceFactory.GetCommands();

            foreach (var command in commands)
            {
                bool     found   = false;
                MenuItem topMenu = null;
                foreach (MenuItem mi in this.mainMenu1.MenuItems)
                {
                    if (mi.Text == command.Metadata.Category)
                    {
                        found   = true;
                        topMenu = mi;
                    }
                }
                if (!found)
                {
                    topMenu = new MenuItem(command.Metadata.Category);
                    this.mainMenu1.MenuItems.Add(topMenu);
                    menuItems.Add(topMenu);
                }
                MenuItem realItem = new MenuItem(command.Metadata.Name);
                topMenu.MenuItems.Add(realItem);
                menuItems.Add(realItem);
                realItem.Tag    = new CommandAction(command.Value, hostSurface);
                realItem.Click += new EventHandler(realItem_Click);
            }
        }
Esempio n. 12
0
        public void RefreshFieldNodes(HostSurface Surface, Boolean IsNeedReload)
        {
            try
            {
                if (Surface == null || Surface.DesignerHost.RootComponent == null)
                {
                    this.DataSource = null;
                    this.RefreshDataSource();
                    return;
                }
                this.SuspendLayout();

                if (Surface.TreeFieldNodes == null || IsNeedReload)
                {
                    ReloadFieldNodes(Surface);
                }

                this.DataSource = Surface.TreeFieldNodes;
                this.RefreshDataSource();
                this.Refresh();
                if (this.Nodes.Count > 0)
                {
                    this.FocusedNode = this.Nodes[0];
                }

                this.ResumeLayout(false);

                foreach (DevExpress.XtraTreeList.Nodes.TreeListNode node in this.Nodes)
                {
                    ExpandTableNode(node);
                }
            }
            catch (Exception ex)
            {
                this.ResumeLayout(false);
            }
        }
Esempio n. 13
0
        public void RefreshList( )
        {
            DataList.Clear();
            HostSurface surface = (HostSurface)Studio.SurfaceManager.ActiveDesignSurface;

            if (surface == null)
            {
                return;
            }

            foreach (IComponent comp in surface.DesignerHost.Container.Components)
            {
                ComponentObject obj = new ComponentObject(comp.Site.Name, comp.GetType().Name);
                obj.Component = comp;
                DataList.Add(obj);
            }

            this.gridControl1.DataSource = DataList;
            this.gridControl1.RefreshDataSource();
            this.gridView1.OptionsBehavior.Editable = false;
            this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridView1.RowClick       += new DevExpress.XtraGrid.Views.Grid.RowClickEventHandler(gridView1_RowClick);
            this.gridView1.CustomDrawCell += new DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventHandler(gridView1_CustomDrawCell);
        }
Esempio n. 14
0
        public void CloseSurface(HostSurface surface)
        {
            if (surface == null)
            {
                return;
            }

            DevExpress.XtraTab.XtraTabPage currentTab = GetTabPageFromHostSurface(surface);
            if (currentTab == null)
            {
                return;
            }

            if (surface.UndoEngine.CanUndo)
            {
                ABCView view = (ABCView)surface.DesignerHost.RootComponent;
                if (view != null)
                {
                    DialogResult dlgResult = ABCHelper.ABCMessageBox.Show(String.Format(@"Do you want to save '{0}' View   ?", view.Name), "Message", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (dlgResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (dlgResult == DialogResult.Yes)
                    {
                        view.Save();
                    }
                }
            }

            OwnerStudio.SurfaceManager.CloseSurface(surface);

            OwnerStudio.TabViewControl.TabPages.Remove(currentTab);
            OwnerStudio.PropertyGrid.SelectedObject = null;
        }
Esempio n. 15
0
        public static void SelectAll(HostSurface hostSurface)
        {
            IMenuCommandService ims = hostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService;

            ims.GlobalInvoke(StandardCommands.SelectAll);
        }
Esempio n. 16
0
 public static void Run(HostSurface hostSurface)
 {
     (hostSurface.Loader as CodeDomHostLoader).Run();
 }
Esempio n. 17
0
        void Toolbar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (e.Item.Tag == null)
            {
                return;
            }


            if (e.Item.Tag.ToString().Contains("Skin"))
            {
                SetSkin(e.Item as DevExpress.XtraBars.BarCheckItem);
            }

            HostSurface surface = (HostSurface)SurfaceManager.ActiveDesignSurface;

            #region Tools
            if (e.Item.Tag.ToString() == "DataTable")
            {
                DatabaseManagement form = new DatabaseManagement(DatabaseManagement.ActiveTab.DataTable, this);
                form.ShowDialog();
            }
            if (e.Item.Tag.ToString() == "SP")
            {
                DatabaseManagement form = new DatabaseManagement(DatabaseManagement.ActiveTab.StoredProcedure, this);
                form.ShowDialog();
            }
            if (e.Item.Tag.ToString() == "TableConfig")
            {
                DatabaseManagement form = new DatabaseManagement(DatabaseManagement.ActiveTab.TableConfig, this);
                form.ShowDialog();
            }
            if (e.Item.Tag.ToString() == "FieldConfig")
            {
                DatabaseManagement form = new DatabaseManagement(DatabaseManagement.ActiveTab.FieldConfig, this);
                form.ShowDialog();
            }
            if (e.Item.Tag.ToString() == "EnumDefine")
            {
                DatabaseManagement form = new DatabaseManagement(DatabaseManagement.ActiveTab.EnumDefine, this);
                form.ShowDialog();
            }
            if (e.Item.Tag.ToString() == "GenDLL")
            {
                GenerationProvider.GenerateAll();
                ABCHelper.ABCMessageBox.Show("Done!");
            }
            #endregion

            #region Screens
            if (e.Item.Tag.ToString() == "BindConfig")
            {
                ConfigBinding();
            }
            if (e.Item.Tag.ToString() == "BindRefresh")
            {
                RefreshFieldBindingTree(true);
            }
            #endregion

            #region Standard
            if (e.Item.Tag.ToString() == "NewBlank")
            {
                Worker.AddNewForm();
            }
            if (e.Item.Tag.ToString() == "NewWizard")
            {
                new Wizard.NewView(this).ShowDialog();
            }
            if (e.Item.Tag.ToString() == "Save")
            {
                Worker.SaveCurrentView();
            }
            if (e.Item.Tag.ToString() == "Open")
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter           = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
                dlg.FilterIndex      = 2;
                dlg.RestoreDirectory = true;
                dlg.Title            = "Open Layout from XML file";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Worker.OpenFromXMLFile(dlg.FileName);
                }
            }
            #endregion

            if (this.SurfaceManager.ActiveDesignSurface == null)
            {
                return;
            }

            #region Surface

            if (e.Item.Tag.ToString() == "Close")
            {
                Worker.CloseActiveSurface();
            }

            if (e.Item.Tag.ToString() == "Refresh")
            {
                Worker.RefreshActiveSurface();
            }

            if (e.Item.Tag.ToString() == "Run")
            {
                Worker.TestCurrentScreen();
            }


            #region Layout
            if (e.Item.Tag.ToString() == "SelectAll")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.SelectAll);
            }
            if (e.Item.Tag.ToString() == "Delete")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Delete);
            }
            if (e.Item.Tag.ToString() == "Cut")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Cut);
            }
            if (e.Item.Tag.ToString() == "Copy")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Copy);
            }
            if (e.Item.Tag.ToString() == "Paste")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Paste);
            }
            if (e.Item.Tag.ToString() == "Undo")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Undo);
            }
            if (e.Item.Tag.ToString() == "Redo")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.Redo);
            }
            if (e.Item.Tag.ToString() == "Left")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignLeft);
            }
            if (e.Item.Tag.ToString() == "Center")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignVerticalCenters);
            }
            if (e.Item.Tag.ToString() == "Right")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignRight);
            }
            if (e.Item.Tag.ToString() == "Top")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignTop);
            }
            if (e.Item.Tag.ToString() == "Middle")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignHorizontalCenters);
            }
            if (e.Item.Tag.ToString() == "Bottom")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.AlignBottom);
            }
            if (e.Item.Tag.ToString() == "SameWidth")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.SizeToControlWidth);
            }
            if (e.Item.Tag.ToString() == "SameHeight")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.SizeToControlHeight);
            }
            if (e.Item.Tag.ToString() == "SameSize")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.SizeToControl);
            }
            if (e.Item.Tag.ToString() == "BringFront")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.BringToFront);
            }
            if (e.Item.Tag.ToString() == "BringEnd")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.SendToBack);
            }

            if (e.Item.Tag.ToString() == "HorizontalSpacingEqual")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.HorizSpaceMakeEqual);
            }
            if (e.Item.Tag.ToString() == "IncreaseHorizontal")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.HorizSpaceIncrease);
            }
            if (e.Item.Tag.ToString() == "DecreaseHorizontal")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.HorizSpaceDecrease);
            }
            if (e.Item.Tag.ToString() == "RemoveHorizontal")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.HorizSpaceConcatenate);
            }

            if (e.Item.Tag.ToString() == "VerticalSpacingEqual")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.VertSpaceMakeEqual);
            }
            if (e.Item.Tag.ToString() == "IncreaseVertial")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.VertSpaceIncrease);
            }
            if (e.Item.Tag.ToString() == "DecreaseVertical")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.VertSpaceDecrease);
            }
            if (e.Item.Tag.ToString() == "RemoveVertical")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.VertSpaceConcatenate);
            }

            if (e.Item.Tag.ToString() == "Locked")
            {
                surface.PerformAction(System.ComponentModel.Design.StandardCommands.LockControls);
            }

            #endregion

            #region DOCK
            if (e.Item.Tag.ToString() == "DockNone")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.None;
                }
            }

            if (e.Item.Tag.ToString() == "DockFill")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.Fill;
                }
            }
            if (e.Item.Tag.ToString() == "DockLeft")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.Left;
                }
            }
            if (e.Item.Tag.ToString() == "DockRight")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.Right;
                }
            }
            if (e.Item.Tag.ToString() == "DockTop")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.Top;
                }
            }
            if (e.Item.Tag.ToString() == "DockBottom")
            {
                foreach (Control ctrl in surface.ServiceSelection.GetSelectedComponents())
                {
                    ctrl.Dock = DockStyle.Bottom;
                }
            }
            #endregion

            #endregion
        }
Esempio n. 18
0
        protected override void OnDragDrop(System.Windows.Forms.DragEventArgs e)
        {
            base.OnDragDrop(e);

            Point pt = new Point(e.X, e.Y);

            //We need client coordinates.
            pt = PointToClient(pt);

            //Get the tab we are hovering over.
            TabPage hover_tab = GetTabPageByTab(pt);

            //Make sure we are on a tab.
            if (hover_tab != null)
            {
                //Make sure there is a TabPage being dragged.
                if (e.Data.GetDataPresent(typeof(TabPage)))
                {
                    e.Effect = DragDropEffects.Move;
                    TabPage drag_tab = (TabPage)e.Data.GetData(typeof(TabPage));

                    int item_drag_index     = FindIndex(drag_tab);
                    int drop_location_index = FindIndex(hover_tab);

                    HostSurface drag_surf = HostSurface.hostSurfaces[item_drag_index];

                    //Don't do anything if we are hovering over ourself.
                    if (item_drag_index != drop_location_index)
                    {
                        ArrayList pages    = new ArrayList();
                        ArrayList surfaces = new ArrayList();

                        //Put all tab pages into an array.
                        for (int i = 0; i < TabPages.Count; i++)
                        {
                            //Except the one we are dragging.
                            if (i != item_drag_index)
                            {
                                pages.Add(TabPages[i]);
                                surfaces.Add(HostSurface.hostSurfaces[i]);
                            }
                        }

                        //Now put the one we are dragging it at the proper location.
                        pages.Insert(drop_location_index, drag_tab);
                        surfaces.Insert(drop_location_index, drag_surf);

                        //Make them all go away for a nanosec.
                        TabPages.Clear();
                        HostSurface.hostSurfaces.Clear();

                        //Add them all back in.
                        TabPages.AddRange((TabPage[])pages.ToArray(typeof(TabPage)));
                        foreach (HostSurface surf in surfaces)
                        {
                            HostSurface.hostSurfaces.Add(surf);
                        }

                        //Make sure the drag tab is selected.
                        SelectedTab = drag_tab;

                        ITU.modified = true;
                    }
                }
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
Esempio n. 19
0
 public CommandAction(Action <HostSurface> action, HostSurface hostSurface)
 {
     Action      = action;
     HostSurface = hostSurface;
 }