⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 installerdialog.cs

📁 以前做NOKIA手机与PC通信时所参考的源代码,里面包括两个程序,一个是手机文件夹浏览源码,另一个手机SIS安装程序.
💻 CS
📖 第 1 页 / 共 4 页
字号:
                            pDevices[i] = (CONADefinitions.CONAPI_DEVICE)Marshal.PtrToStructure(ptr, typeof(CONADefinitions.CONAPI_DEVICE));
                            // Add item to combo
                            strCombo = pDevices[i].pstrFriendlyName;
                            this.ComboPhone.Items.Add(strCombo);
                            strSerialNumbers[i] = pDevices[i].pstrSerialNumber;
                        }
                        this.ComboPhone.Enabled = true;
                        this.ComboPhone.SelectedIndex = 0;
                        // Free memory allocated by CONAGetDevices
                        iResult = CONADeviceManagement.CONAFreeDeviceStructure(iCount, buffer);
                        if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("CONAFreeDeviceStructure", iResult);
                    }
                    Marshal.FreeHGlobal(buffer);
                }
                else
                {
                    this.ComboPhone.Text = "No phones connected";
                    this.ComboPhone.Enabled = false;
                    this.ComboPhone.SelectedIndex = -1;
                }
                Timer1.Enabled = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(),"Exception");
            }
        }

        //===================================================================
        // TypeSelectionChanged
        //
        // User has changed installation type from combobox,
        // so make some UI changes
        //
        //===================================================================
        private void TypeSelectionChanged()
        {
            TextJar.Text = "";
            TextJad.Text = "";
            TextSis.Text = "";
            TextNth.Text = "";
            TextJad.Enabled = false;
            TextJar.Enabled = false;
            TextSis.Enabled = false;
            TextNth.Enabled = false;
            TextNGage.Enabled = false;
            CommandJar.Enabled = false;
            CommandJad.Enabled = false;
            CommandSis.Enabled = false;
            CommandNth.Enabled = false;
            CommandNGage.Enabled = false;
            string strItem = ComboType.SelectedItem.ToString();
            if(strItem == strJavaItem)
                iInstallationType = INSTALL_TYPE_JAVA;
            else if(strItem == strSymbianItem)
                iInstallationType = INSTALL_TYPE_SYMBIAN;
            else if(strItem == strThemesItem)
                iInstallationType = INSTALL_TYPE_THEMES;
            else if (strItem == strNGageItem)
                iInstallationType = INSTALL_TYPE_NGAGE;
            switch (iInstallationType)
            {
                case INSTALL_TYPE_JAVA:
                    TextJad.Enabled = true;
                    TextJar.Enabled = true;
                    CommandJar.Enabled = true;
                    CommandJad.Enabled = true;
                    break;
                case INSTALL_TYPE_NGAGE:
                    TextNGage.Enabled = true;
                    CommandNGage.Enabled = true;
                    break;
                case INSTALL_TYPE_SYMBIAN:
                    TextSis.Enabled = true;
                    CommandSis.Enabled = true;
                    break;
                case INSTALL_TYPE_THEMES:
                    TextNth.Enabled = true;
                    CommandNth.Enabled = true;
                    break;
                default:
                    // This should never happen, but...
                    TextJad.Enabled = false;
                    TextJar.Enabled = false;
                    CommandJar.Enabled = false;
                    CommandJad.Enabled = false;
                    TextNGage.Enabled = false;
                    CommandNGage.Enabled = false;
                    TextSis.Enabled = false;
                    CommandSis.Enabled = false;
                    TextNth.Enabled = false;
                    CommandNth.Enabled = false;
                    break;
            }
        }
        //===================================================================
        // SetProgress
        //
        // Sets progress bar state
        //
        //===================================================================
        public void SetProgress(int iState)
        {
            ProgressBar1.Value = iState;
        }

        //===================================================================
        // IsCancelled
        //
        // Returns true if user has clicked Cancel button
        //
        //===================================================================
        public bool IsCancelled()
        {
            bool functionReturnValue = false;
            Application.DoEvents();
            functionReturnValue = bCancelled;
            bCancelled = false;
            return functionReturnValue;
        }

        //===================================================================
        // UninitializePCCAPI
        //
        // Uninitialize Nokia PC Connectivity API
        //
        //===================================================================
        private void UninitializePCCAPI()
        {
            try
            {
                int iResult;

                // Unregister device notification callback function
                iResult = CONADeviceManagement.CONARegisterNotifyCallback(Common.hDMHandle, CONADefinitions.API_UNREGISTER, pDeviceCallBack);
                if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("CONARegisterNotifyCallback", iResult);
                // Close device management handle
                iResult = CONADeviceManagement.CONACloseDM(Common.hDMHandle);
                if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("CONACloseDM", iResult);
                // Uninitialize Nokia PC Connectivity API

                // Terminate File System API
                iResult = CONAFileSystem.FSAPI_Terminate(IntPtr.Zero);
                if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FSAPI_Terminate", iResult);

                // Terminate Device Management APi
                iResult = CONADeviceManagement.DMAPI_Terminate(0);
                if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("DMAPI_Terminate", iResult);

                Application.Exit();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(),"Exception");
            }
        }

        //===================================================================
        // InstallerDialog_Load
        //
        // Initialization of InstallerDialog form
        //
        //===================================================================
        private void InstallerDialog_Load(object sender, System.EventArgs e)
        {
            int iResult;
            Common.MainForm = this;
            bCancelled = false;
            ProgressBar1.Minimum = 0;
            ProgressBar1.Maximum = 100;
            ProgressBar1.Value = 0;

            // Initialize Device Management APi
            iResult = CONADeviceManagement.DMAPI_Initialize(CONADeviceManagement.DMAPI_VERSION_32, 0);
            if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("DMAPI_Initialize", iResult);
            // Initialize File System APi
            iResult = CONAFileSystem.FSAPI_Initialize(CONAFileSystem.FSAPI_VERSION_32, IntPtr.Zero);
            if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("FSAPI_Initialize", iResult);

            // Get Device management handle
            iResult = CONADeviceManagement.CONAOpenDM(ref Common.hDMHandle);
            if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("CONAOpenDM", iResult);
            // Register device notification callback function
            pDeviceCallBack = Common.DeviceNotifyCallback;
            iResult = CONADeviceManagement.CONARegisterNotifyCallback(Common.hDMHandle, CONADefinitions.API_REGISTER, pDeviceCallBack);
            if (iResult != PCCSErrors.CONA_OK) PCCAPIUtils.ShowErrorMessage("CONARegisterNotifyCallback", iResult);
            // Get connected devices list
            Timer1.Enabled = true;
            Timer1.Start();
            //Refresh phonelist
            bRefreshPhonecombo = true;
        }

        //===================================================================
        // ComboType_SelectedIndexChanged
        //
        // User has changed installation type from combobox
        //
        //===================================================================
        private void ComboType_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            TypeSelectionChanged();
        }

        //=========================================================
        // CommandJar_Click 
        //
        // Opens file open dialog for selecting a file
        //
        //=========================================================
        private void CommandJar_Click(object eventSender, System.EventArgs eventArgs)
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Jar files (*.jar)|*.jar";
            openFileDialog.FilterIndex = 0;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TextJar.Text = openFileDialog.FileName;
            }
        }

        //=========================================================
        // CommandJad_Click 
        //
        // Opens file open dialog for selecting a file
        //
        //=========================================================
        private void CommandJad_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Jad files (*.jad)|*.jad";
            openFileDialog.FilterIndex = 0;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TextJad.Text = openFileDialog.FileName;
            }
        }

        //=========================================================
        // CommandSis_Click 
        //
        // Opens file open dialog for selecting a file
        //
        //=========================================================
        private void CommandSis_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            if (bPhoneSupportsSisX)
            {
                openFileDialog.Filter = "Sis files (*.sis)|*.sis|Sisx files (*.sisx)|*.sisx";
            }
            else
            {
                openFileDialog.Filter = "Sis files (*.sis)|*.sis";
            }
            openFileDialog.FilterIndex = 0;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TextSis.Text = openFileDialog.FileName;
            }
        }

        //=========================================================
        // CommandNGage_Click 
        //
        // Opens file open dialog for selecting a file
        //
        //=========================================================
        private void CommandNGage_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog openFileDialog;
            openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "N-Gage files (*.n-gage)|*.n-gage";
            openFileDialog.FilterIndex = 0;
            openFileDialog.RestoreDirectory = true;
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                TextNGage.Text = openFileDialog.FileName;
            }
        }

        //=========================================================
        // CommandNth_Click 
        //
        // Opens file open dialog for selecting a file
        //
        //=========================================================
        private void CommandNth_Click(object sender, System.EventArgs e)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -