Ejemplo n.º 1
0
 /// We are always using standard ToolboxItems, so they are always supported.
 bool System.Drawing.Design.IToolboxService.IsSupported(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
 {
     return(true);
 }
Ejemplo n.º 2
0
 public ToolboxItem GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host)
 {
     return(GetSelectedToolboxItem());
 }
Ejemplo n.º 3
0
 /// Get all of the tools. We're always using our current host though.
 ToolboxItemCollection System.Drawing.Design.IToolboxService.GetToolboxItems(System.ComponentModel.Design.IDesignerHost host)
 {
     return(toolbox.GetAllTools());
 }
Ejemplo n.º 4
0
        private void GetDataModule()
        {
            Project P = GlobalProject;

            ProjectItem PI;
            for (int I = 1; I <= P.ProjectItems.Count; I++)
            {
                PI = P.ProjectItems.Item(I);
                if (string.Compare(PI.Name, "Component." + FServerData.Language) == 0)
                {
                    string Path = PI.get_FileNames(0);
                    Path = System.IO.Path.GetDirectoryName(Path);
                    RenameNameSpace(Path + "\\Component." + FServerData.Language);
                    Window W = PI.Open("{00000000-0000-0000-0000-000000000000}");
                    W.Activate();
                    GlobalWindow = W;
                    GlobalPI = PI;
                    //return;//???
                    FDesignerHost = (IDesignerHost)W.Object;
                    FDataModule = (Component)FDesignerHost.RootComponent;
                    break;
                }
            }
        }
Ejemplo n.º 5
0
 private void btnDone_Click(object sender, EventArgs e)
 {
     if (currentStep == 2)
     {
         //產生Client Project
         if (checkStepCompleted(currentStep))
         {
             if (this._isWebReport)
             {
                 CreateWebClient();
             }
             else
             {
                 CreateWinClient();
             }
             if (GenSuccess)
             {
                 setWizardStep(currentStep + 1);
             }
         }
     }
     else
     {
         ReportParameter rptParams = GetRptParams();
         if (this._isWebReport)
         {
             Project proj = WebClientProject();
             if (proj != null)
             {
                 ProjectItem reportDir = ReportCreator.FindProjectItem(proj, rptParams.RptRootName);
                 if (reportDir == null)
                 {
                     //为Report创建文件夹
                     reportDir = ReportCreator.CreateProjectItem(proj, rptParams.RptRootName, 0);
                 }
                 ProjectItem piDataSet = ReportCreator.FindProjectItem(reportDir, rptParams.RptXSDFile);
                 if (piDataSet != null)
                 {
                     List<string> prtFileNames = new List<string>(new string[] { this.txtRptFileName.Text });
                     List<string> RealTableName = new List<string>(new string[] { this.tbTableNameF.Text });
                     if (this.chkIsMasterDetails.Checked)
                     {
                         prtFileNames.Add(this.txtDetailsRptFileName.Text);
                         RealTableName.Add(this.tbRealChildTableName.Text.Split(',')[0]);
                     }
                     ReportCreator.GenWebReportFiles(reportDir, piDataSet, rptParams, prtFileNames, RealTableName);
                     WebClientCreator.GenReportViewProperty(FDesignWindow, reportDir, chkIsMasterDetails.Checked, cmbRootName.SelectedItem.ToString(), txtRptFileName.Text);
                 }
             }
         }
         else
         {
             Project proj = WinClientProject(this.cmbProName.Text);
             ProjectItem piDataSet = ReportCreator.FindProjectItem(proj, rptParams.RptXSDFile);
             if (piDataSet != null)
             {
                 String lan = GetLanguage();
                 List<string> prtFileNames = new List<string>(new string[] { this.txtRptFileName.Text });
                 List<string> RealTableName = new List<string>(new string[] { this.tbTableNameF.Text });
                 if (this.chkIsMasterDetails.Checked)
                 {
                     prtFileNames.Add(this.txtDetailsRptFileName.Text);
                     RealTableName.Add(this.tbRealChildTableName.Text.Split(',')[0]);
                 }
                 ReportCreator.GenWinReportFiles(proj, piDataSet, rptParams, prtFileNames, RealTableName);
                 WinClientCreator.GetReportViewProperty(FRootForm, proj, chkIsMasterDetails.Checked, tbTableName.Text, tbPackageName.Text, tbFormName.Text, txtRptFileName.Text, tbChildTableName.Text, lan);
                 GlobalProject.Save(GlobalProject.FullName);
                 Solution sln = _dte2.Solution;
                 sln.Remove(GlobalProject);
                 string FilePath = tbOutputPath.Text + "\\" + tbPackageName.Text;
                 Project P = sln.AddFromFile(FilePath + "\\" + tbPackageName.Text + lan + "proj", false);
                 if (lan != ".vb")
                     P.Properties.Item("RootNamespace").Value = tbPackageName.Text;
                 sln.SaveAs(sln.FileName);
                 sln.SolutionBuild.StartupProjects = P;
                 sln.SolutionBuild.BuildProject(sln.SolutionBuild.ActiveConfiguration.Name, P.FullName, true);
                 GlobalProject = P;
                 _dte2.Solution.SolutionBuild.BuildProject(_dte2.Solution.SolutionBuild.ActiveConfiguration.Name,
                     GlobalProject.FullName, true);
                 foreach (ProjectItem PI in GlobalProject.ProjectItems)
                 {
                     if (PI.Name == tbFormName.Text + lan)
                     {
                         Window W = PI.Open("{00000000-0000-0000-0000-000000000000}");
                         W.Activate();
                         FDesignerHost = (IDesignerHost)W.Object;
                     }
                 }
             }
         }
         this.Close();
     }
 }
Ejemplo n.º 6
0
 /// We deserialize a ToolboxItem when we drop it onto our design surface.
 /// The ToolboxItem comes packaged in a DataObject. We're just working
 /// with standard tools and one host, so the host parameter is ignored.
 public ToolboxItem DeserializeToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
 {
     return((ToolboxItem)((DataObject)serializedObject).GetData(typeof(ToolboxItem)));
 }
        /// <summary>
        ///  Here is where all the fun stuff starts.  We create the structure and apply the naming here.
        /// </summary>
        private void CreateStandardMenuStrip(System.ComponentModel.Design.IDesignerHost host, MenuStrip tool)
        {
            // build the static menu items structure.
            string[][] menuItemNames = new string[][] {
                new string[] { SR.StandardMenuFile, SR.StandardMenuNew, SR.StandardMenuOpen, "-", SR.StandardMenuSave, SR.StandardMenuSaveAs, "-", SR.StandardMenuPrint, SR.StandardMenuPrintPreview, "-", SR.StandardMenuExit },
                new string[] { SR.StandardMenuEdit, SR.StandardMenuUndo, SR.StandardMenuRedo, "-", SR.StandardMenuCut, SR.StandardMenuCopy, SR.StandardMenuPaste, "-", SR.StandardMenuSelectAll },
                new string[] { SR.StandardMenuTools, SR.StandardMenuCustomize, SR.StandardMenuOptions },
                new string[] { SR.StandardMenuHelp, SR.StandardMenuContents, SR.StandardMenuIndex, SR.StandardMenuSearch, "-", SR.StandardMenuAbout }
            };

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

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

            Debug.Assert(host != null, "can't create standard menu without designer _host.");
            if (host == null)
            {
                return;
            }
            tool.SuspendLayout();
            ToolStripDesigner.s_autoAddNewItems = false;
            // create a transaction so this happens as an atomic unit.
            DesignerTransaction createMenu = _host.CreateTransaction(SR.StandardMenuCreateDesc);

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

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

                // now build the menu items themselves.
                for (int j = 0; j < menuItemNames.Length; j++)
                {
                    string[]          menuArray = menuItemNames[j];
                    ToolStripMenuItem rootItem  = null;
                    for (int i = 0; i < menuArray.Length; i++)
                    {
                        name = null;
                        // for separators, just use the default name.  Otherwise, remove any non-characters and  get the name from the text.
                        string itemText = menuArray[i];
                        name = NameFromText(itemText, typeof(ToolStripMenuItem), nameCreationService, true);
                        ToolStripItem item = null;
                        if (name.Contains("Separator"))
                        {
                            // create the componennt.
                            item = (ToolStripSeparator)_host.CreateComponent(typeof(ToolStripSeparator), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }
                            item.Text = itemText;
                        }
                        else
                        {
                            // create the componennt.
                            item = (ToolStripMenuItem)_host.CreateComponent(typeof(ToolStripMenuItem), name);
                            IDesigner designer = _host.GetDesigner(item);
                            if (designer is ComponentDesigner)
                            {
                                ((ComponentDesigner)designer).InitializeNewComponent(null);
                            }
                            item.Text = itemText;
                            Keys shortcut = menuItemShortcuts[j][i];
                            if ((item is ToolStripMenuItem) && shortcut != Keys.None)
                            {
                                if (!ToolStripManager.IsShortcutDefined(shortcut) && ToolStripManager.IsValidShortcut(shortcut))
                                {
                                    ((ToolStripMenuItem)item).ShortcutKeys = shortcut;
                                }
                            }
                            Bitmap image = null;
                            try
                            {
                                image = GetImage(menuItemImageNames[j][i]);
                            }
                            catch
                            {
                                // eat the exception.. as you may not find image for all MenuItems.
                            }
                            if (image != null)
                            {
                                PropertyDescriptor imageProperty = TypeDescriptor.GetProperties(item)["Image"];
                                Debug.Assert(imageProperty != null, "Could not find 'Image' property in ToolStripItem.");
                                if (imageProperty != null)
                                {
                                    imageProperty.SetValue(item, image);
                                }
                                item.ImageTransparentColor = Color.Magenta;
                            }
                        }

                        // the first item in each array is the root item.
                        if (i == 0)
                        {
                            rootItem = (ToolStripMenuItem)item;
                            rootItem.DropDown.SuspendLayout();
                        }
                        else
                        {
                            rootItem.DropDownItems.Add(item);
                        }
                        //If Last SubItem Added the Raise the Events
                        if (i == menuArray.Length - 1)
                        {
                            // member is OK to be null...
                            MemberDescriptor member = TypeDescriptor.GetProperties(rootItem)["DropDownItems"];
                            _componentChangeSvc.OnComponentChanging(rootItem, member);
                            _componentChangeSvc.OnComponentChanged(rootItem, member, null, null);
                        }
                    }

                    // finally, add it to the MainMenu.
                    rootItem.DropDown.ResumeLayout(false);
                    tool.Items.Add(rootItem);
                    //If Last SubItem Added the Raise the Events
                    if (j == menuItemNames.Length - 1)
                    {
                        // member is OK to be null...
                        MemberDescriptor topMember = TypeDescriptor.GetProperties(tool)["Items"];
                        _componentChangeSvc.OnComponentChanging(tool, topMember);
                        _componentChangeSvc.OnComponentChanged(tool, topMember, null, null);
                    }
                }
            }
            catch (Exception e)
            {
                if (e is InvalidOperationException)
                {
                    IUIService uiService = (IUIService)_provider.GetService(typeof(IUIService));
                    uiService.ShowError(e.Message);
                }
                if (createMenu != null)
                {
                    createMenu.Cancel();
                    createMenu = null;
                }
            }
            finally
            {
                ToolStripDesigner.s_autoAddNewItems = true;
                if (createMenu != null)
                {
                    createMenu.Commit();
                    createMenu = null;
                }
                tool.ResumeLayout();
                // Select the Main Menu...
                ISelectionService selSvc = (ISelectionService)_provider.GetService(typeof(ISelectionService));
                if (selSvc != null)
                {
                    selSvc.SetSelectedComponents(new object[] { _designer.Component });
                }
                //Refresh the Glyph
                DesignerActionUIService actionUIService = (DesignerActionUIService)_provider.GetService(typeof(DesignerActionUIService));
                if (actionUIService != null)
                {
                    actionUIService.Refresh(_designer.Component);
                }
                // this will invalidate the Selection Glyphs.
                SelectionManager selMgr = (SelectionManager)_provider.GetService(typeof(SelectionManager));
                selMgr.Refresh();
            }
        }
Ejemplo n.º 8
0
 public void AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, System.ComponentModel.Design.IDesignerHost host)
 {
 }
Ejemplo n.º 9
0
 public System.Drawing.Design.ToolboxItem DeserializeToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
 {
     return(null);
 }
Ejemplo n.º 10
0
 public void RemoveCreator(string format, System.ComponentModel.Design.IDesignerHost host)
 {
 }
Ejemplo n.º 11
0
 public void AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host)
 {
 }
Ejemplo n.º 12
0
 public bool IsToolboxItem(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
 {
     return(false);
 }
Ejemplo n.º 13
0
 public bool IsSupported(object serializedObject, System.ComponentModel.Design.IDesignerHost host)
 {
     return(false);
 }
Ejemplo n.º 14
0
 public ToolboxItemCollection GetToolboxItems(System.ComponentModel.Design.IDesignerHost host)
 {
     return(GetToolboxItems());
 }
Ejemplo n.º 15
0
 /// Add a ToolboxItem to our toolbox, in a specific category, bound to a certain host.
 public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host)
 {
     // UNIMPLEMENTED - We didn't end up doing a project system, so there's no need
     // to add custom tools (despite that we do have a tab for such tools).
 }
Ejemplo n.º 16
0
 public System.Drawing.Design.ToolboxItem GetSelectedToolboxItem(System.ComponentModel.Design.IDesignerHost host)
 {
     return(this.GetSelectedToolboxItem());
 }
Ejemplo n.º 17
0
 /// Add a ToolboxItem to our toolbox, bound to a certain host.
 void System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(ToolboxItem toolboxItem, System.ComponentModel.Design.IDesignerHost host)
 {
     // UNIMPLEMENTED - We didn't end up doing a project system, so there's no need
     // to add custom tools (despite that we do have a tab for such tools).
 }
Ejemplo n.º 18
0
 public System.Drawing.Design.ToolboxItemCollection GetToolboxItems(string category, System.ComponentModel.Design.IDesignerHost host)
 {
     return(this.GetToolboxItems());
 }
Ejemplo n.º 19
0
 private void GetDataModule()
 {
     Solution Sln = FDTE2.Solution;
     Project P = null;
     int I;
     for (I = 1; I <= Sln.Projects.Count; I++)
     {
         P = Sln.Projects.Item(I);
         if (string.Compare(FServerData.PackageName, P.Name) == 0)
             break;
         P = null;
     }
     if (P == null)
         throw new Exception("Can not find project " + FServerData.PackageName + " in solution");
     ProjectItem PI;
     for (I = 1; I <= P.ProjectItems.Count; I++)
     {
         PI = P.ProjectItems.Item(I);
         if (string.Compare(PI.Name, "Component." + FServerData.Language) == 0)
         {
             string Path = PI.get_FileNames(0);
             Path = System.IO.Path.GetDirectoryName(Path);
             RenameNameSpace(Path + "\\Component." + FServerData.Language);
             Window W = PI.Open("{00000000-0000-0000-0000-000000000000}");
             W.Activate();
             GlobalWindow = W;
             GlobalPI = PI;
             //return;//???
             FDesignerHost = (IDesignerHost)W.Object;
             FDataModule = (Component)FDesignerHost.RootComponent;
         }
     }
 }
Ejemplo n.º 20
0
 /// Add a creator that will convert non-standard tools in the specified format into ToolboxItems, to be associated with a host.
 public void AddCreator(System.Drawing.Design.ToolboxItemCreatorCallback creator, string format, System.ComponentModel.Design.IDesignerHost host)
 {
     // UNIMPLEMENTED - We aren't handling any non-standard tools here. Our toolset is constant.
 }
Ejemplo n.º 21
0
        //</Snippet3>


        //<Snippet4>
        public ToolboxComponentsCreatingEventArgs CreateToolboxComponentsCreatingEventArgs(System.ComponentModel.Design.IDesignerHost host)
        {
            ToolboxComponentsCreatingEventArgs e = new ToolboxComponentsCreatingEventArgs(host);

            // The designer host of the document receiving the components        e.DesignerHost
            return(e);
        }
Ejemplo n.º 22
0
 /// Remove the creator for the specified format, associated with a particular host.
 public void RemoveCreator(string format, System.ComponentModel.Design.IDesignerHost host)
 {
     // UNIMPLEMENTED - We aren't handling any non-standard tools here. Our toolset is constant.
 }
Ejemplo n.º 23
0
        private void GetWebDesignerHost(ProjectItem projItem)
        {
            #if VS90
            //FDesignWindow = projItem.Open("{7651A702-06E5-11D1-8EBD-00A0C90F26EA}");
            FDesignWindow = projItem.Open(Constants.vsViewKindDesigner);
            FDesignWindow.Activate();

            HTMLWindow W = (HTMLWindow)FDesignWindow.Object;

            W.CurrentTab = vsHTMLTabs.vsHTMLTabsDesign;
            if (W.CurrentTabObject is WebDevPage.DesignerDocument)
            {
                FDesignerDocument = W.CurrentTabObject as WebDevPage.DesignerDocument;
            }
            #else
            FDesignWindow = projItem.Open("{00000000-0000-0000-0000-000000000000}");
            FDesignWindow.Activate();
            FDesignWindow = projItem.Open("{7651A702-06E5-11D1-8EBD-00A0C90F26EA}");
            FDesignWindow.Activate();
            HTMLWindow W = (HTMLWindow)FDesignWindow.Object;
            object o = W.CurrentTabObject;
            IntPtr pObject;
            Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleSP = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)o;
            Guid sid = typeof(IVSMDDesigner).GUID;
            Guid iid = typeof(IVSMDDesigner).GUID;
            int hr = oleSP.QueryService(ref sid, ref iid, out pObject);
            System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(hr);
            if (pObject != IntPtr.Zero)
            {
                try
                {
                    Object TempObj = Marshal.GetObjectForIUnknown(pObject);
                    if (TempObj is IDesignerHost)
                    {
                        FDesignerHost = (IDesignerHost)TempObj;
                    }
                    else
                    {
                        Object ObjContainer = TempObj.GetType().InvokeMember("ComponentContainer",
                            System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public |
                            System.Reflection.BindingFlags.GetProperty, null, TempObj, null);
                        if (ObjContainer is IDesignerHost)
                        {
                            FDesignerHost = (IDesignerHost)ObjContainer;
                        }
                    }
                    FPage = (System.Web.UI.Page)FDesignerHost.RootComponent;
                    //NotifyRefresh(200);
                    Application.DoEvents();
                }
                finally
                {
                    Marshal.Release(pObject);
                }
            }
            #endif
        }
Ejemplo n.º 24
0
 ///  Get all the tools in a category.
 public ToolboxItemCollection GetToolboxItems(string category, System.ComponentModel.Design.IDesignerHost host)
 {
     return(toolbox.GetToolsFromCategory(category));
 }
Ejemplo n.º 25
0
 private void GenWinForm(WinClientParam winParam, ClientParam cParam)
 {
     Solution Sln = _dte2.Solution;
     Project P = null;
     int I;
     for (I = 1; I <= Sln.Projects.Count; I++)
     {
         P = Sln.Projects.Item(I);
         if (string.Compare(winParam.PackageName, P.Name) == 0)
             break;
         P = null;
     }
     if (P == null)
         throw new Exception("Can not find project " + winParam.PackageName + " in solution");
     ProjectItem PI;
     String lan = GetLanguage();
     for (I = P.ProjectItems.Count; I >= 1; I--)
     {
         PI = P.ProjectItems.Item(I);
         if (string.Compare(PI.Name, "Form1" + lan) == 0)
         {
             string Path = PI.get_FileNames(0);
             Path = System.IO.Path.GetDirectoryName(Path);
             RenameNameSpace(Path + "\\Form1" + lan, winParam.PackageName, cParam.FormName);
             RenameNameSpace(Path + "\\Form1.Designer" + lan, winParam.PackageName, cParam.FormName);
             Window W = PI.Open("{00000000-0000-0000-0000-000000000000}");
             W.Activate();
             GlobalPI = PI;
             GlobalWindow = W;
             if (string.Compare(cParam.FormName, "Form1") != 0)
             {
                 PI.Name = cParam.FormName + lan;
                 W.Close(vsSaveChanges.vsSaveChangesYes);
                 W = PI.Open("{00000000-0000-0000-0000-000000000000}");
                 W.Activate();
             }
             FDesignerHost = (IDesignerHost)W.Object;
             FRootForm = (System.Windows.Forms.Form)FDesignerHost.RootComponent;
             FRootForm.Name = cParam.FormName;
             FRootForm.Text = cParam.FormTitle;
             IComponentChangeService FComponentChangeService = (IComponentChangeService)FDesignerHost.RootComponent.Site.GetService(typeof(IComponentChangeService));
         }
         if (string.Compare(PI.Name, "Program" + lan) == 0)
         {
             RenameNameSpace(PI.get_FileNames(0), winParam.PackageName, cParam.FormName);
         }
     }
 }
Ejemplo n.º 26
0
 public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host)
 {
 }