Example #1
0
 private void OpenFile()
 {
     OpenDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
     OpenDialog.Filter           = "Bin File|*.bin";
     if (OpenDialog.ShowDialog() == true)
     {
         string filepath = OpenDialog.FileName;
         if (File.Exists(filepath))
         {
             int    filelen        = (int)IOBinaryOperation.fileLength(filepath);
             byte[] TempFileData   = IOBinaryOperation.readBinaryFile(filepath, filelen);
             int    SegementsCount = filelen / FinalConst.MaxLength + 1;
             FileData = new byte[SegementsCount, FinalConst.MaxLength];
             int Count = 0;
             for (int i = 0; i < SegementsCount; i++)
             {
                 for (int j = 0; j < FinalConst.MaxLength; j++)
                 {
                     if (Count < TempFileData.Length)
                     {
                         FileData[i, j] = TempFileData[Count++];
                     }
                     else
                     {
                         break;
                     }
                 }
             }
             Data.ProgressBarMax   = SegementsCount;
             Data.ProgressBarValue = 0;
             Data.FileInfo        += filepath;
             Data.FileInfo        += "\n";
         }
     }
 }
        private void loadBtn_Click(object sender, RoutedEventArgs e)
        {
            if (itemRadio_0.IsChecked.HasValue && itemRadio_0.IsChecked.Value) //load from device
            {
                int  selNum  = pLstBox.SelectedIndex + 1;
                bool isEmpty = CMatrixData.matrixData.determinePresetEmptyInPos(selNum);
                if (isEmpty)
                {
                    System.Windows.Forms.MessageBox.Show("You cannot load a empty Preset!");
                    return;
                }
                if (selNum >= 1)
                {
                    if (NetCilent.netCilent.isConnected())
                    {
                        _parentWin.isDefaultSetting_beging = true;
                        _parentWin.ackTimer.Stop();
                        sprocketSaveLoad.IsIndeterminate = true;
                        _parentWin.onLineCheckCounter    = 0;
                        CMatrixData.matrixData.sendCMD_recallSinglePreset(selNum);
                    }
                }
            }
            else  //load from local
            {
                openDlg.InitialDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
                openDlg.Filter           = CDefine.MPFFilter;
                openDlg.CheckFileExists  = true;
                if (openDlg.ShowDialog() == true)
                {
                    string strp    = openDlg.FileName;
                    int    fileLen = (int)IOBinaryOperation.fileLength(strp);
                    if (fileLen == (CDefine.LEN_Sence - 18))
                    {
                        byte[] iread = IOBinaryOperation.readBinaryFile(strp, fileLen); //sencenlen-
                        CMatrixData.matrixData.iRead_CurrentScene(iread, true);

                        //   string bStr = BitConverter.ToString(iread);
                        // Debug.WriteLine("load factory presets: " + bStr);
                        if (NetCilent.netCilent.isConnected())
                        {
                            _parentWin.isDefaultSetting_beging = true;
                            sprocketSaveLoad.IsIndeterminate   = true;
                            _parentWin.onLineCheckCounter      = 0;
                            CMatrixData.matrixData.sendCMD_loadFromPC(iread);
                        }
                    }
                    else
                    {
                        System.Windows.MessageBox.Show("Dismatch the factory presets,maybe the file has been damaged!");
                        return;
                    }
                }
            }
        }
Example #3
0
        private bool ReadSinglePresetFromFile()
        {
            bool Result = false;

            OpenDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            OpenDialog.Filter           = string.Format("PresetExportFile({0})|*.{0}", FinalConst.PresetFilter);
            if (OpenDialog.ShowDialog() == true)
            {
                string filepath = OpenDialog.FileName;
                if (File.Exists(filepath))
                {
                    int filelen = (int)IOBinaryOperation.fileLength(filepath);
                    if (filelen != (FinalConst.Len_Sence_Pack + 16))
                    {
                        return(false);
                    }
                    //PresetLoadData = IOBinaryOperation.readBinaryFile(filepath, filelen);
                    CoreData.SetLocalPreset(IOBinaryOperation.readBinaryFile(filepath, filelen));
                    Result = true;
                }
            }
            return(Result);
        }
Example #4
0
        private bool LoadMemoryFile()
        {
            bool Result = false;

            OpenDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory;
            OpenDialog.Filter           = "MemoryExportFile(*.ept)|*.ept";
            if (OpenDialog.ShowDialog() == true)
            {
                string filepath = OpenDialog.FileName;
                if (File.Exists(filepath))
                {
                    int filelen = (int)IOBinaryOperation.fileLength(filepath);
                    if (filelen != (FinalConst.Len_Sence_Pack * 16 + 16))
                    {
                        return(false);
                    }
                    MemoryLoadData = IOBinaryOperation.readBinaryFile(filepath, filelen);
                    CoreData.SetMemory(MemoryLoadData);
                    Result = true;
                }
            }

            return(Result);
        }