Space Data Management Platform 3 (C # Development) based on ArcGIS10.0 and Oracle10g-Multi-skin main interface function

Source: Internet
Author: User

The previous article introduced the implementation of simple login functions, and explained the SQL help classes. The constructor of the SqlHelper class has two methods to initialize the connection string, which are reflected in the Code. One is to directly assign values to the required connection string, in this way, the connection information of your specific database is invisible to others, but it is not convenient to modify. The code needs to be modified and re-compiled every time you modify the database. The second method is to configure it in the configuration file, in this way, when our system runs on another computer, we only need to modify the connection string information in the configuration file, which is very convenient. Let's take a brief look at the class content of the configuration file and explain the significance of each configuration option in the configuration file.

<?xml version="1.0" encoding="utf-8" ?><configuration>  <appSettings>    <!--<add key="ConnectionString" value="Data Source=scdzyj;Persist Security Info=True;User ID=dzyj;Password=dzyj;Unicode=True" />-->    <add key="ConnectionString" value="Data Source=BRUCEWOO;Persist Security Info=True;User ID=sde;Password=sde;Unicode=True;" />    <!--<add key="SERVER" value="10.51.6.233"/>-->    <add key="SERVER" value="127.0.0.1"/>    <add key="INSTANCE" value="port:5151"/>    <add key="USER" value="sde"/>    <add key="PASSWORD" value="sde"/>    <add key="DATABASE" value="sde"/>    <add key="VERSION" value="SDE.DEFAULT"/>  </appSettings></configuration>

 

 

The preceding configuration file <! --> Is the comment out content. The configured key can access the value of value through the following code:

 

ConfigurationSettings. etettings ["ConnectionString"]; // The Code retrieves the value corresponding to the ConnectionString keyword.

 

In addition to connecting Oracle10g, the configuration file of this system is also used to connect to the spatial database. I will introduce it in detail when it involves operations on the spatial database, this article introduces how to connect to a spatial database, because it is quite different from connecting to a general relational database!

After successful login, we will enter the main interface of the entire system. the main interface adopts the office2007 interface style and implements a variety of interface skins, which can be switched at will, another important function is to implement multi-tag interfaces. These functions are implemented using a third-party interface library. Here we will not detail the use of this interface library. However, it is a pity that such a good library will not be used. Therefore, you can upload a video to the CSDN Download Area for download and use by friends who need it. For details, see http://download.csdn.net/detail/wanweiaiaqiang/381289. If not, search for the Resource Name "video tutorial of the office style interface library" in the download area ". If you have a video tutorial, you must have an Office2007 library file. This library file is provided in a relatively simple way and requires no installation or registration, because it is provided as a DLL file, you only need to import this DLL file to the Reference Directory in your project, similarly, I uploaded this file to the CSDN Download Zone for download by the users who need it. (do not worry about the need for many resources. After all, I think it is worth something. If I didn't have these, I don't have to hesitate to pay 20 credits for anyone who gives me this offer. I would like to ask everyone to comment more when downloading and try more to help others get the points, I am very disgusted with the kind of people who only know the request and do not contribute), is ". I believe most people should know how to load DLL files to their own projects. I will explain this process in detail to a few bloggers. First, find the small window of the solution and find the referenced directory, as shown in:

Right-click and select the first item "add reference (R )... ", this will pop up a window for adding reference, and then switch to the browser interface, find the DLL file (download CSDN, I uploaded), as shown in:

Then click the OK button to complete a function library in the form of a DLL file.

Next we will introduce the functions implemented on the main interface. In fact, the login function is also called in this main interface function, but it's just a relatively early call, it is called in the constructor of the class on the main interface. The constructor of the main interface is implemented as follows:

 

                public FrmMain()        {            Thread t = new Thread(Login);            t.Start();            //m_AoInitialize = new AoInitializeClass();            //esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;            //licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);                        InitializeComponent();            isInitFinish = true;            while (username == null || username == "")            {                ;            }        }

 

The above code first starts a login thread. Why do we need to use a separate thread to log on? Because it takes dozens of seconds to initialize ArcGIS later. In order to prevent users from waiting too long, therefore, when the user enters the login user name and password, it has begun to initialize the relevant components of ArcGIS. This is also a small aspect to improve user experience, but do not do it because it is small, only by doing this in the most delicate way can we satisfy our system users. The annotated code is used to initialize the License of ArcGIS. Because ArcGIS is a paid software, and the fee is not low (the fees vary depending on the function, the Enterprise Edition is the most expensive, and the function is of course the strongest ), therefore, you have to purchase his License for ArcGIS development. When I was a part-time employee, the company provided these Licnese services. Of course, there were cracked versions on the Internet. I tried some of them and some of them were actually usable, we will not recommend it here (we still respect others' knowledge versions, because we are also doing software development); but there is another way to use it, arcGIS provides a way for students to apply for a time period from the official website, and can continue to apply after the time period expires (I have not tried this, I heard from one of our colleagues). If you are interested, you can try it. If you are successful, you can write a blog to introduce some specific application processes, and leave a message to this blog. Because my time is also very limited, I need to go to work during the day and study new technologies after work, such as cloud computing, cloud storage, distributed computing, and distributed file systems, of course, I also have my favorite linux source code. I recently studied the linux kernel of linux3.1.RC4 and shared it among other companies. I like technology discussion and sharing. If anyone wants to discuss technology with me, I will not feel that it is too much time for three days and three nights. However, everyone has limited time and learning is still limited. Therefore, they can learn more quickly only through more communication and sharing, you see, basically all my blogs are completed after AM. The reason for this comment is that I dragged a control with the same function during the interface design (the effects of the two methods are the same, but the drag is convenient and simple, in addition, you must drag the control provided by ArcGIS before using the interface design. Otherwise, the use is forbidden and an error is reported ). Then, a bool variable is used to check whether the user has logged on, because the user may remain in the logon status. If the user does not determine whether the user is logged on, the user will directly go to the main interface (because the initialization may be completed at any time ), the username value is not null here for determination, because in the login function (that is, the thread entry function) if the user name is successfully initialized (which is also easy to use later), the Code is as follows:

 

// Login thread, in order to make License initialization and synchronization, shorten the user wait time private void Login () {FrmUserLogin ful = new FrmUserLogin (); ful. showDialog (); username = ful. getUsername ();}

 

Next let's take a look at how the multi-skin interface is implemented through code. The detailed implementation process is described in the video above. The Code is as follows:

 

 

Multi-Tag feature implementation

        private void CommandTheme_Executed(object sender, EventArgs e)        {            ICommandSource source = sender as ICommandSource;            if (source.CommandParameter is string)            {                eOffice2007ColorScheme colorScheme = (eOffice2007ColorScheme)Enum.Parse(typeof(eOffice2007ColorScheme), source.CommandParameter.ToString());                ribbonControl1.Office2007ColorTable = colorScheme;            }            else if (source.CommandParameter is Color)            {                RibbonPredefinedColorSchemes.ChangeOffice2007ColorTable(this, m_BaseColorScheme, (Color)source.CommandParameter);            }            this.Invalidate();        }

 

As shown in the following figure, This is different from the one introduced in the video. It is found that there will be some bugs later (the bug of Multi-tag switching to maximize the result). The following code can solve the problem:

 

/// <Summary> /// check whether a child form has been opened. If yes, true is returned; otherwise, false is returned. Prevent opening multiple identical forms /// </summary> /// <param name = "tabName"> form name </param> /// <returns> </returns> public bool IsOpenTab (string tabName) {bool isOpened = false; foreach (Form child in this. mdichilname) {if (tabName = child. text) {child. windowState = FormWindowState. maximized;} else {child. windowState = FormWindowState. normal;} foreach (TabItem tab in tabStrip1.Tabs) {if (tab. text. trim () = tabName) {isOpened = true; tabStrip1.SelectedTab = tab; break;} return isOpened ;}

 

The first foreach loop in the code above first traverses all the subwindows (nested in the main window) based on the subwindow name. If the previous window status (size status) exists) changes to the normal state, so that the newly created window can be displayed to the maximum extent (if this happens, the program may exit or exit after an error is reported). It is willing to maximize the subwindow competition, at the same time, only one maximized subwindow can be allowed. The second foreach loop is to make the new sub-window in the open state, and let the stop bar select the new window to display (a bar control, all subwindows are stuck in the form of tags. Click these tags to switch to the subwindow display ).

The following code creates a subwindow Based on the function of each button (either a subwindow or a modal window is displayed, and all the remaining dialog boxes are non-modal, for the differences between modal and non-modal modes, You can query google ).

 

// General database management private void DataEdit_Click (object sender, EventArgs e) {string tabName = "Data Management"; if (! IsOpenTab (tabName) {FrmDataManager dm = new FrmDataManager (); dm. mdiParent = this; dm. windowState = FormWindowState. maximized; dm. show () ;}// layer classification definition private void LayerManager_Click (object sender, EventArgs e) {string tabName = "layer Hierarchy Standard definition"; if (! IsOpenTab (tabName) {FrmLayerStandDefine dm = new FrmLayerStandDefine (); dm. mdiParent = this; dm. windowState = FormWindowState. maximized; dm. show () ;}// import space data to private void SpatialDataImport_Click (object sender, EventArgs e) {FrmSelectFileFormat fsff = new FrmSelectFileFormat (); fsff. showDialog ();} private void FrmMain_Load (object sender, EventArgs e) {SqlHelper sh = new SqlHelper (); string s Ql = "select department from jcsjk_users where username = '" + username + "'"; OracleDataReader ord = sh. returnDataReader (SQL); if (ord. read () {department = ord [0]. toString () ;}// log management private void lookLogBtn_Click (object sender, EventArgs e) {string tabName = "log management"; if (! IsOpenTab (tabName) {LogManager lm = new LogManager (); lm. mdiParent = this; lm. windowState = FormWindowState. maximized; lm. show () ;}// metadata management private void MetaDatabaseManager_Click (object sender, EventArgs e) {if (! MetaIsLgoin) {FrmUserLogin ful = new FrmUserLogin (); ful. userType = 2; ful. ShowDialog () ;}if (! MetaIsLgoin) {return;} string tabName = "metabase management"; if (! IsOpenTab (tabName) {FrmMetaDataBaseManage fmdbm = new FrmMetaDataBaseManage (); fmdbm. mdiParent = this; fmdbm. windowState = FormWindowState. maximized; fmdbm. show () ;}// export space data private void SpatialDataExport_Click (object sender, EventArgs e) {FrmDataExport fde = new FrmDataExport (); fde. showDialog ();} // edit the space data private void DataUpdate_Click (object sender, EventArgs e) {/* string tabName = "data update "; If (! IsOpenTab (tabName) {FrmDataUpdate fsl = new FrmDataUpdate (); fsl. text = "Data Update"; fsl. mdiParent = this; fsl. windowState = FormWindowState. maximized; SqlHelper sh = new SqlHelper (); string SQL = string. empty; SQL = "select table_name from layer where type = 'py' or type = 'pl 'or type = 'pt'"; OracleDataReader odr = sh. returnDataReader (SQL); while (odr. read () {fsl. addLayerToMapCtl (odr [0]. toString (), tru E);} fsl. show ();} FrmDataUpdate fsl = new FrmDataUpdate (); fsl. text = "Data Update"; SqlHelper sh = new SqlHelper (); string SQL = string. empty; SQL = "select table_name from layer where type = 'py' or type = 'pl 'or type = 'pt'"; OracleDataReader odr = sh. returnDataReader (SQL); while (odr. read () {fsl. addLayerToMapCtl (odr [0]. toString (), true);} fsl. showDialog (); */string tabName = "spatial data editing"; if (! IsOpenTab (tabName) {FrmSpatialDataEdit fsde = new FrmSpatialDataEdit (); fsde. mdiParent = this; fsde. windowState = FormWindowState. maximized; fsde. show () ;}// edit the data dictionary private void DataDictionaryEdit_Click (object sender, EventArgs e) {string tabName = "Data Dictionary Editing"; if (! IsOpenTab (tabName) {FrmDataDictionaryEdit dde = new FrmDataDictionaryEdit (); dde. mdiParent = this; dde. windowState = FormWindowState. maximized; dde. show () ;}// data dictionary query private void DataDictionaryQuery_Click (object sender, EventArgs e) {string tabName = "data dictionary query"; if (! IsOpenTab (tabName) {FrmDataDictionaryQuery fddq = new FrmDataDictionaryQuery (); fddq. mdiParent = this; fddq. windowState = FormWindowState. maximized; fddq. show () ;}// image library management private void MapLibManagement_Click (object sender, EventArgs e) {string tabName = "Image Library Management"; if (! IsOpenTab (tabName) {FrmMapLibManagement fdx = new FrmMapLibManagement (); fdx. mdiParent = this; fdx. windowState = FormWindowState. maximized; fdx. show () ;}// exit the system private void ExitSystem_Click (object sender, EventArgs e) {Application. exit ();} // metadata edit private void metaDataEdit_Click (object sender, EventArgs e) {if (! MetaIsLgoin) {FrmUserLogin ful = new FrmUserLogin (); ful. userType = 2; ful. ShowDialog () ;}if (! MetaIsLgoin) {return;} else {string tabName = "metadata editing"; if (! IsOpenTab (tabName) {FrmMetaDataEdit fmde = new FrmMetaDataEdit (); fmde. mdiParent = this; fmde. windowState = FormWindowState. maximized; fmde. show () ;}}// metadata Directory management private void MetaDataDirManager_Click (object sender, EventArgs e) {if (! MetaIsLgoin) {FrmUserLogin ful = new FrmUserLogin (); ful. userType = 2; ful. ShowDialog () ;}if (! MetaIsLgoin) {return;} else {string tabName = "metadata Directory management"; if (! IsOpenTab (tabName) {FrmDirManager OFDM = new FrmDirManager (); OFDM. mdiParent = this; OFDM. windowState = FormWindowState. maximized; OFDM. show () ;}}// metadata query subsystem private void MetaDataQuery_Click (object sender, EventArgs e) {if (! MetaIsLgoin) {FrmUserLogin ful = new FrmUserLogin (); ful. userType = 2; ful. ShowDialog () ;}if (! MetaIsLgoin) {return;} else {string tabName = "Metadata Query System"; if (! IsOpenTab (tabName) {FrmMetaDataQuery fmdq = new FrmMetaDataQuery (); fmdq. mdiParent = this; fmdq. windowState = FormWindowState. maximized; fmdq. show () ;}}// metadata Import and Export private void MetaDataImport_Click (object sender, EventArgs e) {if (! MetaIsLgoin) {FrmUserLogin ful = new FrmUserLogin (); ful. userType = 2; ful. ShowDialog () ;}if (! MetaIsLgoin) {return;} else {string tabName = "metadata Import and Export"; if (! IsOpenTab (tabName) {FrmMetaDataImport fmde = new FrmMetaDataImport (); fmde. mdiParent = this; fmde. windowState = FormWindowState. maximized; fmde. show () ;}}// data statistics private void DataStatistics_Click (object sender, EventArgs e) {string tabName = "Data Statistics"; if (! IsOpenTab (tabName) {F_map fm = new F_map (); fm. mdiParent = this; fm. windowState = FormWindowState. maximized; fm. show () ;}// Standard import private void StandImport_Click (object sender, EventArgs e) {FrmLayerStandImport flsi = new FrmLayerStandImport (); flsi. showDialog () ;}// dataset management private void DataSetManage_Click (object sender, EventArgs e) {string tabName = "dataset management"; if (! IsOpenTab (tabName) {FrmDataSetManage fdsm = new FrmDataSetManage (); fdsm. mdiParent = this; fdsm. windowState = FormWindowState. maximized; fdsm. show () ;}// query attribute data private void DataAttributeQuery_Click (object sender, EventArgs e) {string tabName = "Spatial Data Attribute query"; if (! IsOpenTab (tabName) {FrmAttributeQuery faq = new FrmAttributeQuery (); faq. mdiParent = this; faq. windowState = FormWindowState. maximized; faq. show () ;}// space query private void SpatialQuery_Click (object sender, EventArgs e) {string tabName = "Space query"; if (! IsOpenTab (tabName) {FrmSpatialQuery fsq = new FrmSpatialQuery (); fsq. mdiParent = this; fsq. windowState = FormWindowState. maximized; fsq. show () ;}// Database Backup private void DatabaseBackup_Click (object sender, EventArgs e) {FrmDatabaseBackup fdb = new FrmDatabaseBackup (); fdb. showDialog ();} // restore the database private void RestoreDatabase_Click (object sender, EventArgs e) {FrmRestoreDatabase frd = new FrmResto ReDatabase (); frd. showDialog () ;}// view monitoring logs private void InspectLogShow_Click (object sender, EventArgs e) {FrmShowInspectLog fsil = new FrmShowInspectLog (); fsil. showDialog () ;}// O & M system and system private void OperationMaintain_Click (object sender, EventArgs e) {string tabName = "O & M system and system"; if (! IsOpenTab (tabName) {FrmOperationMaintain fom = new FrmOperationMaintain (); fom. mdiParent = this; fom. windowState = FormWindowState. maximized; fom. show () ;}// database monitoring and optimization private void Inspect_Click (object sender, EventArgs e) {string tabName = "database monitoring and optimization"; if (! IsOpenTab (tabName) {FrmDatabaseInspect fdi = new FrmDatabaseInspect (); fdi. MdiParent = this; fdi. WindowState = FormWindowState. Maximized; fdi. Show ();}}

 

A specific function above represents the function entry of a sub-module or sub-system. In the future, sub-functions and sub-system functions will be implemented on their own interfaces and classes.

All the functions on the main interface have been introduced, and now it is am. Although I will not go to work tomorrow and Saturday, I still need to do something very annoying, in addition, a relatively distant door (relative to Kazakhstan) is required, because a good junior high school girl is about to step into the marriage hall!

Good night and good morning!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.