Esempio n. 1
0
 private void exportPresetDataToFile(List <byte> temp)
 {
     SaveDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
     SaveDialog.Filter           = string.Format("PresetExportFile(*.{0})|*.{0}", FinalConst.PresetFilter);
     SaveDialog.DefaultExt       = string.Format(".{0}", FinalConst.PresetFilter);
     SaveDialog.AddExtension     = true;
     if (SaveDialog.ShowDialog() == true)
     {
         string FilePath = SaveDialog.FileName;
         IOBinaryOperation.writeBinaryToFile(FilePath, System.Text.Encoding.ASCII.GetBytes(FinalConst.PresetHeader));
         IOBinaryOperation.writeBinaryToFile(FilePath, temp.ToArray());
     }
 }
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            if (itemRadio_0.IsChecked.HasValue && itemRadio_0.IsChecked.Value) //save to device with name
            {
                if (pLstBox.SelectedIndex >= 0)
                {
                    var cnew = new CNewDeveName();
                    cnew.onsubmitNewDeviceChangedEvent += new CNewDeveName.submitNewDeviceChanged(onsubmitNewDevname);
                    cnew.Tag   = "presetChangeName";
                    cnew.Title = "Change Preset Name";
                    cnew.setSubTitle("Please input presetname:");
                    cnew.ShowDialog();
                }
                else
                {
                    edCpyPreStatus.Text = "You should select a position first.";
                }
            }
            else  //save current sence to local PC
            {
                saveDlg.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
                saveDlg.Filter           = "MatrixPresets File|*.MCSP";//matrix Current Scene presetfile
                saveDlg.OverwritePrompt  = true;
                if (saveDlg.ShowDialog() == true)
                {
                    string strp     = saveDlg.FileName;
                    string fileName = System.IO.Path.GetFileNameWithoutExtension(strp);
                    // MessageBox.Show(fileName);
                    CMatrixData.matrixData.setPresetName(0, fileName);
                    _parentWin.onLineCheckCounter = 0;
                    CMatrixData.matrixData.resetCommunicateStatus();
                    byte[] mPData  = CMatrixData.matrixData.getPackageOfCurrentScene();
                    bool   resload = (IOBinaryOperation.writeBinaryToFile(strp, mPData));
                    edCpyPreStatus.Text = (resload ? "Sucessful saved to file!" : "Fail to save to file!");

                    // BitConverter.ToString(mFactoryData);//for show...
                }
            }
        }
Esempio n. 3
0
 private void ExportMemoryToFile()
 {
     if (MessageBox.Show("Global Presets downloaded, are you sure to save as file?", "Save Global Presets as file", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         SaveDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
         SaveDialog.Filter           = "MemoryExportFile(*.ept)|*.ept";
         if (SaveDialog.ShowDialog() == true)
         {
             string FilePath = SaveDialog.FileName;
             IOBinaryOperation.writeBinaryToFile(FilePath, System.Text.Encoding.ASCII.GetBytes(FinalConst.MemoryHeader));
             byte[] temp  = new byte[CoreData.m_memory.GetLength(0) * CoreData.m_memory.GetLength(1)];
             int    count = 0;
             for (int i = 0; i < CoreData.m_memory.GetLength(0); i++)
             {
                 for (int j = 0; j < CoreData.m_memory.GetLength(1); j++)
                 {
                     temp[count++] = CoreData.m_memory[i, j];
                 }
             }
             IOBinaryOperation.writeBinaryToFile(FilePath, temp);
         }
     }
 }